Jarves\Configuration\Object::addRelation PHP Méthode

addRelation() public méthode

public addRelation ( Jarves\Admin\FieldTypes\RelationDefinitionInterface $relation )
$relation Jarves\Admin\FieldTypes\RelationDefinitionInterface
    public function addRelation($relation)
    {
        $this->relations[strtolower($relation->getName())] = $relation;
    }

Usage Example

Exemple #1
0
 public function bootRunTime(Object $object, Configs $configs)
 {
     if (!$object->hasRelation($this->getFieldDefinition()->getId())) {
         $relation = new RelationDefinition();
         $relation->setName($this->getFieldDefinition()->getId());
         $relation->setType(AbstractStorage::ONE_TO_MANY);
         $relation->setForeignObjectKey('jarves/content');
         $relation->setRefName($object->getId());
         $object->addRelation($relation);
         $configs->addReboot('Added auto relation because of PageContents type.');
     }
     if (!$object->hasField('layout')) {
         $field = new Field();
         $field->setId('layout');
         $field->setType('text');
         $object->addField($field);
         $configs->addReboot('PageContents needs `layout` field.');
     }
     if (!$object->hasField('theme')) {
         $field = new Field();
         $field->setId('theme');
         $field->setType('text');
         $object->addField($field);
         $configs->addReboot('PageContents needs `theme field.');
     }
 }
All Usage Examples Of Jarves\Configuration\Object::addRelation
Object