Exemplo n.º 1
0
 /**
  * Returns an injection by name.
  *
  * @param string $name the injection name
  * @return Injection the injection
  * @throws InvalidInjectionException if the injection could not be loaded
  */
 public function getInjection($name)
 {
     $res = $this->loader->load(ucfirst($name), array($this->ioc));
     if ($res === null) {
         throw new InvalidInjectionException("Could not find injection {$name}");
     }
     return $res;
 }
Exemplo n.º 2
0
 /**
  * Tests the existence of extensions.
  *
  * @dataProvider existsProvider
  * @covers empire\framework\loader\ExtensionLoader::exists
  *
  * @param string $directory the directory
  * @param string $baseClass the base class or interface
  * @param string $baseNamespace the base namespace
  * @param string $baseName the base name
  * @param string $name the name of the extension to load
  * @param boolean $wrap whether to use wrap folders
  * @param $exists whether the extension exists
  */
 public function testExists($directory, $baseClass, $baseNamespace, $baseName, $name, $wrap, $exists)
 {
     $loader = new ExtensionLoader($directory, $baseClass, $baseNamespace, $baseName, $wrap);
     $this->assertSame($exists, $loader->exists($name));
 }
Exemplo n.º 3
0
 /**
  * Parses a construct.
  *
  * This function loads the language construct and (if found) parses the arguments for it. If the
  * construct is not found, it will be ignored. If it is found, but the arguments are invalid, a
  * warning message will be returned instead.
  *
  * @param string $name the name of the construct
  * @param string $arguments the arguments
  * @param string $source the name of the source variable
  * @return string the parsed construct
  */
 private function parseLanguageConstruct($name, $arguments, $source)
 {
     $extensionID = ucfirst(strtolower($name));
     $construct = $this->loader->load($extensionID);
     /* @var $construct EmpireTemplateLanguageConstruct */
     if ($construct !== null) {
         if ($construct->isValid($arguments)) {
             return $construct->parse($arguments, $source);
         } else {
             return 'echo "!!!MALFORMED COMMAND {' . "{$name} {$arguments}" . '}!!!";';
         }
     }
 }