public function onAreaUpdated(AreaEvent $event) { $area = $event->getArea(); $this->eventDispatcher->dispatch(MilestoneEvents::ACTIVATION_EVENT, new ActivationEvent($area->getProject(), $area->getEntity(), 'profile.updated', function () use($area) { return NewMilestoneStatus::create((bool) $this->canApproveProfile($area)); })); }
private function getActivationFunc(EdkRoute $route) { $conn = $this->conn; return function () use($conn, $route) { $count = $conn->fetchColumn('SELECT COUNT(`id`) FROM `' . EdkTables::ROUTE_TBL . '` WHERE `approved` = 1 AND `routeType` = ' . EdkRoute::TYPE_FULL . ' AND `areaId` = :areaId', [':areaId' => $route->getArea()->getId()]); return NewMilestoneStatus::create($count > 0); }; }
private function spawnActivationEvent(Area $area, $output) { if ($output instanceof CourseProgress) { $this->eventDispatcher->dispatch(MilestoneEvents::ACTIVATION_EVENT, new ActivationEvent($area->getProject(), $area->getEntity(), 'course.completed', function () use($output) { if ($output->getMandatoryCourseNum() == 0) { return NewMilestoneStatus::create(100); } else { return NewMilestoneStatus::create((int) ($output->getPassedCourseNum() / $output->getMandatoryCourseNum() * 100)); } })); } }