当前位置: 首页>>代码示例>>PHP>>正文


PHP User::addGroup方法代码示例

本文整理汇总了PHP中AppBundle\Entity\User::addGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP User::addGroup方法的具体用法?PHP User::addGroup怎么用?PHP User::addGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AppBundle\Entity\User的用法示例。


在下文中一共展示了User::addGroup方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createEntity

 private function createEntity($username, $password, $email)
 {
     $securityEncodeFactory = $this->getContainer()->get('security.encoder_factory');
     $em = $this->getContainer()->get('doctrine')->getEntityManager();
     $groupRepo = $em->getRepository('AppBundle\\Entity\\Group');
     $roleAdminGroup = $groupRepo->findOneByRole('ROLE_ADMIN');
     $user = new User();
     $user->setUsername($username);
     $user->setPassword($password);
     $user->setEmail($email);
     $user->addGroup($roleAdminGroup);
     $user->setIsActive(true);
     $encoder = $securityEncodeFactory->getEncoder($user);
     $password = $encoder->encodePassword($user->getPassword(), $user->getSalt());
     $user->setPassword($password);
     return $user;
 }
开发者ID:nejibem,项目名称:symfony-example,代码行数:17,代码来源:GenerateCommand.php

示例2: processGroupUpdates

 public function processGroupUpdates(UserEntity $user, $data)
 {
     $allGroups = $this->groupManager->findGroups();
     $allGroupNames = [];
     foreach ($allGroups as $g) {
         $allGroupNames[] = $g->getName();
     }
     foreach ($allGroupNames as $groupName) {
         $g = $this->groupManager->findGroupByName($groupName);
         if (!in_array($g->getId(), $data['groups'])) {
             $user->removeGroup($g);
         } else {
             if (!$user->hasGroup($g)) {
                 $user->addGroup($g);
             }
         }
     }
 }
开发者ID:bgamrat,项目名称:crispy-octo-parakeet,代码行数:18,代码来源:User.php

示例3: addGroup

 /**
  * {@inheritDoc}
  */
 public function addGroup(\FOS\UserBundle\Model\GroupInterface $group)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'addGroup', [$group]);
     return parent::addGroup($group);
 }
开发者ID:reathh,项目名称:MotikarqSystem,代码行数:8,代码来源:__CG__AppBundleEntityUser.php

示例4: addUser

 /**
  * Add user
  *
  * @param \AppBundle\Entity\User $user
  *
  * @return Group
  */
 public function addUser(\AppBundle\Entity\User $user)
 {
     $this->user[] = $user;
     $user->addGroup($this);
     return $this;
 }
开发者ID:fer2d2,项目名称:fernando.moro.php.ecp1,代码行数:13,代码来源:Group.php

示例5: basename

<?php

require_once __DIR__ . '/../../config/bootstrap.php';
use AppBundle\Entity\User;
//Check usage
if ($argc !== 6) {
    echo "Usage:\n   php ", basename($argv[0]), ' username email password roles groupID' . PHP_EOL;
    exit;
}
//Create User
$user = new User($argv[1], $argv[2], $argv[3], explode(" ", $argv[4]));
//Get group (object)
$entityManager = GetEntityManager();
$groupsRepository = $entityManager->getRepository('AppBundle\\Entity\\Group');
$group = $groupsRepository->find(intval($argv[5]));
//Add user to group (many to many)
$user->addGroup($group);
//Add user to BBDD
$entityManager->persist($user);
$entityManager->flush();
开发者ID:RaquelDiazG,项目名称:PHP_ClubPadel,代码行数:20,代码来源:create_user.php


注:本文中的AppBundle\Entity\User::addGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。