コード例 #1
0
ファイル: SweetCategory.php プロジェクト: karion/mydrinks
 /**
  * @param int $from
  * @param int $size
  * @return SearchResultSlice
  */
 public function getDrinks($from = 0, $size = 20)
 {
     $criteria = new SearchEngine\Criteria($from);
     $criteria->changeSize($size);
     $criteria->updateRequiredTaste((new TasteBuilder())->sweet()->buildTaste());
     return $this->searchEngine->search($criteria);
 }
コード例 #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);
 }
コード例 #3
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);
 }