| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
if (!defined('ABSPATH')) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Resolves optional and required services for AJAX endpoint adapters. |
| 10 |
*/ |
| 11 |
class ABJ_404_Solution_Ajax_ServiceResolver { |
| 12 |
|
| 13 |
/** |
| 14 |
* @param string $serviceName |
| 15 |
* @return mixed |
| 16 |
*/ |
| 17 |
public static function optional($serviceName) { |
| 18 |
if (!class_exists('ABJ_404_Solution_ServiceContainer')) { |
| 19 |
return null; |
| 20 |
} |
| 21 |
return ABJ_404_Solution_ServiceContainer::safeGet($serviceName); |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* @param string $serviceName |
| 26 |
* @return mixed |
| 27 |
*/ |
| 28 |
public static function required($serviceName) { |
| 29 |
$service = self::optional($serviceName); |
| 30 |
return ($service !== null) ? $service : abj_service($serviceName); |
| 31 |
} |
| 32 |
} |
| 33 |
|