Exemplo n.º 1
0
 /**
  * Get the resource representing the data of this file.
  *
  * Ensures the content object is created
  *
  * @return Resource
  */
 public function getContent()
 {
     if ($this->content === null) {
         $this->content = new Resource();
         $this->content->setLastModified(new \DateTime());
     }
     return $this->content;
 }
Exemplo n.º 2
0
 /**
  * Set the content for this file from the given resource or string.
  *
  * @param resource|string $content the content for the file
  *
  * @return $this
  */
 public function setFileContent($content)
 {
     $this->getContent();
     if (!is_resource($content)) {
         $stream = fopen('php://memory', 'rwb+');
         fwrite($stream, $content);
         rewind($stream);
     } else {
         $stream = $content;
     }
     $this->content->setData($stream);
     return $this;
 }