rename to notifications

This commit is contained in:
PaulCombal
2019-03-01 12:49:26 +01:00
parent 480947afaf
commit d8e915d759
13 changed files with 59 additions and 59 deletions

View File

@@ -0,0 +1,18 @@
<?php
namespace Bluesquare\NotificationsBundle\Controller;
use Bluesquare\NotificationsBundle\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.notifications_bundle.foo')->foo();
die('hello');
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Bluesquare\NotificationsBundle\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;
}
}

View File

@@ -0,0 +1,64 @@
<?php
namespace Bluesquare\NotificationsBundle\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 NotificationsExtension 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.notifications_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.notifications_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]),
]);
}*/
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace Bluesquare\NotificationsBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="Bluesquare\NotificationsBundle\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;
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Bluesquare\NotificationsBundle;
use Bluesquare\NotificationsBundle\Entity\BillingInvoice;
use Bluesquare\NotificationsBundle\Repository\BillingInvoiceRepository;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Bluesquare\NotificationsBundle\DependencyInjection\NotificationsExtension;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class NotificationsBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
parent::build($container);
}
public function getContainerExtension()
{
if (null === $this->extension)
$this->extension = new NotificationsExtension();
return $this->extension;
}
}

View File

@@ -0,0 +1,50 @@
<?php
namespace Bluesquare\NotificationsBundle\Repository;
use Bluesquare\NotificationsBundle\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()
;
}
*/
}

View File

@@ -0,0 +1,3 @@
bluesquare_notifications_bundle_notifications:
path: /test-notifs
controller: Bluesquare\NotificationsBundle\Controller\MainController::index

View File

@@ -0,0 +1,16 @@
services:
# Si on a des repositories...
Bluesquare\NotificationsBundle\Repository\:
resource: '../../Repository'
autowire: true
tags: ['doctrine.repository_service']
# Services : alias
Bluesquare\NotificationsBundle\Service\FooService: '@bluesquare.notifications_bundle.foo'
# Services : params
bluesquare.notifications_bundle.foo:
class: Bluesquare\NotificationsBundle\Service\FooService
autowire: true
public: true
arguments: ['@request_stack']

View File

@@ -0,0 +1,20 @@
<?php
namespace Bluesquare\NotificationsBundle\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';
}
}