/** * Class constructor. * Initializes helper manager. * * @return void */ public function __construct() { parent::__construct(); // Initialize helper manager $this->_helperManager = new \Zend\View\HelperPluginManager(); $this->_helperManager->setRenderer($this); // Inject form-related invokable helpers $helperConfig = new \Zend\Form\View\HelperConfig(); $helperConfig->configureServiceManager($this->_helperManager); }
protected function setFormHelpers() { $formhelperConfig = new \Zend\Form\View\HelperConfig(); $formhelperConfig->configureServiceManager($this->renderer->getHelperPluginManager()); // var_dump($this->renderer->getHelperPluginManager()); exit; $this->renderer->getHelperPluginManager()->setInvokableClass('AttributedFormElement', '\\Ifp\\Form\\View\\Helper\\FormElement'); // $this->renderer->getHelperPluginManager()->setInvokableClass('form','\Zend\Form\View\Helper\Form'); $this->mockErrorBox = \Mockery::mock('\\Ifp\\Form\\View\\Helper\\FormErrors'); $this->renderer->getHelperPluginManager()->setService('ErrorBox', $this->mockErrorBox); // $this->mockFormHelper = \Mockery::mock('\Zend\Form\View\Helper\Form'); // $this->renderer->getHelperPluginManager()->setService('form', $this->mockFormHelper); }
public function getHTML() { $this->checkForGetHTMLZendDependencies(); $html = null; $renderer = new PhpRenderer(); $formHelperConfig = new \Zend\Form\View\HelperConfig(); $formHelperConfig->configureServiceManager($renderer->getHelperPluginManager()); $formRenderer = new \Zend\Form\View\Helper\Form(); $html .= $formRenderer->openTag($this->form); $formRow = new \Zend\Form\View\Helper\FormRow(); $formRow->setView($renderer); foreach ($this->form->getElements() as $key => $element) { $html .= '<div id="' . $key . '" class="element">'; $html .= $formRow->render($element); $html .= '</div>' . PHP_EOL; } $html .= $formRenderer->closeTag(); return $html; }
public function createServiceManager(array $config) { // create ServiceManager $serviceManager = new ServiceManager(); // set an initializer for ServiceLocatorAwareInterface $serviceManager->addInitializer(function ($instance, ServiceLocatorInterface $serviceLocator) { if ($instance instanceof ServiceLocatorAwareInterface) { $instance->setServiceLocator($serviceLocator); } }); // add $serviceManger to the config keys so we can configure it $this->configKeys = ['service_manager' => $serviceManager] + $this->configKeys; // add the pluginManagers to the ServiceManager foreach ($this->pluginManagers as $key => $className) { $serviceManager->setInvokableClass($key, $className); } // add Zend\Form's view helpers to the ViewHelperManager $viewHelperManager = $serviceManager->get('ViewHelperManager'); $vhConfig = new \Zend\Form\View\HelperConfig(); $vhConfig->configureServiceManager($viewHelperManager); // apply configuration $this->applyConfig($serviceManager, $config); return $serviceManager; }
/** * Init renderer object */ protected function initRenderer() { $renderer = new PhpRenderer(); $plugins = $renderer->getHelperPluginManager(); $config = new \Zend\Form\View\HelperConfig(); $config->configureServiceManager($plugins); $resolver = new Resolver\AggregateResolver(); $map = new Resolver\TemplateMapResolver($this->getTable()->getOptions()->getTemplateMap()); $resolver->attach($map); $renderer->setResolver($resolver); $this->renderer = $renderer; }