1: <?php
2:
3: 4: 5: 6:
7:
8: namespace Nette\DI\Extensions;
9:
10: use Nette;
11:
12:
13: 14: 15:
16: class NetteAccessor extends Nette\Object
17: {
18: private $container;
19:
20:
21: public function __construct(Nette\DI\Container $container)
22: {
23: $this->container = $container;
24: }
25:
26:
27: public function __call($name, $args)
28: {
29: if (substr($name, 0, 6) === 'create') {
30: $method = $this->container->getMethodName('nette.' . substr($name, 6));
31: trigger_error("Factory accessing via nette->$name() is deprecated, use $method().", E_USER_DEPRECATED);
32: return call_user_func_array(array($this->container, $method), $args);
33: }
34: throw new Nette\NotSupportedException;
35: }
36:
37:
38: public function &__get($name)
39: {
40: trigger_error("Service accessing via nette->$name is deprecated, use 'nette.$name'.", E_USER_DEPRECATED);
41: $service = $this->container->getService("nette.$name");
42: return $service;
43: }
44:
45: }
46: