/** * @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())); }
/** * @param Recipe $recipe */ public function remove(Recipe $recipe) { unset($this->recipes[(string) $recipe->getName()]); }
/** * @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(); }
/** * @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())]]; }