/** * @param SchoolInterface $entity * @param array $data * @return SchoolInterface * * @see AbstractFixture::populateEntity() */ protected function populateEntity($entity, array $data) { // `school_id`,`template_prefix`,`title`,`ilios_administrator_email`,`deleted`,`change_alert_recipients` $entity->setId($data[0]); $entity->setTemplatePrefix($data[1]); $entity->setTitle($data[2]); $entity->setIliosAdministratorEmail($data[3]); $entity->setDeleted((bool) $data[4]); $entity->setChangeAlertRecipients($data[5]); return $entity; }
/** * @param array $data * @param SchoolInterface $entity */ protected function assertDataEquals(array $data, $entity) { // `school_id`,`template_prefix`,`title`,`ilios_administrator_email`,`deleted`,`change_alert_recipients` $this->assertEquals($data[0], $entity->getId()); $this->assertEquals($data[1], $entity->getTemplatePrefix()); $this->assertEquals($data[2], $entity->getTitle()); $this->assertEquals($data[3], $entity->getIliosAdministratorEmail()); $this->assertEquals((bool) $data[4], $entity->isDeleted()); $this->assertEquals($data[5], $entity->getChangeAlertRecipients()); }
/** * {@inheritdoc} */ public function userHasWritePermissionToSchool(UserInterface $user, SchoolInterface $school) { return $this->userHasPermission($user, self::CAN_WRITE, 'school', $school->getId()); }
/** * Locates the applicable message template for a given school and returns its path. * @param SchoolInterface $school * @return string The template path. */ protected function getTemplatePath(SchoolInterface $school) { $paths = ['@custom_email_templates/' . basename($school->getTemplatePrefix() . '_' . self::DEFAULT_TEMPLATE_NAME), '@custom_email_templates/' . self::DEFAULT_TEMPLATE_NAME]; foreach ($paths as $path) { if ($this->templatingEngine->exists($path)) { return $path; } } return 'IliosCoreBundle:Email:' . self::DEFAULT_TEMPLATE_NAME; }
/** * Checks if two given schools are the same. * @param SchoolInterface|null $schoolA * @param SchoolInterface|null $schoolB * @return bool */ public function schoolsAreIdentical(SchoolInterface $schoolA = null, SchoolInterface $schoolB = null) { return $schoolA instanceof SchoolInterface && $schoolB instanceof SchoolInterface && $schoolA->getId() === $schoolB->getId(); }
/** * Checks if a given user has "read" permissions to any courses in a given school. * @param UserInterface $user * @param SchoolInterface|null $school * @return bool */ public function userHasReadPermissionToCoursesInSchool(UserInterface $user, SchoolInterface $school = null) { if (!$school) { return false; } foreach ($school->getCourses() as $course) { if ($this->userHasReadPermissionToCourse($user, $course->getId())) { return true; } } return false; }
/** * {@inheritdoc} */ public function deleteSchool(SchoolInterface $school) { $school->setDeleted(true); $this->updateSchool($school); }