From 14ac7fe69a0cc28e6991c891d1327580f7a90855 Mon Sep 17 00:00:00 2001 From: PaulCombal Date: Fri, 1 Mar 2019 12:18:06 +0100 Subject: [PATCH] first --- .gitignore | 3 + TestBundle/Controller/MainController.php | 18 ++++++ TestBundle/DependencyInjection/Configuration.php | 22 ++++++++ TestBundle/DependencyInjection/TestExtension.php | 64 ++++++++++++++++++++++ TestBundle/Entity/BillingInvoice.php | 40 ++++++++++++++ TestBundle/Repository/BillingInvoiceRepository.php | 50 +++++++++++++++++ TestBundle/Resources/config/routes.yaml | 3 + TestBundle/Resources/config/services.yaml | 16 ++++++ TestBundle/Service/FooService.php | 20 +++++++ TestBundle/TestBundle.php | 25 +++++++++ composer.json | 21 +++++++ 11 files changed, 282 insertions(+) create mode 100644 .gitignore create mode 100644 TestBundle/Controller/MainController.php create mode 100644 TestBundle/DependencyInjection/Configuration.php create mode 100644 TestBundle/DependencyInjection/TestExtension.php create mode 100644 TestBundle/Entity/BillingInvoice.php create mode 100644 TestBundle/Repository/BillingInvoiceRepository.php create mode 100644 TestBundle/Resources/config/routes.yaml create mode 100644 TestBundle/Resources/config/services.yaml create mode 100644 TestBundle/Service/FooService.php create mode 100644 TestBundle/TestBundle.php create mode 100644 composer.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5408cab --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea/ +vendor/ +.DS_Store diff --git a/TestBundle/Controller/MainController.php b/TestBundle/Controller/MainController.php new file mode 100644 index 0000000..5ce0a0f --- /dev/null +++ b/TestBundle/Controller/MainController.php @@ -0,0 +1,18 @@ +getMethod()); + // ON PEUT PAS INJECTER UN SERVICE DU BUNDLE EN QUESTION DANS LES ARGS DONC ON LE récupère ainsi : + $this->get('bluesquare.test_bundle.foo')->foo(); + die('hello'); + } +} \ No newline at end of file diff --git a/TestBundle/DependencyInjection/Configuration.php b/TestBundle/DependencyInjection/Configuration.php new file mode 100644 index 0000000..0b53f09 --- /dev/null +++ b/TestBundle/DependencyInjection/Configuration.php @@ -0,0 +1,22 @@ +root('billing'); + $root->end(); + return $treeBuilder; + } +} \ No newline at end of file diff --git a/TestBundle/DependencyInjection/TestExtension.php b/TestBundle/DependencyInjection/TestExtension.php new file mode 100644 index 0000000..29ce540 --- /dev/null +++ b/TestBundle/DependencyInjection/TestExtension.php @@ -0,0 +1,64 @@ +load('services.yaml'); + + $config = $this->processConfiguration(new Configuration(), $configs); + // $definition = $container->getDefinition('bluesquare.test_bundle.foo'); + + return $config; + // $this->configurePersistence($loader, $container, $config['provider']); + // $this->configureAuthorizationServer($container, $config['authorization_server']); + // $this->configureResourceServer($container, $config['resource_server']); + // $this->configureScopes($container, $config['scopes']); + } + + /** + * {@inheritdoc} + */ + public function getAlias() + { + return 'bluesquare.test_bundle'; + } + + /** + * {@inheritdoc} + */ + public function prepend(ContainerBuilder $container) + { + // + } + + private function configureScopes(ContainerBuilder $container, array $scopes): void + { + /*$scopeManager = $container + ->getDefinition( + $container->getAlias(ScopeManagerInterface::class) + ) + ; + + foreach ($scopes as $scope) { + $scopeManager->addMethodCall('save', [ + new Definition(ScopeModel::class, [$scope]), + ]); + }*/ + } +} diff --git a/TestBundle/Entity/BillingInvoice.php b/TestBundle/Entity/BillingInvoice.php new file mode 100644 index 0000000..f62b256 --- /dev/null +++ b/TestBundle/Entity/BillingInvoice.php @@ -0,0 +1,40 @@ +id; + } + + public function getAzerty(): ?string + { + return $this->azerty; + } + + public function setAzerty(string $azerty): self + { + $this->azerty = $azerty; + + return $this; + } +} diff --git a/TestBundle/Repository/BillingInvoiceRepository.php b/TestBundle/Repository/BillingInvoiceRepository.php new file mode 100644 index 0000000..5b03cf8 --- /dev/null +++ b/TestBundle/Repository/BillingInvoiceRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('b') + ->andWhere('b.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('b.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?BillingInvoice + { + return $this->createQueryBuilder('b') + ->andWhere('b.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/TestBundle/Resources/config/routes.yaml b/TestBundle/Resources/config/routes.yaml new file mode 100644 index 0000000..e79661b --- /dev/null +++ b/TestBundle/Resources/config/routes.yaml @@ -0,0 +1,3 @@ +bluesquare_test_bundle_test: + path: /test + controller: Bluesquare\TestBundle\Controller\MainController::index diff --git a/TestBundle/Resources/config/services.yaml b/TestBundle/Resources/config/services.yaml new file mode 100644 index 0000000..8c574e1 --- /dev/null +++ b/TestBundle/Resources/config/services.yaml @@ -0,0 +1,16 @@ +services: + # Si on a des repositories... + Bluesquare\TestBundle\Repository\: + resource: '../../Repository' + autowire: true + tags: ['doctrine.repository_service'] + + # Services : alias + Bluesquare\TestBundle\Service\FooService: '@bluesquare.test_bundle.foo' + + # Services : params + bluesquare.test_bundle.foo: + class: Bluesquare\TestBundle\Service\FooService + autowire: true + public: true + arguments: ['@request_stack'] \ No newline at end of file diff --git a/TestBundle/Service/FooService.php b/TestBundle/Service/FooService.php new file mode 100644 index 0000000..1b5d5a7 --- /dev/null +++ b/TestBundle/Service/FooService.php @@ -0,0 +1,20 @@ +extension) + $this->extension = new TestExtension(); + + return $this->extension; + } +} \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..8f7fdd9 --- /dev/null +++ b/composer.json @@ -0,0 +1,21 @@ +{ + "name": "bluesquare-packages/symfony-test", + "description": "Test package created by Bluesquare Computing", + "keywords": ["template", "composer", "package"], + "license": "proprietary", + "authors": [ + { + "name": "RENOU Maxime", + "email": "maxime@bluesquare.io" + } + ], + "type": "symfony-bundle", + "require": { + "php": ">=7.1" + }, + "autoload": { + "psr-4": { + "Bluesquare\\TestBundle\\": "TestBundle/" + } + } +}