Skip to content

Commit

Permalink
removed unused code #728
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermednt committed Oct 30, 2017
1 parent 4d8e4db commit 42bb933
Showing 1 changed file with 10 additions and 38 deletions.
48 changes: 10 additions & 38 deletions src/LoginCidadao/OAuthBundle/Entity/ClientManager.php
Original file line number Diff line number Diff line change
@@ -1,52 +1,24 @@
<?php
/**
* This file is part of the login-cidadao project or it's bundles.
*
* (c) Guilherme Donato <guilhermednt on github>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace LoginCidadao\OAuthBundle\Entity;

use FOS\OAuthServerBundle\Entity\ClientManager as FOSClientManager;
use FOS\OAuthServerBundle\Model\ClientInterface;
use Doctrine\ORM\PersistentCollection;
use LoginCidadao\CoreBundle\Entity\Person;

class ClientManager extends FOSClientManager
{

public function updateClient(ClientInterface $client)
{
// let's see what happens
$this->em->persist($client);
$this->em->flush();
return;

$this->em->getConnection()->beginTransaction();
if ($client->getId()) {
$this->em->createQuery('DELETE from LoginCidadaoOAuthBundle:ClientPerson where client_id = :id')->setParameter('id', $client->getId());
}
$this->em->persist($client);
$itens = $client->getPersons();
if ($itens instanceof PersistentCollection) {
foreach ($itens as $idx => $iten) {
if ($iten instanceof Person) {
$itens->removeElement($iten);
$new = new ClientPerson();
$new->setClient($client);
$new->setPerson($iten);
$this->em->persist($new);
$itens->add($new);
}
}
} else if (is_array($itens)) {
foreach ($itens as $idx => $iten) {
if ($iten instanceof Person) {
$new = new ClientPerson();
$new->setClient($client);
$new->setPerson($iten);
$this->em->persist($new);
} else if ($iten instanceof ClientPerson) {
$iten->setClient($client);
$this->em->persist($iten);
}
}
}
$this->em->flush();
$this->em->getConnection()->commit();
}
}
}

0 comments on commit 42bb933

Please sign in to comment.