示例#1
0
 /**
  * @param Recipe $recipe
  * @throws RecipeNotFoundException
  */
 public function remove(Recipe $recipe)
 {
     if (!$this->hasRecipeWithName($recipe->getName())) {
         throw new RecipeNotFoundException(sprintf("Recipe \"%s\" does not exists", (string) $recipe->getName()));
     }
     $this->filesystem->remove(DIRECTORY_SEPARATOR . $this->slugGenerator->generateFrom((string) $recipe->getName()));
 }
示例#2
0
 /**
  * @param Recipe $recipe
  */
 public function remove(Recipe $recipe)
 {
     unset($this->recipes[(string) $recipe->getName()]);
 }
示例#3
0
 /**
  * @param Recipe $recipe
  */
 public function removeRecipeFromIndex(Recipe $recipe)
 {
     $params = ['index' => ElasticSearch::INDEX, 'type' => 'recipe', 'id' => $this->slugGenerator->generateFrom((string) $recipe->getName())];
     $this->client->delete($params);
     $this->client->indices()->refresh();
 }
示例#4
0
 /**
  * @param Recipe $recipe
  * @return array
  * @throws RuntimeException
  */
 public function toArray(Recipe $recipe)
 {
     return ['name' => (string) $recipe->getName(), 'publicationDate' => $recipe->isPublished() ? $recipe->getPublicationDate()->format('Y-m-d H:i:s') : null, 'steps' => $this->serializeSteps($recipe), 'glass' => $recipe->isGlassRequired() ? (string) $recipe->getGlass()->getName() : null, 'description' => ['text' => $recipe->getDescription()->getText(), 'IBAOfficial' => $recipe->getDescription()->isOfficialIBA(), 'alcoholContent' => $recipe->getDescription()->getAlcoholContent(), 'taste' => $this->serializeTaste($recipe->getDescription()->getTaste())]];
 }