protected function createResource($path, $reference)
    {
        if (null === $reference) {
            $resource = new GenericResource();
        } elseif (isset($reference[0]) && '@' === $reference[0]) {
            $resource = new LinkResource(substr($reference, 1));
        } elseif (is_dir($reference)) {
            $resource = new DirectoryResource($reference);
        } elseif (is_file($reference)) {
            $resource = new FileResource($reference);
        } else {
            throw new RuntimeException(sprintf(
                'Trying to create a FilesystemResource on a non-existing file or directory "%s"',
                $reference
            ));
        }

        $resource->attachTo($this, $path);

        return $resource;
    }
protected function createResource($path, $reference)
    {
        if (null === $reference) {
            $resource = new GenericResource();
        } elseif (isset($reference[0]) && '@' === $reference[0]) {
            $resource = new LinkResource(substr($reference, 1));
        } elseif (is_dir($reference)) {
            $resource = new DirectoryResource($reference);
        } elseif (is_file($reference)) {
            $resource = new FileResource($reference);
        } else {
            throw new RuntimeException(sprintf(
                'Trying to create a FilesystemResource on a non-existing file or directory "%s"',
                $reference
            ));
        }

        $resource->attachTo($this, $path);

        return $resource;
    }
protected function createResource ( $ path , $ reference ) { if ( null === $ reference ) { $ resource = new GenericResource ( ) ; } elseif ( isset ( $ reference [ 0 ] ) && '@' === $ reference [ 0 ] ) { $ resource = new LinkResource ( substr ( $ reference , 1 ) ) ; } elseif ( is_dir ( $ reference ) ) { $ resource = new DirectoryResource ( $ reference ) ; } elseif ( is_file ( $ reference ) ) { $ resource = new FileResource ( $ reference ) ; } else { throw new RuntimeException ( sprintf ( 'Trying to create a FilesystemResource on a non-existing file or directory "%s"' , $ reference ) ) ; } $ resource -> attachTo ( $ this , $ path ) ; return $ resource ; }
Turns a reference into a resource.

@param string      $path      The Puli path.
@param string|null $reference The reference.

@return PuliResource The resource.
Turns a reference into a resource .