first
This commit is contained in:
commit
14ac7fe69a
|
@ -0,0 +1,3 @@
|
||||||
|
.idea/
|
||||||
|
vendor/
|
||||||
|
.DS_Store
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Bluesquare\TestBundle\Controller;
|
||||||
|
|
||||||
|
use Bluesquare\TestBundle\Service\FooService;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
class MainController extends AbstractController
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
die($request->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');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Bluesquare\TestBundle\DependencyInjection;
|
||||||
|
|
||||||
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||||
|
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||||
|
|
||||||
|
class Configuration implements ConfigurationInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Generates the configuration tree builder.
|
||||||
|
*
|
||||||
|
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
|
||||||
|
*/
|
||||||
|
public function getConfigTreeBuilder()
|
||||||
|
{
|
||||||
|
$treeBuilder = new TreeBuilder();
|
||||||
|
$root = $treeBuilder->root('billing');
|
||||||
|
$root->end();
|
||||||
|
return $treeBuilder;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Bluesquare\TestBundle\DependencyInjection;
|
||||||
|
|
||||||
|
use Symfony\Component\Config\FileLocator;
|
||||||
|
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
|
use Symfony\Component\DependencyInjection\Extension\Extension;
|
||||||
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||||
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
|
||||||
|
final class TestExtension extends Extension implements PrependExtensionInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function load(array $configs, ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
|
||||||
|
$loader->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]),
|
||||||
|
]);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Bluesquare\TestBundle\Entity;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Entity(repositoryClass="Bluesquare\TestBundle\Repository\BillingInvoiceRepository")
|
||||||
|
*/
|
||||||
|
class BillingInvoice
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @ORM\Id()
|
||||||
|
* @ORM\GeneratedValue()
|
||||||
|
* @ORM\Column(type="integer")
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=255)
|
||||||
|
*/
|
||||||
|
private $azerty;
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAzerty(): ?string
|
||||||
|
{
|
||||||
|
return $this->azerty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAzerty(string $azerty): self
|
||||||
|
{
|
||||||
|
$this->azerty = $azerty;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Bluesquare\TestBundle\Repository;
|
||||||
|
|
||||||
|
use Bluesquare\TestBundle\Entity\BillingInvoice;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Symfony\Bridge\Doctrine\RegistryInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method BillingInvoice|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
|
* @method BillingInvoice|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
|
* @method BillingInvoice[] findAll()
|
||||||
|
* @method BillingInvoice[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*/
|
||||||
|
class BillingInvoiceRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(RegistryInterface $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, BillingInvoice::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @return BillingInvoice[] Returns an array of BillingInvoice objects
|
||||||
|
// */
|
||||||
|
/*
|
||||||
|
public function findByExampleField($value)
|
||||||
|
{
|
||||||
|
return $this->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()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
bluesquare_test_bundle_test:
|
||||||
|
path: /test
|
||||||
|
controller: Bluesquare\TestBundle\Controller\MainController::index
|
|
@ -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']
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Bluesquare\TestBundle\Service;
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
|
||||||
|
class FooService
|
||||||
|
{
|
||||||
|
public function __construct(RequestStack $requestStack)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function foo()
|
||||||
|
{
|
||||||
|
die(var_dump('azertyu'));
|
||||||
|
return 'bar';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Bluesquare\TestBundle;
|
||||||
|
|
||||||
|
use Bluesquare\TestBundle\Entity\BillingInvoice;
|
||||||
|
use Bluesquare\TestBundle\Repository\BillingInvoiceRepository;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Bluesquare\TestBundle\DependencyInjection\TestExtension;
|
||||||
|
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||||
|
|
||||||
|
class TestBundle extends Bundle
|
||||||
|
{
|
||||||
|
public function build(ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
parent::build($container);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getContainerExtension()
|
||||||
|
{
|
||||||
|
if (null === $this->extension)
|
||||||
|
$this->extension = new TestExtension();
|
||||||
|
|
||||||
|
return $this->extension;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue