コード例 #1
0
ファイル: Factory.php プロジェクト: artmouse/Umc_Base
 /**
  * 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;
 }
コード例 #2
0
ファイル: Module.php プロジェクト: nhc/Umc_Base
 /**
  * add an entity relation
  *
  * @param Relation $relation
  * @return $this
  */
 public function addRelation(Relation $relation)
 {
     $relation->setModule($this);
     $this->relations[] = $relation;
     return $this;
 }