Jelajahi Sumber

Merge branch 'master' of http://github.com/sonata-project/SonataAdminBundle

Luis Cordova 13 tahun lalu
induk
melakukan
3e4d96eef2

+ 16 - 0
.travis.yml

@@ -0,0 +1,16 @@
+language: php
+php:
+  - 5.3
+  # - 5.4
+  
+env:
+  - SYMFONY_VERSION=v2.0.0
+  - SYMFONY_VERSION=v2.0.1
+  # - SYMFONY_VERSION=v2.0.2 # broken tag
+  - SYMFONY_VERSION=v2.0.3
+  - SYMFONY_VERSION=v2.0.4
+  - SYMFONY_VERSION=v2.0.5
+  - SYMFONY_VERSION=origin/master
+
+before_script: php Tests/tests/vendors.php
+script: phpunit

+ 35 - 0
Admin/AdminInterface.php

@@ -164,4 +164,39 @@ interface AdminInterface
      * @return string
      * @return string
      */
      */
     function getRouterIdParameter();
     function getRouterIdParameter();
+
+    /**
+     * add a FieldDescription
+     *
+     * @param string $name
+     * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
+     * @return void
+     */
+     function addShowFieldDescription($name, FieldDescriptionInterface $fieldDescription);
+
+    /**
+     * add a list FieldDescription
+     *
+     * @param string $name
+     * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
+     * @return void
+     */
+     function addListFieldDescription($name, FieldDescriptionInterface $fieldDescription);
+
+    /**
+     * add a filter FieldDescription
+     *
+     * @param string $name
+     * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
+     * @return void
+     */
+    function addFilterFieldDescription($name, FieldDescriptionInterface $fieldDescription);
+
+
+    /**
+     * Returns a list depend on the given $object
+     *
+     * @return \Sonata\AdminBundle\Admin\FieldDescriptionCollection
+     */
+    function getList();
 }
 }

+ 7 - 2
README.md

