flack /
openpsa
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * @package midcom |
||
| 4 | * @author The Midgard Project, http://www.midgard-project.org |
||
| 5 | * @copyright The Midgard Project, http://www.midgard-project.org |
||
| 6 | * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
||
| 7 | */ |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @package midcom |
||
| 11 | */ |
||
| 12 | class midcom |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * MidCOM version |
||
| 16 | * |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | const VERSION = '9.10.0+git'; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Main application singleton |
||
| 23 | */ |
||
| 24 | private static ?midcom_application $_application = null; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Mapping of service names to classes implementing the service |
||
| 28 | */ |
||
| 29 | private static array $_service_classes = []; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @throws midcom_error |
||
| 33 | */ |
||
| 34 | public static function init(string $environment = 'prod', bool $debug = false) : midcom_application |
||
| 35 | { |
||
| 36 | // Instantiate the MidCOM main class |
||
| 37 | self::$_application = new midcom_application($environment, $debug); |
||
| 38 | |||
| 39 | // Define default constants |
||
| 40 | if (!defined('MIDCOM_STATIC_URL')) { |
||
| 41 | define('MIDCOM_STATIC_URL', '/midcom-static'); |
||
| 42 | } |
||
| 43 | define('MIDCOM_STATIC_ROOT', self::$_application->getProjectDir() . '/web' . MIDCOM_STATIC_URL); |
||
| 44 | return self::$_application; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Get midcom_application instance |
||
| 49 | * |
||
| 50 | * Services can also be loaded this way by passing their name as an argument, |
||
| 51 | * but this feature will likely be removed at some point |
||
| 52 | * |
||
| 53 | * @param string $name The service name as listed in the _service_classes array or null to get midcom_application |
||
| 54 | * @return midcom_application The midcom application instance |
||
| 55 | */ |
||
| 56 | 734 | public static function get(?string $name = null) |
|
| 57 | { |
||
| 58 | 734 | if (!self::$_application) { |
|
| 59 | self::init(); |
||
| 60 | } |
||
| 61 | |||
| 62 | 734 | if (null === $name) { |
|
| 63 | 734 | return self::$_application; |
|
| 64 | } |
||
| 65 | |||
| 66 | return self::$_application->getContainer()->get($name); |
||
|
0 ignored issues
–
show
|
|||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Register a service class |
||
| 71 | * |
||
| 72 | * (Experimental, use with caution) |
||
| 73 | */ |
||
| 74 | public static function register_service_class(string $name, string $class) |
||
| 75 | { |
||
| 76 | self::$_service_classes[$name] = $class; |
||
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @internal |
||
| 81 | */ |
||
| 82 | public static function get_registered_service_classes() : array |
||
| 83 | { |
||
| 84 | return self::$_service_classes; |
||
| 85 | } |
||
| 86 | } |
||
| 87 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.