Beispiel #1
0
 protected function setUp()
 {
     $serviceManager = new ServiceManager();
     $serviceLocator = new FormElementManager();
     $serviceLocator->setServiceLocator($serviceManager);
     $pAccounts = $this->getMock('Balance\\Model\\Persistence\\ValueOptionsInterface');
     $pAccounts->method('getValueOptions')->will($this->returnValue([]));
     $serviceManager->setService('Balance\\Model\\Persistence\\Accounts', $pAccounts);
     $serviceLocator->setService('Currency', new CurrencyElement());
     $view = new View();
     $view->getEventManager()->attach(ViewEvent::EVENT_RENDERER, function () {
         $renderer = (new PhpRenderer())->setResolver(new TemplateMapResolver(['layout/page-header' => './module/Balance/view/layout/page-header.phtml', 'balance/postings/edit' => './module/Balance/view/balance/postings/edit.phtml', 'tests/postings/before-entries-a' => './module/Balance/test/BalanceTest/View/Scripts/postings-before-entries-a.phtml', 'tests/postings/before-entries-b' => './module/Balance/test/BalanceTest/View/Scripts/postings-before-entries-b.phtml']));
         $helpers = $renderer->getHelperPluginManager();
         $helpers->get('BasePath')->setBasePath('/');
         $match = $this->getMockBuilder('Zend\\Mvc\\Router\\RouteMatch')->disableOriginalConstructor()->getMock();
         $match->method('getMatchedRouteName')->will($this->returnValue('default'));
         $helpers->get('Url')->setRouter($this->getMock('Zend\\Mvc\\Router\\RouteStackInterface'))->setRouteMatch($match);
         $configs = new HelperConfig();
         $configs->configureServiceManager($helpers);
         return $renderer;
     });
     $form = new PostingsForm();
     $form->setServiceLocator($serviceLocator);
     $model = (new ViewModel())->setTemplate('balance/postings/edit')->setVariable('form', $form)->setOption('has_parent', true);
     $form->init();
     $this->view = $view;
     $this->model = $model;
 }
Beispiel #2
0
 public function setUp()
 {
     $this->helper = new FormRowHelper();
     $this->renderer = new PhpRenderer();
     $helpers = $this->renderer->getHelperPluginManager();
     $config = new HelperConfig();
     $config->configureServiceManager($helpers);
     $this->helper->setView($this->renderer);
 }
Beispiel #3
0
 public function setUp()
 {
     Doctype::unsetDoctypeRegistry();
     $this->renderer = new PhpRenderer();
     $helpers = $this->renderer->getHelperPluginManager();
     $config = new HelperConfig();
     $config->configureServiceManager($helpers);
     $this->helper->setView($this->renderer);
 }
Beispiel #4
0
 /**
  * 
  * @return \Zend\View\Renderer\PhpRenderer
  */
 public function getRenderer()
 {
     if ($this->renderer === null) {
         $renderer = new PhpRenderer();
         // register view helpers
         $formHelperConfig = new ZendFormHelperConfig();
         $formHelperConfig->configureServiceManager($renderer->getHelperPluginManager());
         // register view helpers
         $formHelperConfig = new FormHelperConfig();
         $formHelperConfig->configureServiceManager($renderer->getHelperPluginManager());
         // set base path
         $path = $this->templatePath ?: __DIR__ . '/view/scripts';
         $renderer->resolver()->addPath($path);
         $this->setRenderer($renderer);
     }
     return $this->renderer;
 }
 public static function loadControler($template)
 {
     global $view;
     $template_name = ucfirst(str_replace('.php', '', basename($template)));
     $template_name = ucwords(str_replace('-', ' ', $template_name));
     $template_name = str_replace(' ', '', $template_name);
     $controller_name = 'Bundle\\FrontBundle\\Controller\\' . $template_name . 'Controller';
     $render = new PhpRenderer();
     $plugins = $render->getHelperPluginManager();
     $config = new HelperConfig();
     $config->configureServiceManager($plugins);
     if (class_exists($controller_name)) {
         $controller = new $controller_name();
         $vars = $controller->init();
         $vars['render'] = $render;
         $view = new ViewModel($vars);
     }
     return $template;
 }