Building extensions - interact with extensions
One of the great advantages of the extension life cycle
, is the ability to interact with other extensions. In this section a few important aspects of interacting with other extensions will be covered.
Importing extension functionality
Functionality within an extension may be consumed, by importing the file containing the functionality. To do this we need to know the name of the extension with the given functionality, and the name of the file containing that functionality. This information should be covered in the extension documentation.
Importing a file is as simple as shown in the following line of code.
|$exists = SMExtensionManager::Import("NameOfExtension, "NameOfFile.php);
The Import function returns True if the extension and file exists, otherwise False. The return value may be used to determine whether or not to execute logic, if the given extension does not exists. If an extension depends on another extension and is not supposed to work without it, the extension file can be imported with an additional argument.
|SMExtensionManager::Import("NameOfExtension, "NameOfFile.php, true);
The line above will throw an exception, if the extension and file does not exist.
After importing the given file, its content such as classes, functions and variables are now available. See the extension documentation for information about how to consume the functionality (ie SMPages