/** * {@inheritdoc} */ protected function parseData($data) { if (isset($data['type']) && Operators::IS_EMPTY === strtoupper($data['type'])) { $data['value'] = isset($data['value']) ? $data['value'] : null; return $data; } return parent::parseData($data); }
/** * {@inheritdoc} */ public function getMetadata() { $metadata = parent::getMetadata(); $defaultScope = $this->userContext->getUserChannel(); $metadata['populateDefault'] = false; unset($metadata['placeholder']); return $metadata; }
/** * {@inheritdoc} */ public function getMetadata() { $metadata = parent::getMetadata(); $defaultScope = $this->userContext->getUserChannel(); $metadata['populateDefault'] = true; $metadata['placeholder'] = $defaultScope->getLabel(); $metadata['choices'] = array_filter($metadata['choices'], function ($choice) use($defaultScope) { return $choice['value'] !== $defaultScope->getCode(); }); return $metadata; }
/** * {@inheritdoc} */ public function init($name, array $params) { $params[FilterUtility::FRONTEND_TYPE_KEY] = 'choice'; if (isset($params['class'])) { $params[FilterUtility::FORM_OPTIONS_KEY]['class'] = $params['class']; unset($params['class']); } if (isset($params['enum_code'])) { $params[FilterUtility::FORM_OPTIONS_KEY]['enum_code'] = $params['enum_code']; unset($params['enum_code']); } parent::init($name, $params); }
/** * @param QueryBuilder $qb * @param array $filterData * @param string $rangeField * @param string $activityListAlias */ public function addFiltersToQuery(QueryBuilder $qb, $filterData, $rangeField = 'updatedAt', $activityListAlias = 'activity') { $dataSourceAdapter = new OrmFilterDatasourceAdapter($qb); if (isset($filterData['dateRange'])) { $this->dateTimeRangeFilter->init($rangeField, ['data_name' => sprintf('%s.%s', $activityListAlias, $rangeField)]); $datetimeForm = $this->dateTimeRangeFilter->getForm(); if (!$datetimeForm->isSubmitted()) { $datetimeForm->submit($filterData['dateRange']); } $this->dateTimeRangeFilter->apply($dataSourceAdapter, $datetimeForm->getData()); } if (isset($filterData['activityType'])) { $routingHelper = $this->routingHelper; $filterData['activityType']['value'] = array_map(function ($activityClass) use($routingHelper) { return $routingHelper->resolveEntityClass($activityClass); }, $filterData['activityType']['value']); $this->choiceFilter->init('relatedActivityClass', ['data_name' => sprintf('%s.relatedActivityClass', $activityListAlias), 'options' => ['field_options' => ['multiple' => true, 'choices' => array_flip($this->chainProvider->getSupportedActivities())]]]); $typeForm = $this->choiceFilter->getForm(); if (!$typeForm->isSubmitted()) { $typeForm->submit($filterData['activityType']); } $this->choiceFilter->apply($dataSourceAdapter, $typeForm->getData()); } }
/** * {@inheritdoc} */ public function apply(FilterDatasourceAdapterInterface $ds, $data) { $data = $this->parseData($data); if (!$data) { return false; } if (in_array(FolderType::INBOX, $data['value']) && in_array(FolderType::SENT, $data['value'])) { $data['value'] = []; } elseif (in_array(FolderType::INBOX, $data['value'])) { $data['value'][] = FolderType::SPAM; $data['value'][] = FolderType::OTHER; $data['value'][] = FolderType::TRASH; } elseif (in_array(FolderType::SENT, $data['value'])) { $data['value'][] = FolderType::DRAFTS; } return parent::apply($ds, $data); }
/** * {@inheritdoc} */ public function apply(FilterDatasourceAdapterInterface $ds, $data) { $data = $this->parseData($data); if (!$data) { return false; } if (in_array(FolderType::INBOX, $data['value']) && in_array(FolderType::SENT, $data['value'])) { $data['value'] = []; return parent::apply($ds, $data); } elseif (!in_array(FolderType::INBOX, $data['value']) && !in_array(FolderType::SENT, $data['value'])) { return parent::apply($ds, $data); } if (!$ds instanceof OrmFilterDatasourceAdapter) { return false; } $qb = $ds->getQueryBuilder(); if (in_array(FolderType::INBOX, $data['value'])) { $this->applyInboxFilter($qb); } else { $this->applySentFilter($qb); } return true; }
/** * Constructor * * @param FormFactoryInterface $factory * @param FilterUtility $util */ public function __construct(FormFactoryInterface $factory, FilterUtility $util) { parent::__construct($factory, $util); }
/** * {@inheritdoc} */ public function init($name, array $params) { $params[FilterUtility::TYPE_KEY] = 'choice'; parent::init($name, $params); }
/** * {@inheritdoc} */ public function init($name, array $params) { // static option for metadata $params['contextSearch'] = false; parent::init($name, $params); }