Puli\Repository\AbstractJsonRepository::addResource PHP Method

addResource() private method

Adds a resource to the repository.
private addResource ( string $path, Puli\Repository\Api\Resource\FilesystemResource | LinkResource $resource )
$path string The Puli path to add the resource at.
$resource Puli\Repository\Api\Resource\FilesystemResource | Puli\Repository\Resource\LinkResource The resource to add.
    private function addResource($path, $resource)
    {
        if (!$resource instanceof FilesystemResource && !$resource instanceof LinkResource) {
            throw new UnsupportedResourceException(sprintf('The %s only supports adding FilesystemResource and ' . 'LinkedResource instances. Got: %s', $this->getShortClassName(get_class($this)), $this->getShortClassName(get_class($resource))));
        }
        if ($resource instanceof LinkResource) {
            $resource = clone $resource;
            $resource->attachTo($this, $path);
            $this->insertReference($path, '@' . $resource->getTargetPath());
            $this->storeVersion($resource);
        } else {
            // Extension point for the optimized repository
            $this->addFilesystemResource($path, $resource);
        }
    }