private function getService() { $service = new Service(); $service->setName('Api Service'); $service->setUuid('61ad3d6e-4368-4784-9811-53cf0268feac'); return $service; }
/** * Transform a service to a service name. * * @param Service|null $service * * @return string */ public function transform($service) { if (null === $service) { return; } return $service->getName(); }
/** * update. * * @param Service $service * @param Incident $incident * * @return Service */ public function update(Service $service, Incident $incident) { if ($incident->getStatus() != Incident::RESOLVED) { $service->setStatus(Service::OUTAGE); } else { $service->setStatus(Service::OPERATIONNAL); } return $service; }
/** * Get Status name use to get a status name a service. * * @param Service $service * * @return string */ public function getGlobalServiceStatusName(Service $service) { switch ($service->getStatus()) { case Service::OPERATIONNAL: return $this->translator->trans('status_page.service.up'); case Service::OUTAGE: return $this->translator->trans('status_page.service.down'); default: return ''; } }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $dataSets = [['name' => 'API', 'status' => Service::OPERATIONNAL, 'description' => 'Just an api', 'url' => 'http://api.localhost', 'uuid' => '4fcd899a-91da-4128-8baf-92044fafe3db', 'user' => 'user-admin'], ['name' => 'Demo Site', 'status' => Service::OUTAGE, 'description' => 'Demo website', 'url' => 'http://demo.localhost', 'uuid' => '9e231852-5343-4653-81c8-f52ee223d3d2', 'user' => 'user-admin'], ['name' => 'Sql Service', 'status' => Service::OUTAGE, 'description' => 'Mysql Service', 'url' => 'http://sql.localhost', 'uuid' => '5072b9ac-5492-48d2-8dbb-e6f5e290440c', 'user' => 'user-admin']]; $i = 0; foreach ($dataSets as $data) { $service = new Service(); $service->setName($data['name']); $service->setStatus($data['status']); $service->setDescription($data['description']); $service->setUrl($data['url']); $service->setUuid($data['uuid']); $service->setUser($this->getReference('user-admin')); $this->addReference(sprintf('service-%s', $i), $service); $manager->persist($service); ++$i; } $manager->flush(); }
/** * @ApiDoc( * section="Service", * resource=true, * description="Gets incidents for a service uuid", * output= { * "class"="AppBundle\Entity\Core\Incident", * "groups"={"list"} * }, * statusCodes={ * 200="Returned when successful", * 404="Returned when the metric is not found", * 401="Returned when authentication fails" * } * ) * @Route("/{uuid}/incidents", methods={"GET"}) * @View(serializerGroups={"Default", "list_service_incident"}) * * @param Service $service * * @return \Doctrine\Common\Collections\ArrayCollection */ public function getIncidentsAction(Service $service) { return $service->getIncidents(); }
private function getService() { $service = new Service(); $service->setName('My Test Service'); return $service; }