public function hasRole(Project $project, $role) { $user = $this->getUser(); if ($user instanceof User) { return $project->getUserRole($user)->getRole() <= $role; } else { return false; } }
public function listAction(Project $project, $route = null) { if ($project->isSetupComplete()) { return $this->render('@LeanKoalaHelp/FirstSteps/empty.html.twig'); } else { $currentSteps = 0; $hasComponents = $this->hasComponents($project); if ($hasComponents) { $currentSteps++; } $hasNotificationAlerts = $this->hasNotificationConfiguration($project); if ($hasNotificationAlerts) { $currentSteps++; } $hasNotificationSenders = $this->hasSenderConfiguration($project); if ($hasNotificationSenders) { $currentSteps++; } $hasIntegrationConfigs = $this->hasIntegrationConfigs($project); if ($hasIntegrationConfigs) { $currentSteps++; } if ($currentSteps == self::SUM_STEPS) { $project->setSetupComplete(true); $em = $this->getDoctrine()->getManager(); $em->persist($project); $information = new Information(); $information->setProject($project); $information->setEditAccess(UserRole::ROLE_ADMIN); $information->setEndDate((new \DateTime())->modify('+24 hours')); $information->setReadAccess(UserRole::ROLE_ADMIN); $information->setMessage('Setup complete. Have fun using LeanKoala.'); $em->persist($information); $em->flush(); return $this->render('@LeanKoalaHelp/FirstSteps/empty.html.twig'); } if (!$hasComponents) { $nextStep[] = ['text' => 'Setup Systems and Components', 'url' => $this->generateUrl('koalamon_default_system_admin', ['project' => $project->getIdentifier()])]; } if (!$hasIntegrationConfigs) { $nextStep[] = ['text' => 'Setup Checks', 'url' => $this->generateUrl('koalamon_integration_home', ['project' => $project->getIdentifier()])]; } if (!$hasNotificationSenders) { $nextStep[] = ['text' => 'Setup Notification Channels', 'url' => $this->generateUrl('koalamon_notification_home', ['project' => $project->getIdentifier()])]; } if (!$hasNotificationAlerts) { $nextStep[] = ['text' => 'Setup Alerting', 'url' => $this->generateUrl('koalamon_notification_alerts_home', ['project' => $project->getIdentifier()])]; } return $this->render('@LeanKoalaHelp/FirstSteps/list.html.twig', ['sumSteps' => self::SUM_STEPS, 'currentSteps' => $currentSteps, 'nextSteps' => $nextStep, 'hasComponents' => $hasComponents, 'hasNotificationSenders' => $hasNotificationSenders, 'hasNotificationAlerts' => $hasNotificationAlerts, 'hasIntegrationConfigs' => $hasIntegrationConfigs, 'hasEvents' => $this->hasEventIdentifiers($project), 'project' => $project, 'route' => $route]); } }
public function load(ObjectManager $manager) { foreach ($this->fixtures as $file) { /** @var SplFileInfo $file */ $fixture = json_decode($file->getContents()); $project = new Project(); $project->setName($fixture->name); $project->setDescription($fixture->description); $project->setIdentifier($fixture->identifier); $project->setSlackWebhook($fixture->slackWebhook); $project->setOwner($this->getReference('user-' . $fixture->owner)); if (isset($fixture->users)) { foreach ($fixture->users as $userName) { /** @var User $user */ $user = $this->getReference('user-' . $userName); $project->addUser($user); } } $manager->persist($project); $this->addReference('project-' . $project->getIdentifier(), $project); } $manager->flush(); }
protected function getUrl(Project $project) { return $this->getRouter()->generate($this->getRouteName(), ['project' => $project->getIdentifier()]); }
private function setOpenIncidentCount(Event $event, Project $project, $hasLastEvent) { if ($event->getStatus() == Event::STATUS_SUCCESS) { if ($hasLastEvent && !$event->getEventIdentifier()->isKnownIssue() && !$event->getEventIdentifier()->isIgnoredIssue()) { $project->decOpenIncidentCount(); } } else { if (!$event->getEventIdentifier()->isIgnoredIssue()) { $project->incOpenIncidentCount(); } } }
protected function assertApiKey($apiKey) { if ($this->project->getApiKey() != $apiKey) { throw new AccessDeniedHttpException('You are not allowed to fetch these informations.'); } }
/** * @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()]; }