本文整理汇总了PHP中Illuminate\Routing\Controller类的典型用法代码示例。如果您正苦于以下问题:PHP Controller类的具体用法?PHP Controller怎么用?PHP Controller使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assign
/**
* Register the spamguard middleware on a controller.
*
* @param Controller $controller
* @param array $actions
* @param array $elements
* @return void
*/
public function assign(Controller $controller, $actions = [], $elements = [])
{
$elements = $elements ?: Config::$elements;
foreach ($elements as $middleware) {
$controller->middleware($middleware, $actions);
}
}
示例2: injectControllerDependencies
/**
* Inject the controller dependencies into the controller instance.
*
* @param \Illuminate\Routing\Controller $instance
*
* @return void
*/
protected function injectControllerDependencies($instance)
{
try {
$instance->setDispatcher($this->container['api.dispatcher']);
$instance->setAuthenticator($this->container['api.auth']);
$instance->setResponseFactory($this->container['api.response']);
} catch (BadMethodCallException $exception) {
// This controller does not utilize the trait.
}
}
示例3: makeController
/**
* Make a controller instance via the IoC container.
*
* @param string $controller
* @return mixed
*/
protected function makeController($controller)
{
if ($this->creator) {
Controller::setRouter($this->router);
return $this->creator->createController($controller, $this->getPage());
}
return parent::makeController($controller);
}
示例4: getMiddleware
/**
* Get the middleware for the controller instance.
*
* @param \Illuminate\Routing\Controller $instance
* @param string $method
* @return array
*/
protected function getMiddleware($instance, $method)
{
$results = new Collection();
foreach ($instance->getMiddleware() as $name => $options) {
if (!$this->methodExcludedByOptions($method, $options)) {
$results[] = $this->router->resolveMiddlewareClassName($name);
}
}
return $results->flatten()->all();
}
示例5: getCurrentController
/**
* Get an instance of the possible current controller
* being executed for the current route.
*
* @return mixed
*/
protected function getCurrentController()
{
$router = $this->app->make('router');
$route = $router->currentRouteAction();
if (($pos = strpos($route, '@')) !== false) {
Controller::setFilterer($router);
$controllerName = substr($route, 0, $pos);
return $this->app[$controllerName];
}
}
示例6: getMiddleware
/**
* Get the middleware for the controller instance.
*
* @param \Illuminate\Routing\Controller $instance
* @param string $method
* @return array
*/
protected function getMiddleware($instance, $method)
{
$middleware = $this->router->getMiddleware();
$results = [];
foreach ($instance->getMiddleware() as $name => $options) {
if (!$this->methodExcludedByOptions($method, $options)) {
$results[] = array_get($middleware, $name, $name);
}
}
return $results;
}
示例7: makeController
/**
* Make a controller instance via the IoC container.
*
* @param string $controller
* @return mixed
*/
protected function makeController($controller)
{
Controller::setRouter($this->router);
return $this->container->make($controller);
}
示例8: pushRouteMiddleware
/** @inheritdoc */
public function pushRouteMiddleware(Controller $controller)
{
foreach ($this->routeMiddleware as $_middleware) {
$controller->middleware($_middleware);
}
return $this;
}
示例9: makeController
/**
* Make a controller instance via the IoC container.
*
* @param string $controller
* @return mixed
*/
protected function makeController($controller)
{
Controller::setFilterer($this->filterer);
return $this->container->make($controller)->setContainer($this->container);
}
示例10: assignAfter
/**
* Apply the applicable after filters to the route.
*
* @param \Illuminate\Routing\Controller $instance
* @param \Illuminate\Routing\Route $route
* @param \Illuminate\Http\Request $request
* @param string $method
* @return mixed
*/
protected function assignAfter($instance, $route, $request, $method)
{
foreach ($instance->getAfterFilters() as $filter) {
// If the filter applies, we will add it to the route, since it has already been
// registered on the filterer by the controller, and will just let the normal
// router take care of calling these filters so we do not duplicate logics.
if ($this->filterApplies($filter, $request, $method)) {
$route->after($this->getAssignableAfter($filter));
}
}
}
示例11: __call
/**
* Implements convenient method of calling static methods from
* controller's model.
*
* @return mixed
*/
public function __call($method, $args)
{
if (preg_match('/^staticModel([a-zA-Z0-9]+)$/', $method, $m)) {
$modelClass = $this->getModelClass();
$modelMethod = lcfirst($m[1]);
return call_user_func_array(array($modelClass, $modelMethod), $args);
}
return parent::__call($method, $args);
}
示例12: callAction
/**
* Execute an action on the controller.
*
* And is fired pre and post events on controller
*
* @param string $method
* @param array $parameters
* @return \Symfony\Component\HttpFoundation\Response
*/
public function callAction($method, $parameters)
{
$this->beforeCallAction($method);
$this->response = parent::callAction($method, $parameters);
$this->afterCallAction($method);
return $this->response;
}
示例13: callAction
/**
* Calls controller action.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function callAction($method, array $parameters = [])
{
$isAjax = app()->make('request')->ajax();
$method = $this->checkAjaxMethod($method, $isAjax);
$parameters = $this->checkParametersResolving($method, $parameters);
return parent::callAction($method, $parameters);
}
示例14: callAction
/**
* @param string $method
* @param array $routingParameters
* @return \Illuminate\View\View|mixed
*/
public function callAction($method, $routingParameters)
{
$objects = [];
$this->setupLayout();
try {
$methodParams = $this->detectParameters($method);
} catch (ReflectionException $ex) {
return parent::callAction($method, $routingParameters);
}
foreach ($routingParameters as $rpKey => $rpValue) {
if (is_object($rpValue)) {
$objects[get_class($rpValue)] = $rpValue;
unset($routingParameters[$rpKey]);
}
}
$parameters = array_merge($this->matchClasses($methodParams, $objects), $routingParameters);
$response = call_user_func_array(array($this, $method), $parameters);
// If no response is returned from the controller action and a layout is being
// used we will assume we want to just return the layout view as any nested
// views were probably bound on this view during this controller actions.
if (is_null($response) && !is_null($this->layout)) {
$response = $this->layout;
}
return $response;
}
示例15: __call
public function __call($method, $parameters)
{
if (starts_with($method, 'respond')) {
$responseBuilder = new ResponseBuilder($this->format, ['only' => $this->only, 'modelName' => $this->getModelName(), 'includes' => $this->request->has('includes') ? $this->request->get('includes') : []]);
return call_user_func_array([$responseBuilder, $method], $parameters);
}
return parent::__call($method, $parameters);
}