Here i think you must distinguish between frontend in Javascript and backend in PHP.
The frontend typically uses npm. There was an ancient global variable OC
in the page present that allowed to access various functionality of the core. This has been deprecated and replaced by imported functions.
In the backend the story is a bit different. There are three different namespaces.
- First there is the namespace
OCP
for public classes and interfaces. You are free to use them. They are rather stable. - In contrast the is the internal
OC
namespace that represents the internal classes of the core. These might change without prior notice. (Please keep in mind to not get confused by the ancient JavaScript variable, as described above.) - Finally, there is the
OCA
namespace. All apps get their own namespace within that namespace to separate the classes of the different apps.
So, i see not the problem with the code as mentioned in the first post. Most probably this was a misunderstanding.