| | |
| | | |
| | | namespace SIPL\UCRM\wFirma; |
| | | |
| | | use Ubnt\UcrmPluginSdk\Service\UcrmOptionsManager; |
| | | |
| | | class UcrmHelper { |
| | | protected string $rootDirectory; |
| | | protected ?\Ubnt\UcrmPluginSdk\Service\UcrmApi $api = NULL; |
| | |
| | | |
| | | function __construct(?string $rootDirectory = NULL) { |
| | | if ($rootDirectory === NULL) { |
| | | $rootDirectory = __DIR__ . '/..'; |
| | | $rootDirectory = dirname(__DIR__); |
| | | } |
| | | $this->rootDirectory = $rootDirectory; |
| | | } |
| | |
| | | return $this->api; |
| | | } |
| | | |
| | | function getSelfUrl(): string { |
| | | $ucrmOptionsManager = new UcrmOptionsManager($this->rootDirectory); |
| | | $options = $ucrmOptionsManager->loadOptions(); |
| | | return $options->ucrmLocalUrl ?? $options->ucrmPublicUrl ?? ''; |
| | | } |
| | | |
| | | function getAttributes(): UcrmAttributes { |
| | | if ($this->attributes === NULL) { |
| | | $this->attributes = new UcrmAttributes($this); |