Skip to content

Commit

Permalink
Rename Users => User
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jul 19, 2023
1 parent 1b059a7 commit c811891
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 48 deletions.
14 changes: 7 additions & 7 deletions application/src/Controller/BackOfficeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use App\Entity\Room;
use App\Entity\Threepids;
use App\Entity\Tokens;
use App\Entity\Users;
use App\Entity\User;
use App\Traits\GeneralTrait;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
Expand All @@ -36,9 +36,9 @@ public function backOfficeCreateAdmin(string $serverID, Request $request) : Json
if ($method === 'POST') {
$entityManager = $this->getDoctrine()->getManager();

$user = $entityManager->getRepository(Users::class)->findOneBy(['userid' => '@admin:synapse']);
$user = $entityManager->getRepository(User::class)->findOneBy(['userid' => '@admin:synapse']);
if (!$user) {
$user = new Users();
$user = new User();
$user->setServerid($serverID);
$user->setUserid('@admin:synapse');
$user->setDisplayname('Admin User');
Expand Down Expand Up @@ -102,7 +102,7 @@ public function backOfficeCreateAdmin(string $serverID, Request $request) : Json
public function backOfficeReset(string $serverID) : JsonResponse
{
$entities = [
Users::class,
User::class,
Room::class,
Medias::class
];
Expand Down Expand Up @@ -161,7 +161,7 @@ function (RoomMember $membership): bool {
public function getAllUsers(string $serverID): JSONResponse
{
$users = $this->getDoctrine()
->getRepository(Users::class)
->getRepository(User::class)
->findBy(['serverid' => $serverID]);

return new JsonResponse(
Expand Down Expand Up @@ -190,7 +190,7 @@ public function setData(
'rooms' => [],
];

$userRepository = $entityManager->getRepository(Users::class);
$userRepository = $entityManager->getRepository(User::class);
$admin = $userRepository->findOneBy(
[
'admin' => true,
Expand All @@ -200,7 +200,7 @@ public function setData(

if (property_exists($payload, 'users')) {
foreach ($payload->users as $userdata) {
$user = new Users();
$user = new User();
$user->setServerid($serverID);
$user->setDisplayname($userdata->fullname);
$user->setUserid($userdata->id);
Expand Down
6 changes: 3 additions & 3 deletions application/src/Controller/MatrixController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use App\Entity\Room;
use App\Entity\RoomMember;
use App\Entity\Tokens;
use App\Entity\Users;
use App\Entity\User;
use App\Traits\GeneralTrait;
use App\Traits\MatrixSynapseTrait;
use stdClass;
Expand Down Expand Up @@ -126,7 +126,7 @@ public function login(string $serverID, Request $request): JsonResponse {
}

$entityManager = $this->getDoctrine()->getManager();
$user = $entityManager->getRepository(Users::class)->findOneBy($check['loginidentifier']);
$user = $entityManager->getRepository(User::class)->findOneBy($check['loginidentifier']);

$passwordpatter = $user ? $user->getPasswordpattern() : null;
$userid = $user ? $user->getId() : null;
Expand Down Expand Up @@ -309,7 +309,7 @@ public function kick(
return $check['message'];
}

$user = $entityManager->getRepository(Users::class)->findOneBy([
$user = $entityManager->getRepository(User::class)->findOneBy([
'serverid' => $serverID,
'userid' => $payload->user_id,
]);
Expand Down
12 changes: 6 additions & 6 deletions application/src/Controller/SynapseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
use App\Entity\Users;
use App\Entity\User;
use App\Entity\Threepids;
use App\Entity\RoomMember;
use App\Entity\Room;
Expand Down Expand Up @@ -55,7 +55,7 @@ public function registerUser(string $serverID, string $userID, Request $request)

// Add, update of get user info.
$entityManager = $this->getDoctrine()->getManager();
$user = $entityManager->getRepository(Users::class)->findOneBy(['userid' => $userID, 'serverid' => $serverID]);
$user = $entityManager->getRepository(User::class)->findOneBy(['userid' => $userID, 'serverid' => $serverID]);

if ($method == 'PUT' && !$user) {
// Create user.
Expand Down Expand Up @@ -107,7 +107,7 @@ public function registerUser(string $serverID, string $userID, Request $request)
*/
private function createUser(string $serverID, string $userID, Request $request): JsonResponse
{
$user = new Users();
$user = new User();
return $this->upsertUser($serverID, $userID, $request, $user);
}

Expand All @@ -119,7 +119,7 @@ private function createUser(string $serverID, string $userID, Request $request):
* @param Request $request
* @return JsonResponse
*/
private function updateUser(string $serverID, string $userID, Request $request, Users $user): JsonResponse
private function updateUser(string $serverID, string $userID, Request $request, User $user): JsonResponse
{
return $this->upsertUser($serverID, $userID, $request, $user, 200);
}
Expand All @@ -133,7 +133,7 @@ private function updateUser(string $serverID, string $userID, Request $request,
* @param Request $request
* @return JsonResponse
*/
private function upsertUser(string $serverID, string $userID, Request $request, Users $user, int $status = 201): JsonResponse
private function upsertUser(string $serverID, string $userID, Request $request, User $user, int $status = 201): JsonResponse
{
$payload = json_decode($request->getContent());
$entityManager = $this->getDoctrine()->getManager();
Expand Down Expand Up @@ -274,7 +274,7 @@ public function inviteUser(string $serverID, string $roomID, Request $request):
return $check['message'];
}

$user = $entityManager->getRepository(Users::class)->findOneBy([
$user = $entityManager->getRepository(User::class)->findOneBy([
'serverid' => $serverID,
'userid' => $payload->user_id,
]);
Expand Down
6 changes: 3 additions & 3 deletions application/src/Entity/Externalids.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Externalids
private $serverid;

/**
* @ORM\ManyToOne(targetEntity=Users::class, inversedBy="externalids")
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="externalids")
* @ORM\JoinColumn(nullable=false)
*/
private $userid;
Expand Down Expand Up @@ -79,12 +79,12 @@ public function setServerid(string $serverid): self
return $this;
}

public function getUserid(): ?Users
public function getUserid(): ?User
{
return $this->userid;
}

public function setUserid(?Users $userid): self
public function setUserid(?User $userid): self
{
$this->userid = $userid;

Expand Down
2 changes: 1 addition & 1 deletion application/src/Entity/Medias.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use App\Repository\MediasRepository;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Room;
use App\Entity\Users;
use App\Entity\User;

/**
* @ORM\Entity(repositoryClass=MediasRepository::class)
Expand Down
6 changes: 3 additions & 3 deletions application/src/Entity/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Password
private $serverid;

/**
* @ORM\ManyToOne(targetEntity=Users::class, inversedBy="passwords")
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="passwords")
* @ORM\JoinColumn(nullable=false)
*/
private $userid;
Expand All @@ -50,12 +50,12 @@ public function setServerid(string $serverid): self
return $this;
}

public function getUserid(): ?Users
public function getUserid(): ?User
{
return $this->userid;
}

public function setUserid(?Users $userid): self
public function setUserid(?User $userid): self
{
$this->userid = $userid;

Expand Down
2 changes: 1 addition & 1 deletion application/src/Entity/Room.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function setCreator(?string $creator): self
return $this;
}

public function addMember(Users $user): self
public function addMember(User $user): self
{
$roomMember = new RoomMember();
$roomMember->setRoom($this);
Expand Down
8 changes: 4 additions & 4 deletions application/src/Entity/RoomMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use App\Repository\RoomMemberRepository;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Room;
use App\Entity\Users;
use App\Entity\User;

/**
* @ORM\Entity(repositoryClass=RoomMemberRepository::class)
Expand All @@ -31,7 +31,7 @@ class RoomMember
private $room;

/**
* @ORM\ManyToOne(targetEntity=Users::class, inversedBy="rooms")
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="rooms")
* @ORM\JoinColumn(nullable=false)
*/
private $user;
Expand Down Expand Up @@ -90,12 +90,12 @@ public function getRoomid(): ?string
return $this->getRoom()->getRoomid();
}

public function getUser(): Users
public function getUser(): User
{
return $this->user;
}

public function setUser(Users $user): self
public function setUser(User $user): self
{
$this->user = $user;

Expand Down
6 changes: 3 additions & 3 deletions application/src/Entity/Threepids.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Threepids
private $address;

/**
* @ORM\ManyToOne(targetEntity=Users::class, inversedBy="threepids")
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="threepids")
* @ORM\JoinColumn(nullable=false)
*/
private $userid;
Expand Down Expand Up @@ -67,12 +67,12 @@ public function setAddress(string $address): self
return $this;
}

public function getUserid(): ?Users
public function getUserid(): ?User
{
return $this->userid;
}

public function setUserid(?Users $userid): self
public function setUserid(?User $userid): self
{
$this->userid = $userid;

Expand Down
6 changes: 3 additions & 3 deletions application/src/Entity/Tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Tokens
private $id;

/**
* @ORM\ManyToOne(targetEntity=Users::class, inversedBy="tokens")
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="tokens")
* @ORM\JoinColumn(nullable=false)
*/
private $userid;
Expand Down Expand Up @@ -48,12 +48,12 @@ public function getId(): ?int
return $this->id;
}

public function getUserid(): ?Users
public function getUserid(): ?User
{
return $this->userid;
}

public function setUserid(?Users $userid): self
public function setUserid(?User $userid): self
{
$this->userid = $userid;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace App\Entity;

use App\Repository\UsersRepository;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity(repositoryClass=UsersRepository::class)
* @ORM\Entity(repositoryClass=UserRepository::class)
*/
class Users
class User
{
/**
* @ORM\Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@

namespace App\Repository;

use App\Entity\Users;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMException;
use Doctrine\Persistence\ManagerRegistry;

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

/**
* @throws ORMException
* @throws OptimisticLockException
*/
public function add(Users $entity, bool $flush = true): void
public function add(User $entity, bool $flush = true): void
{
$this->_em->persist($entity);
if ($flush) {
Expand All @@ -39,7 +39,7 @@ public function add(Users $entity, bool $flush = true): void
* @throws ORMException
* @throws OptimisticLockException
*/
public function remove(Users $entity, bool $flush = true): void
public function remove(User $entity, bool $flush = true): void
{
$this->_em->remove($entity);
if ($flush) {
Expand Down
2 changes: 1 addition & 1 deletion application/src/Traits/MatrixSynapseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use App\Entity\Room;
use App\Entity\RoomMember;
use App\Entity\Tokens;
use App\Entity\Users;
use App\Entity\User;

trait MatrixSynapseTrait {
private function getUnknownRoomResponse(): JsonResponse
Expand Down

0 comments on commit c811891

Please sign in to comment.