eZPublishCommunityProject  2012.12
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension Class Reference

Twig content extension for eZ Publish specific usage. More...

+ Inheritance diagram for eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension:
+ Collaboration diagram for eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension:

Public Member Functions

 __construct (ContainerInterface $container, ConfigResolverInterface $resolver)
 
 getFilters ()
 Returns a list of filters to add to the existing list. More...
 
 getFunctions ()
 Returns a list of functions to add to the existing list. More...
 
 getImageVariation (Field $field, VersionInfo $versionInfo, $variationName)
 Returns the image variant object for $field/$versionInfo. More...
 
 getName ()
 Returns the name of the extension. More...
 
 initRuntime (Twig_Environment $environment)
 Initializes the template runtime (aka Twig environment). More...
 
 renderField (Content $content, $fieldIdentifier, array $params=array())
 Renders the HTML for a given field. More...
 
 xmltextToHtml5 ($xmlData)
 Implements the "xmltext_to_html5" filter. More...
 

Protected Member Functions

 getBlocksByField (Content $content, Field $field, $localTemplate=null)
 Returns template blocks for $field. More...
 
 getFieldBlockName (Content $content, Field $field)
 Returns expected block name for $field, attached in $content. More...
 
 getFieldTypeIdentifier (Content $content, Field $field)
 Returns the field type identifier for $field. More...
 
 getRenderFieldBlockParameters (Content $content, Field $field, array $params=array())
 Generates the array of parameter to pass to the field template. More...
 
 getXmlTextConverter ()
 
 searchBlock ($blockName, Twig_Template $tpl)
 Returns the block named $blockName in the given template. More...
 

Protected Attributes

 $blocks
 
 $container
 
 $environment
 
 $fieldTypeIdentifiers = array()
 
 $imageVariationService
 
 $resources
 
 $template
 
 $xmlTextConverter
 

Detailed Description

Twig content extension for eZ Publish specific usage.

Exposes helpers to play with public API objects.

Constructor & Destructor Documentation

eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::__construct ( ContainerInterface  $container,
ConfigResolverInterface  $resolver 
)

Member Function Documentation

eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::getBlocksByField ( Content  $content,
Field  $field,
  $localTemplate = null 
)
protected

Returns template blocks for $field.

First check in the $localTemplate if it's provided. Template block convention name is <fieldTypeIdentifier>_field Example: 'ezstring_field' will be relevant for a full view of ezstring field type

Parameters
Content$content
Field$field
null | string$localTemplatea file where to look for the block first
Exceptions
\LogicExceptionIf no template block can be found for $field
Returns
array

Referenced by eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension\renderField().

eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::getFieldBlockName ( Content  $content,
Field  $field 
)
protected

Returns expected block name for $field, attached in $content.

Parameters
\eZ\Publish\Core\Repository\Values\Content\Content$content
\eZ\Publish\API\Repository\Values\Content\Field$field
Returns
string

Referenced by eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension\getBlocksByField(), and eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension\renderField().

eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::getFieldTypeIdentifier ( Content  $content,
Field  $field 
)
protected

Returns the field type identifier for $field.

Parameters
\eZ\Publish\Core\Repository\Values\Content\Content$content
\eZ\Publish\API\Repository\Values\Content\Field$field
Returns
string

Referenced by eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension\getFieldBlockName(), and eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension\getRenderFieldBlockParameters().

eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::getFilters ( )

Returns a list of filters to add to the existing list.

Returns
array
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::getFunctions ( )

Returns a list of functions to add to the existing list.

Returns
array
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::getImageVariation ( Field  $field,
VersionInfo  $versionInfo,
  $variationName 
)

Returns the image variant object for $field/$versionInfo.

Parameters
\eZ\Publish\API\Repository\Values\Content\Field$field
\eZ\Publish\API\Repository\Values\Content\VersionInfo$versionInfo
string$variationName
Returns
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::getName ( )

Returns the name of the extension.

Returns
string The extension name
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::getRenderFieldBlockParameters ( Content  $content,
Field  $field,
array  $params = array() 
)
protected

Generates the array of parameter to pass to the field template.

Parameters
\eZ\Publish\Core\Repository\Values\Content\Content$content
\eZ\Publish\Core\Repository\Values\Content\Field$fieldthe Field to display
array$paramsAn array of parameters to pass to the field view
Returns
array

Referenced by eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension\renderField().

eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::getXmlTextConverter ( )
protected
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::initRuntime ( Twig_Environment  $environment)

Initializes the template runtime (aka Twig environment).

Parameters
\Twig_Environment$environment
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::renderField ( Content  $content,
  $fieldIdentifier,
array  $params = array() 
)

Renders the HTML for a given field.

Parameters
\eZ\Publish\Core\Repository\Values\Content\Content$content
string$fieldIdentifierIdentifier for the field we want to render
array$paramsAn array of parameters to pass to the field view
Exceptions
\InvalidArgumentExceptionIf $fieldIdentifier is invalid in $content
Returns
string The HTML markup
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::searchBlock (   $blockName,
Twig_Template  $tpl 
)
protected

Returns the block named $blockName in the given template.

If it's not found, returns null.

Parameters
string$blockName
\Twig_Template$tpl
Returns
array|null

Referenced by eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension\getBlocksByField().

eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::xmltextToHtml5 (   $xmlData)

Implements the "xmltext_to_html5" filter.

Parameters
string$xmlData
Returns
string

Member Data Documentation

eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::$blocks
protected
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::$container
protected
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::$environment
protected
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::$fieldTypeIdentifiers = array()
protected
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::$imageVariationService
protected
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::$resources
protected
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::$template
protected
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::$xmlTextConverter
protected

The documentation for this class was generated from the following file: