1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6: */
7:
8: namespace Nette\DI\Extensions;
9:
10: use Nette;
11:
12:
13: /**
14: * Enables registration of other extensions in $config file
15: */
16: class ExtensionsExtension extends Nette\DI\CompilerExtension
17: {
18:
19: public function loadConfiguration()
20: {
21: foreach ($this->getConfig() as $name => $class) {
22: if (is_int($name)) {
23: $name = NULL;
24: }
25: if ($class instanceof Nette\DI\Statement) {
26: $rc = new \ReflectionClass($class->getEntity());
27: $this->compiler->addExtension($name, $rc->newInstanceArgs($class->arguments));
28: } else {
29: $this->compiler->addExtension($name, new $class);
30: }
31: }
32: }
33:
34: }
35: