Bolt\Twig\Handler\WidgetHandler::countWidgets PHP Method

countWidgets() public method

Return the number of widgets in the queue for a given type / location.
public countWidgets ( string $location = null, string $zone = Zone::FRONTEND ) : integer
$location string Location (e.g. 'dashboard_aside_top')
$zone string Either Zone::FRONTEND or Zone::BACKEND
return integer
    public function countWidgets($location = null, $zone = Zone::FRONTEND)
    {
        if ($location === null && $this->app['twig.options']['strict_variables'] === true) {
            throw new \InvalidArgumentException('countwidgets() requires a location, none given');
        }
        return $this->app['asset.queue.widget']->countItemsInQueue($location, $zone);
    }

Usage Example

Beispiel #1
0
 public function testCountWidgetsNoLocationStrict()
 {
     $app = $this->getStrictVariablesApp(true);
     $handler = new WidgetHandler($app);
     $widget = (new Widget())->setZone('frontend')->setLocation('gum-tree')->setContent('<blink>Drop Bear Warning!</blink>');
     $this->setExpectedException('InvalidArgumentException', 'countwidgets() requires a location, none given');
     $app['asset.queue.widget']->add($widget);
     $handler->countWidgets();
 }