Inheritance: implements FOS\UserBundle\Util\CanonicalizerInterface
Esempio n. 1
0
 public function canonicalize($string)
 {
     if (extension_loaded('mbstring')) {
         return parent::canonicalize($string);
     } else {
         return strtolower($string);
     }
 }
Esempio n. 2
0
 protected function migrate(&$user)
 {
     if (array_key_exists('isActive', $user)) {
         $user['enabled'] = (bool) $user['isActive'];
         unset($user['isActive']);
     }
     if (!array_key_exists('roles', $user)) {
         $user['roles'] = array();
     }
     if (isset($user['confirmationToken'])) {
         unset($user['confirmationToken']);
     }
     if (isset($user['usernameLower'])) {
         $canonicalizer = new Canonicalizer();
         $user['usernameCanonical'] = $canonicalizer->canonicalize($user['usernameLower']);
         $user['emailCanonical'] = $canonicalizer->canonicalize($user['email']);
         unset($user['usernameLower']);
     }
     if (isset($user['isSuperAdmin'])) {
         unset($user['isSuperAdmin']);
         $user['roles'] = array(User::ROLE_SUPER_ADMIN);
     }
 }
Esempio n. 3
0
 /**
  * @dataProvider canonicalizeProvider
  */
 public function testCanonicalize($source, $expectedResult)
 {
     $canonicalizer = new Canonicalizer();
     $this->assertSame($expectedResult, $canonicalizer->canonicalize($source));
 }