| 1 |
<?php |
| 2 |
/** |
| 3 |
* Help: Service provider |
| 4 |
* |
| 5 |
* @package SimplePay |
| 6 |
* @subpackage Core |
| 7 |
* @copyright Copyright (c) 2022, Sandhills Development, LLC |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 4.4.6 |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace SimplePay\Core\Help; |
| 13 |
|
| 14 |
use SimplePay\Core\AbstractPluginServiceProvider; |
| 15 |
|
| 16 |
/** |
| 17 |
* HelpServiceProvider class. |
| 18 |
* |
| 19 |
* @since 4.4.6 |
| 20 |
*/ |
| 21 |
class HelpServiceProvider extends AbstractPluginServiceProvider { |
| 22 |
|
| 23 |
/* |
| 24 |
* {@inheritdoc} |
| 25 |
*/ |
| 26 |
public function get_services() { |
| 27 |
return array( |
| 28 |
'admin-help-docs-context', |
| 29 |
); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* {@inheritdoc} |
| 34 |
*/ |
| 35 |
public function get_subscribers() { |
| 36 |
return array( |
| 37 |
'admin-help-docs-importer', |
| 38 |
'admin-help-ui', |
| 39 |
); |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* {@inheritdoc} |
| 44 |
*/ |
| 45 |
public function register() { |
| 46 |
$container = $this->getContainer(); |
| 47 |
|
| 48 |
// Docs importer. |
| 49 |
$container->share( |
| 50 |
'admin-help-docs-importer', |
| 51 |
HelpDocsImporter::class |
| 52 |
) |
| 53 |
->withArgument( $this->get_remote_api_url() ) |
| 54 |
->withArgument( $container->get( 'scheduler' ) ); |
| 55 |
|
| 56 |
// Context. |
| 57 |
$container->share( |
| 58 |
'admin-help-docs-context', |
| 59 |
HelpDocsContext::class |
| 60 |
); |
| 61 |
|
| 62 |
// UI. |
| 63 |
$container->share( 'admin-help-ui', HelpUi::class ) |
| 64 |
->withArgument( $container->get( 'admin-help-docs-context' ) ); |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Returns the API URL for remote doc articles to import. |
| 69 |
* |
| 70 |
* @since 4.4.6 |
| 71 |
* |
| 72 |
* @return string |
| 73 |
*/ |
| 74 |
private function get_remote_api_url() { |
| 75 |
if ( defined( 'SIMPAY_HELP_DOCS_API_URL' ) ) { |
| 76 |
return SIMPAY_HELP_DOCS_API_URL; |
| 77 |
} |
| 78 |
|
| 79 |
return 'https://wpsimplepay.com/wp-content/docs.json'; |
| 80 |
} |
| 81 |
|
| 82 |
} |
| 83 |
|