/**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $stepOrg = new Organization();
     $stepOrg->setName('Step Inventory');
     $manager->persist($stepOrg);
     $demoOrg = new Organization();
     $demoOrg->setName('Acme Inc.');
     $manager->persist($demoOrg);
     $manager->flush();
     $this->addReference('stepOrg', $stepOrg);
     $this->addReference('demoOrg', $demoOrg);
     $aclProvider = $this->container->get('security.acl.provider');
     $devRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_DEV');
     $adminRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_ADMIN');
     $leadRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_LEAD');
     $userRoleSecurityIdentity = new RoleSecurityIdentity('ROLE_USER');
     $objectIdentity = ObjectIdentity::fromDomainObject($stepOrg);
     $acl = $aclProvider->createAcl($objectIdentity);
     $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
     $acl->insertObjectAce($devRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
     $aclProvider->updateAcl($acl);
     $objectIdentity = ObjectIdentity::fromDomainObject($demoOrg);
     $acl = $aclProvider->createAcl($objectIdentity);
     $acl->insertObjectAce($userRoleSecurityIdentity, MaskBuilder::MASK_VIEW);
     $acl->insertObjectAce($adminRoleSecurityIdentity, MaskBuilder::MASK_OPERATOR);
     $aclProvider->updateAcl($acl);
 }
 /**
  * @Route("/signup", name="signup_route")
  */
 public function signupAction(Request $request)
 {
     $user = new User();
     $form = $this->createForm(SignupType::class, $user);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $password = $this->get('security.password_encoder')->encodePassword($user, $user->getPlainPassword());
         $user->setPassword($password);
         $adminRole = $this->getDoctrine()->getRepository('AppBundle:Role')->findOneBy(['name' => 'Admin']);
         $adminUserRole = new UserRole();
         $adminUserRole->setRole($adminRole);
         $adminUserRole->setUser($user);
         $em->persist($adminUserRole);
         $user->addUserRole($adminUserRole);
         $em->persist($user);
         $organization = new Organization();
         $organization->setName($form->get('organizationName')->getData());
         $em->persist($organization);
         $user->setOrganization($organization);
         $account = new Account();
         $em->persist($account);
         $accountOwnerChange = new AccountOwnerChange();
         $accountOwnerChange->setChangedBy($user);
         $accountOwnerChange->setChangedAt(new \DateTime());
         $accountOwnerChange->setAccount($account);
         $accountOwnerChange->setNewOwner($user);
         $em->persist($accountOwnerChange);
         $accountOwnerChange->updateAccount();
         $trialSubscription = $this->getDoctrine()->getRepository('AppBundle:Subscription')->findOneBy(['name' => 'Trial']);
         $accountSubscriptionChange = new AccountSubscriptionChange();
         $accountSubscriptionChange->setChangedBy($user);
         $accountSubscriptionChange->setChangedAt(new \DateTime());
         $accountSubscriptionChange->setAccount($account);
         $accountSubscriptionChange->setNewSubscription($trialSubscription);
         $em->persist($accountSubscriptionChange);
         $accountSubscriptionChange->updateAccount();
         $organization->setAccount($account);
         $em->flush();
         $this->updateAclByRoles($user, ['ROLE_USER' => 'view', 'ROLE_ADMIN' => 'operator']);
         foreach ($user->getUserRoles() as $userRole) {
             $this->updateAclByRoles($userRole, ['ROLE_USER' => 'view', 'ROLE_ADMIN' => 'operator']);
         }
         $this->updateAclByRoles($organization, ['ROLE_USER' => 'view', 'ROLE_ADMIN' => 'operator']);
         return $this->redirectToRoute('login_route');
     }
     return $this->render('security/signup.html.twig', ['form' => $form->createView()]);
 }
 public function load(ObjectManager $manager)
 {
     // Orange - Companie
     $companieOrange = new Organization();
     $companieOrange->setName('Orange Romania');
     /** @var PostalAddress $adresaOrange */
     $adresaOrange = $this->getReference('adresa-orange');
     $companieOrange->setAddress($adresaOrange);
     /** @var Person $contactOrange */
     $contactOrange = $this->getReference('contact-orange');
     $companieOrange->setEmployee($contactOrange);
     $companieOrange->setEmail('*****@*****.**');
     $companieOrange->setTelephone('0744.744.744');
     /** @var User $userCompanyOrange */
     $userCompanyOrange = $this->getReference('orange-companie');
     $userCompanyOrange->addOrganization($companieOrange);
     // Orange - Bucuresti - Victoria
     $orangeBucurestiVictoria = new Organization();
     $orangeBucurestiVictoria->setName('Orange Bucuresti Victoria');
     /** @var PostalAddress $adresaDepartamentOrange */
     $adresaDepartamentOrange = $this->getReference('adresa-orange-bucuresti-victoria');
     $orangeBucurestiVictoria->setAddress($adresaDepartamentOrange);
     /** @var Person $contactOrangeBucurestiVictoria */
     $contactOrangeBucurestiVictoria = $this->getReference('contact-orange-bucuresti-victoria');
     $orangeBucurestiVictoria->setEmployee($contactOrangeBucurestiVictoria);
     $orangeBucurestiVictoria->setEmail('*****@*****.**');
     $orangeBucurestiVictoria->setTelephone('0745.745.745');
     /** @var User $userOrangeBucurestiVictoria */
     $userOrangeBucurestiVictoria = $this->getReference('orange-departament');
     $userOrangeBucurestiVictoria->addOrganization($orangeBucurestiVictoria);
     $manager->persist($orangeBucurestiVictoria);
     $companieOrange->addDepartment($orangeBucurestiVictoria);
     // Orange - Brasov - Tehnic
     $orangeBrasovTehnic = new Organization();
     $orangeBrasovTehnic->setName('Orange Brasov Tehnic');
     /** @var PostalAddress $adresaOrangeBrasovTehnic */
     $adresaOrangeBrasovTehnic = $this->getReference('adresa-orange-brasov-tehnic');
     $orangeBrasovTehnic->setAddress($adresaOrangeBrasovTehnic);
     /** @var Person $contactOrangeBrasovTehnic */
     $contactOrangeBrasovTehnic = $this->getReference('contact-orange-brasov-tehnic');
     $orangeBrasovTehnic->setEmployee($contactOrangeBrasovTehnic);
     $orangeBrasovTehnic->setEmail('*****@*****.**');
     $orangeBrasovTehnic->setTelephone('0745.545.545');
     /** @var User $userOrangeBrasov */
     $userOrangeBrasov = $this->getReference('orange-brasov');
     $userOrangeBrasov->addOrganization($orangeBrasovTehnic);
     $manager->persist($orangeBrasovTehnic);
     $companieOrange->addDepartment($orangeBrasovTehnic);
     // Orange - Brasov - Muresenilor
     $orangeBrasovMuresenilor = new Organization();
     $orangeBrasovMuresenilor->setName('Orange Brasov Shop Muresenilor');
     /** @var PostalAddress $adresaOrangeBrasovMuresenilor */
     $adresaOrangeBrasovMuresenilor = $this->getReference('adresa-orange-brasov-muresenilor');
     $orangeBrasovMuresenilor->setAddress($adresaOrangeBrasovMuresenilor);
     /** @var Person $contactOrangeBrasovMuresenilor */
     $contactOrangeBrasovMuresenilor = $this->getReference('contact-orange-brasov-muresenilor');
     $orangeBrasovMuresenilor->setEmployee($contactOrangeBrasovMuresenilor);
     $orangeBrasovMuresenilor->setEmail('*****@*****.**');
     $orangeBrasovMuresenilor->setTelephone('0745.345.345');
     $userOrangeBrasov->addOrganization($orangeBrasovMuresenilor);
     $manager->persist($orangeBrasovMuresenilor);
     $companieOrange->addDepartment($orangeBrasovMuresenilor);
     // Orange - Brasov - Saturn
     $orangeBrasovSaturn = new Organization();
     $orangeBrasovSaturn->setName('Orange Brasov Shop Saturn');
     /** @var PostalAddress $adresaOrangeBrasovSaturn */
     $adresaOrangeBrasovSaturn = $this->getReference('adresa-orange-brasov-saturn');
     $orangeBrasovSaturn->setAddress($adresaOrangeBrasovSaturn);
     /** @var Person $contactOrangeBrasovSaturn */
     $contactOrangeBrasovSaturn = $this->getReference('contact-orange-brasov-saturn');
     $orangeBrasovSaturn->setEmployee($contactOrangeBrasovSaturn);
     $orangeBrasovSaturn->setEmail('*****@*****.**');
     $orangeBrasovSaturn->setTelephone('0745.345.345');
     $userOrangeBrasov->addOrganization($orangeBrasovSaturn);
     $manager->persist($orangeBrasovSaturn);
     $companieOrange->addDepartment($orangeBrasovSaturn);
     // Orange - Brasov - Coresi
     $orangeBrasovCoresi = new Organization();
     $orangeBrasovCoresi->setName('Orange Brasov Shop Coresi');
     /** @var PostalAddress $adresaOrangeBrasovCoresi */
     $adresaOrangeBrasovCoresi = $this->getReference('adresa-orange-brasov-coresi');
     $orangeBrasovCoresi->setAddress($adresaOrangeBrasovCoresi);
     /** @var Person $contactOrangeBrasovCoresi */
     $contactOrangeBrasovCoresi = $this->getReference('contact-orange-brasov-coresi');
     $orangeBrasovCoresi->setEmployee($contactOrangeBrasovCoresi);
     $orangeBrasovCoresi->setEmail('*****@*****.**');
     $orangeBrasovCoresi->setTelephone('0745.345.345');
     $userOrangeBrasov->addOrganization($orangeBrasovCoresi);
     $manager->persist($orangeBrasovCoresi);
     $companieOrange->addDepartment($orangeBrasovCoresi);
     $manager->persist($companieOrange);
     // Cargus - Companie
     $companieCargus = new Organization();
     $companieCargus->setName('Urgent Cargus');
     /** @var PostalAddress $adresaCargus */
     $adresaCargus = $this->getReference('adresa-cargus');
     $companieCargus->setAddress($adresaCargus);
     /** @var Person $contactCargus */
     $contactCargus = $this->getReference('contact-cargus');
     $companieCargus->setEmployee($contactCargus);
     $companieCargus->setEmail('*****@*****.**');
     $companieCargus->setTelephone('0744.744.744');
     /** @var User $userCompanyCargus */
     $userCompanyCargus = $this->getReference('cargus-companie');
     $userCompanyCargus->addOrganization($companieCargus);
     $manager->persist($companieCargus);
     $manager->flush();
     //        $this->addReference('companie-orange', $companieOrange);
     //        $this->addReference('companie-cargus', $companieCargus);
 }