/** * @param AdministratorEvent $event * @param $eventName * @param EventDispatcherInterface $dispatcher */ public function create(AdministratorEvent $event, $eventName, EventDispatcherInterface $dispatcher) { $administrator = new AdminModel(); $administrator->setDispatcher($dispatcher)->setFirstname($event->getFirstname())->setLastname($event->getLastname())->setEmail($event->getEmail())->setLogin($event->getLogin())->setPassword($event->getPassword())->setProfileId($event->getProfile())->setLocale($event->getLocale()); $administrator->save(); $event->setAdministrator($administrator); }
protected function applyUserLocale(Admin $user) { // Set the current language according to Admin locale preference $locale = $user->getLocale(); if (null === ($lang = LangQuery::create()->findOneByLocale($locale))) { $lang = Lang::getDefaultLanguage(); } $this->getSession()->setLang($lang); }
/** * Ask to user all needed information * * @param InputInterface $input * @param OutputInterface $output * @return array */ protected function getAdminInfo(InputInterface $input, OutputInterface $output) { $dialog = $this->getHelperSet()->get('dialog'); $admin = new Admin(); $admin->setLogin($input->getOption("login_name") ?: $this->enterLogin($dialog, $output)); $admin->setFirstname($input->getOption("first_name") ?: $this->enterData($dialog, $output, "User first name : ", "Please enter user first name.")); $admin->setLastname($input->getOption("last_name") ?: $this->enterData($dialog, $output, "User last name : ", "Please enter user last name.")); $admin->setLocale($input->getOption("locale") ?: 'en_US'); $admin->setEmail($input->getOption("email") ?: $this->enterEmail($dialog, $output)); do { $password = $input->getOption("password") ?: $this->enterData($dialog, $output, "Password : "******"Please enter a password.", true); $password_again = $input->getOption("password") ?: $this->enterData($dialog, $output, "Password (again): ", "Please enter the password again.", true); if (!empty($password) && $password == $password_again) { $admin->setPassword($password); break; } $output->writeln("Passwords are different, please try again."); } while (true); $admin->setProfile(null); return $admin; }
/** * @param Admin $object * * @return \Thelia\Form\BaseForm */ protected function hydrateObjectForm($object) { $data = array('id' => $object->getId(), 'firstname' => $object->getFirstname(), 'lastname' => $object->getLastname(), 'login' => $object->getLogin(), 'profile' => $object->getProfileId(), 'locale' => $object->getLocale(), 'email' => $object->getEmail()); // Setup the object form return $this->createForm(AdminForm::ADMINISTRATOR_MODIFICATION, "form", $data); }
/** * Filter the query by a related \Thelia\Model\Admin object * * @param \Thelia\Model\Admin|ObjectCollection $admin the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildProfileQuery The current query, for fluid interface */ public function filterByAdmin($admin, $comparison = null) { if ($admin instanceof \Thelia\Model\Admin) { return $this->addUsingAlias(ProfileTableMap::ID, $admin->getProfileId(), $comparison); } elseif ($admin instanceof ObjectCollection) { return $this->useAdminQuery()->filterByPrimaryKeys($admin->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByAdmin() only accepts arguments of type \\Thelia\\Model\\Admin or Collection'); } }
/** * Exclude object from result * * @param ChildAdmin $admin Object to remove from the list of results * * @return ChildAdminQuery The current query, for fluid interface */ public function prune($admin = null) { if ($admin) { $this->addUsingAlias(AdminTableMap::ID, $admin->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * @param Admin $object * @return int */ protected function getObjectId($object) { return $object->getId(); }