예제 #1
0
 /**
  * Executes loadables sets or loadables by ID
  * 
  * @param array $ids List of loadables sets IDs or loadables IDs
  */
 public function load(array $ids = array())
 {
     // Get model configuration instance
     $instance = static::__getInstance();
     // Handle loadables sets
     if (!is_null($instance->loadables_sets)) {
         foreach ($ids as $loadable_set_key => $loadable_set_id) {
             if ($instance->loadables_sets->hasKey($loadable_set_id) && !in_array($loadable_set_id, $this->loaded)) {
                 // Making sure we do not load a loadable
                 // with the same name as this loadable set
                 unset($ids[$loadable_set_key]);
                 // Loop through all loadables ids on this set
                 foreach ($instance->loadables_sets->get($loadable_set_id) as $loadable_id) {
                     // Add loadable ID, if not already present
                     if ($loadable_id != $loadable_set_id && !in_array($loadable_id, $ids)) {
                         $ids[] = $loadable_id;
                     }
                 }
                 // Mark loadable set as loaded
                 $this->loaded[] = $loadable_set_id;
             }
         }
     }
     // Handle loadables
     if (!is_null($instance->loadables)) {
         foreach ($ids as $id) {
             if ($instance->loadables->hasKey($id) && !in_array($id, $this->loaded)) {
                 $lac_feature = FeatureManager::getInstance()->get('mvc/model/loadables_auto_context');
                 if ($lac_feature && $lac_feature->isEnabled()) {
                     ContextManager::getInstance()->overrideCurrent('loadable/' . static::$__type . '/' . $id);
                 }
                 call_user_func_array($instance->loadables->get($id), array($this));
                 if ($lac_feature && $lac_feature->isEnabled()) {
                     ContextManager::getInstance()->restoreCurrent();
                 }
                 // Mark loadable as loaded
                 $this->loaded[] = $id;
             }
         }
     }
     return $this;
 }
예제 #2
0
 /**
  * Returns feature manager OR optionaly a feature configuration object
  * 
  * @param string $id Id of the target feature
  */
 public static function Feature($id = null)
 {
     $feature_manager = FeatureManager::getInstance();
     return $id && is_string($id) ? $feature_manager->get($id) : $feature_manager;
 }