public function resetPasswordForUser(UserInterface $user)
 {
     $password = Helper::generateRandomPassword();
     $user->setPassword($password);
     $this->manager->updateResource($user);
     $this->mailerHelper->sendEmail(['recipient' => $user->getEmail(), 'subject' => 'user.email.title.reset_password', 'template' => 'WellCommerceAdminBundle:Admin/Email:reset_password.html.twig', 'parameters' => ['user' => $user, 'password' => $password], 'configuration' => $this->shopStorage->getCurrentShop()->getMailerConfiguration()]);
 }
 public function resetPassword(ClientInterface $client)
 {
     $hash = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36) . $client->getId();
     $client->getClientDetails()->setResetPasswordHash($hash);
     $client->getClientDetails()->setHashedPassword(Helper::generateRandomPassword(8));
     $this->updateResource($client);
 }
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     if (!$this->isEnabled()) {
         return;
     }
     $role = $this->container->get('role.factory')->create();
     $role->setName('admin');
     $role->setRole('ROLE_ADMIN');
     $manager->persist($role);
     $this->setReference('default_role', $role);
     $group = $this->container->get('user_group.factory')->create();
     $group->setName('Administration');
     $group->setPermissions($this->getPermissions($group));
     $manager->persist($group);
     $this->setReference('default_group', $group);
     $user = $this->container->get('user.factory')->create();
     $user->setFirstName('John');
     $user->setLastName('Doe');
     $user->setUsername('admin');
     $user->setEmail('*****@*****.**');
     $user->setEnabled(1);
     $user->setPassword('admin');
     $user->addRole($role);
     $user->getGroups()->add($group);
     $user->setApiKey(Helper::generateRandomPassword(8));
     $manager->persist($user);
     $manager->flush();
 }
 public function getSortingOptions(array $columns = []) : array
 {
     $sorting = [];
     foreach ($columns as $column => $directions) {
         foreach ($directions as $direction) {
             $label = sprintf('product.options.order_by.%s.%s', Helper::snake($column), $direction);
             $active = $this->isSortingActive($column, $direction);
             $sorting[] = ['orderBy' => $column, 'orderDir' => $direction, 'label' => $label, 'active' => $active];
         }
     }
     return $sorting;
 }
 /**
  * Automatic register process
  *
  * @param FacebookUser $facebookUser
  *
  * @return ClientInterface
  */
 protected function autoRegisterClient(FacebookUser $facebookUser)
 {
     $firstName = $facebookUser->getFirstName();
     $lastName = $facebookUser->getLastName();
     $email = $facebookUser->getEmail();
     /** @var $client ClientInterface */
     $client = $this->clientManager->initResource();
     $client->getClientDetails()->setUsername($email);
     $client->getClientDetails()->setPassword(Helper::generateRandomPassword());
     $client->getContactDetails()->setEmail($email);
     $client->getContactDetails()->setFirstName($firstName);
     $client->getContactDetails()->setLastName($lastName);
     $client->getContactDetails()->setPhone(' ');
     $client->getContactDetails()->setSecondaryPhone(' ');
     $this->clientManager->createResource($client);
     return $client;
 }
 /**
  * {@inheritdoc}
  */
 public function createIndex($name)
 {
     $kernelDir = $this->kernel->getRootDir();
     $indexDir = $kernelDir . '/store/lucene/' . Helper::snake($name);
     $this->luceneManager->setIndex($name, $indexDir, 'ZendSearch\\Lucene\\Analysis\\Analyzer\\Common\\Utf8\\CaseInsensitive');
 }
 /**
  * Returns event name for bundle
  *
  * @param         $name
  * @param Request $request
  *
  * @return string
  */
 private function getEventName($name, Request $request)
 {
     $bundle = $request->request->get('_bundle');
     $snake = Helper::snake($bundle);
     return sprintf('%s.%s', $snake, $name);
 }
 /**
  * Synchronizes translations to database
  *
  * @param array $mergedTranslations
  */
 protected function syncDatabaseTranslations(array $mergedTranslations)
 {
     foreach ($mergedTranslations as $locale => $data) {
         $flattened = Helper::flattenArrayToDotNotation($data);
         $this->saveDatabaseTranslations($locale, $flattened);
     }
 }
 /**
  * Returns event name for particular resource
  *
  * @param string $class
  * @param string $name
  *
  * @return string
  */
 protected function getResourceEventName($class, $name)
 {
     return sprintf('%s.%s', Helper::snake($class), $name);
 }
Exemple #10
0
 private function getEventName($class, $name)
 {
     return sprintf('%s.%s', Helper::snake($class), $name);
 }
 public function getAlias() : string
 {
     $parts = explode('\\', $this->getEntityName());
     $entityName = end($parts);
     return Helper::snake($entityName);
 }
 /**
  * Adds a setter method to generator
  *
  * @param TraitGenerator $generator
  * @param string         $property
  */
 protected function addSetterMethod(TraitGenerator $generator, string $property)
 {
     $setterMethodName = 'set' . Helper::studly($property);
     $variableName = strval($property);
     $method = new MethodGenerator($setterMethodName);
     $method->addBodyLine(new CodeLineGenerator('$this->' . $variableName . ' = $' . $variableName . ';'));
     $method->addParameter(new ParameterGenerator($variableName));
     $method->setVisibility(Modifiers::VISIBILITY_PUBLIC);
     $generator->addMethod($method);
 }
 /**
  * Returns a function name used in DataGrid events and actions
  *
  * @param $name
  *
  * @return string
  */
 protected function getFunction($name)
 {
     $functionName = sprintf('%s%s', $name, ucfirst($this->identifier));
     return lcfirst(Helper::studly($functionName));
 }