Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     foreach ($options['data_schema'] as $schemaOptions) {
         $excludedProperties = [];
         if (isset($schemaOptions['type_filter']) && $schemaOptions['type_filter']) {
             $excludedProperties = array_merge($excludedProperties, $this->manager->getExcludedProperties($schemaOptions['type_filter']));
         }
         $fieldOptions = ['label' => $schemaOptions['label'], 'required' => $schemaOptions['required'], 'attr' => ['data-type-filter' => json_encode($excludedProperties), 'data-validation-optional-group' => true, 'data-validation' => json_encode(['NotBlank' => []])]];
         $builder->add($schemaOptions['name'], 'text', $fieldOptions);
     }
 }
 /**
  * Returns prepared filter object.
  *
  * @param string $name       A filter name.
  * @param string $columnName A column name this filter should be applied.
  * @param string $operator   A filter operator. Can be "OR" or "AND".
  * @return FilterInterface
  */
 protected function getFilterObject($name, $columnName, $operator = null)
 {
     $params = [FilterUtility::DATA_NAME_KEY => $columnName];
     if ($operator !== null) {
         $params[FilterUtility::CONDITION_KEY] = $operator;
     }
     return $this->manager->createFilter($name, $params);
 }
Exemplo n.º 3
0
 /**
  * @param FilterDatasourceAdapterInterface $ds
  * @param string $name
  * @param string $field
  * @param mixed $data
  */
 protected function applyFilter(FilterDatasourceAdapterInterface $ds, $name, $field, $data)
 {
     $filter = $this->queryDesignerManager->createFilter($name, [FilterUtility::DATA_NAME_KEY => $field]);
     $form = $filter->getForm();
     if (!$form->isSubmitted()) {
         $form->submit($data);
     }
     if ($form->isValid()) {
         $filter->apply($ds, $form->getData());
     }
 }
Exemplo n.º 4
0
 /**
  * Returns prepared filter object.
  *
  * @param string $name       A filter name.
  * @param string $columnName A column name this filter should be applied.
  * @param array  $params     The filter parameters.
  *
  * @return FilterInterface
  */
 protected function getFilterObject($name, $columnName, array $params = [])
 {
     $params[FilterUtility::DATA_NAME_KEY] = $columnName;
     return $this->manager->createFilter($name, $params);
 }