本文整理汇总了PHP中IoC::core方法的典型用法代码示例。如果您正苦于以下问题:PHP IoC::core方法的具体用法?PHP IoC::core怎么用?PHP IoC::core使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IoC
的用法示例。
在下文中一共展示了IoC::core方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: with
/**
* Add an item to the session flash data.
*
* This is useful for passing status messages or other temporary data to the next request.
*
* <code>
* // Create a redirect response and flash something to the session
* return Redirect::to('user/profile')->with('message', 'Welcome Back!');
* </code>
*
* @param string $key
* @param mixed $value
* @return Response
*/
public function with($key, $value)
{
if (Config::get('session.driver') == '') {
throw new \LogicException('A session driver must be set before setting flash data.');
}
IoC::core('session')->flash($key, $value);
return $this;
}
示例2: to_route
/**
* Generate a URL from a route name.
*
* For routes that have wildcard parameters, an array may be passed as the
* second parameter to the method. The values of this array will be used to
* fill the wildcard segments of the route URI.
*
* <code>
* // Create a URL to the "profile" named route
* $url = URL::to_route('profile');
*
* // Create a URL to the "profile" named route with wildcard parameters
* $url = URL::to_route('profile', array($username));
* </code>
*
* @param string $name
* @param array $parameters
* @param bool $https
* @return string
*/
public static function to_route($name, $parameters = array(), $https = false)
{
if (!is_null($route = IoC::core('routing.router')->find($name))) {
$uris = explode(', ', key($route));
$uri = substr($uris[0], strpos($uris[0], '/'));
// Spin through each route parameter and replace the route wildcard
// segment with the corresponding parameter passed to the method.
// Afterwards, we will replace all of the remaining optional URI
// segments with spaces since they may not have been specified
// in the array of parameters.
foreach ((array) $parameters as $parameter) {
$uri = preg_replace('/\\(.+?\\)/', $parameter, $uri, 1);
}
return static::to(str_replace(array('/(:any?)', '/(:num?)'), '', $uri), $https);
}
throw new \OutOfBoundsException("Error creating URL for undefined route [{$name}].");
}
示例3: old
/**
* Get input data from the previous request.
*
* <code>
* // Get the "email" item from the old input
* $email = Input::old('email');
*
* // Return a default value if the specified item doesn't exist
* $email = Input::old('name', 'Taylor');
* </code>
*
* @param string $key
* @param mixed $default
* @return string
*/
public static function old($key = null, $default = null)
{
$old = IoC::core('session')->get(Input::old_input, array());
return Arr::get($old, $key, $default);
}
示例4: logout
/**
* Log the current user out of the application.
*
* The "logout" closure in the authenciation configuration file will be
* called. All authentication cookies will be deleted and the user ID
* will be removed from the session.
*
* @return void
*/
public static function logout()
{
call_user_func(Config::get('auth.logout'), static::user());
static::$user = null;
Cookie::forget(Auth::user_key);
Cookie::forget(Auth::remember_key);
IoC::core('session')->forget(Auth::user_key);
}
示例5: unset
* in the input array could cause unexpected results if the developer
* fills an Eloquent model with the input.
*/
unset($input[Request::spoofer]);
Input::$input = $input;
/**
* Route the request to the proper route in the application. If a
* route is found, the route will be called with the current request
* instance. If no route is found, the 404 response will be returned
* to the browser.
*/
Routing\Filter::register(require APP_PATH . 'filters' . EXT);
$loader = new Routing\Loader(APP_PATH, ROUTE_PATH);
$router = new Routing\Router($loader, CONTROLLER_PATH);
IoC::instance('laravel.routing.router', $router);
Request::$route = $router->route(Request::method(), URI::current());
if (!is_null(Request::$route)) {
$response = Request::$route->call();
} else {
$response = Response::error('404');
}
/**
* Close the session and write the active payload to persistent
* storage. The session cookie will also be written and if the
* driver is a sweeper, session garbage collection might be
* performed depending on the "sweepage" probability.
*/
if (Config::$items['session']['driver'] !== '') {
IoC::core('session')->save();
}
$response->send();
示例6: logout
/**
* Log the current user out of the application.
*
* The "logout" closure in the authenciation configuration file will be
* called. All authentication cookies will be deleted and the user ID
* will be removed from the session.
*
* @return void
*/
public static function logout()
{
call_user_func(Config::get('auth.logout'), static::user());
static::$user = null;
$config = Config::get('session');
extract($config, EXTR_SKIP);
// When forgetting the cookie, we need to also pass in the path and
// domain that would have been used when the cookie was originally
// set by the framework, otherwise it will not be deleted.
Cookie::forget(Auth::user_key, $path, $domain, $secure);
Cookie::forget(Auth::remember_key, $path, $domain, $secure);
IoC::core('session')->forget(Auth::user_key);
}