protected function _resolveWidget($widget)
    {
        $type = gettype($widget);
        if ($type === 'object') {
            return $widget;
        }

        if ($type === 'string') {
            $widget = [$widget];
        }

        $class = array_shift($widget);
        $className = App::className($class, 'View/Widget', 'Widget');
        if ($className === false || !class_exists($className)) {
            throw new RuntimeException(sprintf('Unable to locate widget class "%s"', $class));
        }
        if ($type === 'array' && count($widget)) {
            $reflection = new ReflectionClass($className);
            $arguments = [$this->_templates];
            foreach ($widget as $requirement) {
                $arguments[] = $this->get($requirement);
            }
            $instance = $reflection->newInstanceArgs($arguments);
        } else {
            $instance = new $className($this->_templates);
        }
        if (!($instance instanceof WidgetInterface)) {
            throw new RuntimeException(sprintf('"%s" does not implement the WidgetInterface', $className));
        }

        return $instance;
    }
protected function _resolveWidget($widget)
    {
        $type = gettype($widget);
        if ($type === 'object') {
            return $widget;
        }

        if ($type === 'string') {
            $widget = [$widget];
        }

        $class = array_shift($widget);
        $className = App::className($class, 'View/Widget', 'Widget');
        if ($className === false || !class_exists($className)) {
            throw new RuntimeException(sprintf('Unable to locate widget class "%s"', $class));
        }
        if ($type === 'array' && count($widget)) {
            $reflection = new ReflectionClass($className);
            $arguments = [$this->_templates];
            foreach ($widget as $requirement) {
                $arguments[] = $this->get($requirement);
            }
            $instance = $reflection->newInstanceArgs($arguments);
        } else {
            $instance = new $className($this->_templates);
        }
        if (!($instance instanceof WidgetInterface)) {
            throw new RuntimeException(sprintf('"%s" does not implement the WidgetInterface', $className));
        }

        return $instance;
    }
protected function _resolveWidget ( $ widget ) { $ type = gettype ( $ widget ) ; if ( $ type === 'object' ) { return $ widget ; } if ( $ type === 'string' ) { $ widget = [ $ widget ] ; } $ class = array_shift ( $ widget ) ; $ className = App :: className ( $ class , 'View/Widget' , 'Widget' ) ; if ( $ className === false || ! class_exists ( $ className ) ) { throw new RuntimeException ( sprintf ( 'Unable to locate widget class "%s"' , $ class ) ) ; } if ( $ type === 'array' && count ( $ widget ) ) { $ reflection = new ReflectionClass ( $ className ) ; $ arguments = [ $ this -> _templates ] ; foreach ( $ widget as $ requirement ) { $ arguments [ ] = $ this -> get ( $ requirement ) ; } $ instance = $ reflection -> newInstanceArgs ( $ arguments ) ; } else { $ instance = new $ className ( $ this -> _templates ) ; } if ( ! ( $ instance instanceof WidgetInterface ) ) { throw new RuntimeException ( sprintf ( '"%s" does not implement the WidgetInterface' , $ className ) ) ; } return $ instance ; }
Resolves a widget spec into an instance.

@param mixed $widget The widget to get
@return \Cake\View\Widget\WidgetInterface
@throws \RuntimeException when class cannot be loaded or does not implement WidgetInterface.
@throws \ReflectionException
Resolves a widget spec into an instance .