public function createXTestingDataGrid()
 {
     $presenterFactory = new Nette\Application\PresenterFactory();
     $presenterFactory->setMapping(['*' => 'Ublaboo\\DataGrid\\Tests\\Files\\*Presenter']);
     $presenter = $presenterFactory->createPresenter('XTesting');
     $url = new Http\UrlScript('localhost');
     $request = new Http\Request($url);
     $response = new Http\Response();
     $session = new Http\Session($request, $response);
     $presenter->injectPrimary(NULL, NULL, NULL, $request, $response, $session);
     return new DataGrid($presenter, 'XTestingGrid');
 }
Esempio n. 2
0
 public function invoke(PresenterFactory $fact)
 {
     /** @var Homepage $presenter */
     $presenter = $fact->createPresenter('Homepage');
     $ref = new \ReflectionProperty(Presenter::class, 'globalParams');
     $ref->setAccessible(TRUE);
     $ref->setValue($presenter, []);
     $args = [];
     foreach ($this->in->getVariadics() as $part) {
         list($key, $val) = explode('=', $part);
         $args[$key] = $val;
     }
     $link = $presenter->link($this->in->getArgument('target'), $args);
     $this->out->writeln($link);
 }
Esempio n. 3
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);
 }
 /**
  * @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;
 }
Esempio n. 5
0
 /**
  * Array of all resources.
  *
  * @return array
  */
 protected function scanResources()
 {
     $ret = array();
     foreach ($this->presenterFactory->getPresenters() as $class => $name) {
         $schema = $this->reader->getSchema($class);
         foreach ($schema as $item) {
             if (!array_key_exists($item['resource'], $ret)) {
                 $ret[$item['resource']] = array();
             }
             $ret[$item['resource']] = array_unique(array_merge($ret[$item['resource']], $item['privilege'] ? (array) $item['privilege'] : array()));
         }
     }
     return $ret;
 }
Esempio n. 6
0
 public function __construct($baseDir, \Nette\DI\IContainer $context)
 {
     parent::__construct($baseDir, $context);
     $this->context = $context;
 }
Esempio n. 7
0
 /**
  * @param string $name
  * @return IPresenter|UI\Presenter
  */
 public function createPresenter($name)
 {
     return $this->presenterFactory->createPresenter($name);
 }
Esempio n. 8
0
	/**
	 * Formats presenter name from class name.
	 *
	 * @author   Jan Tvrdík
	 * @param    string
	 * @return   string
	 */
	public function unformatPresenterClass($class)
	{
		return parent::unformatPresenterClass(substr($class, strlen(__NAMESPACE__) + 1));
	}
Esempio n. 9
0
 /**
  * @param $presenter
  * @return string
  */
 public function formatPresenterFile($presenter)
 {
     $service = $this->formatPresenterFromServiceName($presenter);
     if ($this->container->hasService($service)) {
         return get_class($this->container->getService($service));
     }
     return parent::formatPresenterFile($presenter);
 }