Create a group

@param ObjectManager $manager The object manager
@param string        $name    The name of the group
@param array         $roles   The roles connected to this group

@return Group
343091
private function createGroup(ObjectManager $manager, $name, array $roles = array())
    {
        $group = new Group($name);
        foreach ($roles as $role) {
            $group->addRole($role);
        }
        $manager->persist($group);

        return $group;
    }
815517
public function load(ObjectManager $manager)
    {
        /**
         * @var ObjectDirector $menuNodeDirector
         */
        $menuNodeDirector = $this->getDirector('menu_node');

        $menuNodeHim = $menuNodeDirector
            ->create()
            ->setName('him')
            ->setCode('him')
            ->setUrl('elcodi.dev/him')
            ->setActiveUrls([])
            ->setEnabled(true);

        $menuNodeHer = $menuNodeDirector
            ->create()
            ->setName('her')
            ->setCode('her')
            ->setUrl('elcodi.dev/her')
            ->setActiveUrls(
                [
                    'her_products_list_route',
                    'her_offers_list_route',
                ]
            )
            ->setEnabled(true);

        $menuNodeVogue = $menuNodeDirector
            ->create()
            ->setName('vogue')
            ->setCode('vogue')
            ->setEnabled(true)
            ->setActiveUrls([])
            ->addSubnode($menuNodeHim)
            ->addSubnode($menuNodeHer);

        $menuNodeDirector->save($menuNodeVogue);
        $this->addReference('menu-node-him', $menuNodeHim);
        $this->addReference('menu-node-her', $menuNodeHer);
        $this->addReference('menu-node-vogue', $menuNodeVogue);
    }
1258834
private function _setAnnotationManager(AnnotationManager $manager)
	{
		foreach ( $this->annotationRegistry as $annotation_name => $annotation_class ) {
			$manager->registry[$annotation_name] = $annotation_class;
		}

		$this->annotationManager = $manager;

		return $this;
	}
43766
public function addMember(OrganizationInterface $organization, User $user, array $roles)
    {
        if ($organization->getOwner() === null) {
            $organization->setOwner($user);
        }

        $user->addOrganization($organization);
        $organization->addUser($user);

        $role = new Role();
        $role->setOrganization($organization);
        $role->setUser($user);
        $role->setRoles($roles);

        $this->dm->persist($user);
        $this->dm->persist($organization);
        $this->dm->persist($role);
        $this->dm->flush();
    }
282637
public function load(ObjectManager $manager)
    {
        /**
         * @var ObjectDirector $menuDirector
         */
        $menuDirector = $this->getDirector('menu');

        /**
         * Admin menu.
         */
        $menuAdmin = $menuDirector
            ->create()
            ->setCode('menu-admin')
            ->setEnabled(true)
            ->addSubnode($this->getReference('menu-node-vogue'));

        $menuDirector->save($menuAdmin);
        $this->addReference('menu-admin', $menuAdmin);

        /**
         * Front menu.
         */
        $menuFront = $menuDirector
            ->create()
            ->setCode('menu-front')
            ->setEnabled(true)
            ->addSubnode($this->getReference('menu-node-him'))
            ->addSubnode($this->getReference('menu-node-her'));

        $menuDirector->save($menuFront);
        $this->addReference('menu-front', $menuFront);
    }
496950
public function load(ObjectManager $manager)
    {
        $this->manager = $manager;
        $options = $this->getOptions();

        $parser = new Parser();

        $data = [];
        foreach ($this->getFixtures() as $fixture) {
            $data[] = $parser->parse(file_get_contents($fixture));
        }

        $fixtures = $this->initFixtures($data);
        $builder = $this->container->get('kunstmaan_fixtures.builder.builder');
        $locale = isset($options['locale']) ? $options['locale'] : 'en_US';

        foreach ($this->getProviders() as $provider) {
            $builder->addProvider($provider);
        }

        /*
         * because of faker's magic calls we'll want to add this as last provider
         */
        $builder->addProvider(Factory::create($locale));
        $builder->setFixtures($fixtures);
        $builder->buildFixtures($manager);
    }
880232
public function closeManager($name = null)
    {
        $name = $name ?: $this->getDefaultManagerName();

        if (!$this->managerExists($name)) {
            throw new InvalidArgumentException(sprintf('Doctrine Manager named "%s" does not exist.', $name));
        }

        // force the creation of a new document manager
        // if the current one is closed
        $this->resetService(
            $this->getManagerBindingName($this->managers[$name])
        );

        $this->resetService(
            $this->getConnectionBindingName($this->connections[$name])
        );

        unset($this->managersMap[$name]);
        unset($this->connectionsMap[$name]);
    }
