فهرست منبع

Changed direct call of container get method to getInstance. Added isset check to make testing possible.

Leszek 13 سال پیش
والد
کامیت
507a3cca1e
2فایلهای تغییر یافته به همراه7 افزوده شده و 5 حذف شده
  1. 5 4
      Admin/Pool.php
  2. 2 1
      Tests/Admin/PoolTest.php

+ 5 - 4
Admin/Pool.php

@@ -46,9 +46,10 @@ class Pool
         $groups = $this->adminGroups;
 
         foreach ($this->adminGroups as $name => $adminGroup) {
-
-            foreach ($adminGroup['items'] as $key => $id) {
-                $groups[$name]['items'][$key] = $this->container->get($id);
+            if (isset($adminGroup['items'])) {
+                foreach ($adminGroup['items'] as $key => $id) {
+                    $groups[$name]['items'][$key] = $this->getInstance($id);
+                }
             }
 
             if (empty($groups[$name])) {
@@ -141,4 +142,4 @@ class Pool
     {
         return $this->adminClasses;
     }
-}
+}

+ 2 - 1
Tests/Admin/PoolTest.php

@@ -45,7 +45,8 @@ class PoolTest extends \PHPUnit_Framework_TestCase
         $this->pool->setAdminGroups(array(
             'adminGroup1' => array(
                 'items' => array('itemKey' => 'sonata.user.admin.group1')
-            )
+            ),
+            'adminGroup2' => array()
         ));
 
         $expectedOutput = array(