Ejemplo n.º 1
0
 /**
  * @param GroupInterface $group
  * @param string         $type
  *
  * @throws \InvalidArgumentException
  */
 protected function setType(GroupInterface $group, $type)
 {
     $groupType = $this->groupTypeRepository->findOneByIdentifier($type);
     if (null !== $groupType) {
         $group->setType($groupType);
     } else {
         throw new \InvalidArgumentException(sprintf('Type "%s" does not exist', $type));
     }
 }
Ejemplo n.º 2
0
 /**
  * Create and configure a group instance
  *
  * @param string $groupTypeCode
  *
  * @return GroupInterface
  */
 public function createGroup($groupTypeCode = null)
 {
     $group = new $this->groupClass();
     if (null !== $groupTypeCode) {
         $groupType = $this->groupTypeRepository->findOneByIdentifier($groupTypeCode);
         if (null === $groupType) {
             throw new \InvalidArgumentException(sprintf('Group type with code "%s" was not found', $groupTypeCode));
         }
         $group->setType($groupType);
     }
     return $group;
 }
 /**
  * @param GroupInterface $group
  * @param array          $data
  */
 protected function setGroupType(GroupInterface $group, $data)
 {
     if (isset($data['type'])) {
         $typeCode = $data['type'];
         /** @var GroupType|null $type */
         $type = $this->groupTypeRepository->findOneByIdentifier($typeCode);
         if (!$type) {
             throw new \LogicException(sprintf('Group Type with identifier "%s" not found', $typeCode));
         }
         $group->setType($type);
     }
 }