/**
  * @param string $name
  * @return string
  * @throws InvalidPresenterException
  */
 public function getPresenterClass(&$name)
 {
     $class = parent::getPresenterClass($name);
     if (isset($this->extra[$class])) {
         $extendPresenter = $this->extra[$class];
     } else {
         if (preg_match(self::SCAN_FILTER, $class, $matches)) {
             $extendPresenter = str_replace('*', $matches[1], $this->mapping);
         }
     }
     if (isset($extendPresenter) && class_exists($extendPresenter)) {
         $implements = class_implements($extendPresenter);
         if (isset($implements['WebChemistry\\Application\\IExtendPresenter'])) {
             return $extendPresenter;
         } else {
             if (isset($this->extra[$class])) {
                 throw new InvalidPresenterException("Presenter '{$extendPresenter}' must implements interface WebChemistry\\Application\\IExtendPresenter.");
             }
         }
     }
     $implements = class_implements($class);
     if (isset($implements['WebChemistry\\Application\\IExtendPresenter'])) {
         throw new InvalidPresenterException("Cannot load presenter '{$class}', because extends other presenter.");
     }
     return $class;
 }
Ejemplo n.º 2
0
 /**
  * @param string $name
  * @return string
  */
 public function getPresenterClass(&$name)
 {
     $mapping = $this->mapping;
     $presenter = $name;
     while ($presenter) {
         if (isset($this->mapping[$presenter])) {
             $module = substr($presenter, 0, strpos($presenter, ':'));
             $mapping = array($module => $this->mapping[$presenter]);
             break;
         }
         $presenter = substr($presenter, 0, strrpos($presenter, ':'));
     }
     $this->resetMappingToPresenterFactory();
     $this->presenterFactory->setMapping($mapping);
     return $this->presenterFactory->getPresenterClass($name);
 }
Ejemplo n.º 3
0
 /**
  * @param $name
  * @return string
  */
 public function getPresenterClass(&$name)
 {
     $service = $this->formatServiceNameFromPresenter($name);
     if (isset($this->presentersByName[$service])) {
         return $this->presentersByName[$service];
     } else {
         if (isset($this->presentersByName[$service . 'Factory'])) {
             return $this->presentersByName[$service . 'Factory'];
         } else {
             return parent::getPresenterClass($name);
         }
     }
 }