Exemple #1
0
 /**
  * create type instance
  *
  * @param Entity $entity
  * @return TypeInterface
  * @throws \Exception
  */
 public function create(Entity $entity)
 {
     $type = $entity->getType();
     $typeConfig = $this->typeConfig->getConfig('entity/' . $entity->getEntityCode() . '/type/' . $type);
     if (!isset($typeConfig['model'])) {
         throw new \Exception('Entity type "' . $type . '" does not exist');
     }
     /** @var TypeInterface $typeInstance */
     $typeInstance = $this->objectManager->create($typeConfig['model']);
     if (false == $typeInstance instanceof TypeInterface) {
         throw new \Exception('Entity type instance is not instance on \\Umc\\Base\\Model\\Core\\Entity\\Type\\TypeInterface');
     }
     $typeInstance->setEntity($entity);
     return $typeInstance;
 }
Exemple #2
0
 /**
  * tests Entity->getType()
  */
 public function testGetType()
 {
     $type = 'flat';
     $this->entity->setData('type', $type);
     $this->assertEquals($type, $this->entity->getType());
 }