/** * Relations constructor * * @param array $data Property data * @param ObjectInterface $object Owner object */ public function __construct(array $data, ObjectInterface $object) { parent::__construct($data, $object); // Run through all registered relation type collections /** * @var string $relationType * @var RelationInterface[] $relations */ foreach ($this->data as $relationType => $relations) { // If the relation type collection is invalid or empty if (!is_array($relations) || !count($relations)) { // TODO Trigger warning continue; } // Run through all (serialized) relations foreach ($relations as $serializedRelation) { $this->addRelationInstance(RelationFactory::createFromString($relationType, $serializedRelation, $this->object->getRepositoryLocator()->getRepository())); } } }
/** * Property collection constructor * * @param array $data Property data * @param ObjectInterface $object Owner object */ public function __construct(array $data, ObjectInterface $object) { parent::__construct($data, $object); }
/** * System properties constructor * * @param array $data Property data * @param ObjectInterface $object Owner object */ public function __construct(array $data, ObjectInterface $object) { parent::__construct($data, $object); // Initialize the object ID if (array_key_exists(self::PROPERTY_ID, $data)) { $this->uid = Id::unserialize($data[self::PROPERTY_ID]); } // Initialize the object type if (array_key_exists(self::PROPERTY_TYPE, $data)) { $this->type = Type::unserialize($data[self::PROPERTY_TYPE]); } // Initialize the object creation date if (array_key_exists(self::PROPERTY_CREATED, $data)) { $this->created = $data[self::PROPERTY_CREATED]; } // Initialize the object modification date if (array_key_exists(self::PROPERTY_MODIFIED, $data)) { $this->modified = $data[self::PROPERTY_MODIFIED]; } // Initialize the object publication date if (array_key_exists(self::PROPERTY_PUBLISHED, $data)) { $this->published = $data[self::PROPERTY_PUBLISHED]; } // Initialize the object deletion date if (array_key_exists(self::PROPERTY_DELETED, $data)) { $this->deleted = $data[self::PROPERTY_DELETED]; } // Initialize the object language if (array_key_exists(self::PROPERTY_LANGUAGE, $data)) { $this->language = trim($data[self::PROPERTY_LANGUAGE]); } // Initialize the location $this->location = Kernel::create(LocationProperties::class, [empty($data[self::PROPERTY_LOCATION]) ? [] : $data[self::PROPERTY_LOCATION], $this->object]); // Initialize the object revision if (array_key_exists(self::PROPERTY_REVISION, $data)) { $this->revision = Revision::unserialize($data[self::PROPERTY_REVISION])->setDraft($this->isDraft()); } // Test if all mandatory properties are set if (!$this->uid instanceof Id || !$this->type instanceof Type || !$this->revision instanceof Revision || !$this->created instanceof \DateTimeInterface || !$this->modified instanceof \DateTimeInterface || !strlen($this->language)) { throw new InvalidArgumentException('Invalid system properties', InvalidArgumentException::INVALID_SYSTEM_PROPERTIES); } }
/** * Meta properties constructor * * @param array $data Property data * @param ObjectInterface $object Owner object */ public function __construct(array $data, ObjectInterface $object) { parent::__construct($data, $object); // Initialize the title if (array_key_exists(self::PROPERTY_TITLE, $data)) { $this->title = $data[self::PROPERTY_TITLE]; } // Initialize the slug if (array_key_exists(self::PROPERTY_SLUG, $data)) { $this->slug = $data[self::PROPERTY_SLUG]; } // Initialize the description if (array_key_exists(self::PROPERTY_DESCRIPTION, $data)) { $this->description = $data[self::PROPERTY_DESCRIPTION]; } // Initialize the abstract if (array_key_exists(self::PROPERTY_ABSTRACT, $data)) { $this->abstract = $data[self::PROPERTY_ABSTRACT]; } // Initialize the keywords if (array_key_exists(self::PROPERTY_KEYWORDS, $data)) { $this->keywords = $this->normalizeSortedPropertyValues((array) $data[self::PROPERTY_KEYWORDS]); } // Initialize the categories if (array_key_exists(self::PROPERTY_CATEGORIES, $data)) { $this->categories = $this->normalizeSortedPropertyValues((array) $data[self::PROPERTY_CATEGORIES]); } // Initialize the privacy if (array_key_exists(self::PROPERTY_PRIVACY, $data)) { $this->privacy = $data[self::PROPERTY_PRIVACY]; } }
/** * Location constructor * * @param array $data Property data * @param ObjectInterface $object Owner object */ public function __construct(array $data, ObjectInterface $object) { parent::__construct($data, $object); // Set the latitude if (!empty($data[self::LATITUDE]) && $this->validateLocationProperty($data[self::LATITUDE])) { $this->latitude = $data[self::LATITUDE]; } // Set the longitude if (!empty($data[self::LONGITUDE]) && $this->validateLocationProperty($data[self::LONGITUDE])) { $this->longitude = $data[self::LONGITUDE]; } // Set the elevation if (!empty($data[self::ELEVATION]) && $this->validateLocationProperty($data[self::ELEVATION])) { $this->elevation = $data[self::ELEVATION]; } }