src/Theme.php
public function widget($className, $attributes = array())
    {
        static $widgets = array();

        // If the class name is not lead with upper case add prefix "Widget".
        if (! preg_match('|^[A-Z]|', $className)) {
            $className = ucfirst($className);
        }

        $widgetNamespace = $this->getConfig('namespaces.widget');

        $className = $widgetNamespace.'\\'.$className;

        if (! $instance = array_get($widgets, $className)) {
            $reflector = new ReflectionClass($className);

            if (! $reflector->isInstantiable()) {
                throw new UnknownWidgetClassException("Widget target [$className] is not instantiable.");
            }

            $instance = $reflector->newInstance($this, $this->config, $this->view);
            array_set($widgets, $className, $instance);
        }

        $instance->setAttributes($attributes);
        $instance->beginWidget();
        $instance->endWidget();

        return $instance;
    }
public function widget($className, $attributes = array())
    {
        static $widgets = array();

        // If the class name is not lead with upper case add prefix "Widget".
        if (! preg_match('|^[A-Z]|', $className)) {
            $className = ucfirst($className);
        }

        $widgetNamespace = $this->getConfig('namespaces.widget');

        $className = $widgetNamespace.'\\'.$className;

        if (! $instance = array_get($widgets, $className)) {
            $reflector = new ReflectionClass($className);

            if (! $reflector->isInstantiable()) {
                throw new UnknownWidgetClassException("Widget target [$className] is not instantiable.");
            }

            $instance = $reflector->newInstance($this, $this->config, $this->view);
            array_set($widgets, $className, $instance);
        }

        $instance->setAttributes($attributes);
        $instance->beginWidget();
        $instance->endWidget();

        return $instance;
    }
public function widget ( $ className , $ attributes = array ( ) ) { static $ widgets = array ( ) ; // If the class name is not lead with upper case add prefix "Widget". if ( ! preg_match ( '|^[A-Z]|' , $ className ) ) { $ className = ucfirst ( $ className ) ; } $ widgetNamespace = $ this -> getConfig ( 'namespaces.widget' ) ; $ className = $ widgetNamespace . '\\' . $ className ; if ( ! $ instance = array_get ( $ widgets , $ className ) ) { $ reflector = new ReflectionClass ( $ className ) ; if ( ! $ reflector -> isInstantiable ( ) ) { throw new UnknownWidgetClassException ( "Widget target [$className] is not instantiable." ) ; } $ instance = $ reflector -> newInstance ( $ this , $ this -> config , $ this -> view ) ; array_set ( $ widgets , $ className , $ instance ) ; } $ instance -> setAttributes ( $ attributes ) ; $ instance -> beginWidget ( ) ; $ instance -> endWidget ( ) ; return $ instance ; }
Widget instance.

@param  string $className
@param  array $attributes
@throws UnknownWidgetClassException
@return Teepluss\Theme\Widget
Widget instance .