Procházet zdrojové kódy

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

Leszek před 13 roky
rodič
revize
507a3cca1e
2 změnil soubory, kde provedl 7 přidání a 5 odebrání
  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(