Exemplo n.º 1
0
 /**
  * Processes the file contents and writes it to a stream.
  *
  * @param string $contents The file contents.
  *
  * @return resource The processed contents stream.
  *
  * @throws ProcessingException If a memory stream could not be opened.
  */
 private function processContents($contents)
 {
     // @codeCoverageIgnoreStart
     if (false === ($resource = fopen('php://memory', 'rb+'))) {
         throw new ProcessingException('The memory stream could not be opened.');
     }
     // @codeCoverageIgnoreEnd
     if ($this->processor->supports($this->key)) {
         $contents = $this->processor->process($this->key, $contents);
     }
     fwrite($resource, $contents);
     rewind($resource);
     return $resource;
 }
Exemplo n.º 2
0
 /**
  * Processes a file that is about to be added from a string.
  *
  * @param PreAddFromStringEvent $event The event arguments.
  */
 public function onAddFromString(PreAddFromStringEvent $event)
 {
     if ($this->processor->supports($event->getLocal())) {
         $event->setContents($this->processor->process($event->getLocal(), $event->getContents()));
     }
 }