Skip to content

Commit 28ea437

Browse files
author
Wazabii
committed
Shortcut to container
1 parent ab9cc4f commit 28ea437

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

SwiftRender.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
use PHPFuse\DTO\Format\Str;
1616
use PHPFuse\DTO\Traverse;
17-
use PHPFuse\Output\Dom\Document;
18-
use PHPFuse\Output\Dom\Element;
17+
//use PHPFuse\Output\Dom\Document;
18+
//use PHPFuse\Output\Dom\Element;
1919

2020
class SwiftRender {
2121

@@ -43,6 +43,23 @@ function __construct() {
4343

4444
}
4545

46+
47+
/**
48+
* This will make shortcuts to container.
49+
* @param string $m [description]
50+
* @param string $a [description]
51+
* @return ContainerInterface
52+
*/
53+
function __call($m, $a) {
54+
if(!is_null($this->container)) {
55+
if($this->container->has($m)) {
56+
return $this->container->get($m, $a);
57+
} else {
58+
throw new BadMethodCallException('The method "'.$m.'" does not exist in the Container or the Class "'.static::class.'"!', 1);
59+
}
60+
}
61+
}
62+
4663
/**
4764
* Pass a container class instance of ContainerInterface, that can be used with in your templates
4865
* @param ContainerInterface $container

0 commit comments

Comments
 (0)