@@ -5,6 +5,9 @@ The online documentation of the bundle is in http://sonata-project.org/bundles/a
 
 
 For contribution to the documentation you cand find it on [Resources/doc](https://github.com/sonata-project/SonataAdminBundle/tree/master/Resources/doc).
 For contribution to the documentation you cand find it on [Resources/doc](https://github.com/sonata-project/SonataAdminBundle/tree/master/Resources/doc).
 
 
+**Warning**: documentation files are not rendering correctly in Github (reStructuredText format)
+and some content might be broken or hidden, make sure to read raw files.
+
 **Warning**: The bundle has been split into 4 bundles :
 **Warning**: The bundle has been split into 4 bundles :
 
 
 * SonataAdminBundle : the current one, contains core librairies and services
 * SonataAdminBundle : the current one, contains core librairies and services
@@ -15,8 +18,10 @@ For contribution to the documentation you cand find it on [Resources/doc](https:
 * [SonataDoctrinePhpcrAdminBundle](https://github.com/sonata-project/SonataDoctrinePhpcrAdminBundle) 
 * [SonataDoctrinePhpcrAdminBundle](https://github.com/sonata-project/SonataDoctrinePhpcrAdminBundle) 
 : Integrates the admin bundle into with PHPCR (early stage)
 : Integrates the admin bundle into with PHPCR (early stage)
 
 
-**Warning**: documentation files are not rendering correctly in Github (reStructuredText format)
-and some content might be broken or hidden, make sure to read raw files.
+**Google Groups**: For questions and proposals you can post on this google groups
+
+* [Sonata Users](https://groups.google.com/group/sonata-users): Only for user questions
+* [Sonata Devs](https://groups.google.com/group/sonata-devs): Only for devs
 
 
 Quick example
 Quick example
 -------------
 -------------

+ 8 - 2
Resources/doc/index.rst

@@ -8,11 +8,17 @@ Welcome to Sonata - Doctrine ORM Admin's documentation!
 
 
 The ``Doctrine ORM Admin`` provides services to work with the ``Admin Bundle`` and the ``Doctrine Project``.
 The ``Doctrine ORM Admin`` provides services to work with the ``Admin Bundle`` and the ``Doctrine Project``.
 
 
-**Warning**: The bundle has been split into 2 bundles :
+**Warning**: The bundle has been split into 4 bundles :
 
 
 * SonataAdminBundle : the current one, contains core librairies and services
 * SonataAdminBundle : the current one, contains core librairies and services
-* SonataDoctrineORMAdminBundle : Integrates the admin bundle into with the Doctrine ORM project
+* `SonataDoctrineORMAdminBundle <https://github.com/sonata-project/SonataDoctrineORMAdminBundle>`_: Integrates the admin bundle into with the Doctrine ORM project
+* `SonataDoctrineMongoDBAdminBundle <https://github.com/sonata-project/SonataDoctrineMongoDBAdminBundle>`_: Integrates the admin bundle into with MongoDB (early stage)
+* `SonataDoctrinePhpcrAdminBundle <https://github.com/sonata-project/SonataDoctrinePhpcrAdminBundle>`_: Integrates the admin bundle into with PHPCR (early stage)
 
 
+**Google Groups**: For questions and proposals you can post on this google groups
+
+* `Sonata Users <https://groups.google.com/group/sonata-users>`_: Only for user questions
+* `Sonata Devs <https://groups.google.com/group/sonata-devs>`_: Only for devs
 
 
 Reference Guide
 Reference Guide
 ---------------
 ---------------

+ 26 - 7
Resources/doc/reference/installation.rst

@@ -11,10 +11,6 @@ the following lines to the file ``deps``::
       git=http://github.com/sonata-project/SonatajQueryBundle.git
       git=http://github.com/sonata-project/SonatajQueryBundle.git
       target=/bundles/Sonata/jQueryBundle
       target=/bundles/Sonata/jQueryBundle
 
 
-  [SonataUserBundle]
-      git=http://github.com/sonata-project/SonataUserBundle.git
-      target=/bundles/Sonata/UserBundle
-
   [SonataAdminBundle]
   [SonataAdminBundle]
       git=http://github.com/sonata-project/SonataAdminBundle.git
       git=http://github.com/sonata-project/SonataAdminBundle.git
       target=/bundles/Sonata/AdminBundle
       target=/bundles/Sonata/AdminBundle
@@ -43,8 +39,8 @@ files:
   // app/autoload.php
   // app/autoload.php
   $loader->registerNamespaces(array(
   $loader->registerNamespaces(array(
       // ...
       // ...
-      'Sonata'                         => __DIR__.'/../vendor/bundles',
-      'Knp'                             => array(
+      'Sonata' => __DIR__.'/../vendor/bundles',
+      'Knp'    => array(
           __DIR__.'/../vendor/bundles',
           __DIR__.'/../vendor/bundles',
           __DIR__.'/../vendor/knp/menu/src',
           __DIR__.'/../vendor/knp/menu/src',
       ),
       ),
@@ -89,4 +85,27 @@ At this point you can access to the dashboard with the url:
     the above configuration and routing will actually be placed in those
     the above configuration and routing will actually be placed in those
     files, with the correct format (i.e. XML or PHP).
     files, with the correct format (i.e. XML or PHP).
 
 
-The last important step is security, please refer to the dedicated section.
+The last important step is security, please refer to the dedicated section.
+
+Users management
+----------------
+
+By default, the AdminBundle does not come with any user management, however it is most likely the application
+requires such feature. The Sonata Project includes a ``SonataUserBundle`` which integrates the ``FOSUserBundle``.
+
+The ``FOSUserBundle`` adds support for a database-backed user system in Symfony2. It provides a flexible framework
+for user management that aims to handle common tasks such as user login, registration and password retrieval.
+
+The ``SonataUserBundle`` is just a thin wrapper to include the ``FOSUserBundle`` into the ``AdminBundle``. The
+``SonataUserBundle`` includes :
+
+* A default login area
+* A default ``user_block`` template which is used to display the current user and the logout link
+* 2 Admin class : User and Group
+* A default class for User and Group.
+
+There is a little magic in the ``SonataAdminBundle`` if the bundle detects the ``SonataUserBundle`` class, then
+the default ``user_block`` template will be changed to use the one provided by the ``SonataUserBundle``.
+
+The install process is available on the dedicated `SonataUserBundle's documentation area <http://sonata-project.org/bundles/user/master/doc/reference/installation.html>`_
+

Resources/views/Core/user_blog.html.twig → Resources/views/Core/user_block.html.twig


+ 2 - 2
Tests/Admin/PoolTest.php

@@ -22,7 +22,7 @@ class PoolTest extends \PHPUnit_Framework_TestCase
 
 
     public function setUp()
     public function setUp()
     {
     {
-        $this->pool = new Pool($this->getContainer());
+        $this->pool = new Pool($this->getContainer(), 'Sonata Admin', '/path/to/pic.png');
     }
     }
 
 
     public function testGetGroups()
     public function testGetGroups()
@@ -93,7 +93,7 @@ class PoolTest extends \PHPUnit_Framework_TestCase
             ->method('get')
             ->method('get')
             ->will($this->returnValue($adminMock));
             ->will($this->returnValue($adminMock));
 
 
-        $this->pool = new Pool($containerMock);
+        $this->pool = new Pool($containerMock, 'Sonata', '/path/to/logo.png');
 
 
         $this->assertEquals('commentAdminClass', $this->pool->getAdminByAdminCode('sonata.news.admin.post|sonata.news.admin.comment'));
         $this->assertEquals('commentAdminClass', $this->pool->getAdminByAdminCode('sonata.news.admin.post|sonata.news.admin.comment'));
     }
     }

+ 25 - 0
Tests/tests/autoload.php.dist

@@ -0,0 +1,25 @@
+<?php
+
+$vendorDir = __DIR__.'/../../vendor';
+require_once $vendorDir.'/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
+
+use Symfony\Component\ClassLoader\UniversalClassLoader;
+
+$loader = new UniversalClassLoader();
+$loader->registerNamespaces(array(
+    'Symfony'  => array($vendorDir.'/symfony/src'),
+    'Knp'      => array($vendorDir.'/knpmenu/src'),
+));
+$loader->register();
+
+spl_autoload_register(function($class) {
+    if (0 === strpos($class, 'Sonata\\AdminBundle\\')) {
+        $path = __DIR__.'/../../'.implode('/', array_slice(explode('\\', $class), 2)).'.php';
+        
+        if (!stream_resolve_include_path($path)) {
+            return false;
+        }
+        require_once $path;
+        return true;
+    }
+});

+ 5 - 4
Tests/tests/bootstrap.php

@@ -9,7 +9,8 @@
  * file that was distributed with this source code.
  * file that was distributed with this source code.
  */
  */
 
 
-$rootDir = __DIR__.'/../../../../../../';
-
-require_once $rootDir.'/vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
-require_once $rootDir.'/app/autoload.php';
+if (file_exists($file = __DIR__.'/autoload.php')) {
+    require_once $file;
+} elseif (file_exists($file = __DIR__.'/autoload.php.dist')) {
+    require_once $file;
+}

+ 27 - 0
Tests/tests/vendors.php

@@ -0,0 +1,27 @@
+#!/usr/bin/env php
+<?php
+
+set_time_limit(0);
+
+$vendorDir = __DIR__.'/../../vendor';
+if (!is_dir($vendorDir)) {
+  mkdir($vendorDir);
+}
+
+$deps = array(
+    array('symfony', 'git://github.com/symfony/symfony.git', isset($_SERVER['SYMFONY_VERSION']) ? $_SERVER['SYMFONY_VERSION'] : 'origin/master'),
+    array('knpmenu', 'git://github.com/knplabs/KnpMenu.git', 'origin/master')
+);
+
+foreach ($deps as $dep) {
+    list($name, $url, $rev) = $dep;
+
+    echo "> Installing/Updating $name\n";
+
+    $installDir = $vendorDir.'/'.$name;
+    if (!is_dir($installDir)) {
+        system(sprintf('git clone --quiet %s %s', escapeshellarg($url), escapeshellarg($installDir)));
+    }
+
+    system(sprintf('cd %s && git fetch origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($rev)));
+}