private function addSystemTools(Project $project)
 {
     $healthStatus = new Tool();
     $healthStatus->setProject($project);
     $healthStatus->setActive(true);
     $healthStatus->setIdentifier('system_health_status');
     $healthStatus->setDescription('Every system hat its own health status that will be calculated using all failed checks.');
     $healthStatus->setName('System Health Status');
     $em = $this->getDoctrine()->getManager();
     $em->persist($healthStatus);
     $em->flush();
 }
 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function storeAction(Request $request)
 {
     $this->assertUserRights(UserRole::ROLE_ADMIN);
     $tool = $request->get('tool');
     if (array_key_exists("id", $tool)) {
         $toolObject = $this->getDoctrine()->getRepository('KoalamonIncidentDashboardBundle:Tool')->find($tool["id"]);
     } else {
         $toolObject = new Tool();
         $toolObject->setProject($this->getProject());
     }
     if (array_key_exists('identifier', $tool)) {
         $existingTool = $this->getDoctrine()->getRepository('KoalamonIncidentDashboardBundle:Tool')->findOneBy(['identifier' => $tool["identifier"], 'project' => $this->getProject()]);
         if ($existingTool) {
             if (!array_key_exists('id', $tool) || $existingTool->getId() != $tool['id']) {
                 $this->addFlash('notice', 'The parameter "identifier" already exists.');
                 return $this->redirect($this->generateUrl('koalamon_default_tool_admin', ['project' => $this->getProject()->getIdentifier()]));
             }
         }
     }
     if ($tool["identifier"] != "") {
         $toolObject->setIdentifier($tool["identifier"]);
     } else {
         $this->addFlash('notice', 'The parameter "identifier" is required');
         return $this->redirect($this->generateUrl('koalamon_default_tool_admin', ['project' => $this->getProject()->getIdentifier()]));
     }
     if ($tool["name"] != "") {
         $toolObject->setName($tool["name"]);
     } else {
         $this->addFlash('notice', 'The parameter "name" is required');
         return $this->redirect($this->generateUrl('koalamon_default_tool_admin', ['project' => $this->getProject()->getIdentifier()]));
     }
     $toolObject->setDescription($tool["description"]);
     if (array_key_exists('active', $tool)) {
         $toolObject->setActive(true);
     } else {
         $toolObject->setActive(false);
     }
     if (array_key_exists('notify', $tool)) {
         $toolObject->setNotify(true);
     } else {
         $toolObject->setNotify(false);
     }
     if (array_key_exists('systemSpecific', $tool)) {
         $toolObject->setSystemSpecific(true);
     } else {
         $toolObject->setSystemSpecific(false);
     }
     $em = $this->getDoctrine()->getManager();
     $em->persist($toolObject);
     $em->flush();
     $this->addFlash('success', 'Tool "' . $toolObject->getName() . '" successfully saved.');
     return $this->redirect($this->generateUrl('koalamon_default_tool_admin', ['project' => $this->getProject()->getIdentifier()]));
 }
 public function load(ObjectManager $manager)
 {
     foreach ($this->fixtures as $file) {
         /** @var SplFileInfo $file */
         $fixture = json_decode($file->getContents());
         $tool = new Tool();
         $tool->setIdentifier($fixture->identifier);
         $tool->setName($fixture->name);
         $tool->setImage($fixture->image);
         $tool->setNotify($fixture->notify);
         $tool->setDescription($fixture->description);
         /** @var Project $project */
         $project = $this->getReference('project-' . $fixture->project);
         $tool->setProject($project);
         $manager->persist($tool);
     }
     $manager->flush();
 }