diff --git a/migrations/Version20250626124556.php b/migrations/Version20250626124556.php new file mode 100644 index 0000000..cb7a926 --- /dev/null +++ b/migrations/Version20250626124556.php @@ -0,0 +1,47 @@ +addSql(<<<'SQL' + CREATE TABLE user_tab (id SERIAL NOT NULL, users_id INT NOT NULL, tab_open INT NOT NULL, PRIMARY KEY(id)) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_98F5228767B3B43D ON user_tab (users_id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE user_tab ADD CONSTRAINT FK_98F5228767B3B43D FOREIGN KEY (users_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE + SQL); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql(<<<'SQL' + CREATE SCHEMA public + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE user_tab DROP CONSTRAINT FK_98F5228767B3B43D + SQL); + $this->addSql(<<<'SQL' + DROP TABLE user_tab + SQL); + } +} diff --git a/migrations/Version20250626134726.php b/migrations/Version20250626134726.php new file mode 100644 index 0000000..3c21c27 --- /dev/null +++ b/migrations/Version20250626134726.php @@ -0,0 +1,38 @@ +addSql(<<<'SQL' + ALTER TABLE user_tab RENAME COLUMN tab_open TO ip_address + SQL); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql(<<<'SQL' + CREATE SCHEMA public + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE user_tab RENAME COLUMN ip_address TO tab_open + SQL); + } +} diff --git a/migrations/Version20250626135125.php b/migrations/Version20250626135125.php new file mode 100644 index 0000000..6db16e0 --- /dev/null +++ b/migrations/Version20250626135125.php @@ -0,0 +1,38 @@ +addSql(<<<'SQL' + ALTER TABLE user_tab ALTER ip_address TYPE VARCHAR(255) + SQL); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql(<<<'SQL' + CREATE SCHEMA public + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE user_tab ALTER ip_address TYPE INT + SQL); + } +} diff --git a/migrations/Version20250626145913.php b/migrations/Version20250626145913.php new file mode 100644 index 0000000..78c421e --- /dev/null +++ b/migrations/Version20250626145913.php @@ -0,0 +1,38 @@ +addSql(<<<'SQL' + ALTER TABLE user_tab ADD tab_id VARCHAR(255) DEFAULT NULL + SQL); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql(<<<'SQL' + CREATE SCHEMA public + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE user_tab DROP tab_id + SQL); + } +} diff --git a/migrations/Version20250627073903.php b/migrations/Version20250627073903.php new file mode 100644 index 0000000..8538b17 --- /dev/null +++ b/migrations/Version20250627073903.php @@ -0,0 +1,47 @@ +addSql(<<<'SQL' + CREATE TABLE subscriptions (id SERIAL NOT NULL, users_id INT NOT NULL, PRIMARY KEY(id)) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_4778A0167B3B43D ON subscriptions (users_id) + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE subscriptions ADD CONSTRAINT FK_4778A0167B3B43D FOREIGN KEY (users_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE + SQL); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql(<<<'SQL' + CREATE SCHEMA public + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE subscriptions DROP CONSTRAINT FK_4778A0167B3B43D + SQL); + $this->addSql(<<<'SQL' + DROP TABLE subscriptions + SQL); + } +} diff --git a/src/Controller/MercureController.php b/src/Controller/MercureController.php new file mode 100644 index 0000000..267e969 --- /dev/null +++ b/src/Controller/MercureController.php @@ -0,0 +1,25 @@ + 'OutOfStock']) + ); + + $hub->publish($update); + + return new Response('published!'); + } +} + diff --git a/src/Entity/Subscriptions.php b/src/Entity/Subscriptions.php new file mode 100644 index 0000000..7a85ce0 --- /dev/null +++ b/src/Entity/Subscriptions.php @@ -0,0 +1,36 @@ +id; + } + + public function getUsers(): ?User + { + return $this->users; + } + + public function setUsers(?User $users): static + { + $this->users = $users; + + return $this; + } +} diff --git a/src/Entity/UserTab.php b/src/Entity/UserTab.php new file mode 100644 index 0000000..1e7ef8d --- /dev/null +++ b/src/Entity/UserTab.php @@ -0,0 +1,66 @@ +id; + } + + public function getUsers(): ?User + { + return $this->users; + } + + public function setUsers(?User $users): static + { + $this->users = $users; + + return $this; + } + + public function getIpAddress(): ?String + { + return $this->ipAddress; + } + + public function setIpAddres(String $ipAddress): static + { + $this->ipAddress = $ipAddress; + + return $this; + } + + public function getTabId(): ?string + { + return $this->tabId; + } + + public function setTabId(?string $tabId): static + { + $this->tabId = $tabId; + + return $this; + } +} diff --git a/src/EventSubscriber/LogoutSubscriber.php b/src/EventSubscriber/LogoutSubscriber.php new file mode 100644 index 0000000..a790f3b --- /dev/null +++ b/src/EventSubscriber/LogoutSubscriber.php @@ -0,0 +1,25 @@ + 'onKernelResponse', + ]; + } + + public function onKernelResponse($event): void + { +// // This method can be used to perform actions after a logout response is sent. +// // For example, you could log the logout event or clear session data. +// +//// Example: Log the logout event +// $logger = $this->container->get('logger'); +// $logger->info('User logged out successfully.'); + } +} \ No newline at end of file diff --git a/src/Repository/SubscriptionsRepository.php b/src/Repository/SubscriptionsRepository.php new file mode 100644 index 0000000..0eb9e7a --- /dev/null +++ b/src/Repository/SubscriptionsRepository.php @@ -0,0 +1,43 @@ + + */ +class SubscriptionsRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Subscriptions::class); + } + + // /** + // * @return Subscriptions[] Returns an array of Subscriptions objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('s') + // ->andWhere('s.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('s.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Subscriptions + // { + // return $this->createQueryBuilder('s') + // ->andWhere('s.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/templates/testing/index.html.twig b/templates/testing/index.html.twig new file mode 100644 index 0000000..2f0e016 --- /dev/null +++ b/templates/testing/index.html.twig @@ -0,0 +1,44 @@ +{% extends 'base.html.twig' %} + +{% block title %}Test - index{% endblock %} +{#{% block jaa %}#} +{# #} +{#{% endblock %}#} + +{% block body %} + {% if app.user %} +
+ You are logged in as {{ app.user.userIdentifier }}, Logout +
+ {% endif %} +

Testing Page

+ +{#

Active Tabs per User

#} +{# #} + +{#

All Subscriptions

#} +{# #} +{# {{ mercure('http://portail.solutions-easy.moi/connect?userId=' ~ app.user.userIdentifier) }}#} + +{% endblock %}