Skip to content

Commit

Permalink
Merge pull request #104 from samsonasik/apply-doctrine-orm-29-setlist
Browse files Browse the repository at this point in the history
[Rector] Apply Doctrine ORM 2.9 SetList
  • Loading branch information
ad3n authored Aug 27, 2021
2 parents 12bbf21 + 7a9e757 commit 0f9c656
Show file tree
Hide file tree
Showing 83 changed files with 375 additions and 576 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"nunomaduro/phpinsights": "^2.0",
"phpstan/phpstan": "^0.12.94",
"phpunit/phpunit": ">=9.5",
"rector/rector": "^0.11.49",
"rector/rector": "^0.11.51",
"symfony/browser-kit": ">=5.3",
"symfony/css-selector": ">=5.3",
"symfony/debug-bundle": ">=5.3",
Expand Down
50 changes: 25 additions & 25 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions lib/Admin/Controller/ApiClient/Audit.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ public function __construct(private ApiClientService $service, private UserServi
}

/**
* @Route(path="users/{userId}/api-clients/{id}/audit", name=Audit::class, methods={"GET"}, priority=-255)
*
* @throws InvalidArgumentException
*/
#[Route(path: 'users/{userId}/api-clients/{id}/audit', name: Audit::class, methods: ['GET'], priority: -255)]
public function __invoke(string $userId, string $id): Response
{
$user = $this->userService->get($userId);
Expand All @@ -47,20 +46,17 @@ public function __invoke(string $userId, string $id): Response

return new RedirectResponse($this->generateUrl(GetAllUser::class));
}

$entity = $this->service->get($id);
if (!$entity instanceof ApiClientInterface) {
$this->addFlash('error', 'sas.page.api_client.not_found');

return new RedirectResponse($this->generateUrl(Main::class));
}

if (!$this->reader->getProvider()->isAuditable(Group::class)) {
$this->addFlash('error', 'sas.page.audit.not_found');

return new RedirectResponse($this->generateUrl(Main::class));
}

$audit = $this->audit->getAudits($entity, $id)->toArray();
$class = new ReflectionClass(ApiClient::class);
$context = StringUtil::lowercase($class->getShortName());
Expand Down
7 changes: 1 addition & 6 deletions lib/Admin/Controller/ApiClient/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public function __construct(private ApiClientService $service, private UserServi
{
}

/**
* @Route(path="users/{userId}/api-clients/{id}/delete", name=Delete::class, methods={"GET"})
*/
#[Route(path: 'users/{userId}/api-clients/{id}/delete', name: Delete::class, methods: ['GET'])]
public function __invoke(string $userId, string $id): Response
{
$user = $this->userService->get($userId);
Expand All @@ -37,16 +35,13 @@ public function __invoke(string $userId, string $id): Response

return new RedirectResponse($this->generateUrl(GetAllUser::class));
}

$client = $this->service->get($id);
if (!$client instanceof ApiClientInterface) {
$this->addFlash('error', 'sas.page.api_client.not_found');

return new RedirectResponse($this->generateUrl(Main::class));
}

$this->service->remove($client);

$this->addFlash('info', 'sas.page.api_client.deleted');

return new RedirectResponse($this->generateUrl(Main::class));
Expand Down
7 changes: 1 addition & 6 deletions lib/Admin/Controller/ApiClient/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public function __construct(private ApiClientService $service, private UserServi
{
}

/**
* @Route(path="/users/{userId}/api-clients/download", name=Download::class, methods={"GET"})
*/
#[Route(path: '/users/{userId}/api-clients/download', name: Download::class, methods: ['GET'])]
public function __invoke(string $userId): Response
{
$user = $this->userService->get($userId);
Expand All @@ -37,19 +35,16 @@ public function __invoke(string $userId): Response

return new RedirectResponse($this->generateUrl(GetAllUser::class));
}

$records = $this->service->total();
if (10000 < $records) {
$this->addFlash('error', 'sas.page.error.too_many_records');

return new RedirectResponse($this->generateUrl(Main::class));
}

$response = new Response();
$response->headers->set('Cache-Control', 'private');
$response->headers->set('Content-type', 'text/csv');
$response->headers->set('Content-Disposition', sprintf('attachment; filename="%s_%s.csv"', 'api-clients', date('YmdHis')));

$response->setContent($this->serializer->serialize($this->service->all(), 'csv', ['groups' => 'read']));

return $response;
Expand Down
6 changes: 1 addition & 5 deletions lib/Admin/Controller/ApiClient/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ public function __construct(
) {
}

/**
* @Route(path="/users/{userId}/api-clients", name=Main::class, methods={"GET", "POST"}, defaults={"userId": "2e0cac45-822f-4b97-95f1-9516ad824ec1"})
*/
#[Route(path: '/users/{userId}/api-clients', name: Main::class, methods: ['GET', 'POST'], defaults: ['userId' => '2e0cac45-822f-4b97-95f1-9516ad824ec1'])]
public function __invoke(Request $request, string $userId): Response
{
$user = $this->userService->get($userId);
Expand All @@ -46,7 +44,6 @@ public function __invoke(Request $request, string $userId): Response

return new RedirectResponse($this->generateUrl(GetAllUser::class));
}

$client = new ApiClient();
$client->setUser($user);
$form = $this->createForm(ApiClientType::class, $client);
Expand All @@ -58,7 +55,6 @@ public function __invoke(Request $request, string $userId): Response
$this->addFlash('info', 'sas.page.api_client.saved');
}
}

