Skip to content

Commit

Permalink
Rename Externalids => ExternalId
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jul 19, 2023
1 parent c811891 commit 37a8fcd
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion application/src/Controller/BackOfficeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Controller;

use App\Entity\Externalids;
use App\Entity\ExternalId;
use App\Entity\Medias;
use App\Entity\Password;
use App\Entity\RoomMember;
Expand Down
18 changes: 9 additions & 9 deletions application/src/Controller/SynapseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use App\Entity\Externalids;
use App\Entity\ExternalId;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -74,8 +74,8 @@ public function registerUser(string $serverID, string $userID, Request $request)
// Finally return user info.
$threepids = $this->getDoctrine()->getRepository(Threepids::class)
->getUserThreepids($serverID, $user->getId());
$externalids = $this->getDoctrine()->getRepository(Externalids::class)
->getUserExternalids($serverID, $user->getId());
$externalids = $this->getDoctrine()->getRepository(ExternalId::class)
->getUserExternalIds($serverID, $user->getId());

return new JsonResponse((object) [
'name' => $userID,
Expand Down Expand Up @@ -138,7 +138,7 @@ private function upsertUser(string $serverID, string $userID, Request $request,
$payload = json_decode($request->getContent());
$entityManager = $this->getDoctrine()->getManager();
$hasThreepids = false;
$hasExternalids = false;
$hasExternalIds = false;

$user->setServerid($serverID);
$user->setUserid($userID);
Expand Down Expand Up @@ -186,11 +186,11 @@ private function upsertUser(string $serverID, string $userID, Request $request,
// Process external ids.
if (!empty($payload->external_ids)){
foreach ($payload->external_ids as $eid) {
$externalid = $entityManager->getRepository(Externalids::class)
$externalid = $entityManager->getRepository(ExternalId::class)
->findOneBy(['serverid' => $serverID, 'userid' => $user->getId(), 'auth_provider' => $eid->auth_provider]);
if (!$externalid) {
// New user, or existing user without any associated Externalids.
$externalid = new Externalids();
// New user, or existing user without any associated ExternalIds.
$externalid = new ExternalId();
$externalid->setAuthProvider($eid->auth_provider);
$externalid->setServerid($serverID);

Expand All @@ -200,7 +200,7 @@ private function upsertUser(string $serverID, string $userID, Request $request,
$externalid->setExternalId($this->generateExternalId($eid->external_id));
$entityManager->persist($externalid);
}
$hasExternalids = true;
$hasExternalIds = true;
}

$entityManager->persist($user);
Expand Down Expand Up @@ -231,7 +231,7 @@ private function upsertUser(string $serverID, string $userID, Request $request,
$responseObj->threepids = [$payload->threepids];
}

if ($hasExternalids) {
if ($hasExternalIds) {
$payload->external_ids['validated_at'] = time();
$payload->external_ids['added_at'] = time();
$responseObj->threepids = [$payload->external_ids];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace App\Entity;

use App\Repository\ExternalidsRepository;
use App\Repository\ExternalIdRepository;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity(repositoryClass=ExternalidsRepository::class)
* @ORM\Entity(repositoryClass=ExternalidRepository::class)
*/
class Externalids
class ExternalId
{
/**
* @ORM\Id
Expand Down
10 changes: 5 additions & 5 deletions application/src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class User
private $serverid;

/**
* @ORM\OneToMany(targetEntity=Externalids::class, mappedBy="userid", cascade={"persist", "remove"})
* @ORM\OneToMany(targetEntity=ExternalId::class, mappedBy="userid", cascade={"persist", "remove"})
*/
private $externalids;

Expand Down Expand Up @@ -206,14 +206,14 @@ public function setAvatarurl(string $avatarurl = null): self
}

/**
* @return Collection<int, Externalids>
* @return Collection<int, ExternalId>
*/
public function getExternalids(): Collection
public function getExternalIds(): Collection
{
return $this->externalids;
}

public function addExternalid(Externalids $externalid): self
public function addExternalid(ExternalId $externalid): self
{
if (!$this->externalids->contains($externalid)) {
$this->externalids[] = $externalid;
Expand All @@ -223,7 +223,7 @@ public function addExternalid(Externalids $externalid): self
return $this;
}

public function removeExternalid(Externalids $externalid): self
public function removeExternalid(ExternalId $externalid): self
{
if ($this->externalids->removeElement($externalid)) {
// set the owning side to null (unless already changed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@

namespace App\Repository;

use App\Entity\Externalids;
use App\Entity\ExternalId;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMException;
use Doctrine\Persistence\ManagerRegistry;

/**
* @extends ServiceEntityRepository<Externalids>
* @extends ServiceEntityRepository<ExternalId>
*
* @method Externalids|null find($id, $lockMode = null, $lockVersion = null)
* @method Externalids|null findOneBy(array $criteria, array $orderBy = null)
* @method Externalids[] findAll()
* @method Externalids[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
* @method ExternalId|null find($id, $lockMode = null, $lockVersion = null)
* @method ExternalId|null findOneBy(array $criteria, array $orderBy = null)
* @method ExternalId[] findAll()
* @method ExternalId[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ExternalidsRepository extends ServiceEntityRepository
class ExternalIdRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Externalids::class);
parent::__construct($registry, ExternalId::class);
}

/**
* @throws ORMException
* @throws OptimisticLockException
*/
public function add(Externalids $entity, bool $flush = true): void
public function add(ExternalId $entity, bool $flush = true): void
{
$this->_em->persist($entity);
if ($flush) {
Expand All @@ -39,7 +39,7 @@ public function add(Externalids $entity, bool $flush = true): void
* @throws ORMException
* @throws OptimisticLockException
*/
public function remove(Externalids $entity, bool $flush = true): void
public function remove(ExternalId $entity, bool $flush = true): void
{
$this->_em->remove($entity);
if ($flush) {
Expand All @@ -54,7 +54,7 @@ public function remove(Externalids $entity, bool $flush = true): void
* @param string $serverID
* @return float|int|mixed|string
*/
public function getUserExternalids(string $serverID, string $userID)
public function getUserExternalIds(string $serverID, string $userID)
{
return $this->createQueryBuilder('t')
->andWhere('t.userid = :userid')
Expand Down

0 comments on commit 37a8fcd

Please sign in to comment.