소스 검색

Mse en place des Bundle permettant de faire des fixtures. Mise en place de fixtures User.

bastien 12 년 전
부모
커밋
151dab6c16

+ 1 - 0
app/AppKernel.php 파일 보기

@@ -18,6 +18,7 @@ class AppKernel extends Kernel
18 18
             new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
19 19
             new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
20 20
             new FOS\UserBundle\FOSUserBundle(),
21
+            new Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle(),
21 22
             new Muzich\CoreBundle\MuzichCoreBundle(),
22 23
             new Muzich\UserBundle\MuzichUserBundle(),
23 24
             new Muzich\IndexBundle\MuzichIndexBundle(),

+ 2 - 0
app/autoload.php 파일 보기

@@ -16,6 +16,8 @@ $loader->registerNamespaces(array(
16 16
     'Metadata'         => __DIR__.'/../vendor/metadata/src',
17 17
     'FOS'              => __DIR__.'/../vendor/bundles',
18 18
     //'Muzich'           => __DIR__.'/../vendor/src',
19
+    'Doctrine\\Common\\DataFixtures' => __DIR__.'/../vendor/doctrine-fixtures/lib',
20
+    'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
19 21
 ));
20 22
 $loader->registerPrefixes(array(
21 23
     'Twig_Extensions_' => __DIR__.'/../vendor/twig-extensions/lib',

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 5708 - 0
app/logs/dev.log


+ 7 - 0
deps 파일 보기

@@ -61,3 +61,10 @@
61 61
 [FOSUserBundle]
62 62
     git=git://github.com/FriendsOfSymfony/FOSUserBundle.git
63 63
     target=bundles/FOS/UserBundle
64
+
65
+[doctrine-fixtures]
66
+    git=http://github.com/doctrine/data-fixtures.git
67
+
68
+[DoctrineFixturesBundle]
69
+    git=http://github.com/symfony/DoctrineFixturesBundle.git
70
+    target=/bundles/Symfony/Bundle/DoctrineFixturesBundle

+ 63 - 0
deps~ 파일 보기

@@ -0,0 +1,63 @@
1
+[symfony]
2
+    git=http://github.com/symfony/symfony.git
3
+    version=v2.0.1
4
+
5
+[twig]
6
+    git=http://github.com/fabpot/Twig.git
7
+    version=v1.1.2
8
+
9
+[monolog]
10
+    git=http://github.com/Seldaek/monolog.git
11
+    version=1.0.1
12
+
13
+[doctrine-common]
14
+    git=http://github.com/doctrine/common.git
15
+    version=2.1.1
16
+
17
+[doctrine-dbal]
18
+    git=http://github.com/doctrine/dbal.git
19
+    version=2.1.1
20
+
21
+[doctrine]
22
+    git=http://github.com/doctrine/doctrine2.git
23
+    version=2.1.1
24
+
25
+[swiftmailer]
26
+    git=http://github.com/swiftmailer/swiftmailer.git
27
+    version=v4.1.1
28
+
29
+[assetic]
30
+    git=http://github.com/kriswallsmith/assetic.git
31
+    version=v1.0.1
32
+
33
+[twig-extensions]
34
+    git=http://github.com/fabpot/Twig-extensions.git
35
+
36
+[metadata]
37
+    git=http://github.com/schmittjoh/metadata.git
38
+    version=1.0.0
39
+
40
+[SensioFrameworkExtraBundle]
41
+    git=http://github.com/sensio/SensioFrameworkExtraBundle.git
42
+    target=/bundles/Sensio/Bundle/FrameworkExtraBundle
43
+
44
+[JMSSecurityExtraBundle]
45
+    git=http://github.com/schmittjoh/JMSSecurityExtraBundle.git
46
+    target=/bundles/JMS/SecurityExtraBundle
47
+
48
+[SensioDistributionBundle]
49
+    git=http://github.com/sensio/SensioDistributionBundle.git
50
+    target=/bundles/Sensio/Bundle/DistributionBundle
51
+
52
+[SensioGeneratorBundle]
53
+    git=http://github.com/sensio/SensioGeneratorBundle.git
54
+    target=/bundles/Sensio/Bundle/GeneratorBundle
55
+
56
+[AsseticBundle]
57
+    git=http://github.com/symfony/AsseticBundle.git
58
+    target=/bundles/Symfony/Bundle/AsseticBundle
59
+    version=v1.0.0
60
+
61
+[FOSUserBundle]
62
+    git=git://github.com/FriendsOfSymfony/FOSUserBundle.git
63
+    target=bundles/FOS/UserBundle

+ 9 - 0
src/Muzich/CoreBundle/Entity/Tag.php 파일 보기

@@ -54,6 +54,15 @@ class Tag
54 54
   protected $name;
55 55
   
56 56
   /**
57
+   * Compteur total d'utilisation. Utilisé pour faire ressortir les 
58
+   * tags les plus utilisés.
59
+   * 
60
+   * @ORM\Column(type="integer")
61
+   * @var int
62
+   */
63
+  protected $count = 0;
64
+  
65
+  /**
57 66
    * 
58 67
    */
59 68
   public function __construct()

+ 26 - 1
src/Muzich/CoreBundle/Resources/config/security.yml 파일 보기

@@ -17,4 +17,29 @@ security:
17 17
             logout:
18 18
                 path:   /logout
19 19
                 target: /
20
-            anonymous:  true
20
+            anonymous:  true
21
+            
22
+    role_hierarchy:
23
+        ROLE_ADMIN:       ROLE_USER
24
+        ROLE_SUPER_ADMIN: ROLE_ADMIN
25
+        
26
+    ## La en tant qu'exemple, exploiter ça (http://j-place.developpez.com/tutoriels/php/ameliorez-vos-applications-developpees-avec-symfony2/#LVI-A-3)
27
+#    access_control:
28
+#        # Liste des pages accessibles à tous les utilisateurs (ne pas toucher)
29
+#        - { path: ^/_wdt/, role: IS_AUTHENTICATED_ANONYMOUSLY }
30
+#        - { path: ^/_profiler/, role: IS_AUTHENTICATED_ANONYMOUSLY }
31
+#        - { path: ^/js/, role: IS_AUTHENTICATED_ANONYMOUSLY }
32
+#        - { path: ^/css/, role: IS_AUTHENTICATED_ANONYMOUSLY }
33
+#        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
34
+#        - { path: ^/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
35
+#        - { path: ^/register$, role: IS_AUTHENTICATED_ANONYMOUSLY }
36
+#        - { path: ^/resseting$, role: IS_AUTHENTICATED_ANONYMOUSLY }
37
+#        
38
+#        # PAGES ACCESSIBLES AUX ADMINISTRATEURS
39
+#        - { path: ^/myapp/admin/, role: ROLE_ADMIN }
40
+#        
41
+#        # PAGES ACCESSIBLES AUX UTILISATEURS CONNECTES
42
+#        - { path: ^/myapp/change-password, role: ROLE_USER }
43
+#
44
+#        # PAGES ACCESSIBLES À TOUS
45
+#        - { path: ^/myapp.*, role: IS_AUTHENTICATED_ANONYMOUSLY }

+ 60 - 0
src/Muzich/UserBundle/DataFixtures/ORM/LoadUserData.php 파일 보기

@@ -0,0 +1,60 @@
1
+<?php
2
+
3
+namespace Muzich\UserBundle\DataFixtures\ORM;
4
+
5
+use Doctrine\Common\DataFixtures\FixtureInterface;
6
+use Muzich\CoreBundle\Entity\User;
7
+use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
8
+use Symfony\Component\DependencyInjection\ContainerAwareInterface;
9
+use Symfony\Component\DependencyInjection\ContainerInterface;
10
+
11
+class LoadUserData implements FixtureInterface, ContainerAwareInterface
12
+{
13
+  
14
+  private $container;
15
+  private $user_manager;
16
+  private $entity_manager;
17
+  
18
+  public function setContainer(ContainerInterface $container = null)
19
+  {
20
+    $this->container = $container;
21
+  }
22
+  
23
+  /**
24
+   * 
25
+   * 
26
+   * @param string $username
27
+   * @param string $email
28
+   * @param string $password_raw
29
+   * @param array $roles
30
+   * @return User 
31
+   */
32
+  protected function createUser($username, $email, $password_raw, $superadmin = false, $enabled = true)
33
+  {
34
+    
35
+    $user = $this->user_manager->createUser();
36
+    $user = new User();
37
+    $user->setUsername($username);
38
+    $user->setEmail($email);
39
+    $user->setSuperAdmin($superadmin);
40
+    $user->setAlgorithm('sha512');
41
+    
42
+    $user->setPlainPassword($password_raw);
43
+    $user->setEnabled($enabled);
44
+    $this->user_manager->updatePassword($user);
45
+    
46
+    $this->user_manager->updateUser($user, false);
47
+    $this->entity_manager->persist($user);
48
+  }
49
+  
50
+  public function load($entity_manager)
51
+  {
52
+    $this->entity_manager = $entity_manager;
53
+    $this->user_manager = $this->container->get('fos_user.user_manager');
54
+    
55
+    $this->createUser('admin', 'admin@root', 'toor');
56
+    $this->createUser('bux', 'bux@root', 'toor');
57
+
58
+    $this->entity_manager->flush();
59
+  }
60
+}

+ 1 - 0
vendor/bundles/Symfony/Bundle/DoctrineFixturesBundle

@@ -0,0 +1 @@
1
+Subproject commit 275e33be3ed4aa76afc21ff0aa5517b0e4795ba1

+ 1 - 0
vendor/doctrine-fixtures

@@ -0,0 +1 @@
1
+Subproject commit 4a8464ef83093de2378cef2770e13da7e4858ffc