670709
public function create( $model, $config = [] ) {

		$modelClass	= static::$modelClass;

		$group	= isset( $config[ 'group' ] ) ? $config[ 'group' ] : null;
		$role	= isset( $config[ 'role' ] ) ? $config[ 'role' ] : null;
		$user	= isset( $config[ 'user' ] ) ? $config[ 'user' ] : null;

		$model->groupId	= isset( $group ) ? $group->id : $model->groupId;
		$model->roleId	= isset( $role ) ? $role->id : $model->roleId;
		$model->userId	= isset( $user ) ? $user->id : $model->userId;

		$model->status	= isset( $model->status ) ? $model->status : $modelClass::STATUS_NEW;

		if( empty( $model->roleId ) ) {

			$role = $this->roleService->getBySlugType( CmnGlobal::ROLE_GROUP_MEMBER, CmnGlobal::TYPE_COMMUNITY );

			$model->roleId = $role->id;
		}

		return parent::create( $model, $config );
	}
126118
public function addGroup($name, $group_index_or_role = 0)
    {
      $group = new SignerGroup(array(
        'name' => $name
      ));

      $this->signers[$group_index_or_role] = $group;

      return $this;
    }
1224586
protected function createPermissionObject($resource, $context, $action, $roles) {
    $permission = $this->persistenceFacade->create($this->permissionType);
    $permission->setValue('resource', $resource);
    $permission->setValue('context', $context);
    $permission->setValue('action', $action);
    $permission->setValue('roles', $roles);
    return $permission;
  }
741745
public function load(ObjectManager $manager)
    {
        $user = new User();
        $user->setFirstname('admin');
        $user->setFirstname('admin');
        $user->setUsername('admin');
        $user->setEmail('admin@test.com');
        $user->setState(1);

        $newPass = 'playground';

        $bcrypt = new Bcrypt;
        $bcrypt->setCost(14);

        $pass = $bcrypt->create($newPass);
        $user->setPassword($pass);

        $user->addRole(
            $this->getReference('admin-role') // load the stored reference
        );

        $manager->persist($user);

        $manager->flush();

        $user = new User();
        $user->setFirstname('supervisor');
        $user->setFirstname('supervisor');
        $user->setUsername('supervisor');
        $user->setEmail('supervisor@test.com');
        $user->setState(1);

        $newPass = 'playground';

        $bcrypt = new Bcrypt;
        $bcrypt->setCost(14);

        $pass = $bcrypt->create($newPass);
        $user->setPassword($pass);

        $user->addRole(
            $this->getReference('supervisor-role') // load the stored reference
        );

        $manager->persist($user);

        $manager->flush();

        $user = new User();
        $user->setFirstname('game-manager');
        $user->setFirstname('game-manager');
        $user->setUsername('gamemanager');
        $user->setEmail('game-manager@test.com');
        $user->setState(1);

        $newPass = 'playground';

        $bcrypt = new Bcrypt;
        $bcrypt->setCost(14);

        $pass = $bcrypt->create($newPass);
        $user->setPassword($pass);

        $user->addRole(
            $this->getReference('game-role') // load the stored reference
        );

        $manager->persist($user);

        $manager->flush();
    }
