PHP Class Bolt\Asset\Widget\Queue

Author: Gawain Lynch ([email protected])
Author: Bob den Otter ([email protected])
Inheritance: implements Bolt\Asset\QueueInterface, use trait Bolt\Asset\AssetSortTrait
Show file Open project: bolt/bolt

Protected Properties

Property Type Description
$cache Doctrine\Common\Cache\CacheProvider
$injector Bolt\Asset\Injector
$queue Queue with snippets of HTML to insert.
$render Twig_Environment

Public Methods

Method Description
__construct ( Bolt\Asset\Injector $injector, CacheProvider $cache, Twig_Environment $render ) Constructor.
add ( Bolt\Asset\Widget\WidgetAssetInterface $widget ) Add a wiget to the queue.
clear ( )
countItemsInQueue ( string $location, string $zone = Zone::FRONTEND ) : boolean Get the number of queued widgets.
get ( string $key ) : Bolt\Asset\Widget\WidgetAssetInterface Get a widget from the queue.
getQueue ( ) : Bolt\Asset\Widget\WidgetAssetInterface[] Get the queued widgets.
getRendered ( string $key ) : Twig_Markup | string Get a rendered (and potentially cached) widget from the queue.
hasItemsInQueue ( string $location, string $zone = Zone::FRONTEND ) : boolean Get the number of queued widgets.
process ( Request $request, Response $response )
render ( string $location, string $zone = Zone::FRONTEND, string $wrapperTemplate = 'widgetwrapper.twig' ) : string | null Render a location's widget.

Protected Methods

Method Description
addDeferredJavaScript ( Bolt\Asset\Widget\WidgetAssetInterface $widget, Response $response ) Insert a snippet of Javascript to fetch the actual widget's contents.
getHtml ( Bolt\Asset\Widget\WidgetAssetInterface $widget ) : string Get the HTML content from the widget.

Method Details

__construct() public method

NOTE: Constructor type hint for TwigEnvironment omitted for BC, add in v4
public __construct ( Bolt\Asset\Injector $injector, CacheProvider $cache, Twig_Environment $render )
$injector Bolt\Asset\Injector
$cache Doctrine\Common\Cache\CacheProvider
$render Twig_Environment

add() public method

Add a wiget to the queue.
public add ( Bolt\Asset\Widget\WidgetAssetInterface $widget )
$widget Bolt\Asset\Widget\WidgetAssetInterface

addDeferredJavaScript() protected method

Insert a snippet of Javascript to fetch the actual widget's contents.
protected addDeferredJavaScript ( Bolt\Asset\Widget\WidgetAssetInterface $widget, Response $response )
$widget Bolt\Asset\Widget\WidgetAssetInterface
$response Symfony\Component\HttpFoundation\Response

clear() public method

public clear ( )

countItemsInQueue() public method

Get the number of queued widgets.
public countItemsInQueue ( string $location, string $zone = Zone::FRONTEND ) : boolean
$location string Location (e.g. 'dashboard_aside_top')
$zone string Either Zone::FRONTEND or Zone::BACKEND
return boolean

get() public method

Get a widget from the queue.
public get ( string $key ) : Bolt\Asset\Widget\WidgetAssetInterface
$key string
return Bolt\Asset\Widget\WidgetAssetInterface

getHtml() protected method

Get the HTML content from the widget.
protected getHtml ( Bolt\Asset\Widget\WidgetAssetInterface $widget ) : string
$widget Bolt\Asset\Widget\WidgetAssetInterface
return string

getQueue() public method

Get the queued widgets.
public getQueue ( ) : Bolt\Asset\Widget\WidgetAssetInterface[]
return Bolt\Asset\Widget\WidgetAssetInterface[]

getRendered() public method

Get a rendered (and potentially cached) widget from the queue.
public getRendered ( string $key ) : Twig_Markup | string
$key string
return Twig_Markup | string

hasItemsInQueue() public method

Get the number of queued widgets.
public hasItemsInQueue ( string $location, string $zone = Zone::FRONTEND ) : boolean
$location string Location (e.g. 'dashboard_aside_top')
$zone string Either Zone::FRONTEND or Zone::BACKEND
return boolean

process() public method

public process ( Request $request, Response $response )
$request Symfony\Component\HttpFoundation\Request
$response Symfony\Component\HttpFoundation\Response

render() public method

Render a location's widget.
public render ( string $location, string $zone = Zone::FRONTEND, string $wrapperTemplate = 'widgetwrapper.twig' ) : string | null
$location string Location (e.g. 'dashboard_aside_top')
$zone string Either Zone::FRONTEND or Zone::BACKEND
$wrapperTemplate string Template file for wrapper
return string | null

Property Details

$cache protected property

protected CacheProvider,Doctrine\Common\Cache $cache
return Doctrine\Common\Cache\CacheProvider

$injector protected property

protected Injector,Bolt\Asset $injector
return Bolt\Asset\Injector

$queue protected property

Queue with snippets of HTML to insert.
protected $queue

$render protected property

protected Twig_Environment $render
return Twig_Environment