Blocks
4 years ago
Contracts
5 years ago
Database
4 years ago
Integrations
4 years ago
Libraries
5 years ago
Models
4 years ago
Seeds
5 years ago
Services
4 years ago
Support
4 years ago
config
4 years ago
Activator.php
5 years ago
Attachment.php
5 years ago
Controller.php
5 years ago
Core.php
5 years ago
Factory.php
5 years ago
Files.php
5 years ago
Plugin.php
5 years ago
Requirements.php
5 years ago
support.php
4 years ago
Core.php
55 lines
| 1 | <?php |
| 2 | |
| 3 | namespace PrestoPlayer; |
| 4 | |
| 5 | class Core |
| 6 | { |
| 7 | /** |
| 8 | * The singleton instance. |
| 9 | * |
| 10 | * @var Core |
| 11 | */ |
| 12 | private static $instance; |
| 13 | |
| 14 | /** |
| 15 | * Retrieves (and if necessary creates) the API instance. Should not be called outside of plugin set-up. |
| 16 | * |
| 17 | * @internal |
| 18 | * |
| 19 | * @since 1.0.0 |
| 20 | * |
| 21 | * @param Core $instance Only used for plugin initialization. Don't ever pass a value in user code. |
| 22 | * |
| 23 | * @return void |
| 24 | * |
| 25 | * @throws \BadMethodCallException Thrown when Avatar_Privacy_Core::set_instance after plugin initialization. |
| 26 | */ |
| 27 | public static function set_instance(Core $instance) |
| 28 | { |
| 29 | if (null === self::$instance) { |
| 30 | self::$instance = $instance; |
| 31 | } else { |
| 32 | // throw new \BadMethodCallException(__METHOD__ . ' called more than once.'); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | |
| 37 | /** |
| 38 | * Retrieves the plugin instance. |
| 39 | * |
| 40 | * @since 1.0.0 |
| 41 | * |
| 42 | * @throws \BadMethodCallException Thrown when Avatar_Privacy_Core::get_instance is called before plugin initialization. |
| 43 | * |
| 44 | * @return Core |
| 45 | */ |
| 46 | public static function get_instance() |
| 47 | { |
| 48 | if (null === self::$instance) { |
| 49 | throw new \BadMethodCallException(__METHOD__ . ' called without prior plugin intialization.'); |
| 50 | } |
| 51 | |
| 52 | return self::$instance; |
| 53 | } |
| 54 | } |
| 55 |