瀏覽代碼

Moved titleMode to pool options

Hugo Briand 11 年之前
父節點
當前提交
116c9adcf6

+ 1 - 13
Admin/Pool.php

@@ -31,23 +31,19 @@ class Pool
 
     protected $titleLogo;
 
-    protected $titleMode;
-
     protected $options;
 
     /**
      * @param ContainerInterface $container
      * @param string             $title
      * @param string             $logoTitle
-     * @param string             $titleMode
      * @param array              $options
      */
-    public function __construct(ContainerInterface $container, $title, $logoTitle, $titleMode = "both", $options = array())
+    public function __construct(ContainerInterface $container, $title, $logoTitle, $options = array())
     {
         $this->container = $container;
         $this->title     = $title;
         $this->titleLogo = $logoTitle;
-        $this->titleMode = $titleMode;
         $this->options   = $options;
     }
 
@@ -311,14 +307,6 @@ class Pool
         return $this->title;
     }
 
-    /**
-     * @return string
-     */
-    public function getTitleMode()
-    {
-        return $this->titleMode;
-    }
-
     /**
      * @param string $name
      * @param mixed  $default

+ 5 - 5
DependencyInjection/Configuration.php

@@ -71,11 +71,6 @@ class Configuration implements ConfigurationInterface
 
                 ->scalarNode('title')->defaultValue('Sonata Admin')->cannotBeEmpty()->end()
                 ->scalarNode('title_logo')->defaultValue('bundles/sonataadmin/logo_title.png')->cannotBeEmpty()->end()
-                ->enumNode('title_mode')
-                    ->values(array('single_text', 'single_image', 'both'))
-                    ->defaultValue('both')
-                    ->cannotBeEmpty()
-                ->end()
                 ->arrayNode('options')
                     ->addDefaultsIfNotSet()
                     ->children()
@@ -85,6 +80,11 @@ class Configuration implements ConfigurationInterface
                         ->integerNode('pager_links')->defaultValue(null)->end()
                         ->scalarNode('form_type')->defaultValue('standard')->end()
                         ->integerNode('dropdown_number_groups_per_colums')->defaultValue(2)->end()
+                        ->enumNode('title_mode')
+                            ->values(array('single_text', 'single_image', 'both'))
+                            ->defaultValue('both')
+                            ->cannotBeEmpty()
+                        ->end()
                     ->end()
                 ->end()
                 ->arrayNode('dashboard')

+ 1 - 2
DependencyInjection/SonataAdminExtension.php

@@ -83,8 +83,7 @@ BOOM
         $pool = $container->getDefinition('sonata.admin.pool');
         $pool->replaceArgument(1, $config['title']);
         $pool->replaceArgument(2, $config['title_logo']);
-        $pool->replaceArgument(3, $config['title_mode']);
-        $pool->replaceArgument(4, $config['options']);
+        $pool->replaceArgument(3, $config['options']);
 
         $container->setParameter('sonata.admin.configuration.templates', $config['templates']);
         $container->setParameter('sonata.admin.configuration.admin_services', $config['admin_services']);

+ 1 - 1
Resources/doc/reference/configuration.rst

@@ -55,13 +55,13 @@ Full Configuration Options
                 acl_user_manager:     ~         # Name of the user manager service used to retrieve ACL users
             title:                Sonata Admin
             title_logo:           bundles/sonataadmin/logo_title.png
-            title_mode:           'both'            # 'both', 'single_text' or 'single_image'
             options:
                 html5_validate:                         true      # use html5 validation
                 confirm_exit:                           true      # enabled confirmation when quitting with unsaved changes
                 use_select2:                            true      # enable select2
                 pager_links:                            ~         # pager max links to display
                 dropdown_number_groups_per_colums:      2         # max items per column in dropdown menu (add button in top nav)
+                title_mode:           'both'                      # 'both', 'single_text' or 'single_image'
             dashboard:
                 groups:
 

+ 3 - 3
Resources/views/standard_layout.html.twig

@@ -77,10 +77,10 @@ file that was distributed with this source code.
         <header class="header">
             {% block logo %}
                 <a class="logo" href="{{ url('sonata_admin_dashboard') }}">
-                    {% if 'single_image' == admin_pool.titleMode or 'both' == admin_pool.titleMode %}
-                        <img src="{{ asset(admin_pool.titlelogo) }}" alt="{{ admin_pool.title }}">{% if 'both' == admin_pool.titleMode %}&nbsp;{% endif %}
+                    {% if 'single_image' == admin_pool.getOption('title_mode') or 'both' == admin_pool.getOption('title_mode') %}
+                        <img src="{{ asset(admin_pool.titlelogo) }}" alt="{{ admin_pool.title }}">{% if 'both' == admin_pool.getOption('title_mode') %}&nbsp;{% endif %}
                     {% endif %}
-                    {% if 'single_text' == admin_pool.titleMode or 'both' == admin_pool.titleMode %}
+                    {% if 'single_text' == admin_pool.getOption('title_mode') or 'both' == admin_pool.getOption('title_mode') %}
                         {{ admin_pool.title }}
                     {% endif %}
                 </a>

+ 1 - 1
Tests/Admin/PoolTest.php

@@ -22,7 +22,7 @@ class PoolTest extends \PHPUnit_Framework_TestCase
 
     public function setUp()
     {
-        $this->pool = new Pool($this->getContainer(), 'Sonata Admin', '/path/to/pic.png', 'both', array('foo'=>'bar'));
+        $this->pool = new Pool($this->getContainer(), 'Sonata Admin', '/path/to/pic.png', array('foo'=>'bar'));
     }
 
     public function testGetGroups()