コード例 #1
0
 /**
  * @param array $data
  * @param CurriculumInventoryInstitutionInterface $entity
  */
 protected function assertDataEquals(array $data, $entity)
 {
     // `school_id`,`name`,`aamc_code`,`address_street`,`address_city`,
     // `address_state_or_province`,`address_zipcode`,
     // `address_country_code`,`institution_id`
     $this->assertEquals($data[0], $entity->getSchool()->getId());
     $this->assertEquals($data[1], $entity->getName());
     $this->assertEquals($data[2], $entity->getAamcCode());
     $this->assertEquals($data[3], $entity->getAddressStreet());
     $this->assertEquals($data[4], $entity->getAddressCity());
     $this->assertEquals($data[5], $entity->getAddressStateOrProvince());
     $this->assertEquals($data[6], $entity->getAddressZipcode());
     $this->assertEquals($data[7], $entity->getAddressCountryCode());
     $this->assertEquals($data[8], $entity->getId());
 }
コード例 #2
0
 /**
  * @param string $attribute
  * @param CurriculumInventoryInstitutionInterface $institution
  * @param TokenInterface $token
  * @return bool
  */
 protected function voteOnAttribute($attribute, $institution, TokenInterface $token)
 {
     $user = $token->getUser();
     if (!$user instanceof UserInterface) {
         return false;
     }
     switch ($attribute) {
         case self::VIEW:
         case self::EDIT:
         case self::DELETE:
             return $this->userHasRole($user, ['Course Director', 'Developer']);
             break;
     }
     switch ($attribute) {
         case self::VIEW:
             // Only grant VIEW permissions to users with at least one of
             // 'Course Director' and 'Developer' roles.
             // - and -
             // the user must be associated with the institution's school
             // either by its primary school attribute
             //     - or - by READ rights for the school
             // via the permissions system.
             return $this->userHasRole($user, ['Course Director', 'Developer']) && ($this->schoolsAreIdentical($user->getSchool(), $institution->getSchool()) || $this->permissionManager->userHasReadPermissionToSchool($user, $institution->getSchool()->getId()));
             break;
         case self::CREATE:
         case self::EDIT:
         case self::DELETE:
             // Only grant CREATE, EDIT and DELETE permissions to users with at least one of
             // 'Course Director' and 'Developer' roles.
             // - and -
             // the user must be associated with the institution's school
             // either by its primary school attribute
             //     - or - by WRITE rights for the school
             // via the permissions system.
             return $this->userHasRole($user, ['Course Director', 'Developer']) && ($this->schoolsAreIdentical($user->getSchool(), $institution->getSchool()) || $this->permissionManager->userHasWritePermissionToSchool($user, $institution->getSchool()->getId()));
             break;
     }
     return false;
 }
コード例 #3
0
 /**
  * @param CurriculumInventoryInstitutionInterface $entity
  * @param array $data
  * @return CurriculumInventoryInstitutionInterface
  *
  * AbstractFixture::populateEntity()
  */
 protected function populateEntity($entity, array $data)
 {
     // `school_id`,`name`,`aamc_code`,`address_street`,`address_city`,
     // `address_state_or_province`,`address_zipcode`,
     // `address_country_code`,`institution_id`
     $entity->setSchool($this->getReference('school' . $data[0]));
     $entity->setName($data[1]);
     $entity->setAamcCode($data[2]);
     $entity->setAddressStreet($data[3]);
     $entity->setAddressCity($data[4]);
     $entity->setAddressStateOrProvince($data[5]);
     $entity->setAddressZipCode($data[6]);
     $entity->setAddressCountryCode($data[7]);
     $entity->setId($data[8]);
     return $entity;
 }