Working with System Classes and Objects
Under InstantCMS system classes and objects generated by them we assume all files from the /system/core/action.php
directory. A full list of them and their purpose is considered in a Separate Article.
All system classes start with the “cms” symbols, for example, cmsMailer, cmsTemplate, cmsUser, cmsCore and so on.
In InstantCMS versions higher than 2.4.0, there is no need to get singletones or manually create objects of specified system classes. It will be enough if you request them as object properties of a controller according to the cmsCore
— $this→cms_core
scheme. In other words, we take the title of a relevant class, find the first capital letter in the middle of a word, turn it into a lowercase letter and enter an underscore sign before it.
For example, you can get the core object in a controller in the following way:
$core = cmsCore::getInstance();
And further use the $core variable to request core objects:
$uri_action = $core->uri_action;
Nevertheless, you can avoid getting a singleton (in this case) and use a simplified structure; at first request, the engine will itself link a relevant object and will save it into the property to use further:
$uri_action = $this->cms_core->uri_action;
Do the same with other objects, for example:
Class title | Requesting a controller object |
---|---|
cmsConfig | $this->cms_config |
cmsUser | $this->cms_user |
cmsTemplate | $this->cms_template |
cmsUploader | $this->cms_uploader |
And so on. It is guaranteed that you will always be able to request these objects, their files will be loaded automatically, an object will be created and will be bound to a property.