Browse Source

projet de base

raphael 3 years ago
parent
commit
a5013ae967

+ 4
- 0
.gitignore View File

@@ -0,0 +1,4 @@
1
+/vendor/
2
+composer.lock
3
+.phpunit.result.cache
4
+/.idea/

+ 13
- 0
Controller/ExampleController.php View File

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace Logipro\Bundle\Phoenix\Controller;
4
+
5
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
6
+
7
+class ExampleController extends AbstractController
8
+{
9
+    public function view()
10
+    {
11
+        return $this->render('@LogiproExample/Example/example.html.twig');
12
+    }
13
+}

+ 23
- 0
DependencyInjection/Configuration.php View File

@@ -0,0 +1,23 @@
1
+<?php
2
+
3
+
4
+namespace Logipro\Bundle\Phoenix\DependencyInjection;
5
+
6
+use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
+use Symfony\Component\Config\Definition\ConfigurationInterface;
8
+
9
+class Configuration implements ConfigurationInterface
10
+{
11
+    public function getConfigTreeBuilder()
12
+    {
13
+        $treeBuilder = new TreeBuilder('logipro_example');
14
+
15
+        $treeBuilder->getRootNode()
16
+            ->children()
17
+                ->node('username_provider', 'scalar')->end()
18
+            ->end()
19
+        ;
20
+
21
+        return $treeBuilder;
22
+    }
23
+}

+ 26
- 0
DependencyInjection/LogiproExampleExtension.php View File

@@ -0,0 +1,26 @@
1
+<?php
2
+
3
+namespace Logipro\Bundle\Phoenix\DependencyInjection;
4
+
5
+use Symfony\Component\Config\FileLocator;
6
+use Symfony\Component\DependencyInjection\ContainerBuilder;
7
+use Symfony\Component\DependencyInjection\Extension\Extension;
8
+use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
9
+
10
+class LogiproExampleExtension extends Extension
11
+{
12
+    public function load(array $configs, ContainerBuilder $container)
13
+    {
14
+        $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
15
+        $loader->load('services.xml');
16
+
17
+        $configuration = new Configuration();
18
+        $config = $this->processConfiguration($configuration, $configs);
19
+
20
+        /**
21
+         * @TODO for real bundle, create an user service for use username provider
22
+         * $definition = $container->getDefinition('logipro_example.user.service');
23
+         * $definition->replaceArgument(0, $config['username_provider']);
24
+         */
25
+    }
26
+}

+ 54
- 0
Entity/User.php View File

@@ -0,0 +1,54 @@
1
+<?php
2
+
3
+namespace Logipro\Bundle\Phoenix\Entity;
4
+
5
+use Doctrine\ORM\Mapping as ORM;
6
+
7
+class User implements UserInterface
8
+{
9
+    /**
10
+     * @ORM\Column(type="integer")
11
+     * @ORM\Id
12
+     * @ORM\GeneratedValue(strategy="AUTO")
13
+     */
14
+    private $id;
15
+
16
+    /**
17
+     * @ORM\Column(name="username", length=25, unique=true)
18
+     */
19
+    private $username;
20
+
21
+    /**
22
+     * @return mixed
23
+     */
24
+    public function getId()
25
+    {
26
+        return $this->id;
27
+    }
28
+
29
+    /**
30
+     * @param mixed $id
31
+     * @return User
32
+     */
33
+    public function setId($id)
34
+    {
35
+        $this->id = $id;
36
+        return $this;
37
+    }
38
+
39
+    public function getUsername(): string
40
+    {
41
+        return $this->username;
42
+    }
43
+
44
+    /**
45
+     * @param $username
46
+     * @return $this
47
+     */
48
+    public function setUsername($username)
49
+    {
50
+        $this->username = $username;
51
+
52
+        return $this;
53
+    }
54
+}

+ 10
- 0
Entity/UserInterface.php View File

@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+
4
+namespace Logipro\Bundle\Phoenix\Entity;
5
+
6
+
7
+interface UserInterface
8
+{
9
+    public function getUsername(): string;
10
+}

+ 21
- 0
LICENSE View File

@@ -0,0 +1,21 @@
1
+MIT License
2
+
3
+Copyright (c) 2019 Logipro
4
+
5
+Permission is hereby granted, free of charge, to any person obtaining a copy
6
+of this software and associated documentation files (the "Software"), to deal
7
+in the Software without restriction, including without limitation the rights
8
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+copies of the Software, and to permit persons to whom the Software is
10
+furnished to do so, subject to the following conditions:
11
+
12
+The above copyright notice and this permission notice shall be included in all
13
+copies or substantial portions of the Software.
14
+
15
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+SOFTWARE.

+ 9
- 0
LogiproExampleBundle.php View File

@@ -0,0 +1,9 @@
1
+<?php
2
+
3
+namespace Logipro\Bundle\Phoenix;
4
+
5
+use Symfony\Component\HttpKernel\Bundle\Bundle;
6
+
7
+class PhoenixBundle extends Bundle
8
+{
9
+}

+ 2
- 0
Resources/config/packages/logipro_example.yaml View File

@@ -0,0 +1,2 @@
1
+logipro_example:
2
+  username_provider: Logipro\Bundle\ExampleBundle\Entity\User

