Skip to content

Commit

Permalink
php-cs-fixer run with @symfony rules
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Aug 27, 2021
1 parent fea452b commit 7a9e757
Show file tree
Hide file tree
Showing 76 changed files with 137 additions and 98 deletions.
3 changes: 2 additions & 1 deletion lib/Admin/Controller/ApiClient/Audit.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(private ApiClientService $service, private UserServi
* @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
public function __invoke(string $userId, string $id): Response
{
$user = $this->userService->get($userId);
if (!$user instanceof UserInterface) {
Expand All @@ -60,6 +60,7 @@ public function __invoke(string $userId, string $id) : Response
$audit = $this->audit->getAudits($entity, $id)->toArray();
$class = new ReflectionClass(ApiClient::class);
$context = StringUtil::lowercase($class->getShortName());

return $this->render(sprintf('%s/audit.html.twig', $context), [
'page_title' => 'sas.page.audit.view',
'context' => $context,
Expand Down
3 changes: 2 additions & 1 deletion lib/Admin/Controller/ApiClient/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(private ApiClientService $service, private UserServi
}

#[Route(path: 'users/{userId}/api-clients/{id}/delete', name: Delete::class, methods: ['GET'])]
public function __invoke(string $userId, string $id) : Response
public function __invoke(string $userId, string $id): Response
{
$user = $this->userService->get($userId);
if (!$user instanceof UserInterface) {
Expand All @@ -43,6 +43,7 @@ public function __invoke(string $userId, string $id) : Response
}
$this->service->remove($client);
$this->addFlash('info', 'sas.page.api_client.deleted');

return new RedirectResponse($this->generateUrl(Main::class));
}
}
3 changes: 2 additions & 1 deletion lib/Admin/Controller/ApiClient/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(private ApiClientService $service, private UserServi
}

#[Route(path: '/users/{userId}/api-clients/download', name: Download::class, methods: ['GET'])]
public function __invoke(string $userId) : Response
public function __invoke(string $userId): Response
{
$user = $this->userService->get($userId);
if (!$user instanceof UserInterface) {
Expand All @@ -46,6 +46,7 @@ public function __invoke(string $userId) : Response
$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;
}
}
3 changes: 2 additions & 1 deletion lib/Admin/Controller/ApiClient/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(
}

#[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
public function __invoke(Request $request, string $userId): Response
{
$user = $this->userService->get($userId);
if (!$user instanceof UserInterface) {
Expand All @@ -57,6 +57,7 @@ public function __invoke(Request $request, string $userId) : Response
}
$class = new ReflectionClass(ApiClient::class);
$context = StringUtil::lowercase($class->getShortName());

return $this->render(sprintf('%s/all.html.twig', $context), [
'page_title' => 'sas.page.api_client.list',
'context' => $context,
Expand Down
3 changes: 2 additions & 1 deletion lib/Admin/Controller/ApiClient/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(private ApiClientRequestService $service, private Us
}

#[Route(path: '/users/{userId}/api-clients/{id}/logs', name: Report::class, methods: ['GET'])]
public function __invoke(Request $request, string $userId, string $id) : Response
public function __invoke(Request $request, string $userId, string $id): Response
{
$user = $this->userService->get($userId);
if (!$user instanceof UserInterface) {
Expand All @@ -41,6 +41,7 @@ public function __invoke(Request $request, string $userId, string $id) : Respons
return new RedirectResponse($this->generateUrl(GetAllUser::class));
}
$class = new ReflectionClass(ApiClientRequest::class);

return $this->render('apiclient/report.html.twig', [
'page_title' => 'sas.page.api_client.report',
'id' => $id,
Expand Down
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Cron/Audit.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(private CronService $service, private AuditService $
* @throws InvalidArgumentException
*/
#[Route(path: '/crons/{id}/audit', name: Audit::class, methods: ['GET'], priority: -255)]
public function __invoke(string $id) : Response
public function __invoke(string $id): Response
{
if (!$entity = $this->service->get($id)) {
$this->addFlash('error', 'sas.page.cron.not_found');
Expand All @@ -44,6 +44,7 @@ public function __invoke(string $id) : Response

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

return $this->renderAudit($this->audit->getAudits($entity, $id), new ReflectionClass(Cron::class));
}
}
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Cron/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(private CronService $service)
}

#[Route(path: '/crons/{id}/delete', name: Delete::class, methods: ['GET'])]
public function __invoke(string $id) : Response
public function __invoke(string $id): Response
{
$cron = $this->service->get($id);
if (!$cron instanceof CronInterface) {
Expand All @@ -34,6 +34,7 @@ public function __invoke(string $id) : Response
}
$this->service->remove($cron);
$this->addFlash('info', 'sas.page.cron.deleted');

return new RedirectResponse($this->generateUrl(Main::class));
}
}
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Cron/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(private CronService $service, private SerializerInte
}

#[Route(path: '/crons/download', name: Download::class, methods: ['GET'])]
public function __invoke() : Response
public function __invoke(): Response
{
$records = $this->service->total();
if (10000 < $records) {
Expand All @@ -37,6 +37,7 @@ public function __invoke() : Response
$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;
}
}
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Cron/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(private CronService $service, private AuditService $
}

#[Route(path: '/crons/{id}', name: Get::class, methods: ['GET'])]
public function __invoke(string $id) : Response
public function __invoke(string $id): Response
{
$cron = $this->service->get($id);
if (!$cron instanceof CronInterface) {
Expand All @@ -42,6 +42,7 @@ public function __invoke(string $id) : Response
if ($this->reader->getProvider()->isAuditable(Cron::class)) {
$audit = $this->audit->getAudits($cron, $id, 1);
}

return $this->renderDetail($audit, new ReflectionClass(Cron::class));
}
}
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Cron/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(private CronService $service, Paginator $paginator)
}

#[Route(path: '/crons', name: Main::class, methods: ['GET', 'POST'])]
public function __invoke(Request $request) : Response
public function __invoke(Request $request): Response
{
$cron = new Cron();
if ($request->isMethod(Request::METHOD_POST)) {
Expand All @@ -52,6 +52,7 @@ public function __invoke(Request $request) : Response
$this->addFlash('info', 'sas.page.cron.saved');
}
}

return $this->renderList($form, $request, new ReflectionClass(Cron::class));
}
}
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Cron/Put.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ public function __construct(private CronService $service)
}

#[Route(path: '/crons/{id}/edit', name: Put::class, methods: ['GET'], priority: 1)]
public function __invoke(Request $request, string $id) : Response
public function __invoke(Request $request, string $id): Response
{
$cron = $this->service->get($id);
if (!$cron instanceof CronInterface) {
$this->addFlash('error', 'sas.page.cron.not_found');
}
$this->addFlash('id', $cron->getId());

return new RedirectResponse($this->generateUrl(Main::class, $request->query->all()));
}
}
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Cron/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ public function __construct(private CronReportService $service, private Paginato
}

#[Route(path: '/crons/{id}/logs', name: Report::class, methods: ['GET'], priority: -27)]
public function __invoke(Request $request, string $id) : Response
public function __invoke(Request $request, string $id): Response
{
$class = new ReflectionClass(CronReport::class);
$request->query->set($this->settingService->getPerPageField(), 10);

return $this->render('cron/report.html.twig', [
'page_title' => 'sas.page.cron_report.list',
'id' => $id,
Expand Down
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Cron/Run.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(private CronService $service, private KernelInterfac
}

#[Route(path: '/crons/{id}/run', name: Run::class, methods: ['GET'], priority: -17)]
public function __invoke(string $id) : Response
public function __invoke(string $id): Response
{
$cron = $this->service->get($id);
if (!$cron instanceof CronInterface) {
Expand All @@ -49,6 +49,7 @@ public function __invoke(string $id) : Response
} else {
$this->addFlash('error', 'sas.page.cron.run_failed');
}

return new RedirectResponse($this->generateUrl(Get::class, ['id' => $id]));
}
}
2 changes: 1 addition & 1 deletion lib/Admin/Controller/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
final class DashboardController extends Base
{
#[Route(path: '/', name: AdminContext::ADMIN_ROUTE, methods: ['GET'])]
public function __invoke() : Response
public function __invoke(): Response
{
return $this->render('dashboard/layout.html.twig', ['page_title' => 'sas.page.dashboard']);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Group/Audit.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(private GroupService $service, private AuditService
* @throws InvalidArgumentException
*/
#[Route(path: '/groups/{id}/audit', name: Audit::class, methods: ['GET'], priority: -255)]
public function __invoke(string $id) : Response
public function __invoke(string $id): Response
{
if (!$entity = $this->service->get($id)) {
$this->addFlash('error', 'sas.page.group.not_found');
Expand All @@ -44,6 +44,7 @@ public function __invoke(string $id) : Response

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

return $this->renderAudit($this->audit->getAudits($entity, $id), new ReflectionClass(Group::class));
}
}
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Group/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(private GroupService $service)
}

#[Route(path: '/groups/{id}/delete', name: Delete::class, methods: ['GET'])]
public function __invoke(string $id) : Response
public function __invoke(string $id): Response
{
$group = $this->service->get($id);
if (!$group instanceof GroupInterface) {
Expand All @@ -34,6 +34,7 @@ public function __invoke(string $id) : Response
}
$this->service->remove($group);
$this->addFlash('info', 'sas.page.group.deleted');

return new RedirectResponse($this->generateUrl(Main::class));
}
}
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Group/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(private GroupService $service, private SerializerInt
}

#[Route(path: '/groups/download', name: Download::class, methods: ['GET'])]
public function __invoke() : Response
public function __invoke(): Response
{
$records = $this->service->total();
if (10000 < $records) {
Expand All @@ -37,6 +37,7 @@ public function __invoke() : Response
$response->headers->set('Content-type', 'text/csv');
$response->headers->set('Content-Disposition', sprintf('attachment; filename="%s_%s.csv"', 'groups', date('YmdHis')));
$response->setContent($this->serializer->serialize($this->service->all(), 'csv', ['groups' => 'read']));

return $response;
}
}
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Group/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(private GroupService $service, private AuditService
}

#[Route(path: '/groups/{id}', name: Get::class, methods: ['GET'])]
public function __invoke(string $id) : Response
public function __invoke(string $id): Response
{
$group = $this->service->get($id);
if (!$group instanceof GroupInterface) {
Expand All @@ -42,6 +42,7 @@ public function __invoke(string $id) : Response
if ($this->reader->getProvider()->isAuditable(Group::class)) {
$audit = $this->audit->getAudits($group, $id, 1);
}

return $this->renderDetail($audit, new ReflectionClass(Group::class));
}
}
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Group/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(private GroupService $service, Paginator $paginator)
}

#[Route(path: '/groups', name: Main::class, methods: ['GET', 'POST'])]
public function __invoke(Request $request) : Response
public function __invoke(Request $request): Response
{
$group = new Group();
if ($request->isMethod(Request::METHOD_POST)) {
Expand All @@ -52,6 +52,7 @@ public function __invoke(Request $request) : Response
$this->addFlash('info', 'sas.page.group.saved');
}
}

return $this->renderList($form, $request, new ReflectionClass(Group::class));
}
}
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Group/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(
}

#[Route(path: '/groups/{id}/permissions', name: Permission::class, methods: ['GET'])]
public function __invoke(Request $request, string $id) : Response
public function __invoke(Request $request, string $id): Response
{
$group = $this->groupService->get($id);
if (!$group instanceof GroupInterface) {
Expand All @@ -46,6 +46,7 @@ public function __invoke(Request $request, string $id) : Response
}
$request->query->set($this->settingService->getPerPageField(), 10);
$class = new ReflectionClass(Entity::class);

return $this->render('group/permission.html.twig', [
'page_title' => 'sas.page.permission.list',
'group' => $group,
Expand Down
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Group/PermissionPut.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(private GroupService $groupService, private Permissi
}

#[Route(path: '/groups/{groupId}/permissions/{id}', name: PermissionPut::class, methods: ['POST'])]
public function __invoke(Request $request, string $groupId, string $id) : Response
public function __invoke(Request $request, string $groupId, string $id): Response
{
$group = $this->groupService->get($groupId);
if (!$group) {
Expand Down Expand Up @@ -63,6 +63,7 @@ public function __invoke(Request $request, string $groupId, string $id) : Respon
}
$this->service->save($permission);
$this->addFlash('info', 'sas.page.permission.saved');

return new RedirectResponse($this->generateUrl(GetPermission::class, ['id' => $groupId]));
}
}
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Group/Put.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(private GroupService $service)
}

#[Route(path: '/groups/{id}/edit', name: Put::class, methods: ['GET'], priority: 1)]
public function __invoke(Request $request, string $id) : Response
public function __invoke(Request $request, string $id): Response
{
$group = $this->service->get($id);
if (!$group instanceof GroupInterface) {
Expand All @@ -34,6 +34,7 @@ public function __invoke(Request $request, string $id) : Response
return new RedirectResponse($this->generateUrl(Main::class, $request->query->all()));
}
$this->addFlash('id', $group->getId());

return new RedirectResponse($this->generateUrl(Main::class, $request->query->all()));
}
}
2 changes: 1 addition & 1 deletion lib/Admin/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(private AuthenticationUtils $authenticationUtils)
}

#[Route(path: '/login', name: AdminContext::LOGIN_ROUTE, methods: ['GET', 'POST'])]
public function __invoke() : Response
public function __invoke(): Response
{
return $this->render('layout/login.html.twig', [
'error' => $this->authenticationUtils->getLastAuthenticationError(),
Expand Down
3 changes: 2 additions & 1 deletion lib/Admin/Controller/Me/CreateApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(private UserProviderFactory $userProviderFactory, pr
}

#[Route(path: '/me/api-clients', name: CreateApiClient::class, methods: ['POST'])]
public function __invoke(Request $request) : Response
public function __invoke(Request $request): Response
{
$user = $this->getUser();
if (!$user instanceof User) {
Expand All @@ -51,6 +51,7 @@ public function __invoke(Request $request) : Response
$client->setUser($user);
$this->addFlash('info', 'sas.page.api_client.saved');
$this->service->save($client);

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

0 comments on commit 7a9e757

Please sign in to comment.