Example #1
0
 /**
  * Set the current source for loaders
  *
  * @param \MUtil_Registry_SourceInterface $source
  * @param boolean $setExisting When true the source is set for all exiting loaders
  * @return void
  */
 public static function setSource(\MUtil_Registry_SourceInterface $source, $setExisting = true)
 {
     self::$_source = $source;
     if ($setExisting) {
         foreach (self::$_loaders as $loader) {
             if ($loader instanceof \MUtil_Loader_SourcePluginLoader) {
                 $loader->setSource($source);
             }
         }
     }
 }
 /**
  * Initialize the Project or Gems loader.
  *
  * Use $this->loader to access afterwards
  *
  * @return \Gems_Loader
  */
 protected function _initLoader()
 {
     $loader = $this->createProjectClass('Loader', $this->getContainer(), $this->_loaderDirs);
     \MUtil_Model::setSource($loader, true);
     return $loader;
 }
Example #3
0
 /**
  * Set the bridge class for the specific identifier
  *
  * @param string $identifier
  * @param string $bridge Class name for a \MUtil_Model_Bridge_BridgeInterface, optioanlly loaded using *_Model_Bridge_*
  * @return \MUtil_Model_ModelAbstract (continuation pattern)
  */
 public function setBridgeFor($identifier, $bridge)
 {
     if (!is_string($bridge)) {
         throw new \MUtil_Model_ModelException("Non string bridge class specified for {$identifier}.");
     }
     $bridges = $this->getMeta(\MUtil_Model::META_BRIDGES);
     if (!$bridges) {
         $bridges = \MUtil_Model::getDefaultBridges();
     }
     $bridges[$identifier] = $bridge;
     $this->setMeta(\MUtil_Model::META_BRIDGES, $bridges);
 }
 /**
  * Returns the model for the current $action.
  *
  * The parameters allow you to easily adapt the model to the current action. The $detailed
  * parameter was added, because the most common use of action is a split between detailed
  * and summarized actions.
  *
  * @return \MUtil_Model_ModelAbstract
  */
 protected function getModel()
 {
     $request = $this->getRequest();
     $action = null === $request ? '' : $request->getActionName();
     // Only get new model if there is no model or the model was for a different action
     if (!($this->_model && $this->_model->isMeta('action', $action))) {
         $detailed = !$this->isSummarized($action);
         \MUtil_Model::getSource()->addRegistryContainer(array('action' => $action, 'detailed' => $detailed, 'forForm' => $this->forForm($action)), 'actionVariables');
         $this->_model = $this->createModel($detailed, $action);
         $this->_model->setMeta('action', $action);
         // Detailed models DO NOT USE $_POST for filtering,
         // multirow models DO USE $_POST parameters for filtering.
         $this->_model->applyRequest($request, $detailed, $this->includeNumericFilters);
     }
     return $this->_model;
 }