/**
  * @param \livetyping\hermitage\foundation\bus\commands\StoreImageCommand $command
  */
 public function handle(StoreImageCommand $command)
 {
     $image = new Image($command->getBinary(), $command->getMimeType(), $this->generator->path());
     $image = $this->processor->optimize($image);
     $this->storage->put($image);
     $command->setPath($image->getPath());
 }
Exemplo n.º 2
0
 /**
  * @param string $filename
  *
  * @return \livetyping\hermitage\foundation\entities\Image
  * @throws \livetyping\hermitage\foundation\exceptions\ImageNotFoundException
  */
 protected function prepare(string $filename)
 {
     if (!Util::isOriginal($filename) && !$this->storage->has($filename)) {
         $this->makeVersion($filename);
     }
 }
 /**
  * @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);
 }