/**
  * Unloads an extension by removing it from ActiveExtensions setting,
  * clearing extensions cache and remove ini dir (not extension siteaccess)
  *
  * @param string $extension Extension name to unload
  * @return bool True on success, false if not loaded
  */
 public static function unload($extension)
 {
     $ini = eZINI::instance();
     $activeExtensions = $ini->variable('ExtensionSettings', 'ActiveExtensions');
     if (!in_array($extension, $activeExtensions, true)) {
         return false;
     }
     $ini->setVariable('ExtensionSettings', 'ActiveExtensions', array_diff($activeExtensions, array($extension)));
     $ini->removeOverrideDir('extension:' . $extension);
     eZExtension::clearActiveExtensionsMemoryCache();
     return true;
 }
    /**
     * Reloads extensions and changes siteaccess globally
     * If you only want changes on a instance of ini, use {@link eZSiteAccess::getIni()}
     *
     * - clears all in-memory caches used by the INI system
     * - re-builds the list of paths where INI files are searched for
     * - runs {@link eZSiteAccess::change()}
     * - re-searches module paths {@link eZModule::setGlobalPathList()}
     *
     * @since 4.4
     * @param array $access An associative array with 'name' (string), 'type' (int) and 'uri_part' (array).
     *                      See {@link eZSiteAccess::match()} for array structure definition
     * @param eZINI|null $siteINI Optional parameter to be able to only do change on specific instance of site.ini
     *                            If set, then global siteacceess will not be changed as well.
     * @return array The $access parameter
     */
    static function load( array $access, eZINI $siteINI = null )
    {
        $currentSiteAccess = $GLOBALS['eZCurrentAccess'];
        unset( $GLOBALS['eZCurrentAccess'] );

        // Clear all ini override dirs
        if ( $siteINI instanceof eZINI )
        {
            $siteINI->resetOverrideDirs();
        }
        else
        {
            eZINI::resetAllInstances();
            eZExtension::clearActiveExtensionsMemoryCache();
            eZTemplateDesignResource::clearInMemoryCache();
        }

        // Reload extensions, siteaccess and access extensions
        eZExtension::activateExtensions( 'default', $siteINI );
        $access = self::change( $access, $siteINI );
        eZExtension::activateExtensions( 'access', $siteINI );

        // Restore current (old) siteacces if changes where only to be applied to locale instance of site.ini
        if ( $siteINI instanceof eZINI )
        {
            $GLOBALS['eZCurrentAccess'] = $currentSiteAccess;
        }
        else
        {
            $moduleRepositories = eZModule::activeModuleRepositories();
            eZModule::setGlobalPathList( $moduleRepositories );
        }

        return $access;
    }
Exemple #3
0
 /**
  * Clears active extensions list cache
  */
 static function clearActiveExtensions($cacheItem)
 {
     eZExpiryHandler::registerShutdownFunction();
     $handler = eZExpiryHandler::instance();
     $handler->setTimestamp($cacheItem['expiry-key'], time());
     $handler->store();
     eZExtension::clearActiveExtensionsMemoryCache();
 }
    /**
     * Reloads extensions and changes siteaccess globally
     * If you only want changes on a instance of ini, use {@link eZSiteAccess::getIni()}
     *
     * - clears all in-memory caches used by the INI system
     * - re-builds the list of paths where INI files are searched for
     * - runs {@link eZSiteAccess::change()}
     * - re-searches module paths {@link eZModule::setGlobalPathList()}
     *
     * @since 4.4
     * @param array $access An associative array with 'name' (string), 'type' (int) and 'uri_part' (array).
     *                      See {@link eZSiteAccess::match()} for array structure definition
     * @param eZINI|null $siteINI Optional parameter to be able to only do change on specific instance of site.ini
     *                            If set, then global siteacceess will not be changed as well.
     * @return array The $access parameter
     */
    static function load( array $access, eZINI $siteINI = null )
    {
        $currentSiteAccess = $GLOBALS['eZCurrentAccess'];
        unset( $GLOBALS['eZCurrentAccess'] );

        // Clear all ini override dirs
        if ( $siteINI instanceof eZINI )
        {
            $siteINI->resetOverrideDirs();
        }
        else
        {
            eZINI::resetAllInstances();
            eZExtension::clearActiveExtensionsMemoryCache();
            eZTemplateDesignResource::clearInMemoryCache();
        }

        // Reload extensions, siteaccess and access extensions
        eZExtension::activateExtensions( 'default', $siteINI );
        $access = self::change( $access, $siteINI );
        eZExtension::activateExtensions( 'access', $siteINI );

        // Reload Extenion ordering to reorder eZINI Global Override Dirs.
        // @TODO : Améliorer la gestion globale (éviter des appels multiples !!!)
        if (  $siteINI instanceof eZINI  && $siteINI->variable( 'ExtensionSettings', 'ExtensionOrdering' ) === 'enabled' )
        {
            eZINI::removeGlobalOverrideDirsByScope( 'sa-extension' );
            eZINI::removeGlobalOverrideDirsByScope( 'extension' );
            eZExtension::activateExtensions( false );
        }

        // Restore current (old) siteacces if changes where only to be applied to locale instance of site.ini
        if ( $siteINI instanceof eZINI )
        {
            $GLOBALS['eZCurrentAccess'] = $currentSiteAccess;
        }
        else
        {
            $moduleRepositories = eZModule::activeModuleRepositories();
            eZModule::setGlobalPathList( $moduleRepositories );
        }

        return $access;
    }