コード例 #1
0
ファイル: GroupHandler.php プロジェクト: QuangDang212/roadiz
 /**
  * This method does not flush ORM. You'll need to manually call it.
  *
  * @param RZ\Roadiz\Core\Entities\Group $newGroup
  *
  * @throws \RuntimeException If newGroup param is null
  */
 public function diff(Group $newGroup)
 {
     if (null !== $newGroup) {
         if ("" != $newGroup->getName()) {
             $this->group->setName($newGroup->getName());
         }
         $existingRolesNames = $this->group->getRoles();
         foreach ($newGroup->getRolesEntities() as $newRole) {
             if (false === in_array($newRole->getName(), $existingRolesNames)) {
                 $role = Kernel::getService('em')->getRepository('RZ\\Roadiz\\Core\\Entities\\Role')->findOneByName($newRole->getName());
                 $this->group->addRole($role);
             }
         }
     } else {
         throw new \RuntimeException("New group is null", 1);
     }
 }
コード例 #2
0
 /**
  * @param RZ\Roadiz\Core\Entities\Group $group
  *
  * @return \Symfony\Component\Form\Form
  */
 private function buildEditRolesForm(Group $group)
 {
     $defaults = ['groupId' => $group->getId()];
     $builder = $this->createFormBuilder($defaults)->add('groupId', 'hidden', ['data' => $group->getId(), 'constraints' => [new NotBlank()]])->add('roleId', new \RZ\Roadiz\CMS\Forms\RolesType($group->getRolesEntities()), ['label' => 'choose.role']);
     return $builder->getForm();
 }