Beispiel #1
0
 /**
  * Retrieve a value and return $default if there is no element set.
  *
  * @param  string $name
  * @param  mixed  $default
  * @return mixed
  */
 public function get($name, $default = null)
 {
     $name = $this->inflector->filter(['name' => $name]);
     if (array_key_exists($name, $this->data)) {
         return $this->data[$name];
     }
     return $default;
 }
Beispiel #2
0
    /**
     * Render layout
     *
     * Sets internal script path as last path on script path stack, assigns
     * layout variables to view, determines layout name using inflector, and
     * renders layout view script.
     *
     * $name will be passed to the inflector as the key 'script'.
     *
     * @param  mixed $name
     * @return mixed
     */
    public function render($name = null)
    {
        if (null === $name) {
            $name = $this->getLayout();
        }

        if ($this->inflectorEnabled() && (null !== ($inflector = $this->getInflector())))
        {
            $name = $this->_inflector->filter(array('script' => $name));
        }

        $view = $this->getView();

        if (null !== ($path = $this->getViewScriptPath())) {
            if ($view instanceof \Zend\View\PhpRenderer) {
                $view->resolver()->addPath($path);
            }
        } elseif (null !== ($path = $this->getViewBasePath())) {
            if ($view instanceof \Zend\View\PhpRenderer) {
                $view->resolver()->addPath($path . '/scripts');
            }
        }

        return $view->render($name);
    }
Beispiel #3
0
 /**
  * Render layout
  *
  * Sets internal script path as last path on script path stack, assigns
  * layout variables to view, determines layout name using inflector, and
  * renders layout view script.
  *
  * $name will be passed to the inflector as the key 'script'.
  *
  * @param  mixed $name
  * @return mixed
  */
 public function render($name = null)
 {
     if (null === $name) {
         $name = $this->getLayout();
     }
     if ($this->inflectorEnabled() && null !== ($inflector = $this->getInflector())) {
         $name = $this->_inflector->filter(array('script' => $name));
     }
     $view = $this->getView();
     if (null !== ($path = $this->getViewScriptPath())) {
         if (method_exists($view, 'addScriptPath')) {
             $view->addScriptPath($path);
         } else {
             $view->setScriptPath($path);
         }
     } elseif (null !== ($path = $this->getViewBasePath())) {
         $view->addBasePath($path, $this->_viewBasePrefix);
     }
     return $view->render($name);
 }
Beispiel #4
0
 /**
  * Returns template name
  *
  * If a template name is not specified as a widget's param
  * it is auto created from widget type name
  * (Note: each word of the widget type name will be separated with a dash ('-').
  *
  * @return string
  */
 protected function prepareTplName()
 {
     // We're separating each word of a widget class name using a dash (‘-‘).
     $inflector = new Inflector(':tplName');
     $inflector->setRules(array(':tplName' => array('Word\\CamelCaseToDash')));
     $className = $this->getWidgetTypeName();
     $tplName = $inflector->filter(array('tplName' => $className));
     return $tplName;
 }