예제 #1
0
 /**
  * @return array
  */
 public function getColumns()
 {
     /*
      * @var ModuleInterface $module
      */
     //        $module = $this->_module;
     $module_id = $this->_module ? $this->_module->getId() : 0;
     $fields = $this->_em->getRepository('BigfishEavBundle:Module')->getFields($module_id);
     //        var_dump($fields);
     //        exit;
     $aFields = array();
     //        $i = 0;
     //        foreach ($fields as $object) {
     //
     //            $field = $object["field"];
     //
     //
     //            $column = $this->_columnManager->getColumn(ColumnMapperInterface::DB, $field["formType"]);
     //            $cast = $this->_columnManager->getCast($field["formType"]);
     //
     //
     //            if ($column) {
     //                $aFields[$i]['identifier'] = 'tv_'.$field["identifier"];
     //                $aFields[$i]['label'] = $field["name"];
     //                $aFields[$i]['field_id'] = $field["id"];
     //                $aFields[$i]['type'] = $field["formType"];
     //                $aFields[$i]['column'] = $column;
     //                $aFields[$i]['cast'] = $cast;
     //                $i++;
     //            }
     //        }
     $i = 0;
     foreach ($fields as $module) {
         foreach ($module->getModuleHasField() as $koppeling) {
             $field = $koppeling->getField();
             $moduleBelongsTo = $koppeling->getBelongsTo();
             $column = $this->_columnManager->getColumn(ColumnMapperInterface::DB, $field->getFormType());
             $cast = $this->_columnManager->getCast($field->getFormType());
             if ($column) {
                 $aFields[$i]['identifier'] = 'tv_' . $field->getIdentifier();
                 $aFields[$i]['label'] = $field->getName();
                 $aFields[$i]['field_id'] = $field->getId();
                 $aFields[$i]['translate'] = $field->getTranslate();
                 $aFields[$i]['type'] = $field->getFormType();
                 $aFields[$i]['column'] = $column;
                 $aFields[$i]['cast'] = $cast;
                 if ($moduleBelongsTo) {
                     $aFields[$i]['module_belongs_to'] = $moduleBelongsTo->getId();
                 } else {
                     $aFields[$i]['module_belongs_to'] = null;
                 }
                 ++$i;
             }
         }
     }
     return $aFields;
 }
예제 #2
0
 /**
  * @param PersisterObjectInterface $object
  * @param ModuleInterface          $module
  *
  * @return Container|mixed
  */
 public function loadModel(ModuleInterface $module, Context $context, PersisterObjectInterface $object = null)
 {
     $container = null;
     if ($object) {
         // find container
         $container = $this->objectManager->getRepository('BigfishEavBundle:Container')->findOneBy(array('id' => $object->getId(), 'module' => $module->getId(), 'context' => $context->getId()));
     }
     // if container is not found, create one
     if (!$container) {
         $container = new Container();
         $container->setDeleted(new \DateTime());
         $container->setExpireTemporaryDate(new \DateTime('+ 3 hour'));
         $container->setModule($module);
         $container->setContext($context);
         $this->objectManager->persist($container);
         return $container;
     }
     return $container;
 }
예제 #3
0
 /**
  * @param Resource $resource
  * @param Module $module
  * @return Container
  */
 public function loadModel(ModuleInterface $module, PersisterObjectInterface $object = null)
 {
     $context = $this->contextLanguageMediator->getContextManager()->getContext();
     // find container
     $container = $this->objectManager->getRepository("BigfishEavBundle:Container")->findOneByResource($object->getId(), $module->getId(), $context->getId());
     // if container is not found, create one
     if (!$container) {
         $container = new Container();
         $container->setContext($context);
         $container->setResource($object);
         $container->setModule($module);
         $this->objectManager->persist($container);
         return $container;
     }
     return $container;
 }
예제 #4
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('container_id', 'hidden', array('data' => $this->container->getId(), 'constraints' => array(new EqualTo(array('value' => $this->container->getId())))))->add('module_id', 'hidden', array('data' => $this->module->getId(), 'constraints' => array(new EqualTo(array('value' => $this->module->getId())))));
 }