/** * @param NewCommand $command */ public function handle(NewCommand $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->save($recipe); $this->engine->indexRecipe($recipe); }
/** * @param NewCommand $command */ public function handle(NewCommand $command) { $this->persistedEntities[] = $command->getEntity(); //After persisting entity we need to give it some unique identity $this->propertyAccessor->setValue($command->getEntity(), "id", time()); }
/** * @param NewCommand $command */ public function handle(NewCommand $command) { $this->persistedObjects[] = $command->getEntity(); }