| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* This provider will be loaded always (admin/public) |
| 5 |
*/ |
| 6 |
|
| 7 |
namespace FluentForm\App\Providers; |
| 8 |
|
| 9 |
use FluentForm\Framework\Foundation\Provider; |
| 10 |
|
| 11 |
class CommonProvider extends Provider |
| 12 |
{ |
| 13 |
/** |
| 14 |
* The provider booting method to boot this provider |
| 15 |
* @return void |
| 16 |
*/ |
| 17 |
public function booting() |
| 18 |
{ |
| 19 |
// ... |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* The provider booted method to be called after booting |
| 24 |
* @return void |
| 25 |
*/ |
| 26 |
public function booted() |
| 27 |
{ |
| 28 |
/** |
| 29 |
* Fire fluentform-loaded event when app is ready. |
| 30 |
* The ready event will be fired by framework once |
| 31 |
* the framework is booted and the app (plugin) is |
| 32 |
* completely ready. |
| 33 |
*/ |
| 34 |
$this->app->ready(function($app) { |
| 35 |
$app->addAction('init', function() use ($app) { |
| 36 |
$app->doAction('fluentform-loaded', $app); |
| 37 |
}); |
| 38 |
}); |
| 39 |
|
| 40 |
/** |
| 41 |
* Register "admin_init" hook to run before ajax callbacks |
| 42 |
*/ |
| 43 |
$this->app->addAction('admin_init', function() { |
| 44 |
if (defined('DOING_AJAX') && DOING_AJAX) { |
| 45 |
$action = $this->app->request->get('action'); |
| 46 |
if($this->app->has("__ajax_before__{$action}")) { |
| 47 |
$callback = $this->app->make("__ajax_before__{$action}"); |
| 48 |
return $callback($this->app); |
| 49 |
} |
| 50 |
} |
| 51 |
}); |
| 52 |
} |
| 53 |
} |