Ejemplo n.º 1
0
 function it_save_and_index_updated_recipes(Storage $storage, SearchEngine $searchEngine)
 {
     $recipe = new Recipe(new Name("Screwdriver"));
     $recipe->publish();
     $command = new EditCommand($recipe, new ChangeSet());
     $searchEngine->indexRecipe(Argument::any())->shouldBeCalled();
     $storage->save(Argument::type(Recipe::class))->shouldBeCalled();
     $this->handle($command);
 }
Ejemplo n.º 2
0
 /**
  * @param RemoveCommand $command
  */
 public function handle(RemoveCommand $command)
 {
     $recipe = $command->getEntity();
     if (!$recipe instanceof Recipe) {
         throw new \RuntimeException(sprintf("Entity \"%s\" can't be handled by Recipe\\NewCommandHandler", get_class($recipe)));
     }
     $this->storage->remove($recipe);
     $this->engine->removeRecipeFromIndex($recipe);
 }
Ejemplo n.º 3
0
 /**
  * @param string $slug
  * @return null|Recipe
  */
 public function findBySlug($slug)
 {
     $recipe = $this->storage->fetchBySlug($slug);
     if (!is_null($recipe)) {
         if ($this->isolate->getContext()->hasOpenTransaction()) {
             $transaction = $this->isolate->getContext()->getTransaction();
             $transaction->persist($recipe);
         }
     }
     return $recipe;
 }
Ejemplo n.º 4
0
 /**
  * @param mixed $entity
  * @return boolean
  */
 public function isIdentified($entity)
 {
     return $this->storage->hasRecipeWithName($entity->getName());
 }