Exemplo n.º 1
0
 /**
  * Magic overload: Proxy to other navigation helpers or the container
  *
  * Examples of usage from a view script or layout:
  * <code>
  * // proxy to Menu helper and render container:
  * echo $this->navigation()->menu();
  *
  * // proxy to Breadcrumbs helper and set indentation:
  * $this->navigation()->breadcrumbs()->setIndent(8);
  *
  * // proxy to container and find all pages with 'blog' route:
  * $blogPages = $this->navigation()->findAllByRoute('blog');
  * </code>
  *
  * @param  string $method             helper name or method name in
  *                                    container
  * @param  array  $arguments          [optional] arguments to pass
  * @return mixed                      returns what the proxied call returns
  * @throws \Zend\View\Exception        if proxying to a helper, and the
  *                                    helper is not an instance of the
  *                                    interface specified in
  *                                    {@link findHelper()}
  * @throws \Zend\Navigation\Exception  if method does not exist in container
  */
 public function __call($method, array $arguments = array())
 {
     // check if call should proxy to another helper
     if ($helper = $this->findHelper($method, false)) {
         return call_user_func_array($helper, $arguments);
     }
     // default behaviour: proxy call to container
     return parent::__call($method, $arguments);
 }
Exemplo n.º 2
0
Arquivo: Links.php Projeto: noose/zf2
    /**
     * Magic overload: Proxy calls to {@link findRelation()} or container
     *
     * Examples of finder calls:
     * <code>
     * // METHOD                  // SAME AS
     * $h->findRelNext($page);    // $h->findRelation($page, 'rel', 'next')
     * $h->findRevSection($page); // $h->findRelation($page, 'rev', 'section');
     * $h->findRelFoo($page);     // $h->findRelation($page, 'rel', 'foo');
     * </code>
     *
     * @param  string $method             method name
     * @param  array  $arguments          method arguments
     * @throws \Zend\Navigation\Exception  if method does not exist in container
     */
    public function __call($method, array $arguments = array())
    {
        if (@preg_match('/find(Rel|Rev)(.+)/', $method, $match)) {
            return $this->findRelation($arguments[0],
                                       strtolower($match[1]),
                                       strtolower($match[2]));
        }

        return parent::__call($method, $arguments);
    }
Exemplo n.º 3
0
 /**
  * Magic overload: Proxy to other navigation helpers or the container
  *
  * Examples of usage from a view script or layout:
  * <code>
  * // proxy to Menu helper and render container:
  * echo $this->navigation()->menu();
  *
  * // proxy to Breadcrumbs helper and set indentation:
  * $this->navigation()->breadcrumbs()->setIndent(8);
  *
  * // proxy to container and find all pages with 'blog' route:
  * $blogPages = $this->navigation()->findAllByRoute('blog');
  * </code>
  *
  * @param  string $method             helper name or method name in container
  * @param  array  $arguments          [optional] arguments to pass
  * @throws \Zend\View\Exception\ExceptionInterface        if proxying to a helper, and the
  *                                    helper is not an instance of the
  *                                    interface specified in
  *                                    {@link findHelper()}
  * @throws \Zend\Navigation\Exception\ExceptionInterface  if method does not exist in container
  * @return mixed                      returns what the proxied call returns
  */
 public function __call($method, array $arguments = array())
 {
     // check if call should proxy to another helper
     $helper = $this->findHelper($method, false);
     if ($helper) {
         if ($helper instanceof ServiceLocatorAwareInterface && $this->getServiceLocator()) {
             $helper->setServiceLocator($this->getServiceLocator());
         }
         return call_user_func_array($helper, $arguments);
     }
     // default behaviour: proxy call to container
     return parent::__call($method, $arguments);
 }
Exemplo n.º 4
0
 /**
  * Magic overload: Proxy calls to {@link findRelation()} or container
  *
  * Examples of finder calls:
  * <code>
  * // METHOD                  // SAME AS
  * $h->findRelNext($page);    // $h->findRelation($page, 'rel', 'next')
  * $h->findRevSection($page); // $h->findRelation($page, 'rev', 'section');
  * $h->findRelFoo($page);     // $h->findRelation($page, 'rel', 'foo');
  * </code>
  *
  * @param  string $method
  * @param  array  $arguments
  * @return mixed
  * @throws Exception\ExceptionInterface
  */
 public function __call($method, array $arguments = array())
 {
     ErrorHandler::start(E_WARNING);
     $result = preg_match('/find(Rel|Rev)(.+)/', $method, $match);
     ErrorHandler::stop();
     if ($result) {
         return $this->findRelation($arguments[0], strtolower($match[1]), strtolower($match[2]));
     }
     return parent::__call($method, $arguments);
 }