mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
Simplifiying Helper and twig functions
Now, the CustomFieldsHelper methods and the twig function which render customFields require always a `Chill\CustomFields\Entity\CustomField`. The possibility to add a slug and an object as argument to those method is abandoned, and was not used in other bundle (nevertheless, the method to catch a customField from his slug was buggy).
This commit is contained in:
@@ -85,10 +85,10 @@ class CustomFieldRenderingTwig extends \Twig_Extension implements ContainerAware
|
||||
}
|
||||
|
||||
|
||||
public function isEmptyValue($customFieldorClass, $fields, $slug = null)
|
||||
public function isEmptyValue(CustomField $customField, $fields, $slug = null)
|
||||
{
|
||||
return $this->container->get('chill.custom_field.helper')
|
||||
->isEmptyValue($fields, $customFieldorClass);
|
||||
->isEmptyValue($fields, $customField);
|
||||
}
|
||||
|
||||
/* (non-PHPdoc)
|
||||
@@ -102,19 +102,15 @@ class CustomFieldRenderingTwig extends \Twig_Extension implements ContainerAware
|
||||
/**
|
||||
* Twig Extension that is used to render the label of a custom field.
|
||||
*
|
||||
* @param CustomField|object|string $customFieldOrClass Either a customField OR a customizable_entity OR the FQDN of the entity
|
||||
* @param CustomField $customField Either a customField OR a customizable_entity OR the FQDN of the entity
|
||||
* @param string $slug The slug ONLY necessary if the first argument is NOT a CustomField instance
|
||||
* @param array $params The parameters for rendering. Currently, 'label_layout' allow to choose a different label. Default is 'ChillCustomFieldsBundle:CustomField:render_label.html.twig'
|
||||
* @return string HTML representation of the custom field label.
|
||||
*/
|
||||
public function renderLabel($customFieldOrClass, $slug = null, array $params = array())
|
||||
public function renderLabel(CustomField $customField, $slug = null, array $params = array())
|
||||
{
|
||||
$resolvedParams = array_merge($this->defaultParams, $params);
|
||||
|
||||
$customField = ($customFieldOrClass instanceof CustomField)
|
||||
? $customFieldOrClass : $this->container->get('chill.custom_field.provider')
|
||||
->getCustomField($customFieldOrClass, $slug);
|
||||
|
||||
return $this->container->get('templating')
|
||||
->render($resolvedParams['label_layout'], array('customField' => $customField));
|
||||
}
|
||||
@@ -125,14 +121,14 @@ class CustomFieldRenderingTwig extends \Twig_Extension implements ContainerAware
|
||||
* The presentation of the value is influenced by the document type.
|
||||
*
|
||||
* @param array $fields The array raw, as stored in the db
|
||||
* @param CustomField|object|string $customFieldOrClass Either a customField OR a customizable_entity OR the FQDN of the entity
|
||||
* @param CustomField $customField Either a customField OR a customizable_entity OR the FQDN of the entity
|
||||
* @param string $documentType The type of the document (csv, html)
|
||||
* @param string $slug The slug of the custom field ONLY necessary if the first argument is NOT a CustomField instance
|
||||
* @return string HTML representation of the custom field value, as described in the CustomFieldInterface. Is HTML safe
|
||||
*/
|
||||
public function renderWidget(array $fields, $customFieldOrClass, $documentType='html', $slug = null)
|
||||
public function renderWidget(array $fields, CustomField $customField, $documentType='html')
|
||||
{
|
||||
return $this->container->get('chill.custom_field.helper')
|
||||
->renderCustomField($fields, $customFieldOrClass, $documentType, $slug);
|
||||
->renderCustomField($fields, $customField, $documentType);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user