PluginProbe
Gianism / trunk
Gianism vtrunk
4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.4.0 5.0.0 5.0.1 5.0.2 5.1.0 5.2.1 5.2.2 5.3.0 6.0.0 6.0.1 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 All 65 releases
gianism / app / Gianism / Pattern / AppBase.php

AppBase.php in Gianism trunk, at app/Gianism/Pattern/AppBase.php

74 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Gianism\Pattern;
4
5 use Gianism\Controller\Network;
6 use Gianism\Controller\ProfileChecker;
7 use Gianism\Helper\MessageHelper;
8 use Gianism\Helper\i18n;
9 use Gianism\Helper\Option;
10 use Gianism\Helper\Input;
11 use Gianism\Helper\ServiceManager;
12 use Gianism\Helper\Session;
13
14 /**
15 * Application base trait
16 * @package Gianism
17 * @property \wpdb $db Database controller
18 * @property string $url Base URL of plugin.
19 * @property string $dir Base directory of plugin.
20 * @property Option $option Option instance.
21 * @property Session $session Session instance
22 * @property Input $input Input instance.
23 * @property ServiceManager $service ServiceManager instance
24 * @property ProfileChecker $profile_checker Profile checker instance
25 * @property Network $network Network controller
26 */
27 trait AppBase {
28
29 use i18n;
30 use MessageHelper;
31
32 protected $name = 'gianism';
33
34 /**
35 * Version number
36 *
37 * @var string
38 */
39 protected $version = \GIANISM_VERSION;
40
41 /**
42 * Getter
43 *
44 * @param string $name
45 *
46 * @return mixed
47 */
48 public function __get( $name ) {
49 switch ( $name ) {
50 case 'db':
51 global $wpdb;
52 return $wpdb;
53 case 'url':
54 return plugin_dir_url( dirname( __DIR__, 2 ) );
55 case 'dir':
56 return plugin_dir_path( dirname( __DIR__, 2 ) );
57 case 'option':
58 return Option::get_instance();
59 case 'input':
60 return Input::get_instance();
61 case 'session':
62 return Session::get_instance();
63 case 'service':
64 return ServiceManager::get_instance();
65 case 'profile_checker':
66 return ProfileChecker::get_instance();
67 case 'network':
68 return Network::get_instance();
69 default:
70 return null;
71 }
72 }
73 }
74