| 1 |
<?php |
| 2 |
/** |
| 3 |
* Pimple container |
| 4 |
* |
| 5 |
* @package Allex\Core |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace UpStream; |
| 9 |
|
| 10 |
use Allex\Core; |
| 11 |
|
| 12 |
/** |
| 13 |
* Pimple container |
| 14 |
*/ |
| 15 |
class Container extends \Pimple\Container { |
| 16 |
|
| 17 |
/** |
| 18 |
* Instance of the Pimple container |
| 19 |
* |
| 20 |
* @var $instance Class instance. |
| 21 |
*/ |
| 22 |
protected static $instance; |
| 23 |
|
| 24 |
/** |
| 25 |
* Get class instance. |
| 26 |
*/ |
| 27 |
public static function get_instance() { |
| 28 |
if ( empty( static::$instance ) ) { |
| 29 |
$instance = new self(); |
| 30 |
|
| 31 |
// Define the services. |
| 32 |
$instance['PLUGIN_BASENAME'] = function ( $c ) { |
| 33 |
return plugin_basename( 'upstream/upstream.php' ); |
| 34 |
}; |
| 35 |
|
| 36 |
$instance['EDD_API_URL'] = function ( $c ) { |
| 37 |
return 'https://upstreamplugin.com'; |
| 38 |
}; |
| 39 |
|
| 40 |
$instance['PLUGIN_AUTHOR'] = function ( $c ) { |
| 41 |
return 'UpStream'; |
| 42 |
}; |
| 43 |
|
| 44 |
$instance['UPDATES_DOC_URL'] = function ( $c ) { |
| 45 |
// @todo: Update this link adding an specific page for this subject. |
| 46 |
return 'http://upstreamplugin.com/docs/'; |
| 47 |
}; |
| 48 |
|
| 49 |
$instance['framework'] = function ( $c ) { |
| 50 |
return new Core( |
| 51 |
$c['PLUGIN_BASENAME'], |
| 52 |
$c['EDD_API_URL'], |
| 53 |
$c['PLUGIN_AUTHOR'], |
| 54 |
$c['UPDATES_DOC_URL'] |
| 55 |
); |
| 56 |
}; |
| 57 |
|
| 58 |
if ( is_admin() ) { |
| 59 |
$instance['reviews'] = function ( $c ) { |
| 60 |
return new \UpStream_Admin_Reviews(); |
| 61 |
}; |
| 62 |
} |
| 63 |
|
| 64 |
static::$instance = $instance; |
| 65 |
} |
| 66 |
|
| 67 |
return static::$instance; |
| 68 |
} |
| 69 |
} |
| 70 |
|