public function onRawEventAdd(NewRawEventEvent $rawEventEvent)
 {
     $rawEvent = $rawEventEvent->getRawEvent();
     $system = $this->doctrineManager->getRepository('KoalamonIncidentDashboardBundle:System')->findOneBy(['identifier' => $rawEvent->getSystem(), 'project' => $rawEventEvent->getProject()]);
     if (!$system) {
         $system = new System();
         $system->setName($rawEvent->getSystem());
         $system->setIdentifier($rawEvent->getSystem());
         $system->setProject($rawEventEvent->getProject());
         $this->doctrineManager->persist($system);
         $this->doctrineManager->flush();
         $this->eventDispatcher->dispatch('koalamon.system.create', new NewSystemEvent($system, true));
     }
     $rawEventEvent->getEvent()->setSystem($rawEvent->getSystem());
     $rawEventEvent->getEvent()->getEventIdentifier()->setSystem($system);
 }
 public function load(ObjectManager $manager)
 {
     foreach ($this->fixtures as $file) {
         /** @var SplFileInfo $file */
         $fixture = json_decode($file->getContents());
         $system = new System();
         $system->setIdentifier($fixture->identifier);
         $system->setName($fixture->name);
         $system->setUrl($fixture->url);
         /** @var Project $project */
         $project = $this->getReference('project-' . $fixture->project);
         $system->setProject($project);
         $manager->persist($system);
     }
     $manager->flush();
 }
 public function toggleActiveAction(System $system)
 {
     $this->assertUserRights(UserRole::ROLE_ADMIN);
     if ($system->getProject() != $this->getProject()) {
         throw new AccessDeniedException('System and project do not match');
     }
     if ($system->isActive()) {
         $system->setIsActive(false);
         $message = "System deactivated.";
     } else {
         $system->setIsActive(true);
         $message = "System activated.";
     }
     $em = $this->getDoctrine()->getManager();
     $em->persist($system);
     $em->flush();
     return new JsonResponse(['status' => 'success', 'message' => $message]);
 }
Ejemplo n.º 4
0
 /**
  * @return array
  */
 function jsonSerialize()
 {
     $subSystems = array();
     foreach ($this->children as $subSystem) {
         $subSystems[$subSystem->getId()] = $subSystem->jsonSerialize();
     }
     if ($this->parent) {
         $parent = $this->parent->getId();
     } else {
         $parent = false;
     }
     return ['id' => $this->id, 'identifier' => $this->getIdentifier(), 'name' => $this->getName(), 'url' => $this->getUrl(), 'parent' => $parent, 'project' => $this->getProject()->getIdentifier(), 'image' => $this->getImage(), 'subSystems' => $subSystems, 'project' => $this->project->jsonSerialize(), 'active' => $this->isActive()];
 }
Ejemplo n.º 5
0
 public function isComponentOf(self $system)
 {
     if ($this->isSystem()) {
         return false;
     }
     if ($system->isComponent()) {
         return false;
     }
     return $system->getId() == $this->getParent()->getId();
 }
 /**
  * @param mixed $system
  */
 public function setSystem(System $system)
 {
     $this->system = $system;
     $this->project = $system->getProject();
 }