| 1 |
<?php |
| 2 |
namespace BitCode\BitForm\Core\Ajax; |
| 3 |
|
| 4 |
use BitCode\BitForm\Admin\AdminAjax; |
| 5 |
use BitCode\BitForm\Core\Capability\Request; |
| 6 |
use BitCode\BitForm\Frontend\Ajax\FrontendAjax; |
| 7 |
use BitCode\BitForm\Core\Integration\Integrations; |
| 8 |
|
| 9 |
class AjaxService |
| 10 |
{ |
| 11 |
public function __construct() |
| 12 |
{ |
| 13 |
if (Request::Check('ajax')) { |
| 14 |
$this->loadPublicAjax(); |
| 15 |
} |
| 16 |
if (Request::Check('admin')) { |
| 17 |
$this->loadAdminAjax(); |
| 18 |
$this->loadIntegrationsAjax(); |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Helps to register admin side ajax |
| 24 |
* |
| 25 |
* @return null |
| 26 |
*/ |
| 27 |
public function loadAdminAjax() |
| 28 |
{ |
| 29 |
(new AdminAjax())->register(); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Helps to register frontend ajax |
| 34 |
* |
| 35 |
* @return null |
| 36 |
*/ |
| 37 |
protected function loadPublicAjax() |
| 38 |
{ |
| 39 |
(new FrontendAjax())->register(); |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Helps to register integration ajax |
| 44 |
* |
| 45 |
* @return null |
| 46 |
*/ |
| 47 |
public function loadIntegrationsAjax() |
| 48 |
{ |
| 49 |
(new Integrations())->registerAjax(); |
| 50 |
|
| 51 |
} |
| 52 |
} |
| 53 |
|