setType() public method

public setType ( string $type )
$type string
Exemplo n.º 1
0
 /**
  * @param Schema $schema
  */
 public function up(Schema $schema)
 {
     $this->performDatabaseUpgrade();
     $userProviderRepository = $this->getEM()->getRepository('PartKeeprAuthBundle:UserProvider');
     $builtinProvider = $userProviderRepository->findOneBy(['type' => 'Builtin']);
     if ($builtinProvider === null) {
         $builtinProvider = new UserProvider();
         $builtinProvider->setType('Builtin');
         $this->getEM()->persist($builtinProvider);
     }
     $repository = $this->getEM()->getRepository('PartKeeprAuthBundle:User');
     $users = $repository->findAll();
     foreach ($users as $user) {
         if ($user->getProvider() === null) {
             $user->setProvider($builtinProvider);
         }
         $user->setLegacy(true);
     }
     $this->getEM()->flush();
 }
Exemplo n.º 2
0
 public function getProviderByType($type)
 {
     $provider = $this->entityManager->getRepository("PartKeeprAuthBundle:UserProvider")->findOneBy(array("type" => $type));
     if ($provider !== null) {
         return $provider;
     }
     $provider = new UserProvider();
     $provider->setType($type);
     if ($type !== self::BUILTIN_PROVIDER) {
         $provider->setEditable(false);
     }
     $this->entityManager->persist($provider);
     $this->entityManager->flush();
     return $provider;
 }