public function accountCreateAction() { $firstName = $this->params('first-name'); if (!$firstName) { $firstName = Line::prompt('Please enter the first name of the person: '); } $lastName = $this->params('last-name'); if (!$lastName) { $lastName = Line::prompt('Please enter the last name of the person: '); } $credential = $this->params('credential'); if (!$credential) { $credential = Password::prompt('Please enter the credential of this new account: '); $verification = Password::prompt('Please enter the credential again to verify: '); if ($credential !== $verification) { $this->getConsole()->writeLine('The two credentials do not match.'); return 1; } } $person = new Person($firstName, $lastName); $account = new Account($person); $account->setCredential($this->crypter->create($credential)); $this->entityManager->persist($account); $this->entityManager->flush($account); $this->getConsole()->writeLine('Account created with id ' . $account->getId()->toString()); return 0; }
public function load(ObjectManager $manager) { /** @var PasswordInterface $password */ $password = $this->getServiceLocator()->get(PasswordInterface::class); $person = new Person('Walter', 'Tamboer'); $manager->persist($person); $account = new Account($person); $account->setCredential($password->create('root')); $manager->persist($account); $identity = new Identity($account, 'username', 'root'); $manager->persist($identity); $manager->flush(); }
public function load(ObjectManager $manager) { /** @var PasswordInterface $password */ $password = $this->getServiceLocator()->get(PasswordInterface::class); for ($i = 0; $i < 10; ++$i) { $person = new Person('Account', $i); $manager->persist($person); $account = new AccountEntity($person); $account->setCredential($password->create('account' . $i)); $manager->persist($account); $identity = new Identity($account, 'username', 'account' . $i); $manager->persist($identity); } $manager->flush(); }