public function findHelper($proxy, $strict = true) { $this->view = new \Life\View\View(); if (isset($this->_helpers[$proxy])) { return $this->_helpers[$proxy]; } if (!$this->view->getPluginLoader('helper')->getPaths(self::NS)) { $this->view->addHelperPath(str_replace('_', '/', self::NS), self::NS); } if ($strict) { $helper = $this->view->getHelper($proxy); } else { try { $helper = $this->view->getHelper($proxy); } catch (Exception $e) { return null; } } if (!$helper instanceof Navigation\Helper) { if ($strict) { $e = new Exception(sprintf('Proxy helper "%s" is not an instance of Life\\View\\Helper\\Navigation\\Helper', get_class($helper))); $e->setView($this->view); throw $e; } return null; } $this->_inject($helper); $this->_helpers[$proxy] = $helper; return $helper; }
/** * Start capturing content to push into placeholder * * @param int $type How to capture content into placeholder; append, prepend, or set * @return void * @throws Zend\View\Helper\Placeholer\Container\Exception if nested captures detected */ public function captureStart($type = AbstractContainer::APPEND, $key = null) { if ($this->_captureLock) { $e = new Exception('Cannot nest placeholder captures for the same placeholder'); $e->setView($this->view); throw $e; } $this->_captureLock = true; $this->_captureType = $type; if (null !== $key && is_scalar($key)) { $this->_captureKey = (string) $key; } ob_start(); }
/** * Finds a view script from the available directories. * * @param $name string The base name of the script. * @return void */ protected function _script($name) { if ($this->isLfiProtectionOn() && preg_match('#\\.\\.[\\\\/]#', $name)) { $e = new Exception('Requested scripts may not include parent directory traversal ("../", "..\\" notation)'); $e->setView($this); throw $e; } if (0 == count($this->_path['script'])) { $e = new Exception('no view script directory set; unable to determine location for view script'); $e->setView($this); throw $e; } foreach ($this->_path['script'] as $dir) { if (is_readable($dir . $name)) { return $dir . $name; } } $message = "script '{$name}' not found in path (" . implode(PATH_SEPARATOR, $this->_path['script']) . ")"; $e = new Exception($message); $e->setView($this); throw $e; }
public function setRole($role = null) { if (null === $role || is_string($role) || $role instanceof Zend_Acl_Role_Interface) { $this->_role = $role; } else { $e = new Exception(sprintf('$role must be a string, null, or an instance of Life\\Acl\\Role\\Interface; %s given', gettype($role))); $e->setView($this->view); throw $e; } return $this; }
public function renderPartial(Container $container = null, $partial = null) { if (null === $container) { $container = $this->getContainer(); } if (null === $partial) { $partial = $this->getPartial(); } if (empty($partial)) { $e = new Exception('Unable to render menu: No partial view script provided'); $e->setView($this->view); throw $e; } // put breadcrumb pages in model $model = array('pages' => array()); if ($active = $this->findActive($container)) { $active = $active['page']; $model['pages'][] = $active; while ($parent = $active->getParent()) { if ($parent instanceof NavigationPage) { $model['pages'][] = $parent; } else { break; } if ($parent === $container) { // break if at the root of the given container break; } $active = $parent; } $model['pages'] = array_reverse($model['pages']); } if (is_array($partial)) { if (count($partial) != 2) { $e = new Exception('Unable to render menu: A view partial supplied as an array must contain two values: partial view script and module where script can be found'); $e->setView($this->view); throw $e; } return $this->view->partial($partial[0], $partial[1], $model); } return $this->view->partial($partial, null, $model); }