Example #1
0
 /**
  * @param string                                   $filename
  * @param \Psr\Http\Message\ServerRequestInterface $request
  * @param \Psr\Http\Message\ResponseInterface      $response
  *
  * @return \Psr\Http\Message\ResponseInterface
  * @throws \livetyping\hermitage\foundation\exceptions\ImageNotFoundException
  */
 public function __invoke(string $filename, Request $request, Response $response) : Response
 {
     $this->prepare($filename);
     $image = $this->storage->get($filename);
     $body = new Body(fopen('php://temp', 'r+'));
     $body->write($image->getBinary());
     return $response->withHeader('Content-Type', $image->getMimeType())->withBody($body);
 }
 /**
  * @param \livetyping\hermitage\foundation\bus\commands\DeleteImageCommand $command
  */
 public function handle(DeleteImageCommand $command)
 {
     $image = $this->storage->get($command->getPath());
     $this->storage->delete($image);
 }
 /**
  * @param \livetyping\hermitage\foundation\bus\commands\MakeImageVersionCommand $command
  *
  * @throws \livetyping\hermitage\foundation\exceptions\ImageNotFoundException
  * @throws \livetyping\hermitage\foundation\exceptions\UnknownVersionNameException
  */
 public function handle(MakeImageVersionCommand $command)
 {
     $image = $this->storage->get($command->getPathToOriginal());
     $image = $this->processor->make($image, $command->getVersion());
     $this->storage->put($image);
 }