*/
public function createConnection($dsn, array $config, array $options)
{
$username = array_get($config, 'username');
$password = array_get($config, 'password');
return new PDO($dsn, $username, $password, $options);
}
*/
public function createConnection($dsn, array $config, array $options)
{
$username = array_get($config, 'username');
$password = array_get($config, 'password');
return new PDO($dsn, $username, $password, $options);
}
$dsn = $this->getDsn($config);
// We need to grab the PDO options that should be used while making the brand
// new connection instance. The PDO options control various aspects of the
// connection's behavior, and some might be specified by the developers.
$options = $this->getOptions($config);
$connection = $this->createConnection($dsn, $config, $options);
$collation = $config['collation'];
* Create a single database connection instance.
*
* @param array $config
* @return \Illuminate\Database\Connection
*/
protected function createSingleConnection(array $config)
{
$pdo = $this->createConnector($config)->connect($config);
return $this->createConnection($config['driver'], $pdo, $config['database'], $config['prefix'], $config);
if (isset($config['read']))
{
return $this->createReadWriteConnection($config);
}
else
{
return $this->createSingleConnection($config);
}
}
// and will call the Closure if so, which allows us to have a more generic
// resolver for the drivers themselves which applies to all connections.
if (isset($this->extensions[$driver]))
{
return call_user_func($this->extensions[$driver], $config, $name);
}
return $this->factory->make($config, $name);
}
$name = $name ?: $this->getDefaultConnection();
// If we haven't created this connection, we'll create it based on the config
// provided in the application. Once we've created the connections we will
// set the "fetch mode" for PDO which determines the query return types.
if ( ! isset($this->connections[$name]))
{
$connection = $this->makeConnection($name);
$this->connections[$name] = $this->prepare($connection);
* Resolve a connection instance.
*
* @param string $connection
* @return \Illuminate\Database\Connection
*/
public static function resolveConnection($connection = null)
{
return static::$resolver->connection($connection);
}
/**
* Get the database connection for the model.
*
* @return \Illuminate\Database\Connection
*/
public function getConnection()
{
return static::resolveConnection($this->connection);
}
/**
* Get a new query builder instance for the connection.
*
* @return \Illuminate\Database\Query\Builder
*/
protected function newBaseQueryBuilder()
{
$conn = $this->getConnection();
$grammar = $conn->getQueryGrammar();
* Get a new query builder for the model's table.
*
* @param bool $excludeDeleted
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function newQuery($excludeDeleted = true)
{
$builder = $this->newEloquentBuilder($this->newBaseQueryBuilder());
// Once we have the query builders, we will set the model instances so the
public function __call($method, $parameters)
{
if (in_array($method, array('increment', 'decrement')))
{
return call_user_func_array(array($this, $method), $parameters);
}
$query = $this->newQuery();
return call_user_func_array(array($query, $method), $parameters);
* @param array $parameters
* @return mixed
*/
public static function __callStatic($method, $parameters)
{
$instance = new static;
return call_user_func_array(array($instance, $method), $parameters);
}
| When using the "eloquent" driver and extending the base Eloquent model,
| you have the option to globally set the login attempts.
|
| Supported: int
|
*/
'attempt_limit' => Setting::where('name','=','max_attempt')->first()->value,
/*
| When using the "eloquent" driver and extending the base Eloquent model,
| you have the option to globally set the login attempts.
|
| Supported: int
|
*/
'attempt_limit' => Setting::where('name','=','max_attempt')->first()->value,
/*
* @param string $path
* @return mixed
*
* @throws FileNotFoundException
*/
public function getRequire($path)
{
if ($this->isFile($path)) return require $path;
throw new FileNotFoundException("File does not exist at path {$path}");
* Get a file's contents by requiring it.
*
* @param string $path
* @return mixed
*/
protected function getRequire($path)
{
return $this->files->getRequire($path);
}
// First we will look for a configuration file in the packages configuration
// folder. If it exists, we will load it and merge it with these original
// options so that we will easily "cascade" a package's configurations.
$file = "packages/{$package}/{$group}.php";
if ($this->files->exists($path = $this->defaultPath.'/'.$file))
{
$items = array_merge($items, $this->getRequire($path));
}
$this->afterLoading($namespace, function($me, $group, $items) use ($package)
{
$env = $me->getEnvironment();
$loader = $me->getLoader();
return $loader->cascadePackage($env, $package, $group, $items);
});
}
* @param array $items
* @return array
*/
protected function callAfterLoad($namespace, $group, $items)
{
$callback = $this->afterLoad[$namespace];
return call_user_func($callback, $this, $group, $items);
}
$items = $this->loader->load($env, $group, $namespace);
// If we've already loaded this collection, we will just bail out since we do
// not want to load it again. Once items are loaded a first time they will
// stay kept in memory within this class and not loaded from disk again.
if (isset($this->afterLoad[$namespace]))
{
$items = $this->callAfterLoad($namespace, $group, $items);
}
list($namespace, $group, $item) = $this->parseKey($key);
// Configuration items are actually keyed by "collection", which is simply a
// combination of each namespace and groups, which allows a unique way to
// identify the arrays of configuration items for the particular files.
$collection = $this->getCollection($group, $namespace);
$this->load($group, $namespace, $collection);
return array_get($this->items[$collection], $item, $default);
* Get a configuration option.
*
* @param string $key
* @return mixed
*/
public function offsetGet($key)
{
return $this->get($key);
}
*
* @return void
*/
protected function registerUserProvider()
{
$this->app['sentry.user'] = $this->app->share(function($app)
{
$model = $app['config']['cartalyst/sentry::users.model'];
// We will never be accessing a user in Sentry without accessing
// We'll simply declare a static variable within the Closures and if it has
// not been set we will execute the given Closures to resolve this value
// and return it back to these consumers of the method as an instance.
static $object;
if (is_null($object))
{
$object = $closure($container);
}
public function build($concrete, $parameters = array())
{
// If the concrete type is actually a Closure, we will just execute it and
// hand back the results of the functions, which allows functions to be
// used as resolvers for more fine-tuned resolution of these objects.
if ($concrete instanceof Closure)
{
return $concrete($this, $parameters);
}
$concrete = $this->getConcrete($abstract);
// We're ready to instantiate an instance of the concrete type registered for
// the binding. This will instantiate the types, as well as resolve any of
// its "nested" dependencies recursively until all have gotten resolved.
if ($this->isBuildable($concrete, $abstract))
{
$object = $this->build($concrete, $parameters);
}
else
$abstract = $this->getAlias($abstract);
if (isset($this->deferredServices[$abstract]))
{
$this->loadDeferredProvider($abstract);
}
return parent::make($abstract, $parameters);
}
* Get the value at a given offset.
*
* @param string $key
* @return mixed
*/
public function offsetGet($key)
{
return $this->make($key);
}
* @return void
*/
protected function registerSentry()
{
$this->app['sentry'] = $this->app->share(function($app)
{
return new Sentry(
$app['sentry.user'],
$app['sentry.group'],
$app['sentry.throttle'],
// We'll simply declare a static variable within the Closures and if it has
// not been set we will execute the given Closures to resolve this value
// and return it back to these consumers of the method as an instance.
static $object;
if (is_null($object))
{
$object = $closure($container);
}
public function build($concrete, $parameters = array())
{
// If the concrete type is actually a Closure, we will just execute it and
// hand back the results of the functions, which allows functions to be
// used as resolvers for more fine-tuned resolution of these objects.
if ($concrete instanceof Closure)
{
return $concrete($this, $parameters);
}
$concrete = $this->getConcrete($abstract);
// We're ready to instantiate an instance of the concrete type registered for
// the binding. This will instantiate the types, as well as resolve any of
// its "nested" dependencies recursively until all have gotten resolved.
if ($this->isBuildable($concrete, $abstract))
{
$object = $this->build($concrete, $parameters);
}
else
$abstract = $this->getAlias($abstract);
if (isset($this->deferredServices[$abstract]))
{
$this->loadDeferredProvider($abstract);
}
return parent::make($abstract, $parameters);
}
* Get the value at a given offset.
*
* @param string $key
* @return mixed
*/
public function offsetGet($key)
{
return $this->make($key);
}
if (is_object($name)) return $name;
if (isset(static::$resolvedInstance[$name]))
{
return static::$resolvedInstance[$name];
}
return static::$resolvedInstance[$name] = static::$app[$name];
}
/**
* Get the root object behind the facade.
*
* @return mixed
*/
public static function getFacadeRoot()
{
return static::resolveFacadeInstance(static::getFacadeAccessor());
}
*
* @param string $method
* @param array $args
* @return mixed
*/
public static function __callStatic($method, $args)
{
$instance = static::getFacadeRoot();
switch (count($args))
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/
App::before(function($request)
{
$user = Sentry::getUser();
if( ! is_null($user) )
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/
App::before(function($request)
{
$user = Sentry::getUser();
if( ! is_null($user) )
// payload to each of them so that they receive each of these arguments.
if ( ! is_array($payload)) $payload = array($payload);
$this->firing[] = $event;
foreach ($this->getListeners($event) as $listener)
{
$response = call_user_func_array($listener, $payload);
// If a response is returned from the listener and event halting is enabled
*
* @param string $event
* @param array $payload
* @return mixed
*/
public function until($event, $payload = array())
{
return $this->fire($event, $payload, true);
}
* @param \Illuminate\Http\Response $response
* @return mixed
*/
protected function callFilter($filter, $request, $response = null)
{
if ( ! $this->filtering) return null;
return $this->events->until('router.'.$filter, array($request, $response));
}
public function dispatch(Request $request)
{
$this->currentRequest = $request;
// If no response was returned from the before filter, we will call the proper
// route instance to get the response. If no route is found a response will
// still get returned based on why no routes were found for this request.
$response = $this->callFilter('before', $request);
if (is_null($response))
}
if ($this->runningUnitTests() && ! $this['session']->isStarted())
{
$this['session']->start();
}
return $this['router']->dispatch($this->prepareRequest($request));
}
{
try
{
$this->refreshRequest($request = Request::createFromBase($request));
$this->boot();
return $this->dispatch($request);
}
catch (\Exception $e)
* @param \Symfony\Component\HttpFoundation\Request $request
* @param int $type
* @param bool $catch
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$response = $this->app->handle($request, $type, $catch);
$response->headers->set('X-Frame-Options', 'SAMEORIGIN', false);
if ($this->sessionConfigured())
{
$session = $this->startSession($request);
$request->setSession($session);
}
$response = $this->app->handle($request, $type, $catch);
// Again, if the session has been configured we will need to close out the session
* @param \Symfony\Component\HttpFoundation\Request $request
* @param int $type
* @param bool $catch
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$response = $this->app->handle($request, $type, $catch);
foreach ($this->cookies->getQueuedCookies() as $cookie)
* @param \Symfony\Component\HttpFoundation\Request $request
* @param int $type
* @param bool $catch
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
return $this->encrypt($this->app->handle($this->decrypt($request), $type, $catch));
}
{
$this->app = $app;
$this->middlewares = $middlewares;
}
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
return $this->app->handle($request, $type, $catch);
}
* @param \Symfony\Component\HttpFoundation\Request $request
* @return void
*/
public function run(SymfonyRequest $request = null)
{
$request = $request ?: $this['request'];
$response = with($stack = $this->getStackedClient())->handle($request);
$response->send();
| Once we have the application, we can simply call the run method,
| which will execute the request and send the response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have whipped up for them.
|
*/
$app->run();