Esempio n. 1
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  *
  * TODO Remove the if/else
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->bootstrap($input, $output);
     $mapper = $this->getMapper();
     $relational = new RespectRelational($mapper);
     $fieldRepository = new FieldRepository($relational);
     $collectionRepository = new CollectionRepository($relational);
     $collectionFieldRepository = new CollectionFieldRepository($relational);
     $entity = $input->getArgument('Field|Collection');
     if ($entity === 'Field') {
         $entity = new Field();
         $entity->setType($input->getArgument('type'));
         $entity->setName($input->getArgument('name'));
         $entity->setLabel($input->getArgument('label'));
         $fieldRepository->save($entity);
         if ($input->getArgument('collection') != null) {
             $collection = $collectionRepository->findOne(['name' => $input->getArgument('collection')]);
             if (!$collection) {
                 $output->writeln('<error>The Collection ' . $input->getArgument('collection') . ' not found.</error>');
                 return;
             }
             $collectionField = new CollectionField();
             $collectionField->setFieldId($entity);
             $collectionField->setCollectionId($collection);
             $collectionFieldRepository->save($collectionField);
         }
     } else {
         $entity = new Collection();
         $entity->setName($input->getArgument('name'));
         $entity->setLabel($input->getArgument('label'));
         $collectionRepository->save($entity);
     }
 }
Esempio n. 2
0
 private function createField(InputInterface $input, $storage)
 {
     $fieldRepository = new FieldRepository($storage);
     $field = (object) ['type' => $input->getArgument('type'), 'name' => $input->getArgument('name'), 'label' => $input->getArgument('label')];
     $fieldRepository->save($field);
     return $field;
 }
 /**
  * @param FieldRepository $fieldRepository
  */
 public function __construct(FieldRepository $fieldRepository)
 {
     if ($fieldRepository->getStorage()->getMapper() instanceof Mapper) {
         $this->fieldService = new RespectFieldService($fieldRepository);
     } else {
         $this->fieldService = new DoctrineFieldService($fieldRepository);
     }
 }
Esempio n. 4
0
 private function findField($name, $storage)
 {
     $fieldRepository = new FieldRepository($storage);
     $field = $fieldRepository->findBy(['name' => $name], ['order by name']);
     return $field;
 }
Esempio n. 5
0
 /**
  * @param $name Name of Field
  * @return string Value of field
  */
 public function getFieldValue($name)
 {
     $field = $this->fieldRepository->findOne(['name' => $name]);
     return $field->getValue();
 }