コード例 #1
0
ファイル: DisabledOption.php プロジェクト: ninsuo/GenyBundle
 public function normalize(Field $entity, array $options)
 {
     $config = $entity->getOptions();
     if ($config['disabled']) {
         $options['disabled'] = true;
     }
     return $options;
 }
コード例 #2
0
ファイル: ReadonlyOption.php プロジェクト: ninsuo/GenyBundle
 public function normalize(Field $entity, array $options)
 {
     $config = $entity->getOptions();
     if ($config['readonly']) {
         $options['attr']['readonly'] = true;
     }
     return $options;
 }
コード例 #3
0
 public function normalize(Field $entity)
 {
     $normalized = [];
     $constraints = $entity->getConstraints();
     if (isset($constraints['expression'])) {
         $normalized[] = new Assert\Expression($constraints['expression']);
     }
     return $normalized;
 }
コード例 #4
0
 public function normalize(Field $entity)
 {
     $normalized = [];
     $constraints = $entity->getconstraints();
     if (isset($constraints['regexes'])) {
         foreach ($constraints['regexes'] as $regex) {
             $escaped = str_replace('#', '\\#', $regex);
             $normalized[] = new Assert\Regex(sprintf("#%s#", $escaped));
         }
     }
     return $normalized;
 }
コード例 #5
0
ファイル: FieldRepository.php プロジェクト: ninsuo/GenyBundle
 public function createFilledField(BuilderInterface $builder, Form $form = null, $name = null)
 {
     $field = new Field();
     if ($form) {
         $field->setPosition($form->getFields()->count() + 1);
         $field->setForm($form);
         $field->setName(sprintf("%s_%d", $this->get('translator')->trans('geny.builder.field.name', [], 'geny'), $field->getPosition()));
     }
     if ($name) {
         $field->setName($name);
     }
     $field->setType($builder->getName());
     $field->setData($builder->getDefaultData($field));
     $field->setOptions(null);
     $field->setConstraints(null);
     $field->setLabel($this->get('translator')->trans('geny.builder.field.label', [], 'geny'));
     $field->setHelp($this->get('translator')->trans('geny.builder.field.help', [], 'geny'));
     $field->setRequired(true);
     return $field;
 }
コード例 #6
0
ファイル: TrimOption.php プロジェクト: ninsuo/GenyBundle
 public function normalize(Field $entity, array $options)
 {
     $config = $entity->getOptions();
     $options['trim'] = $config['trim'];
     return $options;
 }
コード例 #7
0
ファイル: Geny.php プロジェクト: ninsuo/GenyBundle
 public function getConstraintsType(BuilderInterface $builder, Field $entity, $data)
 {
     $type = $this->get('form.factory')->createNamedBuilder(sprintf("constraints-%d", $entity->getId()), Type\FormType::class, $data, ['translation_domain' => 'geny']);
     foreach ($builder->supportsConstraints($entity) as $constraintClass) {
         $constraint = $this->getCachedObject($constraintClass);
         $constraint->build($type, $entity, $data);
     }
     return $type->getForm();
 }