summit_repository = $summit_repository; $this->selection_plan_service = $selection_plan_service; } public function addSelectionPlan($summit_id){ try { if(!Request::isJson()) return $this->error400(); $payload = Input::json()->all(); $summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id); if (is_null($summit)) return $this->error404(); $rules = SummitSelectionPlanValidationRulesFactory::build($payload); // Creates a Validator instance and validates the data. $validation = Validator::make($payload, $rules); if ($validation->fails()) { $messages = $validation->messages()->toArray(); return $this->error412 ( $messages ); } $template = $this->selection_plan_service->addSelectionPlan($summit, $payload); return $this->created(SerializerRegistry::getInstance()->getSerializer($template)->serialize()); } catch (ValidationException $ex1) { Log::warning($ex1); return $this->error412([$ex1->getMessage()]); } catch(EntityNotFoundException $ex2) { Log::warning($ex2); return $this->error404(['message'=> $ex2->getMessage()]); } catch (Exception $ex) { Log::error($ex); return $this->error500($ex); } } }