1260485
public function load(ObjectManager $manager)
    {
        $geocoder = new \HarvestCloud\GeoBundle\Util\GoogleGeocoder();

        $buyer = new User();
        $buyer->setEmail('harvest.cloud@example.com');
        $buyer->setFirstname('Harvest');
        $buyer->setLastname('Cloud');
        $buyer->setEnabled(false);
        $buyer->setPassword('');

        $buyerProfile = new Profile();
        $buyerProfile->setName($buyer->getFullname());

        $buyer->addProfile($buyerProfile);

        $location = new Location();
        $location->setName('Default');
        $location->setAddressLine1('150 Main Street');
        $location->setTown('Great Barrington');
        $location->setStateCode('MA');
        $location->setPostalCode('01230');

        $geocoder->geocode($location);

        $buyerProfile->addLocation($location);

        $exchange = $this->container->get('exchange_manager')->getExchange();

        $exchange->setProfile($buyerProfile);

        $manager->persist($exchange);
        $manager->persist($buyer);
        $manager->flush();


        $buyer = new User();
        $buyer->setEmail('craig.buyer@example.com');
        $buyer->setFirstname('Craig');
        $buyer->setLastname('Buyer');
        $buyer->setEnabled(true);

        $encoder = $this->container
            ->get('security.encoder_factory')
            ->getEncoder($buyer)
        ;

        $buyer->setPassword($encoder->encodePassword('buyer', $buyer->getSalt()));

        $buyerProfile = new Profile();
        $buyerProfile->setName($buyer->getFullname());

        $buyer->addProfile($buyerProfile);

        $location = new Location();
        $location->setName('Default');
        $location->setAddressLine1('250 Main Street');
        $location->setTown('Great Barrington');
        $location->setStateCode('MA');
        $location->setPostalCode('01230');

        $geocoder->geocode($location);

        $buyerProfile->addLocation($location);

        $manager->persist($buyer);
        $manager->flush();


        $buyer = new User();
        $buyer->setEmail('peter.buyer@example.com');
        $buyer->setFirstname('Peter');
        $buyer->setLastname('Buyer');
        $buyer->setEnabled(true);

        $encoder = $this->container
            ->get('security.encoder_factory')
            ->getEncoder($buyer)
        ;

        $buyer->setPassword($encoder->encodePassword('buyer', $buyer->getSalt()));

        $buyerProfile = new Profile();
        $buyerProfile->setName($buyer->getFullname());

        $buyer->addProfile($buyerProfile);

        $location = new Location();
        $location->setName('Default');
        $location->setAddressLine1('1 Main Street');
        $location->setTown('Sheffield');
        $location->setStateCode('MA');
        $location->setPostalCode('01257');

        $geocoder->geocode($location);

        $buyerProfile->addLocation($location);

        $manager->persist($buyer);
        $manager->flush();


        $buyer = new User();
        $buyer->setEmail('michael.buyer@example.com');
        $buyer->setFirstname('Michael');
        $buyer->setLastname('Buyer');
        $buyer->setEnabled(true);

        $encoder = $this->container
            ->get('security.encoder_factory')
            ->getEncoder($buyer)
        ;

        $buyer->setPassword($encoder->encodePassword('buyer', $buyer->getSalt()));

        $buyerProfile = new Profile();
        $buyerProfile->setName($buyer->getFullname());

        $buyer->addProfile($buyerProfile);

        $location = new Location();
        $location->setName('Default');
        $location->setAddressLine1('1 Main Street');
        $location->setTown('Lee');
        $location->setStateCode('MA');
        $location->setPostalCode('01238');

        $geocoder->geocode($location);

        $buyerProfile->addLocation($location);

        $manager->persist($buyer);
        $manager->flush();
    }
516542
public function addManager($manager)
    {
        if (is_array($manager)) {
            foreach ($manager as $item) {
                $this->managerList->add($item);
            }

            return $this;
        }

        $this->managerList->add($manager);

        return $this;
    }
1295136
public function createGroup($name){
        if (!$this->access_token && !$this->checkAuth()) return false;
        $data = array(
                'group'=>array('name'=>$name)
        );
        $result = $this->http_post(self::API_URL_PREFIX.self::GROUP_CREATE_URL.'access_token='.$this->access_token,self::json_encode($data));
        if ($result)
        {
            $json = json_decode($result,true);
            if (!$json || !empty($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                return false;
            }
            return $json;
        }
        return false;
    }
345896
public function load(ObjectManager $manager)
    {
        $theme = new Theme();
        $theme->setTitle('Theme 1');
        $theme->setImage('/theme/images/screenshots/1-Penguins.jpg');
        $theme->setArea('admin');
        $theme->setPackage('default');
        $theme->setTheme('base');
        $manager->persist($theme);

        $theme = new Theme();
        $theme->setTitle('Theme 2');
        $theme->setImage('/theme/images/screenshots/2-Desert.jpg');
        $theme->setArea('admin');
        $theme->setPackage('default');
        $theme->setTheme('demo');
        $manager->persist($theme);
        $theme->setIsActive(1);
        $manager->persist($theme);

        $theme = new Theme();
        $theme->setTitle('Theme 3');
        $theme->setImage('/theme/images/screenshots/3-Tulips.jpg');
        $theme->setArea('frontend');
        $theme->setPackage('default');
        $theme->setTheme('base');
        $manager->persist($theme);

        $theme = new Theme();
        $theme->setTitle('Theme 4');
        $theme->setImage('/theme/images/screenshots/4-Koala.jpg');
        $theme->setArea('frontend');
        $theme->setPackage('default');
        $theme->setTheme('demo');
        $manager->persist($theme);
        $theme->setIsActive(1);
        $manager->persist($theme);

        $manager->flush();
    }
72870
public function addRole(string $role): PermissionManager
    {
        if ($this->hasRole($role)) {
            throw new RoleException("Role '{$role}' already exists");
        }

        $this->permissions[$role] = [
            //No associated permissions
        ];

        return $this;
    }
998935
public function load(ObjectManager $manager)
    {
        /**
         * @var ObjectDirector $configurationDirector
         */
        $configurationDirector = $this->getDirector('configuration');

        /**
         * Parameter.
         */
        $parameter = $configurationDirector
            ->create()
            ->setKey('my_boolean_parameter')
            ->setNamespace('app')
            ->setName('My Fixtures Boolean Parameter')
            ->setValue(true)
            ->setType('boolean');

        $configurationDirector->save($parameter);
    }