Selaa lähdekoodia

Mse en place du Bundle User

bastien 13 vuotta sitten
vanhempi
commit
5a76d01720

+ 3 - 1
app/AppKernel.php Näytä tiedosto

@@ -17,8 +17,10 @@ class AppKernel extends Kernel
17 17
             new Symfony\Bundle\AsseticBundle\AsseticBundle(),
18 18
             new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
19 19
             new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
20
+            new FOS\UserBundle\FOSUserBundle(),
20 21
             new Muzich\CoreBundle\MuzichCoreBundle(),
21
-            new Muzich\IndexBundle\MuzichIndexBundle()
22
+            new Muzich\UserBundle\MuzichUserBundle(),
23
+            new Muzich\IndexBundle\MuzichIndexBundle(),
22 24
         );
23 25
 
24 26
         if (in_array($this->getEnvironment(), array('dev', 'test'))) {

+ 1 - 0
app/autoload.php Näytä tiedosto

@@ -14,6 +14,7 @@ $loader->registerNamespaces(array(
14 14
     'Monolog'          => __DIR__.'/../vendor/monolog/src',
15 15
     'Assetic'          => __DIR__.'/../vendor/assetic/src',
16 16
     'Metadata'         => __DIR__.'/../vendor/metadata/src',
17
+    'FOS'              => __DIR__.'/../vendor/bundles',
17 18
 ));
18 19
 $loader->registerPrefixes(array(
19 20
     'Twig_Extensions_' => __DIR__.'/../vendor/twig-extensions/lib',

File diff suppressed because it is too large
+ 2487 - 0
app/logs/dev.log


+ 22 - 2
src/Muzich/CoreBundle/Entity/Element.php Näytä tiedosto

@@ -18,8 +18,8 @@ class Element
18 18
   protected $type;
19 19
   
20 20
   /**
21
-   * @ManyToMany(targetEntity="Tag", inversedBy="elements")
22
-   * @JoinTable(name="elements_tag")
21
+   * @ORM\ManyToMany(targetEntity="Tag", inversedBy="elements")
22
+   * @ORM\JoinTable(name="elements_tag")
23 23
    */
24 24
   private $tags;
25 25
   
@@ -146,4 +146,24 @@ class Element
146 146
     $this->tags = new \Doctrine\Common\Collections\ArrayCollection();
147 147
   }
148 148
   
149
+
150
+    /**
151
+     * Add tags
152
+     *
153
+     * @param Muzich\CoreBundle\Entity\Tag $tags
154
+     */
155
+    public function addTag(\Muzich\CoreBundle\Entity\Tag $tags)
156
+    {
157
+        $this->tags[] = $tags;
158
+    }
159
+
160
+    /**
161
+     * Get tags
162
+     *
163
+     * @return Doctrine\Common\Collections\Collection 
164
+     */
165
+    public function getTags()
166
+    {
167
+        return $this->tags;
168
+    }
149 169
 }

+ 52 - 2
src/Muzich/CoreBundle/Entity/Tag.php Näytä tiedosto

@@ -12,9 +12,9 @@ class Tag
12 12
 {
13 13
   
14 14
   /**
15
-   * @ManyToMany(targetEntity="Tag", mappedBy="tags")
15
+   * @ORM\ManyToMany(targetEntity="Tag", mappedBy="tags")
16 16
    */
17
-  private $elements;
17
+  protected $elements;
18 18
   
19 19
   /**
20 20
    * @ORM\Id
@@ -35,4 +35,54 @@ class Tag
35 35
     $this->elements = new \Doctrine\Common\Collections\ArrayCollection();
36 36
   }
37 37
   
38
+
39
+    /**
40
+     * Get id
41
+     *
42
+     * @return integer 
43
+     */
44
+    public function getId()
45
+    {
46
+        return $this->id;
47
+    }
48
+
49
+    /**
50
+     * Set name
51
+     *
52
+     * @param string $name
53
+     */
54
+    public function setName($name)
55
+    {
56
+        $this->name = $name;
57
+    }
58
+
59
+    /**
60
+     * Get name
61
+     *
62
+     * @return string 
63
+     */
64
+    public function getName()
65
+    {
66
+        return $this->name;
67
+    }
68
+
69
+    /**
70
+     * Add elements
71
+     *
72
+     * @param Muzich\CoreBundle\Entity\Tag $elements
73
+     */
74
+    public function addTag(\Muzich\CoreBundle\Entity\Tag $elements)
75
+    {
76
+        $this->elements[] = $elements;
77
+    }
78
+
79
+    /**
80
+     * Get elements
81
+     *
82
+     * @return Doctrine\Common\Collections\Collection 
83
+     */
84
+    public function getElements()
85
+    {
86
+        return $this->elements;
87
+    }
38 88
 }

+ 0 - 0
src/Muzich/CoreBundle/Resources/views/layout.html.twig Näytä tiedosto


+ 20 - 0
src/Muzich/IndexBundle/Resources/config/routing.yml Näytä tiedosto

@@ -3,3 +3,23 @@
3 3
 index:
4 4
     pattern:  /
5 5
     defaults: { _controller: MuzichIndexBundle:Index:index }
6
+
7
+fos_user_security:
8
+    resource: "@FOSUserBundle/Resources/config/routing/security.xml"
9
+    prefix: /
10
+
11
+fos_user_profile:
12
+    resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
13
+    prefix: /profile
14
+
15
+fos_user_register:
16
+    resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
17
+    prefix: /register
18
+
19
+fos_user_resetting:
20
+    resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
21
+    prefix: /resetting
22
+
23
+fos_user_change_password:
24
+    resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
25
+    prefix: /change-password 

+ 19 - 0
src/Muzich/UserBundle/Controller/DefaultController.php Näytä tiedosto

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace Muzich\UserBundle\Controller;
4
+
5
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
7
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
8
+
9
+class DefaultController extends Controller
10
+{
11
+    /**
12
+     * @Route("/hello/{name}")
13
+     * @Template()
14
+     */
15
+    public function indexAction($name)
16
+    {
17
+        return array('name' => $name);
18
+    }
19
+}

+ 29 - 0
src/Muzich/UserBundle/DependencyInjection/Configuration.php Näytä tiedosto

@@ -0,0 +1,29 @@
1
+<?php
2
+
3
+namespace Muzich\UserBundle\DependencyInjection;
4
+
5
+use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
+use Symfony\Component\Config\Definition\ConfigurationInterface;
7
+
8
+/**
9
+ * This is the class that validates and merges configuration from your app/config files
10
+ *
11
+ * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
12
+ */
13
+class Configuration implements ConfigurationInterface
14
+{
15
+    /**
16
+     * {@inheritDoc}
17
+     */
18
+    public function getConfigTreeBuilder()
19
+    {
20
+        $treeBuilder = new TreeBuilder();
21
+        $rootNode = $treeBuilder->root('muzich_user');
22
+
23
+        // Here you should define the parameters that are allowed to
24
+        // configure your bundle. See the documentation linked above for
25
+        // more information on that topic.
26
+
27
+        return $treeBuilder;
28
+    }
29
+}

+ 28 - 0
src/Muzich/UserBundle/DependencyInjection/MuzichUserExtension.php Näytä tiedosto

@@ -0,0 +1,28 @@
1
+<?php
2
+
3
+namespace Muzich\UserBundle\DependencyInjection;
4
+
5
+use Symfony\Component\DependencyInjection\ContainerBuilder;
6
+use Symfony\Component\Config\FileLocator;
7
+use Symfony\Component\HttpKernel\DependencyInjection\Extension;
8
+use Symfony\Component\DependencyInjection\Loader;
9
+
10
+/**
11
+ * This is the class that loads and manages your bundle configuration
12
+ *
13
+ * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
14
+ */
15
+class MuzichUserExtension extends Extension
16
+{
17
+    /**
18
+     * {@inheritDoc}
19
+     */
20
+    public function load(array $configs, ContainerBuilder $container)
21
+    {
22
+        $configuration = new Configuration();
23
+        $config = $this->processConfiguration($configuration, $configs);
24
+
25
+        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
26
+        $loader->load('services.xml');
27
+    }
28
+}

+ 35 - 0
src/Muzich/UserBundle/Entity/User.php Näytä tiedosto

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+namespace Muzich\UserBundle\Entity;
4
+use FOS\UserBundle\Entity\User as BaseUser;
5
+use Doctrine\ORM\Mapping as ORM;
6
+
7
+/**
8
+ * @ORM\Entity
9
+ * @ORM\Table(name="muzich_user")
10
+ */
11
+class User extends BaseUser
12
+{
13
+  /**
14
+  * @ORM\Id
15
+  * @ORM\Column(type="integer")
16
+  * @ORM\generatedValue(strategy="AUTO")
17
+  */
18
+  protected $id;
19
+
20
+  public function __construct()
21
+  {
22
+      parent::__construct();
23
+  }
24
+
25
+  /**
26
+   * Get id
27
+   *
28
+   * @return integer 
29
+   */
30
+  public function getId()
31
+  {
32
+      return $this->id;
33
+  }
34
+  
35
+}

+ 15 - 0
src/Muzich/UserBundle/MuzichUserBundle.php Näytä tiedosto

@@ -0,0 +1,15 @@
1
+<?php
2
+
3
+namespace Muzich\UserBundle;
4
+
5
+use Symfony\Component\HttpKernel\Bundle\Bundle;
6
+
7
+class MuzichUserBundle extends Bundle
8
+{
9
+  
10
+  public function getParent()
11
+  {
12
+      return 'FOSUserBundle';
13
+  }
14
+
15
+}

+ 20 - 0
src/Muzich/UserBundle/Resources/config/services.xml Näytä tiedosto

@@ -0,0 +1,20 @@
1
+<?xml version="1.0" ?>
2
+
3
+<container xmlns="http://symfony.com/schema/dic/services"
4
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
+    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
6
+
7
+    <!--
8
+    <parameters>
9
+        <parameter key="muzich_user.example.class">Muzich\UserBundle\Example</parameter>
10
+    </parameters>
11
+
12
+    <services>
13
+        <service id="muzich_user.example" class="%muzich_user.example.class%">
14
+            <argument type="service" id="service_id" />
15
+            <argument>plain_value</argument>
16
+            <argument>%parameter_name%</argument>
17
+        </service>
18
+    </services>
19
+    -->
20
+</container>

+ 0 - 0
src/Muzich/UserBundle/Resources/doc/index.rst Näytä tiedosto


+ 11 - 0
src/Muzich/UserBundle/Resources/translations/messages.fr.xliff Näytä tiedosto

@@ -0,0 +1,11 @@
1
+<?xml version="1.0"?>
2
+<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3
+    <file source-language="en" datatype="plaintext" original="file.ext">
4
+        <body>
5
+            <trans-unit id="1">
6
+                <source>Symfony2 is great</source>
7
+                <target>J'aime Symfony2</target>
8
+            </trans-unit>
9
+        </body>
10
+    </file>
11
+</xliff>

+ 1 - 0
src/Muzich/UserBundle/Resources/views/Default/index.html.twig Näytä tiedosto

@@ -0,0 +1 @@
1
+Hello {{ name }}!

+ 7 - 0
src/Muzich/UserBundle/Resources/views/layout.html.twig Näytä tiedosto

@@ -0,0 +1,7 @@
1
+{% extends "MuzichCoreBundle::layout.html.twig" %}
2
+
3
+{% block title %}{% endblock %}
4
+
5
+{% block content %}
6
+    {% block fos_user_content %}{% endblock %}
7
+{% endblock %}

+ 17 - 0
src/Muzich/UserBundle/Tests/Controller/DefaultControllerTest.php Näytä tiedosto

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+namespace Muzich\UserBundle\Tests\Controller;
4
+
5
+use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6
+
7
+class DefaultControllerTest extends WebTestCase
8
+{
9
+    public function testIndex()
10
+    {
11
+        $client = static::createClient();
12
+
13
+        $crawler = $client->request('GET', '/hello/Fabien');
14
+
15
+        $this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0);
16
+    }
17
+}