-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from itk-dev/feature/projects
feature/projects
- Loading branch information
Showing
43 changed files
with
1,529 additions
and
517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20240118132209 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE data_provider ADD enabled TINYINT(1) DEFAULT NULL'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE data_provider DROP enabled'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace App\Command; | ||
|
||
use App\Entity\DataProvider; | ||
use App\Repository\DataProviderRepository; | ||
use Symfony\Component\Console\Attribute\AsCommand; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
|
||
#[AsCommand( | ||
name: 'app:data-provider:list', | ||
description: 'List data providers', | ||
)] | ||
class DataProviderListCommand extends Command | ||
{ | ||
public function __construct( | ||
private readonly DataProviderRepository $dataProviderRepository | ||
) { | ||
parent::__construct($this->getName()); | ||
} | ||
|
||
protected function configure(): void | ||
{ | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$io = new SymfonyStyle($input, $output); | ||
|
||
$dataProviders = $this->dataProviderRepository->findAll(); | ||
|
||
/* @var DataProvider $provider */ | ||
$io->table(['id', 'name', 'enabled', 'class', 'url', 'sync clients', 'sync accounts'], array_map(fn ($provider) => [ | ||
$provider->getId(), | ||
$provider->getName(), | ||
$provider->isEnabled() ? 'true' : 'false', | ||
$provider->getClass(), | ||
$provider->getUrl(), | ||
$provider->isEnableClientSync(), | ||
$provider->isEnableAccountSync(), | ||
], $dataProviders)); | ||
|
||
return Command::SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace App\Command; | ||
|
||
use App\Repository\DataProviderRepository; | ||
use Symfony\Component\Console\Attribute\AsCommand; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
|
||
#[AsCommand( | ||
name: 'app:data-provider:set-enable', | ||
description: 'Enable/disable a data provider', | ||
)] | ||
class DataProviderSetEnableCommand extends Command | ||
{ | ||
public function __construct( | ||
private readonly DataProviderRepository $dataProviderRepository | ||
) { | ||
parent::__construct($this->getName()); | ||
} | ||
|
||
protected function configure(): void | ||
{ | ||
$this->addArgument('id', InputArgument::REQUIRED, 'data provider id'); | ||
$this->addArgument('enable', InputArgument::REQUIRED, 'data provider enable'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$io = new SymfonyStyle($input, $output); | ||
|
||
$id = (int) $input->getArgument('id'); | ||
$enable = $input->getArgument('enable'); | ||
|
||
$dataProvider = $this->dataProviderRepository->find($id); | ||
|
||
if (null != $dataProvider) { | ||
$dataProvider->setEnabled('true' == $enable); | ||
$dataProvider->setUpdatedBy('CLI'); | ||
$this->dataProviderRepository->save($dataProvider, true); | ||
|
||
$io->info('Data provider with id: '.$dataProvider->getId().' '.($dataProvider->isEnabled() ? 'enabled' : 'disabled')); | ||
|
||
return Command::SUCCESS; | ||
} else { | ||
$io->error('Data provider not found'); | ||
|
||
return Command::FAILURE; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
namespace App\Controller; | ||
|
||
use App\Entity\Account; | ||
use App\Form\AccountType; | ||
use App\Repository\AccountRepository; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
#[Route('/admin/account')] | ||
class AccountController extends AbstractController | ||
{ | ||
#[Route('/', name: 'app_account_index', methods: ['GET'])] | ||
public function index(AccountRepository $accountRepository): Response | ||
{ | ||
return $this->render('account/index.html.twig', [ | ||
'accounts' => $accountRepository->findAll(), | ||
]); | ||
} | ||
|
||
#[Route('/new', name: 'app_account_new', methods: ['GET', 'POST'])] | ||
public function new(Request $request, EntityManagerInterface $entityManager): Response | ||
{ | ||
$account = new Account(); | ||
$form = $this->createForm(AccountType::class, $account); | ||
$form->handleRequest($request); | ||
|
||
if ($form->isSubmitted() && $form->isValid()) { | ||
$entityManager->persist($account); | ||
$entityManager->flush(); | ||
|
||
return $this->redirectToRoute('app_account_index', [], Response::HTTP_SEE_OTHER); | ||
} | ||
|
||
return $this->render('account/new.html.twig', [ | ||
'account' => $account, | ||
'form' => $form, | ||
]); | ||
} | ||
|
||
#[Route('/{id}', name: 'app_account_show', methods: ['GET'])] | ||
public function show(Account $account): Response | ||
{ | ||
return $this->render('account/show.html.twig', [ | ||
'account' => $account, | ||
]); | ||
} | ||
|
||
#[Route('/{id}/edit', name: 'app_account_edit', methods: ['GET', 'POST'])] | ||
public function edit(Request $request, Account $account, EntityManagerInterface $entityManager): Response | ||
{ | ||
$form = $this->createForm(AccountType::class, $account); | ||
$form->handleRequest($request); | ||
|
||
if ($form->isSubmitted() && $form->isValid()) { | ||
$entityManager->flush(); | ||
|
||
return $this->redirectToRoute('app_account_index', [], Response::HTTP_SEE_OTHER); | ||
} | ||
|
||
return $this->render('account/edit.html.twig', [ | ||
'account' => $account, | ||
'form' => $form, | ||
]); | ||
} | ||
|
||
#[Route('/{id}', name: 'app_account_delete', methods: ['POST'])] | ||
public function delete(Request $request, Account $account, EntityManagerInterface $entityManager): Response | ||
{ | ||
$token = $request->request->get('_token'); | ||
if (is_string($token) && $this->isCsrfTokenValid('delete'.$account->getId(), $token)) { | ||
$entityManager->remove($account); | ||
$entityManager->flush(); | ||
} | ||
|
||
return $this->redirectToRoute('app_account_index', [], Response::HTTP_SEE_OTHER); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
namespace App\Controller; | ||
|
||
use App\Entity\Client; | ||
use App\Form\ClientType; | ||
use App\Repository\ClientRepository; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
#[Route('/admin/client')] | ||
class ClientController extends AbstractController | ||
{ | ||
#[Route('/', name: 'app_client_index', methods: ['GET'])] | ||
public function index(ClientRepository $clientRepository): Response | ||
{ | ||
return $this->render('client/index.html.twig', [ | ||
'clients' => $clientRepository->findAll(), | ||
]); | ||
} | ||
|
||
#[Route('/new', name: 'app_client_new', methods: ['GET', 'POST'])] | ||
public function new(Request $request, EntityManagerInterface $entityManager): Response | ||
{ | ||
$client = new Client(); | ||
$form = $this->createForm(ClientType::class, $client); | ||
$form->handleRequest($request); | ||
|
||
if ($form->isSubmitted() && $form->isValid()) { | ||
$entityManager->persist($client); | ||
$entityManager->flush(); | ||
|
||
return $this->redirectToRoute('app_client_index', [], Response::HTTP_SEE_OTHER); | ||
} | ||
|
||
return $this->render('client/new.html.twig', [ | ||
'client' => $client, | ||
'form' => $form, | ||
]); | ||
} | ||
|
||
#[Route('/{id}', name: 'app_client_show', methods: ['GET'])] | ||
public function show(Client $client): Response | ||
{ | ||
return $this->render('client/show.html.twig', [ | ||
'client' => $client, | ||
]); | ||
} | ||
|
||
#[Route('/{id}/edit', name: 'app_client_edit', methods: ['GET', 'POST'])] | ||
public function edit(Request $request, Client $client, EntityManagerInterface $entityManager): Response | ||
{ | ||
$form = $this->createForm(ClientType::class, $client); | ||
$form->handleRequest($request); | ||
|
||
if ($form->isSubmitted() && $form->isValid()) { | ||
$entityManager->flush(); | ||
|
||
return $this->redirectToRoute('app_client_index', [], Response::HTTP_SEE_OTHER); | ||
} | ||
|
||
return $this->render('client/edit.html.twig', [ | ||
'client' => $client, | ||
'form' => $form, | ||
]); | ||
} | ||
|
||
#[Route('/{id}', name: 'app_client_delete', methods: ['POST'])] | ||
public function delete(Request $request, Client $client, EntityManagerInterface $entityManager): Response | ||
{ | ||
$token = $request->request->get('_token'); | ||
if (is_string($token) && $this->isCsrfTokenValid('delete'.$client->getId(), $token)) { | ||
$entityManager->remove($client); | ||
$entityManager->flush(); | ||
} | ||
|
||
return $this->redirectToRoute('app_client_index', [], Response::HTTP_SEE_OTHER); | ||
} | ||
} |
Oops, something went wrong.