Common classes

Contents...

For implementation of common functions which should be available in several applications, it is convenient to store their source code in one or more classes and to call methods of such classes in your applications. This method of organizing shared source code is also handy because in this case you can modify custom classes only once without having to update them in each of your applications.

Common custom classes shall be saved in a new subdirectory inside wa-system/vendors/; e.g., in wa-system/vendors/custom/.

To make your custom classes available in all Webasyst applications, add them to the autoloader queue by specifying paths to their files at the end of configuration file wa-config/SystemConfig.class.php (this file is not overwritten by framework updates) as shown in the example below:

waAutoload::getInstance()->add([
    'MyClass1' => 'wa-system/vendors/custom/MyClass1.class.php',
    'MyClass2' => 'wa-system/vendors/custom/MyClass2.class.php',
    ...
]);