ResourceMirror.php
public function materialize($resource, $overwrite = false)
    {
        if ($resource instanceof MaterializedResource) {
            return $resource;
        }

        if ($overwrite || !$this->exists($resource)) {
            try {
                $this->getReplicator()->replicate($resource);
            }
            catch (ReplicatorException $e) {
                throw new MaterializeException(sprintf('Cannot materialize resource: %s', $e->getMessage()), 0, $e);
            }
            $materialized = true;
        }

        $materializedResource = new MaterializedResource($resource, $this->getDirectory());
        if (!empty($materialized)) {
            $this->dispatcher->dispatch(ResourceEvents::MATERIALIZE, new ResourceMaterializeEvent($materializedResource));
        }

        return $materializedResource;
    }
public function materialize($resource, $overwrite = false)
    {
        if ($resource instanceof MaterializedResource) {
            return $resource;
        }

        if ($overwrite || !$this->exists($resource)) {
            try {
                $this->getReplicator()->replicate($resource);
            }
            catch (ReplicatorException $e) {
                throw new MaterializeException(sprintf('Cannot materialize resource: %s', $e->getMessage()), 0, $e);
            }
            $materialized = true;
        }

        $materializedResource = new MaterializedResource($resource, $this->getDirectory());
        if (!empty($materialized)) {
            $this->dispatcher->dispatch(ResourceEvents::MATERIALIZE, new ResourceMaterializeEvent($materializedResource));
        }

        return $materializedResource;
    }
public function materialize ( $ resource , $ overwrite = false ) { if ( $ resource instanceof MaterializedResource ) { return $ resource ; } if ( $ overwrite || ! $ this -> exists ( $ resource ) ) { try { $ this -> getReplicator ( ) -> replicate ( $ resource ) ; } catch ( ReplicatorException $ e ) { throw new MaterializeException ( sprintf ( 'Cannot materialize resource: %s' , $ e -> getMessage ( ) ) , 0 , $ e ) ; } $ materialized = true ; } $ materializedResource = new MaterializedResource ( $ resource , $ this -> getDirectory ( ) ) ; if ( ! empty ( $ materialized ) ) { $ this -> dispatcher -> dispatch ( ResourceEvents :: MATERIALIZE , new ResourceMaterializeEvent ( $ materializedResource ) ) ; } return $ materializedResource ; }
Materializes a resource.

@param Resource\Resource $resource
Resource to materialize.
@param bool $overwrite
Whether to overwrite a resource if it already exists.
@return Resource\MaterializedResource
Materialized resource container, or the given resource if already materialized.

@throws MaterializeException
If the resource cannot be materialized.
Materializes a resource .