/** * {@inheritDoc} */ public function setContainer(ContainerInterface $container = null) { $this->userManager = $container->get('oro_user.manager'); $this->userRepository = $this->userManager->getRepository(); $this->role = $this->userManager->getStorageManager()->getRepository('OroUserBundle:Role')->findBy(array('role' => 'ROLE_ADMINISTRATOR')); $this->businessUnitManager = $container->get('oro_organization.business_unit_manager'); $this->businessUnit = $this->businessUnitManager->getBusinessUnitRepo()->findAll(); $this->businessUnit = $this->businessUnit[0]; }
/** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('firstName', 'text', ['required' => true, 'label' => 'orob2b.account.accountuser.first_name.label'])->add('lastName', 'text', ['required' => true, 'label' => 'orob2b.account.accountuser.last_name.label'])->add('email', 'email', ['required' => true, 'label' => 'orob2b.account.accountuser.email.label']); $builder->add('plainPassword', 'repeated', ['type' => 'password', 'first_options' => ['label' => 'orob2b.account.accountuser.password.label'], 'second_options' => ['label' => 'orob2b.account.accountuser.password_confirmation.label'], 'invalid_message' => 'orob2b.account.message.password_mismatch', 'required' => true, 'validation_groups' => ['create']]); $builder->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) { /** @var AccountUser $accountUser */ $accountUser = $event->getData(); if (!$accountUser->getOwner()) { $userId = $this->configManager->get('oro_b2b_account.default_account_owner'); /** @var User $user */ $user = $this->userManager->getRepository()->find($userId); if ($user) { $accountUser->setOwner($user); } } }); }
/** * {@inheritDoc} */ public function setContainer(ContainerInterface $container = null) { $this->container = $container; if (isset($container->counter)) { $this->maxRecords = $container->counter; } else { $this->maxRecords = self::MAX_RECORDS; } $this->accountManager = $container->get('doctrine.orm.entity_manager'); $this->accountRepository = $this->accountManager->getRepository('OroCRMAccountBundle:Account'); $this->contactManager = $container->get('doctrine.orm.entity_manager'); $this->contactRepository = $this->contactManager->getRepository('OroCRMContactBundle:Contact'); $this->userManager = $container->get('oro_user.manager'); $this->userRepository = $this->userManager->getRepository(); $this->initSupportingEntities(); }