eZPublishCommunityProject  2013.9
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, TranslationHelper $translationHelper, FieldHelper $fieldHelper)
 
 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 variation object for $field/$versionInfo. More...
 
 getName ()
 Returns the name of the extension. More...
 
 getTranslatedContentName (Content $content, $forcedLanguage=null)
 
 getTranslatedFieldValue (Content $content, $fieldDefIdentifier, $forcedLanguage=null)
 
 initRuntime (Twig_Environment $environment)
 Initializes the template runtime (aka Twig environment). More...
 
 isFieldEmpty (Content $content, $fieldDefIdentifier, $forcedLanguage=null)
 Checks if a given field is considered empty. More...
 
 renderField (Content $content, $fieldIdentifier, array $params=array())
 Renders the HTML for a given field. More...
 
 renderFieldDefinitionSettings (FieldDefinition $definition)
 Renders the HTML for the settings for the given field definition $definition. More...
 
 xmltextToHtml5 ($xmlData)
 Implements the "xmltext_to_html5" filter. More...
 

Protected Member Functions

 getBlockByFieldDefinition (FieldDefinition $definition)
 Returns the template block for the settings of the field definition $definition. More...
 
 getBlockByName ($name, $resourcesName)
 Returns the template block of the given $name available in the resources which name is $resourcesName. More...
 
 getBlocksByField (Content $content, Field $field, $localTemplate=null)
 Returns template blocks for $field. More...
 
 getRenderFieldBlockName (Content $content, Field $field)
 Returns expected block name for $field, attached in $content. More...
 
 getRenderFieldDefinitionSettingsBlockName (FieldDefinition $definition)
 Returns the name of the block to render the settings of the field definition $definition. More...
 
 getXmlTextConverter ()
 
 searchBlock ($blockName, Twig_Template $tpl)
 Returns the block named $blockName in the given template. More...
 

Protected Attributes

 $blocks
 
 $configResolver
 
 $container
 
 $environment
 
 $fieldHelper
 
 $fieldTypeIdentifiers = array()
 
 $imageVariationService
 
 $renderFieldDefinitionSettingsResources
 
 $renderFieldResources
 
 $template
 
 $translationHelper
 
 $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,
TranslationHelper  $translationHelper,
FieldHelper  $fieldHelper 
)

Member Function Documentation

eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::getBlockByFieldDefinition ( FieldDefinition  $definition)
protected

Returns the template block for the settings of the field definition $definition.

Parameters
\eZ\Publish\API\Repository\Values\ContentType\FieldDefinition$definition
Returns
array

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

eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::getBlockByName (   $name,
  $resourcesName 
)
protected

Returns the template block of the given $name available in the resources which name is $resourcesName.

Parameters
string$name
string$resourcesName
Exceptions
\LogicExceptionIf no template block can be found for $field
Returns
array

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

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 | \Twig_Template$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::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 variation 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::getRenderFieldBlockName ( 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::getRenderFieldDefinitionSettingsBlockName ( FieldDefinition  $definition)
protected

Returns the name of the block to render the settings of the field definition $definition.

Parameters
\eZ\Publish\API\Repository\Values\ContentType\FieldDefinition$definition
Returns
string

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

eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::getTranslatedContentName ( Content  $content,
  $forcedLanguage = null 
)
Parameters
\eZ\Publish\Core\Repository\Values\Content\Content$content
string$forcedLanguageLocale we want the content name translation in (e.g. "fre-FR"). Null by default (takes current locale)
Returns
string
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::getTranslatedFieldValue ( Content  $content,
  $fieldDefIdentifier,
  $forcedLanguage = null 
)
Parameters
\eZ\Publish\Core\Repository\Values\Content\Content$content
string$fieldDefIdentifierIdentifier for the field we want to get the value from.
string$forcedLanguageLocale we want the content name translation in (e.g. "fre-FR"). Null by default (takes current locale).
Returns
mixed A primitive type or a field type Value object depending on the field type.
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::isFieldEmpty ( Content  $content,
  $fieldDefIdentifier,
  $forcedLanguage = null 
)

Checks if a given field is considered empty.

Parameters
\eZ\Publish\Core\Repository\Values\Content\Content$content
string$fieldDefIdentifierIdentifier for the field we want to get the value from.
string$forcedLanguageLocale we want the content name translation in (e.g. "fre-FR"). Null by default (takes current locale).
Returns
bool
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::renderFieldDefinitionSettings ( FieldDefinition  $definition)

Renders the HTML for the settings for the given field definition $definition.

Parameters
\eZ\Publish\API\Repository\Values\ContentType\FieldDefinition$definition
Returns
string
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\getBlockByName(), and 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::$configResolver
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::$fieldHelper
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::$renderFieldDefinitionSettingsResources
protected
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::$renderFieldResources
protected
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::$template
protected
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::$translationHelper
protected
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\ContentExtension::$xmlTextConverter
protected

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