Exemplo n.º 1
0
 /**
  * Method to preload the JAccessRules object for the given asset type.
  *
  * @param   string|array  $assetTypes  e.g. 'com_content.article'
  * @param   boolean       $reload      Set to true to reload from database.
  *
  * @return   boolean True on success.
  *
  * @since    1.6
  */
 public static function preload($assetTypes = 'components', $reload = false)
 {
     // Check for default case:
     $isDefault = is_string($assetTypes) && in_array($assetTypes, array('components', 'component'));
     // Preload the rules for all of the components:
     if ($isDefault && !self::$componentsPreloaded) {
         // Mark in the profiler.
         !JDEBUG ?: JProfiler::getInstance('Application')->mark('Before JAccess::preload (all components)');
         self::preloadComponents();
         self::$componentsPreloaded = true;
         // Mark in the profiler.
         !JDEBUG ?: JProfiler::getInstance('Application')->mark('After JAccess::preload (all components)');
     }
     // Quick short circuit for default case
     if ($isDefault) {
         return true;
     }
     // If we get to this point, this is a regular asset type
     // and we'll proceed with the preloading process.
     if (!is_array($assetTypes)) {
         $assetTypes = (array) $assetTypes;
     }
     foreach ($assetTypes as $assetType) {
         if (!isset(self::$preloadedAssetTypes[$assetType]) || $reload) {
             !JDEBUG ?: JProfiler::getInstance('Application')->mark('Before JAccess::preload (' . $assetType . ')');
             self::preloadPermissions($assetType);
             self::$preloadedAssetTypes[$assetType] = true;
             !JDEBUG ?: JProfiler::getInstance('Application')->mark('After JAccess::preload (' . $assetType . ')');
         }
     }
     return true;
 }