function __construct($sName, $mComponentType)
 {
     parent::__construct($sName);
     // set component type
     $this->mComponentType = $mComponentType;
     // retrieve available components list
     $asComponents = AnwPlugin::getAvailableComponents($mComponentType);
     $asEnumValues = array();
     // special case for actions
     if ($mComponentType == AnwComponent::TYPE_ACTION) {
         foreach ($asComponents as $sAction) {
             if (!AnwAction::isAlwaysEnabledAction($sAction)) {
                 $asEnumValues[$sAction] = $sAction;
             }
         }
     } else {
         $asEnumValues = $asComponents;
     }
     $this->setEnumValuesFromList($asEnumValues);
 }
Example #2
0
 static function getCachedPluginsMapping()
 {
     $sCacheFile = self::filenameCachedPluginsMapping();
     if (!file_exists($sCacheFile)) {
         throw new AnwCacheNotFoundException();
     }
     //mapping must be newer than enabled-plugins-settings
     try {
         $sConfigFileOverride = AnwUtils::getFileOverride("global.cfg.php", AnwComponent::getGlobalComponentFullDir());
         if (filemtime($sCacheFile) < filemtime($sConfigFileOverride)) {
             self::debug("cachedPluginsMapping obsoleted by settings");
             throw new AnwCacheNotFoundException();
         }
     } catch (AnwFileNotFoundException $e) {
     }
     //no override config
     //mapping must be newer than each enabled plugin
     $asEnabledPlugins = AnwComponent::globalCfgModulesPlugins();
     foreach ($asEnabledPlugins as $sEnabledPlugin) {
         $asPluginFilesLocations = array();
         $sPluginFile = 'plugin_' . $sEnabledPlugin . '.php';
         $sPluginDir = AnwPlugin::getComponentDir($sEnabledPlugin);
         list($sFilePluginDefault, $null) = AnwUtils::getFileDefault($sPluginFile, $sPluginDir);
         $asPluginFilesLocations[] = $sFilePluginDefault;
         try {
             $sFilePluginOverride = AnwUtils::getFileOverride($sPluginFile, $sPluginDir);
             $asPluginFilesLocations[] = $sFilePluginOverride;
         } catch (AnwFileNotFoundException $e) {
         }
         //no override file found
         foreach ($asPluginFilesLocations as $sPluginFileLocation) {
             if (file_exists($sPluginFileLocation) && filemtime($sCacheFile) < filemtime($sPluginFileLocation)) {
                 self::debug("cachedPluginsMapping obsoleted by plugin : " . $sEnabledPlugin);
                 throw new AnwCacheNotFoundException();
             }
         }
     }
     //load it from cache
     $oObject = (array) self::getCachedObject($sCacheFile);
     if (!is_array($oObject)) {
         self::debug("cachedPluginsMapping invalid : " . $sCacheFile);
         throw new AnwCacheNotFoundException();
     } else {
         self::debug("cachedPluginsMapping found : " . $sCacheFile);
     }
     return $oObject;
 }