Pimcore\Model\Asset::getStream PHP Method

getStream() public method

public getStream ( ) : resource
return resource
    public function getStream()
    {
        if ($this->stream) {
            if (!@rewind($this->stream)) {
                $this->stream = null;
            }
        }
        if (!$this->stream && $this->getType() != "folder") {
            if (file_exists($this->getFileSystemPath())) {
                $this->stream = fopen($this->getFileSystemPath(), "r", false, File::getContext());
            } else {
                $this->stream = tmpfile();
            }
        }
        return $this->stream;
    }

Usage Example

Example #1
0
 /**
  * @param  Asset $target
  * @param  Asset $source
  * @return Asset copied asset
  */
 public function copyAsChild($target, $source)
 {
     $source->getProperties();
     $new = clone $source;
     $new->id = null;
     if ($new instanceof Asset\Folder) {
         $new->setChilds(null);
     }
     $new->setFilename(Element\Service::getSaveCopyName("asset", $new->getFilename(), $target));
     $new->setParentId($target->getId());
     $new->setUserOwner($this->_user->getId());
     $new->setUserModification($this->_user->getId());
     $new->setDao(null);
     $new->setLocked(false);
     $new->setCreationDate(time());
     $new->setStream($source->getStream());
     $new->save();
     if ($target instanceof Asset\Folder) {
         $this->updateChilds($target, $new);
     }
     return $new;
 }
All Usage Examples Of Pimcore\Model\Asset::getStream