+ 3
- 0
Resources/config/routing/routing.yml View File

@@ -0,0 +1,3 @@
1
+logipro_example_example_route:
2
+  path:     /example
3
+  controller: Logipro\Bundle\ExampleBundle\Controller\ExampleController::view

+ 9
- 0
Resources/config/services.xml View File

@@ -0,0 +1,9 @@
1
+<?xml version="1.0" ?>
2
+<container xmlns="http://symfony.com/schema/dic/services"
3
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
5
+
6
+    <services>
7
+        <service id="example.services.foo" class="Logipro\Bundle\Phoenix\Services\FooServices" public="true" />
8
+    </services>
9
+</container>

+ 0
- 0
Resources/doc/index.rst View File


+ 1
- 0
Resources/views/Example/example.html.twig View File

@@ -0,0 +1 @@
1
+<h1>Bienvenue sur example bundle</h1>

+ 15
- 0
Services/FooServices.php View File

@@ -0,0 +1,15 @@
1
+<?php
2
+
3
+namespace Logipro\Bundle\Phoenix\Services;
4
+
5
+class FooServices
6
+{
7
+    public function verif(string $param)
8
+    {
9
+        if ($param !== 'foo') {
10
+            return false;
11
+        }
12
+
13
+        return true;
14
+    }
15
+}

+ 24
- 0
Tests/Services/FooServicesTest.php View File

@@ -0,0 +1,24 @@
1
+<?php
2
+
3
+namespace Logipro\Bundle\ExampleBundle\Tests;
4
+
5
+use PHPUnit\Framework\TestCase;
6
+use Logipro\Bundle\ExampleBundle\Services\FooServices;
7
+
8
+class FooServicesTest extends TestCase
9
+{
10
+    public function testMustObtainASuccessWhenParamisEqualFoo()
11
+    {
12
+        $fooServices = new FooServices();
13
+
14
+        $this->assertEquals(true, $fooServices->verif('foo'));
15
+    }
16
+
17
+    public function testMustObtainAnErrorWhenParamisEqualBar()
18
+    {
19
+        $fooServices = new FooServices();
20
+
21
+        $this->assertEquals(false, $fooServices->verif('bar'));
22
+    }
23
+}
24
+

+ 3
- 0
Tests/bootstrap.php View File

@@ -0,0 +1,3 @@
1
+<?php 
2
+
3
+require __DIR__.'/../vendor/autoload.php';

+ 48
- 0
composer.json View File

@@ -0,0 +1,48 @@
1
+{
2
+    "name": "logipro/PhoenixBundle",
3
+    "description": "Bundle example for Phoenix",
4
+    "license": "MIT",
5
+    "type": "symfony-bundle",
6
+    "authors": [
7
+        {
8
+            "name": "Phoenix team",
9
+            "email": "infinity.tree-learning.fr"
10
+        }
11
+    ],
12
+    "require": {
13
+        "php": "^7.2",
14
+        "doctrine/common": "^2.8",
15
+        "doctrine/doctrine-bundle": "^1.8",
16
+        "doctrine/orm": "^2.6",
17
+        "doctrine/persistence": "^1.0",
18
+        "symfony/asset": "^4.1",
19
+        "symfony/cache": "^4.1",
20
+        "symfony/config": "^4.1",
21
+        "symfony/dependency-injection": "^4.1",
22
+        "symfony/doctrine-bridge": "^4.1",
23
+        "symfony/expression-language": "^4.1",
24
+        "symfony/framework-bundle": "^4.1",
25
+        "symfony/http-foundation": "^4.1",
26
+        "symfony/http-kernel": "^4.1",
27
+        "symfony/polyfill-mbstring": "^1.7",
28
+        "symfony/property-access": "^4.1",
29
+        "symfony/security-bundle": "^4.1",
30
+        "symfony/twig-bridge": "^4.1",
31
+        "symfony/twig-bundle": "^4.1",
32
+        "twig/extensions": "^1.5",
33
+        "twig/twig": "^2.4"
34
+    },
35
+    "require-dev": {
36
+        "symfony/browser-kit": "^4.1",
37
+        "symfony/css-selector": "^4.1",
38
+        "symfony/dom-crawler": "^4.1",
39
+        "symfony/phpunit-bridge": "^4.1",
40
+        "symfony/var-dumper": "^4.1",
41
+        "symfony/console": "^4.2"
42
+    },
43
+    "autoload": {
44
+        "psr-4": {
45
+            "Logipro\\Bundle\\Phoenix\\": ""
46
+        }
47
+    }
48
+}

+ 18
- 0
phpunit.xml.dist View File

@@ -0,0 +1,18 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+
3
+<phpunit backupGlobals="false"
4
+         backupStaticAttributes="false"
5
+         colors="true"
6
+         convertErrorsToExceptions="true"
7
+         convertNoticesToExceptions="true"
8
+         convertWarningsToExceptions="true"
9
+         processIsolation="false"
10
+         stopOnFailure="false"
11
+         bootstrap="Tests/bootstrap.php"
12
+>
13
+    <testsuites>
14
+        <testsuite name="Logipro Example Bundle Test Suite">
15
+            <directory suffix="Test.php">./Tests/</directory>
16
+        </testsuite>
17
+    </testsuites>
18
+</phpunit>

Loading…
Cancel
Save