* @package tao * @since 2.4 * */ class tao_install_ExtensionInstaller extends common_ext_ExtensionInstaller { // --- ASSOCIATIONS --- // --- ATTRIBUTES --- // --- OPERATIONS --- /** * Override the default model with the translated model * * (non-PHPdoc) * @see common_ext_ExtensionInstaller::getExtensionModel() */ public function getExtensionModel() { return new ExtensionModel($this->extension); } /** * Will create the model of Modules and Actions (MVC) in the persistent * * @access public * @author Jerome Bogaerts * @return void * @since 2.4 */ public function extendedInstall() { $this->installManagementRole(); $this->applyAccessRules(); $this->registerClientLib(); } /** * Will make the Global Manager include the Management Role of the extension * to install (if it exists). * * @access public * @author Jerome Bogaerts * @return void * @since 2.4 */ public function installManagementRole() { // Try to get a Management Role described by the extension itself. // (this information comes actually from the Manifest of the extension) $roleUri = $this->extension->getManifest()->getManagementRoleUri(); if (! empty($roleUri)) { $role = new core_kernel_classes_Resource($roleUri); $roleService = tao_models_classes_RoleService::singleton(); if (! $role->exists()) { // Management role does not exist yet, so we create it $roleClass = new core_kernel_classes_Class(TaoOntology::CLASS_URI_MANAGEMENT_ROLE); $roleLabel = $this->extension->getId() . ' Manager'; $role = $roleClass->createInstance($roleLabel, $roleLabel . ' Role', $role->getUri()); $roleService->includeRole($role, new core_kernel_classes_Resource(TaoRoles::BACK_OFFICE)); } // Take the Global Manager role and make it include // the Management role of the currently installed extension. if ($role->getUri() !== TaoRoles::GLOBAL_MANAGER) { $globalManagerRole = new core_kernel_classes_Resource(TaoRoles::GLOBAL_MANAGER); $roleService->includeRole($globalManagerRole, $role); } common_Logger::d("Management Role " . $role->getUri() . " created for extension '" . $this->extension->getId() . "'."); } else { // There is no Management role described by the Extension Manifest. common_Logger::i("No management role for extension '" . $this->extension->getId() . "'."); } } /** * Will make the Global Manager include the Management Role of the extension * to install (if it exists). * * @access public * @author Jerome Bogaerts * @return void * @since 2.4 */ public function applyAccessRules() { foreach ($this->extension->getManifest()->getAclTable() as $tableEntry) { $rule = new AccessRule($tableEntry[0], $tableEntry[1], $tableEntry[2]); AclProxy::applyRule($rule); } } /** * Extension may declare client lib to add alias into requireJs * * @author Lionel Lecaque, lionel@taotesting.com */ public function registerClientLib() { $jsPath = trim(Template::js('', $this->extension->getId()), '/'); ClientLibRegistry::getRegistry()->register($this->extension->getId(), $jsPath); $cssPath = trim(Template::css('', $this->extension->getId()), '/'); ClientLibRegistry::getRegistry()->register($this->extension->getId() . 'Css', $cssPath); } }