PluginProbe
Tableberg – Simple Gutenberg Table Block / 0.3.3
Tableberg – Simple Gutenberg Table Block v0.3.3
1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 trunk 0.0.2 0.2.1 0.3.2 0.3.3 0.4.1 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 All 42 releases
tableberg / includes / traits / Manager_Base_Trait.php

Manager_Base_Trait.php in Tableberg – Simple Gutenberg Table Block 0.3.3, at includes/traits/Manager_Base_Trait.php

68 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Manager trait.
4 *
5 * @package Tableberg
6 */
7
8 namespace Tableberg\includes\traits;
9
10 require_once TABLEBERG_DIR_PATH . 'includes/traits/Singleton_Trait.php';
11
12 /**
13 * Manager base trait.
14 */
15 trait Manager_Base_Trait {
16 use Singleton_Trait;
17
18 /**
19 * Initialization status for manager base.
20 *
21 * @var bool
22 */
23 protected static $initialized = false;
24
25 /**
26 * Is manager initialized.
27 *
28 * @return bool initialization status
29 */
30 public static function is_initialized() {
31 return static::$initialized;
32 }
33
34 /**
35 * Set current manager base as initialized.
36 *
37 * @return void
38 */
39 protected static function set_as_initialized() {
40 static::$initialized = true;
41 }
42
43 /**
44 * Main process that will be called during initialization of manager.
45 *
46 * @return void
47 */
48 abstract protected function init_process();
49
50 /**
51 * Initialize manager.
52 *
53 * Since this base is using singleton trait and abstract class together, you should provide class name of extended manager in init function.
54 *
55 * @param array $const_args constructor arguments for singleton instance of manager.
56 * @param string|null $class_name class name to create instance.
57 *
58 * @return void
59 */
60 final public static function init( $const_args = array(), $class_name = null ) {
61 if ( ! static::is_initialized() ) {
62 static::create_instance( $const_args, $class_name );
63 static::$instance->init_process();
64 static::set_as_initialized();
65 }
66 }
67 }
68