/** * create attribute type instance * * @param Relation $relation * @return TypeInterface * @throws \Exception */ public function create(Relation $relation) { $type = $relation->getType(); $typeConfig = $this->typeConfig->getConfig('entity/' . $relation->getEntityCode() . '/type/' . $type); if (!isset($typeConfig['model'])) { throw new \Exception('Relation type "' . $type . '" does not exist'); } /** @var \Umc\Base\Model\Core\Relation\Type\TypeInterface $typeInstance */ $typeInstance = $this->objectManager->create($typeConfig['model']); if (false == $typeInstance instanceof TypeInterface) { throw new \Exception('Relation type instance is not instance on \\Umc\\Base\\Model\\Core\\Relation\\Type\\TypeInterface'); } $typeInstance->setRelation($relation); return $typeInstance; }
/** * add an entity relation * * @param Relation $relation * @return $this */ public function addRelation(Relation $relation) { $relation->setModule($this); $this->relations[] = $relation; return $this; }