$class = new ReflectionClass(ApiClient::class);
$context = StringUtil::lowercase($class->getShortName());

Expand Down
5 changes: 1 addition & 4 deletions lib/Admin/Controller/ApiClient/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public function __construct(private ApiClientRequestService $service, private Us
{
}

/**
* @Route(path="/users/{userId}/api-clients/{id}/logs", name=Report::class, methods={"GET"})
*/
#[Route(path: '/users/{userId}/api-clients/{id}/logs', name: Report::class, methods: ['GET'])]
public function __invoke(Request $request, string $userId, string $id): Response
{
$user = $this->userService->get($userId);
Expand All @@ -42,7 +40,6 @@ public function __invoke(Request $request, string $userId, string $id): Response

return new RedirectResponse($this->generateUrl(GetAllUser::class));
}

$class = new ReflectionClass(ApiClientRequest::class);

return $this->render('apiclient/report.html.twig', [
Expand Down
4 changes: 1 addition & 3 deletions lib/Admin/Controller/Cron/Audit.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,16 @@ public function __construct(private CronService $service, private AuditService $
}

/**
* @Route(path="/crons/{id}/audit", name=Audit::class, methods={"GET"}, priority=-255)
*
* @throws InvalidArgumentException
*/
#[Route(path: '/crons/{id}/audit', name: Audit::class, methods: ['GET'], priority: -255)]
public function __invoke(string $id): Response
{
if (!$entity = $this->service->get($id)) {
$this->addFlash('error', 'sas.page.cron.not_found');

return new RedirectResponse($this->generateUrl(Main::class));
}

if (!$this->reader->getProvider()->isAuditable(Cron::class)) {
$this->addFlash('error', 'sas.page.audit.not_found');

Expand Down
6 changes: 1 addition & 5 deletions lib/Admin/Controller/Cron/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ public function __construct(private CronService $service)
{
}

/**
* @Route(path="/crons/{id}/delete", name=Delete::class, methods={"GET"})
*/
#[Route(path: '/crons/{id}/delete', name: Delete::class, methods: ['GET'])]
public function __invoke(string $id): Response
{
$cron = $this->service->get($id);
Expand All @@ -34,9 +32,7 @@ public function __invoke(string $id): Response

return new RedirectResponse($this->generateUrl(Main::class));
}

$this->service->remove($cron);

$this->addFlash('info', 'sas.page.cron.deleted');

return new RedirectResponse($this->generateUrl(Main::class));
Expand Down
6 changes: 1 addition & 5 deletions lib/Admin/Controller/Cron/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ public function __construct(private CronService $service, private SerializerInte
{
}

/**
* @Route(path="/crons/download", name=Download::class, methods={"GET"})
*/
#[Route(path: '/crons/download', name: Download::class, methods: ['GET'])]
public function __invoke(): Response
{
$records = $this->service->total();
Expand All @@ -34,12 +32,10 @@ public function __invoke(): Response

return new RedirectResponse($this->generateUrl(Main::class));
}

$response = new Response();
$response->headers->set('Cache-Control', 'private');
$response->headers->set('Content-type', 'text/csv');
$response->headers->set('Content-Disposition', sprintf('attachment; filename="%s_%s.csv"', 'crons', date('YmdHis')));

$response->setContent($this->serializer->serialize($this->service->all(), 'csv', ['groups' => 'read']));

return $response;
Expand Down
5 changes: 1 addition & 4 deletions lib/Admin/Controller/Cron/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ public function __construct(private CronService $service, private AuditService $
parent::__construct($this->service);
}

/**
* @Route(path="/crons/{id}", name=Get::class, methods={"GET"})
*/
#[Route(path: '/crons/{id}', name: Get::class, methods: ['GET'])]
public function __invoke(string $id): Response
{
$cron = $this->service->get($id);
Expand All @@ -40,7 +38,6 @@ public function __invoke(string $id): Response

return new RedirectResponse($this->generateUrl(Main::class));
}

$audit = new Record($cron);
if ($this->reader->getProvider()->isAuditable(Cron::class)) {
$audit = $this->audit->getAudits($cron, $id, 1);
Expand Down
5 changes: 1 addition & 4 deletions lib/Admin/Controller/Cron/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ public function __construct(private CronService $service, Paginator $paginator)
parent::__construct($this->service, $paginator);
}

/**
* @Route(path="/crons", name=Main::class, methods={"GET", "POST"})
*/
#[Route(path: '/crons', name: Main::class, methods: ['GET', 'POST'])]
public function __invoke(Request $request): Response
{
$cron = new Cron();
Expand All @@ -46,7 +44,6 @@ public function __invoke(Request $request): Response
}
}
}

$form = $this->createForm(CronType::class, $cron);
if ($request->isMethod(Request::METHOD_POST)) {
$form->handleRequest($request);
Expand Down
Loading

0 comments on commit 0f9c656

Please sign in to comment.