Skip to content

Commit

Permalink
#382 - Support for PHP namespaces in tag libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
maraf committed Dec 13, 2021
1 parent 9bd8eef commit a56735a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/app/scripts/php/classes/LibraryDefinition.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

class LibraryDefinition {
private $prefix;
private $className;
private $xmlPath;
private $xml;

Expand All @@ -27,6 +28,17 @@ public function triggerFail($message, $errorType = E_USER_WARNING) {
return false;
}

public function getClassName() {
if (!$this->className) {
$this->className = basename($this->xmlPath, ".xml");
if ($this->xml->namespace) {
$this->className = $this->xml->namespace . "\\" . $this->className;
}
}

return $this->className;
}

public function isDisposable() {
return isset($this->xml->disposable);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/scripts/php/libs/PhpRuntime.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function register($tagPrefix, $classPath, $params = []) {
$xmlPath = $this->libraryLoader->getXmlPath($classPath);
$library = $this->libraries->add($tagPrefix, $xmlPath);
if ($this->isCountOfInstances($classPath, $library)) {
$className = $this->libraryLoader->getClassName($classPath);
$className = $library->getClassName($classPath);
$GLOBALS[$tagPrefix . "Object"] = new $className($tagPrefix, $params);
$this->addInstanceToCounter($classPath);

Expand Down

0 comments on commit a56735a

Please sign in to comment.