Selaa lähdekoodia

Mise ne place du ElementAdmin.php

bastien 13 vuotta sitten
vanhempi
commit
dcd3ea03c0

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

@@ -20,11 +20,14 @@ class AppKernel extends Kernel
20 20
             new FOS\UserBundle\FOSUserBundle(),
21 21
             new Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle(),
22 22
             new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
23
+            new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
24
+            new WhiteOctober\AdminBundle\WhiteOctoberAdminBundle(),
23 25
             new Muzich\CoreBundle\MuzichCoreBundle(),
24 26
             new Muzich\UserBundle\MuzichUserBundle(),
25 27
             new Muzich\IndexBundle\MuzichIndexBundle(),
26 28
             new Muzich\HomeBundle\MuzichHomeBundle(),
27 29
             new Muzich\MynetworkBundle\MuzichMynetworkBundle(),
30
+            new Muzich\AdminBundle\MuzichAdminBundle(),
28 31
         );
29 32
 
30 33
         if (in_array($this->getEnvironment(), array('dev', 'test'))) {

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

@@ -20,6 +20,8 @@ $loader->registerNamespaces(array(
20 20
     'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
21 21
     'Stof'  => __DIR__.'/../vendor/bundles',
22 22
     'Gedmo' => __DIR__.'/../vendor/gedmo-doctrine-extensions/lib',
23
+    'WhiteOctober' => __DIR__.'/../vendor/bundles',
24
+    'Pagerfanta'   => __DIR__.'/../vendor/pagerfanta/src',
23 25
 ));
24 26
 $loader->registerPrefixes(array(
25 27
     'Twig_Extensions_' => __DIR__.'/../vendor/twig-extensions/lib',

+ 9 - 0
app/config/routing.yml Näytä tiedosto

@@ -5,6 +5,15 @@
5 5
 #   resource: "@FrameworkBundle/Resources/config/routing/internal.xml"
6 6
 #   prefix:   /_internal
7 7
   
8
+_white_october_admin:
9
+    resource: .
10
+    type: white_october_admin
11
+
12
+white_october_admin:
13
+    resource: "@WhiteOctoberAdminBundle/Resources/config/routing/admin.xml"
14
+
15
+  
16
+  
8 17
 MuzichIndexBundle:
9 18
   resource: "@MuzichIndexBundle/Resources/config/routing.yml"
10 19
   prefix: /

+ 33 - 0
src/Muzich/AdminBundle/Admin/ElementAdmin.php Näytä tiedosto

@@ -0,0 +1,33 @@
1
+<?php
2
+
3
+namespace Muzich\AdminBundle\Admin;
4
+
5
+use WhiteOctober\AdminBundle\Admin\Admin;
6
+
7
+class ElementAdmin extends Admin
8
+{
9
+  
10
+  protected function configure()
11
+  {
12
+    $this
13
+      // model class to admin
14
+      ->setDataClass('MuzichCoreBundle\Entity\Element')
15
+      // optional, if not the admin class urlized
16
+      ->setRoutePatternPrefix('/admin/elements')
17
+      // optional, if not the admin class urlized
18
+      ->setRouteNamePrefix('admin_elements')
19
+      // fields to use
20
+      ->addFields(array(
21
+          'name',
22
+          'url'
23
+      ))
24
+      // actions the admin has
25
+      ->addActions(array(
26
+          'mandango.crud',
27
+      ))
28
+    ;
29
+  }
30
+  
31
+}
32
+
33
+?>

+ 15 - 0
src/Muzich/AdminBundle/Controller/DefaultController.php Näytä tiedosto

@@ -0,0 +1,15 @@
1
+<?php
2
+
3
+namespace Muzich\AdminBundle\Controller;
4
+
5
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
+
7
+
8
+class DefaultController extends Controller
9
+{
10
+    
11
+    public function indexAction($name)
12
+    {
13
+        return $this->render('MuzichAdminBundle:Default:index.html.twig', array('name' => $name));
14
+    }
15
+}

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

@@ -0,0 +1,29 @@
1
+<?php
2
+
3
+namespace Muzich\AdminBundle\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_admin');
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/AdminBundle/DependencyInjection/MuzichAdminExtension.php Näytä tiedosto

@@ -0,0 +1,28 @@
1
+<?php
2
+
3
+namespace Muzich\AdminBundle\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 MuzichAdminExtension 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\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
26
+        $loader->load('services.yml');
27
+    }
28
+}

+ 10 - 0
src/Muzich/AdminBundle/MuzichAdminBundle.php Näytä tiedosto

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

+ 3 - 0
src/Muzich/AdminBundle/Resources/config/routing.yml Näytä tiedosto

@@ -0,0 +1,3 @@
1
+MuzichAdminBundle_homepage:
2
+    pattern:  /hello/{name}
3
+    defaults: { _controller: MuzichAdminBundle:Default:index }

+ 7 - 0
src/Muzich/AdminBundle/Resources/config/services.yml Näytä tiedosto

@@ -0,0 +1,7 @@
1
+parameters:
2
+#    muzich_admin.example.class: Muzich\AdminBundle\Example
3
+
4
+services:
5
+#    muzich_admin.example:
6
+#        class: %muzich_admin.example.class%
7
+#        arguments: [@service_id, "plain_value", %parameter%]

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


+ 11 - 0
src/Muzich/AdminBundle/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/AdminBundle/Resources/views/Default/index.html.twig Näytä tiedosto

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

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

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+namespace Muzich\AdminBundle\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
+}