Beispiel #1
0
 /**
  * Instantiate and return an object repository
  *
  * @param string $url Repository URL (relative or absolute including the apparat base URL)
  * @return \Apparat\Object\Domain\Repository\Repository Object repository
  * @throws InvalidArgumentException If the repository URL is invalid
  * @throws InvalidArgumentException If the repository URL is unknown
  * @api
  */
 public static function instance($url)
 {
     // Normalize to return a repository instance matching this URL
     try {
         return Kernel::create(Service::class)->get($url);
     } catch (\Exception $e) {
         throw new InvalidArgumentException($e->getMessage(), $e->getCode());
     }
 }
Beispiel #2
0
 /**
  * Convert the CommonMark source to HTML
  *
  * @return string CommonMark HTML
  */
 public function getHtml()
 {
     $html = '';
     if (strlen($this->content)) {
         $environment = $this->environment();
         $parser = Kernel::create(DocParser::class, [$environment]);
         $renderer = Kernel::create(HtmlRenderer::class, [$environment]);
         $html = $renderer->renderBlock($parser->parse($this->content));
     }
     return $html;
 }
Beispiel #3
0
 /**
  * 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);
     }
 }
Beispiel #4
0
 /**
  * Create and return a new object iterator instance
  *
  * @return ApparatObjectIterator Object iterator instance
  */
 public function getIterator()
 {
     return Kernel::create($this->getIteratorClass(), [$this->mapping, $this->getFlags(), $this]);
 }