entity->getProperties()->getLabel() ?? (string) $this->entity->identifier(); } /** * Identifier of the entity backing this node */ private function entityIdentifier(): EntityIdentifier { return new EntityIdentifier( $this->service->provider(), (string) $this->service->identifier(), (string) $this->entity->collection(), (string) $this->entity->identifier(), ); } /** @return resource|string */ public function get() { return $this->service->entityRead($this->entityIdentifier()); } public function put($data): ?string { if (!$this->service instanceof ServiceEntityMutableInterface) { throw new Forbidden('Entity is immutable'); } $this->service->entityWrite( $this->entityIdentifier(), is_resource($data) ? stream_get_contents($data) : (string) $data, ); return '"' . md5($this->entity->identifier() . time()) . '"'; } public function delete(): void { if (!$this->service instanceof ServiceEntityMutableInterface) { throw new Forbidden('Entity is immutable'); } $this->service->entityDelete($this->entityIdentifier()); } public function getContentType(): ?string { return $this->entity->getProperties()->getMime(); } public function getETag(): ?string { return '"' . $this->entity->signature() . '"'; } public function getSize(): ?int { return $this->entity->getProperties()->size(); } public function getLastModified(): ?int { return $this->entity->modified()?->getTimestamp() ?? null; } }