mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-04 05:44:58 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,57 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\CustomFieldsBundle\CustomFields;
|
||||
|
||||
use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer;
|
||||
use Chill\CustomFieldsBundle\Form\Type\ChoicesListType;
|
||||
use Chill\CustomFieldsBundle\Form\Type\ChoicesType;
|
||||
use Chill\CustomFieldsBundle\Form\Type\ChoiceWithOtherType;
|
||||
use Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer;
|
||||
use Symfony\Bridge\Twig\TwigEngine;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use LogicException;
|
||||
use Symfony\Bridge\Twig\TwigEngine;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function LogicException;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* @author Marc Ducobu <marc@champs-libes.coop>
|
||||
*/
|
||||
class CustomFieldChoice extends AbstractCustomField
|
||||
{
|
||||
const ALLOW_OTHER = 'other';
|
||||
const OTHER_VALUE_LABEL = 'otherValueLabel';
|
||||
const MULTIPLE = 'multiple';
|
||||
const EXPANDED = 'expanded';
|
||||
const CHOICES = 'choices';
|
||||
public const ALLOW_OTHER = 'other';
|
||||
|
||||
public const CHOICES = 'choices';
|
||||
|
||||
public const EXPANDED = 'expanded';
|
||||
|
||||
public const MULTIPLE = 'multiple';
|
||||
|
||||
public const OTHER_VALUE_LABEL = 'otherValueLabel';
|
||||
|
||||
private $defaultLocales;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TwigEngine
|
||||
*/
|
||||
private $templating;
|
||||
@@ -60,48 +46,51 @@ class CustomFieldChoice extends AbstractCustomField
|
||||
* @var TranslatableStringHelper Helper that find the string in current locale from an array of translation
|
||||
*/
|
||||
private $translatableStringHelper;
|
||||
|
||||
|
||||
/**
|
||||
* CustomFieldChoice constructor.
|
||||
*
|
||||
* @param TranslatorInterface $translator
|
||||
* @param TwigEngine $templating
|
||||
* @param TranslatableStringHelper $translatableStringHelper
|
||||
*/
|
||||
public function __construct(
|
||||
TranslatorInterface $translator,
|
||||
TwigEngine $templating,
|
||||
TranslatableStringHelper $translatableStringHelper)
|
||||
TranslatableStringHelper $translatableStringHelper
|
||||
)
|
||||
{
|
||||
$this->defaultLocales = $translator->getFallbackLocales();
|
||||
$this->templating = $templating;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
public function allowOtherChoice(CustomField $cf)
|
||||
{
|
||||
return $cf->getOptions()[self::ALLOW_OTHER];
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, CustomField $customField)
|
||||
{
|
||||
//prepare choices
|
||||
$choices = array();
|
||||
$choices = [];
|
||||
$customFieldOptions = $customField->getOptions();
|
||||
|
||||
foreach($customFieldOptions[self::CHOICES] as $persistedChoices) {
|
||||
if ($persistedChoices['active']){
|
||||
foreach ($customFieldOptions[self::CHOICES] as $persistedChoices) {
|
||||
if ($persistedChoices['active']) {
|
||||
$choices[$persistedChoices['slug']] = $this->translatableStringHelper->localize($persistedChoices['name']);
|
||||
}
|
||||
}
|
||||
|
||||
//prepare $options
|
||||
$options = array(
|
||||
$options = [
|
||||
'multiple' => $customFieldOptions[self::MULTIPLE],
|
||||
'choices' => array_combine(array_values($choices),array_keys($choices)),
|
||||
'choices' => array_combine(array_values($choices), array_keys($choices)),
|
||||
'required' => $customField->isRequired(),
|
||||
'label' => $this->translatableStringHelper->localize($customField->getName())
|
||||
);
|
||||
'label' => $this->translatableStringHelper->localize($customField->getName()),
|
||||
];
|
||||
|
||||
//if allow_other = true
|
||||
if ($customFieldOptions[self::ALLOW_OTHER] == true) {
|
||||
if (true == $customFieldOptions[self::ALLOW_OTHER]) {
|
||||
$otherValueLabel = null;
|
||||
if(array_key_exists(self::OTHER_VALUE_LABEL, $customFieldOptions)) {
|
||||
|
||||
if (array_key_exists(self::OTHER_VALUE_LABEL, $customFieldOptions)) {
|
||||
$otherValueLabel = $this->translatableStringHelper->localize(
|
||||
$customFieldOptions[self::OTHER_VALUE_LABEL]
|
||||
);
|
||||
@@ -113,10 +102,10 @@ class CustomFieldChoice extends AbstractCustomField
|
||||
$customField->getSlug(),
|
||||
ChoiceWithOtherType::class,
|
||||
$options,
|
||||
array('other_value_label'=> $otherValueLabel)
|
||||
)
|
||||
->addModelTransformer(new CustomFieldDataTransformer($this, $customField)));
|
||||
|
||||
['other_value_label' => $otherValueLabel]
|
||||
)
|
||||
->addModelTransformer(new CustomFieldDataTransformer($this, $customField))
|
||||
);
|
||||
} else { //if allow_other = false
|
||||
//we add the 'expanded' to options
|
||||
$options['expanded'] = $customFieldOptions[self::EXPANDED];
|
||||
@@ -131,41 +120,41 @@ class CustomFieldChoice extends AbstractCustomField
|
||||
public function buildOptionsForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add(self::MULTIPLE, ChoiceType::class, array(
|
||||
->add(self::MULTIPLE, ChoiceType::class, [
|
||||
'expanded' => true,
|
||||
'multiple' => false,
|
||||
'choices' => array(
|
||||
'choices' => [
|
||||
'Multiple' => '1',
|
||||
'Unique' => '0'),
|
||||
'Unique' => '0', ],
|
||||
'empty_data' => '0',
|
||||
'label' => 'Multiplicity'
|
||||
))
|
||||
->add(self::EXPANDED, ChoiceType::class, array(
|
||||
'label' => 'Multiplicity',
|
||||
])
|
||||
->add(self::EXPANDED, ChoiceType::class, [
|
||||
'expanded' => true,
|
||||
'multiple' => false,
|
||||
'choices' => array(
|
||||
'choices' => [
|
||||
'Expanded' => '1',
|
||||
'Non expanded' => '0'),
|
||||
'Non expanded' => '0', ],
|
||||
'empty_data' => '0',
|
||||
'label' => 'Choice display'
|
||||
))
|
||||
->add(self::ALLOW_OTHER, ChoiceType::class, array(
|
||||
'label' => 'Choice display',
|
||||
])
|
||||
->add(self::ALLOW_OTHER, ChoiceType::class, [
|
||||
'label' => 'Allow other',
|
||||
'choices' => array(
|
||||
'choices' => [
|
||||
'No' => '0',
|
||||
'Yes' => '1'),
|
||||
'Yes' => '1', ],
|
||||
'empty_data' => '0',
|
||||
'expanded' => true,
|
||||
'multiple' => false
|
||||
))
|
||||
->add(self::OTHER_VALUE_LABEL, TranslatableStringFormType::class, array(
|
||||
'label' => 'Other value label (empty if use by default)'))
|
||||
->add(self::CHOICES, ChoicesType::class, array(
|
||||
'multiple' => false,
|
||||
])
|
||||
->add(self::OTHER_VALUE_LABEL, TranslatableStringFormType::class, [
|
||||
'label' => 'Other value label (empty if use by default)', ])
|
||||
->add(self::CHOICES, ChoicesType::class, [
|
||||
'entry_type' => ChoicesListType::class,
|
||||
'allow_add' => true
|
||||
));
|
||||
'allow_add' => true,
|
||||
]);
|
||||
|
||||
return $builder;
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function deserialize($serialized, CustomField $customField)
|
||||
@@ -175,12 +164,183 @@ class CustomFieldChoice extends AbstractCustomField
|
||||
|
||||
if ($options[self::MULTIPLE]) {
|
||||
return $this->deserializeToMultiple($serialized, $options[self::ALLOW_OTHER]);
|
||||
} else {
|
||||
return $this->deserializeToUnique($serialized, $options[self::ALLOW_OTHER]);
|
||||
}
|
||||
|
||||
return $this->deserializeToUnique($serialized, $options[self::ALLOW_OTHER]);
|
||||
|
||||
return $serialized;
|
||||
}
|
||||
|
||||
public function extractOtherValue(CustomField $cf, ?array $data = null)
|
||||
{
|
||||
return $data['_other'];
|
||||
}
|
||||
|
||||
public function getChoices(CustomField $cf)
|
||||
{
|
||||
if ($cf->getOptions()[self::MULTIPLE]) {
|
||||
$choices = [];
|
||||
|
||||
foreach ($cf->getOptions()[self::CHOICES] as $choice) {
|
||||
if (false === $choices['active']) {
|
||||
continue;
|
||||
}
|
||||
$choices[$choice['slug']] = $this->translatableStringHelper
|
||||
->localize($choice['name']);
|
||||
}
|
||||
|
||||
if ($this->allowOtherChoice($cf)) {
|
||||
$labels = $cf->getOptions()[self::OTHER_VALUE_LABEL];
|
||||
|
||||
if (!is_array($labels) or count($labels) === 0) {
|
||||
$labels['back'] = 'other value';
|
||||
}
|
||||
$choices['_other'] = $this->translatableStringHelper
|
||||
->localize($labels);
|
||||
}
|
||||
|
||||
return $choices;
|
||||
}
|
||||
|
||||
return [
|
||||
$cf->getSlug() => $this->translatableStringHelper->localize($cf->getName()),
|
||||
];
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'Choices';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the choice given in $choiceSlug is checked inside $data.
|
||||
*
|
||||
* Used in list exports.
|
||||
*
|
||||
* @param string $choiceSlug the slug of the choice we want to know if it was checked
|
||||
* @param array|string $data the data of the field
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isChecked(CustomField $cf, $choiceSlug, $data)
|
||||
{
|
||||
if (null === $data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($cf->getOptions()[self::MULTIPLE]) {
|
||||
if ($cf->getOptions()[self::ALLOW_OTHER]) {
|
||||
return \in_array($choiceSlug, $this->deserialize($data, $cf)['_choices']);
|
||||
}
|
||||
|
||||
return \in_array($choiceSlug, $this->deserialize($data, $cf));
|
||||
}
|
||||
|
||||
if ($cf->getOptions()[self::ALLOW_OTHER]) {
|
||||
return $this->deserialize($data, $cf)['_choices'] === $choiceSlug;
|
||||
}
|
||||
|
||||
return $this->deserialize($data, $cf) === $choiceSlug;
|
||||
}
|
||||
|
||||
public function isEmptyValue($value, CustomField $customField)
|
||||
{
|
||||
if (null === $value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// if multiple choice OR multiple/single choice with other
|
||||
if (is_array($value)) {
|
||||
// if allow other
|
||||
if (array_key_exists('_choices', $value)) {
|
||||
if (null === $value['_choices']) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return empty($value['_choices']);
|
||||
} // we do not have 'allow other'
|
||||
|
||||
if (count($value) === 1) {
|
||||
return empty($value[0]);
|
||||
}
|
||||
|
||||
return empty($value);
|
||||
}
|
||||
|
||||
return empty($value);
|
||||
|
||||
throw LogicException('This case is not expected.');
|
||||
}
|
||||
|
||||
public function isMultiple(CustomField $cf)
|
||||
{
|
||||
return $cf->getOptions()[self::MULTIPLE];
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal this function is able to receive data whichever is the value of "other", "multiple"
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $documentType
|
||||
*
|
||||
* @return string html representation
|
||||
*/
|
||||
public function render($value, CustomField $customField, $documentType = 'html')
|
||||
{
|
||||
//extract the data. They are under a _choice key if they are stored with allow_other
|
||||
$data = (isset($value['_choices'])) ? $value['_choices'] : $value;
|
||||
$selected = (is_array($data)) ? $data : [$data];
|
||||
$choices = $customField->getOptions()[self::CHOICES];
|
||||
|
||||
if (in_array('_other', $selected)) {
|
||||
$choices[] = ['name' => $value['_other'], 'slug' => '_other'];
|
||||
}
|
||||
|
||||
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:choice.html.twig';
|
||||
|
||||
if ('csv' == $documentType) {
|
||||
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:choice.csv.twig';
|
||||
}
|
||||
|
||||
return $this->templating
|
||||
->render(
|
||||
$template,
|
||||
[
|
||||
'choices' => $choices,
|
||||
'selected' => $selected,
|
||||
'multiple' => $customField->getOptions()[self::MULTIPLE],
|
||||
'expanded' => $customField->getOptions()[self::EXPANDED],
|
||||
'locales' => $this->defaultLocales,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function serialize($value, CustomField $customField)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* deserialized the data from the database to a multiple
|
||||
* field.
|
||||
*
|
||||
* @param mixed $serialized
|
||||
* @param bool $allowOther
|
||||
*/
|
||||
private function deserializeToMultiple($serialized, $allowOther)
|
||||
{
|
||||
$value = $this->guessValue($serialized);
|
||||
|
||||
// set in an array : we want a multiple
|
||||
$fixedValue = is_array($value) ? $value : [$value];
|
||||
|
||||
if ($allowOther) {
|
||||
return $this->deserializeWithAllowOther($serialized, $fixedValue);
|
||||
}
|
||||
|
||||
return $fixedValue;
|
||||
}
|
||||
|
||||
private function deserializeToUnique($serialized, $allowOther)
|
||||
{
|
||||
$value = $this->guessValue($serialized);
|
||||
@@ -194,40 +354,19 @@ class CustomFieldChoice extends AbstractCustomField
|
||||
|
||||
if ($allowOther) {
|
||||
return $this->deserializeWithAllowOther($serialized, $fixedValue);
|
||||
} else {
|
||||
return $fixedValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* deserialized the data from the database to a multiple
|
||||
* field
|
||||
*
|
||||
* @param mixed $serialized
|
||||
* @param boolean $allowOther
|
||||
*/
|
||||
private function deserializeToMultiple($serialized, $allowOther)
|
||||
{
|
||||
$value = $this->guessValue($serialized);
|
||||
|
||||
// set in an array : we want a multiple
|
||||
$fixedValue = is_array($value) ? $value : array($value);
|
||||
|
||||
if ($allowOther) {
|
||||
return $this->deserializeWithAllowOther($serialized, $fixedValue);
|
||||
} else {
|
||||
return $fixedValue;
|
||||
}
|
||||
return $fixedValue;
|
||||
}
|
||||
|
||||
private function deserializeWithAllowOther($serialized, $value)
|
||||
{
|
||||
$existingOther = isset($serialized['_other']) ? $serialized['_other'] : '';
|
||||
$existingOther = $serialized['_other'] ?? '';
|
||||
|
||||
return array(
|
||||
return [
|
||||
'_other' => $existingOther,
|
||||
'_choices' => $value
|
||||
);
|
||||
'_choices' => $value,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,177 +376,27 @@ class CustomFieldChoice extends AbstractCustomField
|
||||
* **is not** the content of the _other field, but the `_other` string.
|
||||
*
|
||||
* @param array|string $value
|
||||
*
|
||||
* @throws LogicException if the case is not covered by this
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \LogicException if the case is not covered by this
|
||||
*/
|
||||
private function guessValue($value)
|
||||
{
|
||||
if ($value === NULL) {
|
||||
return NULL;
|
||||
if (null === $value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!is_array($value)) {
|
||||
return $value;
|
||||
} else {
|
||||
// we have a field with "allow other"
|
||||
if (array_key_exists('_choices', $value)) {
|
||||
return $value['_choices'];
|
||||
} else {
|
||||
// we have a field with "multiple"
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
throw \LogicException("This case is not expected.");
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'Choices';
|
||||
}
|
||||
|
||||
public function isEmptyValue($value, CustomField $customField)
|
||||
{
|
||||
if ($value === NULL) {
|
||||
return true;
|
||||
// we have a field with "allow other"
|
||||
if (array_key_exists('_choices', $value)) {
|
||||
return $value['_choices'];
|
||||
}
|
||||
|
||||
// if multiple choice OR multiple/single choice with other
|
||||
if (is_array($value))
|
||||
{
|
||||
// if allow other
|
||||
if (array_key_exists('_choices', $value)) {
|
||||
if ($value['_choices'] === NULL) {
|
||||
return true;
|
||||
}
|
||||
return empty($value['_choices']);
|
||||
} else { // we do not have 'allow other'
|
||||
if (count($value) === 1){
|
||||
return empty($value[0]);
|
||||
} else {
|
||||
return empty($value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return empty($value);
|
||||
}
|
||||
|
||||
throw \LogicException("This case is not expected.");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @internal this function is able to receive data whichever is the value of "other", "multiple"
|
||||
* @param mixed $value
|
||||
* @param CustomField $customField
|
||||
* @return string html representation
|
||||
*/
|
||||
public function render($value, CustomField $customField, $documentType = 'html')
|
||||
{
|
||||
//extract the data. They are under a _choice key if they are stored with allow_other
|
||||
$data = (isset($value['_choices'])) ? $value['_choices'] : $value;
|
||||
$selected = (is_array($data)) ? $data : array($data);
|
||||
$choices = $customField->getOptions()[self::CHOICES];
|
||||
|
||||
if (in_array('_other', $selected)){
|
||||
$choices[] = array('name' => $value['_other'], 'slug' => '_other');
|
||||
}
|
||||
|
||||
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:choice.html.twig';
|
||||
if($documentType == 'csv') {
|
||||
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:choice.csv.twig';
|
||||
}
|
||||
|
||||
return $this->templating
|
||||
->render($template,
|
||||
array(
|
||||
'choices' => $choices,
|
||||
'selected' => $selected,
|
||||
'multiple' => $customField->getOptions()[self::MULTIPLE],
|
||||
'expanded' => $customField->getOptions()[self::EXPANDED],
|
||||
'locales' => $this->defaultLocales
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function serialize($value, CustomField $customField)
|
||||
{
|
||||
// we have a field with "multiple"
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getChoices(CustomField $cf)
|
||||
{
|
||||
if ($cf->getOptions()[self::MULTIPLE]) {
|
||||
$choices = array();
|
||||
|
||||
foreach ($cf->getOptions()[self::CHOICES] as $choice) {
|
||||
if ($choices['active'] === false) {
|
||||
continue;
|
||||
}
|
||||
$choices[$choice["slug"]] = $this->translatableStringHelper
|
||||
->localize($choice["name"]);
|
||||
}
|
||||
|
||||
if ($this->allowOtherChoice($cf)) {
|
||||
$labels = $cf->getOptions()[self::OTHER_VALUE_LABEL];
|
||||
if (!is_array($labels) or count($labels) === 0) {
|
||||
$labels['back'] = 'other value';
|
||||
}
|
||||
$choices['_other'] = $this->translatableStringHelper
|
||||
->localize($labels);
|
||||
}
|
||||
|
||||
return $choices;
|
||||
} else {
|
||||
return [
|
||||
$cf->getSlug() => $this->translatableStringHelper->localize($cf->getName())
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the choice given in $choiceSlug is checked inside $data.
|
||||
*
|
||||
* Used in list exports.
|
||||
*
|
||||
* @param CustomField $cf
|
||||
* @param string $choiceSlug the slug of the choice we want to know if it was checked
|
||||
* @param array|string $data the data of the field
|
||||
* @return boolean
|
||||
*/
|
||||
public function isChecked(CustomField $cf, $choiceSlug, $data)
|
||||
{
|
||||
if ($data === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($cf->getOptions()[self::MULTIPLE]) {
|
||||
if ($cf->getOptions()[self::ALLOW_OTHER]) {
|
||||
return \in_array($choiceSlug, $this->deserialize($data, $cf)['_choices']);
|
||||
} else {
|
||||
return \in_array($choiceSlug, $this->deserialize($data, $cf));
|
||||
}
|
||||
} else {
|
||||
if ($cf->getOptions()[self::ALLOW_OTHER]) {
|
||||
return $this->deserialize($data, $cf)['_choices'] === $choiceSlug;
|
||||
} else {
|
||||
return $this->deserialize($data, $cf) === $choiceSlug;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function isMultiple(CustomField $cf)
|
||||
{
|
||||
return $cf->getOptions()[self::MULTIPLE];
|
||||
}
|
||||
|
||||
public function allowOtherChoice(CustomField $cf)
|
||||
{
|
||||
return $cf->getOptions()[self::ALLOW_OTHER];
|
||||
}
|
||||
|
||||
public function extractOtherValue(CustomField $cf, array $data = null)
|
||||
{
|
||||
return $data['_other'];
|
||||
|
||||
throw LogicException('This case is not expected.');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user