Skip to content

Commit a3ea827

Browse files
load bundles from file (#154)
1 parent 13c8648 commit a3ea827

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/HttpKernel/TestKernel.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,29 @@ public function getLogDir()
210210
'logs',
211211
]);
212212
}
213+
214+
/**
215+
* Registers the bundles defined in config/bundles.php.
216+
*/
217+
protected function registerConfiguredBundles()
218+
{
219+
$bundleFilePath = $this->getKernelDir().'/config/bundles.php';
220+
if (!file_exists($bundleFilePath)) {
221+
return;
222+
}
223+
224+
$bundles = require $bundleFilePath;
225+
foreach ($bundles as $class => $environments) {
226+
if (isset($environments['all']) || isset($environments[$this->environment])) {
227+
if (!class_exists($class)) {
228+
throw new \InvalidArgumentException(sprintf(
229+
'Bundle class "%s" does not exist.',
230+
$class
231+
));
232+
}
233+
234+
$this->requiredBundles[$class] = new $class();
235+
}
236+
}
237+
}
213238
}

0 commit comments

Comments
 (0)