本文整理汇总了PHP中Laravel\Bundle::start方法的典型用法代码示例。如果您正苦于以下问题:PHP Bundle::start方法的具体用法?PHP Bundle::start怎么用?PHP Bundle::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Laravel\Bundle
的用法示例。
在下文中一共展示了Bundle::start方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Call a filter or set of filters.
*
* @param array $collections
* @param array $pass
* @param bool $override
* @return mixed
*/
public static function run($collections, $pass = array(), $override = false)
{
foreach ($collections as $collection) {
foreach ($collection->filters as $filter) {
list($filter, $parameters) = $collection->get($filter);
// We will also go ahead and start the bundle for the developer. This allows
// the developer to specify bundle filters on routes without starting the
// bundle manually, and performance is improved since the bundle is only
// started when needed.
Bundle::start(Bundle::name($filter));
if (!isset(static::$filters[$filter])) {
continue;
}
$callback = static::$filters[$filter];
// Parameters may be passed into filters by specifying the list of parameters
// as an array, or by registering a Closure which will return the array of
// parameters. If parameters are present, we will merge them with the
// parameters that were given to the method.
$response = call_user_func_array($callback, array_merge($pass, $parameters));
// "Before" filters may override the request cycle. For example, an auth
// filter may redirect a user to a login view if they are not logged in.
// Because of this, we will return the first filter response if
// overriding is enabled for the filter collections
if (!is_null($response) and $override) {
return $response;
}
}
}
}
示例2: call
/**
* Call an action method on a controller.
*
* <code>
* // Call the "show" method on the "user" controller
* $response = Controller::call('user@show');
*
* // Call the "user/admin" controller and pass parameters
* $response = Controller::call('user.admin@profile', array($username));
* </code>
*
* @param string $destination
* @param array $parameters
* @return Response
*/
public static function call($destination, $parameters = array())
{
static::references($destination, $parameters);
list($bundle, $destination) = Bundle::parse($destination);
// We will always start the bundle, just in case the developer is pointing
// a route to another bundle. This allows us to lazy load the bundle and
// improve speed since the bundle is not loaded on every request.
Bundle::start($bundle);
list($controller, $method) = explode('@', $destination);
$controller = static::resolve($bundle, $controller);
// If the controller could not be resolved, we're out of options and
// will return the 404 error response. If we found the controller,
// we can execute the requested method on the instance.
if (is_null($controller)) {
return Event::first('404');
}
return $controller->execute($method, $parameters);
}
示例3: run
/**
* Run a CLI task with the given arguments.
*
* <code>
* // Call the migrate artisan task
* Command::run(array('migrate'));
*
* // Call the migrate task with some arguments
* Command::run(array('migrate:rollback', 'bundle-name'))
* </code>
*
* @param array $arguments
* @return void
*/
public static function run($arguments = array())
{
static::validate($arguments);
list($bundle, $task, $method) = static::parse($arguments[0]);
// If the task exists within a bundle, we will start the bundle so that any
// dependencies can be registered in the application IoC container. If the
// task is registered in the container, we'll resolve it.
if (Bundle::exists($bundle)) {
Bundle::start($bundle);
}
$task = static::resolve($bundle, $task);
// Once the bundle has been resolved, we'll make sure we could actually
// find that task, and then verify that the method exists on the task
// so we can successfully call it without a problem.
if (is_null($task)) {
throw new \Exception("Sorry, I can't find that task.");
}
if (is_callable(array($task, $method))) {
$task->{$method}(array_slice($arguments, 1));
} else {
throw new \Exception("Sorry, I can't find that method!");
}
}
示例4: path
<?php
namespace Laravel\CLI;
defined('DS') or die('No direct script access.');
use Laravel\Bundle;
use Laravel\Config;
use Laravel\Request;
/**
* Fire up the default bundle. This will ensure any dependencies that
* need to be registered in the IoC container are registered and that
* the auto-loader mappings are registered.
*/
Bundle::start(DEFAULT_BUNDLE);
/**
* The default database connection may be set by specifying a value
* for the "database" CLI option. This allows migrations to be run
* conveniently for a test or staging database.
*/
if (!is_null($database = get_cli_option('db'))) {
Config::set('database.default', $database);
}
/**
* We will register all of the Laravel provided tasks inside the IoC
* container so they can be resolved by the task class. This allows
* us to seamlessly add tasks to the CLI so that the Task class
* doesn't have to worry about how to resolve core tasks.
*/
require path('sys') . 'cli/dependencies' . EXT;
/**
* We will wrap the command execution in a try / catch block and
示例5: route
/**
* Search the routes for the route matching a method and URI.
*
* @param string $method
* @param string $uri
* @return Route
*/
public static function route($method, $uri)
{
Bundle::start($bundle = Bundle::handles($uri));
$routes = (array) static::method($method);
// Of course literal route matches are the quickest to find, so we will
// check for those first. If the destination key exists in the routes
// array we can just return that route now.
if (array_key_exists($uri, $routes)) {
$action = $routes[$uri];
return new Route($method, $uri, $action);
}
// If we can't find a literal match we'll iterate through all of the
// registered routes to find a matching route based on the route's
// regular expressions and wildcards.
if (!is_null($route = static::match($method, $uri))) {
return $route;
}
}
示例6: call
/**
* Call an action method on a controller.
*
* <code>
* // Call the "show" method on the "user" controller
* $response = Controller::call('user@show');
*
* // Call the "user/admin" controller and pass parameters
* $response = Controller::call('user.admin@profile', array($username));
* </code>
*
* @param string $destination
* @param array $parameters
* @return Response
*/
public static function call($destination, $parameters = array())
{
static::references($destination, $parameters);
list($bundle, $destination) = Bundle::parse($destination);
// We will always start the bundle, just in case the developer is pointing
// a route to another bundle. This allows us to lazy load the bundle and
// improve speed since the bundle is not loaded on every request.
Bundle::start($bundle);
list($name, $method) = explode('@', $destination);
$controller = static::resolve($bundle, $name);
// For convenience we will set the current controller and action on the
// Request's route instance so they can be easily accessed from the
// application. This is sometimes useful for dynamic situations.
if (!is_null($route = Request::route())) {
$route->controller = $name;
$route->controller_action = $method;
}
// If the controller could not be resolved, we're out of options and
// will return the 404 error response. If we found the controller,
// we can execute the requested method on the instance.
if (is_null($controller)) {
return Event::first('404');
}
return $controller->execute($method, $parameters);
}
示例7: install
public static function install()
{
$database_settings = Config::get("database.connections.default");
$core_modules = self::get_core_modules_list();
require path('sys') . 'cli' . DS . 'dependencies' . EXT;
$mig = \Laravel\CLI\Command::run(array('migrate:install'));
if (!empty($core_modules)) {
//copy every module to the bundles folder
foreach ($core_modules as $module => $module_path) {
static::migrate($module);
}
Bundle::register('modules');
Bundle::start('modules');
foreach ($core_modules as $module => $module_path) {
$mod = \Modules\Module::make($module)->is_valid();
$new_bundle = new \Modules\Model\Module();
$new_bundle->name = $mod->name;
$new_bundle->slug = $mod->slug;
$new_bundle->description = isset($mod->description) ? $mod->description : '';
$new_bundle->version = $mod->version;
$new_bundle->is_frontend = isset($mod->is_frontend) ? $mod->is_frontend : 0;
$new_bundle->is_backend = isset($mod->is_backend) ? $mod->is_backend : 0;
$new_bundle->is_core = isset($mod->is_core) ? 1 : 0;
$new_bundle->required = $mod->decode('required');
$new_bundle->recommended = $mod->decode('recommended');
$new_bundle->options = $mod->decode('options');
$new_bundle->roles = $mod->decode('roles');
$new_bundle->menu = $mod->decode('menu');
$new_bundle->enabled = 1;
$new_bundle->save();
}
Bundle::disable('modules');
foreach ($core_modules as $module => $module_path) {
static::schema('install', $module);
//
// Publish module assets if any
//
static::publish($module);
}
}
return true;
}
示例8: __construct
/**
* Create a new HelpSpot Migration instance.
*
* @return void
*/
public function __construct()
{
Bundle::start('doctrine');
$this->em = IoC::resolve('doctrine::manager');
$this->sm = $this->em->getConnection()->getSchemaManager();
}
示例9: route
public static function route($method, $uri)
{
Bundle::start($bundle = Bundle::handles($uri));
$routes = (array) static::method($method);
if (array_key_exists($uri, $routes)) {
$action = $routes[$uri];
return new Route($method, $uri, $action);
}
if (!is_null($route = static::match($method, $uri))) {
return $route;
}
}
示例10: path
#require_once path('sys') . 'error' . EXT;
Error::exception($e);
});
set_error_handler(function ($code, $error, $file, $line) {
#require_once path('sys') . 'error' . EXT;
Error::native($code, $error, $file, $line);
});
register_shutdown_function(function () {
#require_once path('sys') . 'error' . EXT;
Error::shutdown();
});
error_reporting(-1);
Bundle::start(DEFAULT_BUNDLE);
foreach (Bundle::$bundles as $bundle => $config) {
if ($config['auto']) {
Bundle::start($bundle);
}
}
Router::register('*', '(:all)', function () {
return Event::first('404');
});
$uri = URI::current();
$languages = Config::get('application.languages', array());
$languages[] = Config::get('application.language');
foreach ($languages as $language) {
if (preg_match("#^{$language}(?:\$|/)#i", $uri)) {
Config::set('application.language', $language);
$uri = trim(substr($uri, strlen($language)), '/');
break;
}
}