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