Example #1
0
 /**
  * Get test config entity.
  *
  * @return ConfigEntity
  */
 protected function _getConfigEntity()
 {
     if ($this->_testEntity) {
         return $this->_testEntity;
     }
     $group = new ConfigGroup();
     $group->setName('testgroup')->setId(5);
     $entity = new ConfigEntity();
     $entity->setName('test')->setConfiggroup($group)->setId(10)->setType(ConfigTypes::TYPE_STRING)->setValue('testvalue');
     return $this->_testEntity = $entity;
 }
 /**
  * Create entity.
  *
  * @param string      $name
  * @param integer     $type
  * @param ConfigGroup $group
  * @param string      $default
  *
  * @throws NoGroupProvidedException
  * @return AbstractConfigProvider
  */
 protected function _createEntity($name, $type, ConfigGroup $group = null, $default = '')
 {
     if (!$group && !$this->_lastGroup) {
         throw new NoGroupProvidedException();
     }
     $name = strtolower($name);
     $entity = $this->_getDoctrine()->getRepository('JeboehmLampcpCoreBundle:ConfigEntity')->findOneBy(array('name' => $name, 'configgroup' => $group));
     if (!$entity) {
         $entity = new ConfigEntity();
         $entity->setName($name)->setConfiggroup($group)->setType($type)->setValue($default);
         $this->_getDoctrine()->persist($entity);
         $this->_getDoctrine()->flush();
     }
     return $this;
 }
 /**
  * Remove doctrine bindings of the ConfigEntity
  *
  * @param DoctrineEntity $entity
  *
  * @return FormEntity
  */
 private function _transformConfigEntity(DoctrineEntity $entity)
 {
     $form = new FormEntity();
     $form->setName($entity->getName())->setType($entity->getType())->setConfiggroup($entity->getConfiggroup());
     $value = $this->_getConfigService()->getParameter($form->getFullName());
     $form->setValue($value);
     return $form;
 }