]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Don not use data description and data dependencies modules initialization
authorMarcin Haba <marcin.haba@bacula.pl>
Mon, 12 Aug 2019 04:39:12 +0000 (06:39 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Sat, 14 Dec 2019 14:55:58 +0000 (15:55 +0100)
gui/baculum/protected/Web/Class/DataDependencies.php
gui/baculum/protected/Web/Class/DataDescription.php

index 4f59f50bb08e9fccb02cac259ae3983939f47956..4c11fd4a39cfcad6312f83987ec83a26299a2985 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
@@ -32,11 +32,13 @@ class DataDependencies extends WebModule {
         */
        const DATA_DEPS_FILE = 'Application.Web.Data.data_deps';
 
-       private $data_deps;
+       private static $data_deps = null;
 
-       public function init($config) {
-               parent::init($config);
-               $this->data_deps = $this->loadDataDependencies();
+       private function getDataDeps() {
+               if (is_null(self::$data_deps)) {
+                       self::$data_deps = $this->loadDataDependencies();
+               }
+               return self::$data_deps;
        }
 
        /**
@@ -72,8 +74,9 @@ class DataDependencies extends WebModule {
         */
        private function getDependencies($component_type, $resource_type) {
                $deps = null;
-               if (isset($this->data_deps->{$component_type}->{$resource_type})) {
-                       $deps = (array)$this->data_deps->{$component_type}->{$resource_type};
+               $data_deps = $this->getDataDeps();
+               if (isset($data_deps->{$component_type}->{$resource_type})) {
+                       $deps = (array)$data_deps->{$component_type}->{$resource_type};
                }
                return $deps;
        }
index 3bb93d087b9ba9550c52ded0a6909d8ecfbcee36..31006a6fa5c2f176dcf85d45064d99f36b2dbd85 100644 (file)
@@ -3,7 +3,7 @@
  * Bacula(R) - The Network Backup Solution
  * Baculum   - Bacula web interface
  *
- * Copyright (C) 2013-2016 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
  *
  * The main author of Baculum is Marcin Haba.
  * The original author of Bacula is Kern Sibbald, with contributions
@@ -29,11 +29,13 @@ class DataDescription extends WebModule {
         */
        const DATA_DESC_FILE = 'Application.Web.Data.data_desc';
 
-       private $data_desc;
+       private static $data_desc = null;
 
-       public function init($config) {
-               parent::init($config);
-               $this->data_desc = $this->loadDataDescription();
+       private function getDataDesc() {
+               if (is_null(self::$data_desc)) {
+                       self::$data_desc = $this->loadDataDescription();
+               }
+               return self::$data_desc;
        }
 
        private function loadDataDescription() {
@@ -48,12 +50,14 @@ class DataDescription extends WebModule {
 
        public function getDescription($component_type, $resource_type, $directive_name = null) {
                $desc = null;
-               if (!is_null($directive_name) && isset($this->data_desc->{$component_type}->{$resource_type}->{$directive_name})) {
-                       $desc = $this->data_desc->{$component_type}->{$resource_type}->{$directive_name};
-               } elseif (isset($this->data_desc->{$component_type}->{$resource_type})) {
-                       $desc = (array)$this->data_desc->{$component_type}->{$resource_type};
+               $data_desc = $this->getDataDesc();
+               if (!is_null($directive_name) && isset($data_desc->{$component_type}->{$resource_type}->{$directive_name})) {
+                       $desc = $data_desc->{$component_type}->{$resource_type}->{$directive_name};
+               } elseif (isset($data_desc->{$component_type}->{$resource_type})) {
+                       $desc = (array)$data_desc->{$component_type}->{$resource_type};
                }
                return $desc;
        }
+
 }
 ?>