/** * Create a new Console application. * * @param \Weloquent\Core\Application $app * @return \Illuminate\Console\Application */ public static function make($app) { $app->boot(); $console = with($console = new static('WEL. A w.eloquent console by artisan.', $app::VERSION))->setLaravel($app)->setExceptionHandler($app['exception'])->setAutoExit(false); $app->instance('artisan', $console); return $console; }
/** * Handle the Ajax response. Run the appropriate * action hooks used by WordPress in order to perform * POST ajax request securely. * Developers have the option to run ajax for the * Front-end, Back-end either users are logged in or not * or both. * * @param string $action Your ajax 'action' name * @param string $logged Accepted values are 'no', 'yes', 'both' * @param callable|string $callable The function to run when ajax action is called * @throws AjaxException */ public function listen($action, $logged = 'no', $callable) { if (!is_string($action) || strlen($action) == 0) { throw new AjaxException("Invalid parameter for the action."); } // resolve callable if (is_callable($callable)) { $this->registerWithClosure($action, $logged, $callable); } else { if (strpos($callable, '@') !== false) { $parts = explode('@', $callable); $callable = $parts[0]; $method = $parts[1]; } else { $method = 'run'; // default } try { $resolvedCallback = $this->app->make($callable); $this->registerWithClassInstance($action, $logged, $resolvedCallback, $method); } catch (\Exception $e) { throw new AjaxException($e->getMessage()); } } }
/** * Execute decorators * * @param $command * @param string $decoratorSide * @return mixed * @throws \InvalidArgumentException */ private function executeDecorators($command, $decoratorSide = '') { $commandState = $command; foreach ($this->{$decoratorSide} as $className) { if (!class_exists($className)) { throw new InvalidArgumentException("The decorate class [{$className}] does not exists."); } $instance = $this->app->make($className); if (!$instance instanceof CommandHandler) { $message = 'The class to decorate must be an implementation of Weloquent\\Bus\\Contracts\\CommandHandler'; throw new InvalidArgumentException($message); } // execute $commandState = $instance->handle($commandState); } return $commandState; }
| are not available by default in PHP. We'll setup this stuff here. | */ Patchwork\Utf8\Bootup::initMbstring(); /* |-------------------------------------------------------------------------- | Create The Application |-------------------------------------------------------------------------- | | The first thing we will do is create a new Laravel application instance | which serves as the "glue" for all the components of Laravel, and is | the IoC container for the system binding all of the various parts. | */ use Weloquent\Core\Application; $app = new \Weloquent\Core\Application(); /** * ----------------------------------------------------- * Set my custom request class * ----------------------------------------------------- */ Application::requestClass('Weloquent\\Core\\Http\\Request'); /* |-------------------------------------------------------------------------- | Detect The Application Environment |-------------------------------------------------------------------------- | | Laravel takes a dead simple approach to your application environments | so you can just specify a machine name for the host that matches a | given environment, then we will automatically detect it for you. |