Commit 83d927c4 by Taylor Otwell

refactoring.

parent c3c0fbce
...@@ -83,7 +83,7 @@ return array( ...@@ -83,7 +83,7 @@ return array(
| |
*/ */
'packages' => array(), 'libraries' => array(),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
......
...@@ -52,7 +52,7 @@ return array( ...@@ -52,7 +52,7 @@ return array(
{ {
if (Config::get('session.driver') !== '') if (Config::get('session.driver') !== '')
{ {
Session::flash(Input::old_input, Input::get()); Input::flash();
} }
}, },
......
...@@ -19,14 +19,20 @@ class Autoloader { ...@@ -19,14 +19,20 @@ class Autoloader {
/** /**
* Load the file corresponding to a given class. * Load the file corresponding to a given class.
* *
* Laravel loads classes out of three directorys: the core "laravel" directory,
* and the application "models" and "libraires" directories. All of the file
* names are lower cased and the directory structure corresponds with the
* class namespaces.
*
* The application "libraries" directory also supports the inclusion of PSR-0
* compliant libraries. These libraries will be detected automatically and
* will be loaded according to the PSR-0 naming conventions.
*
* @param string $class * @param string $class
* @return void * @return void
*/ */
public static function load($class) public static function load($class)
{ {
// Most of the core classes are aliases for convenient access in spite of
// the namespace. If an alias is defined for the class, we will load the
// alias and bail out of the auto-load method.
if (array_key_exists($class, Config::$items['application']['aliases'])) if (array_key_exists($class, Config::$items['application']['aliases']))
{ {
return class_alias(Config::$items['application']['aliases'][$class], $class); return class_alias(Config::$items['application']['aliases'][$class], $class);
...@@ -39,7 +45,7 @@ class Autoloader { ...@@ -39,7 +45,7 @@ class Autoloader {
} }
/** /**
* Find the file associated with a given class name. * Determine the file path associated with a given class name.
* *
* @param string $class * @param string $class
* @return string * @return string
...@@ -50,13 +56,11 @@ class Autoloader { ...@@ -50,13 +56,11 @@ class Autoloader {
$namespace = substr($class, 0, strpos($class, '\\')); $namespace = substr($class, 0, strpos($class, '\\'));
// If the class namespace exists in the libraries array, it means that the // If the namespace has been detected as a PSR-0 compliant library,
// library is PSR-0 compliant, and we will load it following those standards. // we will load the library according to those naming conventions.
// This allows us to add many third-party libraries to an application and be
// able to auto-load them automatically.
if (array_key_exists($namespace, static::$libraries)) if (array_key_exists($namespace, static::$libraries))
{ {
return LIBRARY_PATH.str_replace('_', '/', $file); return str_replace('_', '/', $file).EXT;
} }
foreach (static::$paths as $path) foreach (static::$paths as $path)
...@@ -67,10 +71,10 @@ class Autoloader { ...@@ -67,10 +71,10 @@ class Autoloader {
} }
} }
// If the file exists as-is in the libraries directory, we will assume the // If the file exists according to the PSR-0 naming conventions,
// library is PSR-0 compliant, and will add the namespace to the array of // we will add the namespace to the array of libraries and load
// libraries and load the class accordingly. // the class according to the PSR-0 conventions.
if (file_exists($path = LIBRARY_PATH.str_replace('_', '/', $file))) if (file_exists($path = str_replace('_', '/', $file).EXT))
{ {
static::$libraries[] = $namespace; static::$libraries[] = $namespace;
......
<?php <?php
define('EXT', '.php');
define('BLADE_EXT', '.blade.php'); define('BLADE_EXT', '.blade.php');
define('CRLF', chr(13).chr(10));
define('EXT', '.php');
function constants($constants) function constants($constants)
{ {
...@@ -12,6 +11,11 @@ function constants($constants) ...@@ -12,6 +11,11 @@ function constants($constants)
} }
} }
/**
* Register the core framework paths and all of the paths that
* derive from them. If any constant has already been defined,
* we will not attempt to define it again.
*/
$constants = array( $constants = array(
'APP_PATH' => realpath($application).'/', 'APP_PATH' => realpath($application).'/',
'BASE_PATH' => realpath("$laravel/..").'/', 'BASE_PATH' => realpath("$laravel/..").'/',
...@@ -42,6 +46,11 @@ $constants = array( ...@@ -42,6 +46,11 @@ $constants = array(
constants($constants); constants($constants);
/**
* Register the core framework paths and all of the paths that
* derive from them. If any constant has already been defined,
* we will not attempt to define it again.
*/
$environment = (isset($_SERVER['LARAVEL_ENV'])) ? CONFIG_PATH.$_SERVER['LARAVEL_ENV'].'/' : ''; $environment = (isset($_SERVER['LARAVEL_ENV'])) ? CONFIG_PATH.$_SERVER['LARAVEL_ENV'].'/' : '';
constants(array('ENV_CONFIG_PATH' => $environment)); constants(array('ENV_CONFIG_PATH' => $environment));
......
...@@ -14,8 +14,6 @@ Config::load('session'); ...@@ -14,8 +14,6 @@ Config::load('session');
IoC::bootstrap(); IoC::bootstrap();
$loader = new Autoloader;
spl_autoload_register(array('Laravel\\Autoloader', 'load')); spl_autoload_register(array('Laravel\\Autoloader', 'load'));
function e($value) function e($value)
......
...@@ -59,5 +59,4 @@ abstract class Facade { ...@@ -59,5 +59,4 @@ abstract class Facade {
} }
class Autoloader extends Facade { public static $resolve = 'laravel.autoloader'; } class Session extends Facade { public static $resolve = 'laravel.session'; }
class Session extends Facade { public static $resolve = 'laravel.session'; } \ No newline at end of file
\ No newline at end of file
...@@ -75,6 +75,16 @@ class Input { ...@@ -75,6 +75,16 @@ class Input {
} }
/** /**
* Flash the input for the current request to the session.
*
* @return void
*/
public static function flash()
{
IoC::container()->core('session')->flash(Input::old_input, static::get());
}
/**
* Get input data from the previous request. * Get input data from the previous request.
* *
* <code> * <code>
......
...@@ -145,7 +145,7 @@ class Paginator { ...@@ -145,7 +145,7 @@ class Paginator {
* @param string $text * @param string $text
* @return string * @return string
*/ */
protected function status($text) public function status($text)
{ {
return str_replace(array(':current', ':last'), array($this->page, $this->last), $text); return str_replace(array(':current', ':last'), array($this->page, $this->last), $text);
} }
...@@ -156,7 +156,7 @@ class Paginator { ...@@ -156,7 +156,7 @@ class Paginator {
* @param string $text * @param string $text
* @return string * @return string
*/ */
protected function first($text) public function first($text)
{ {
return $this->backwards(__FUNCTION__, $text, 1); return $this->backwards(__FUNCTION__, $text, 1);
} }
...@@ -167,7 +167,7 @@ class Paginator { ...@@ -167,7 +167,7 @@ class Paginator {
* @param string $text * @param string $text
* @return string * @return string
*/ */
protected function previous($text) public function previous($text)
{ {
return $this->backwards(__FUNCTION__, $text, $this->page - 1); return $this->backwards(__FUNCTION__, $text, $this->page - 1);
} }
...@@ -178,7 +178,7 @@ class Paginator { ...@@ -178,7 +178,7 @@ class Paginator {
* @param string $text * @param string $text
* @return string * @return string
*/ */
protected function next($text) public function next($text)
{ {
return $this->forwards(__FUNCTION__, $text, $this->page + 1); return $this->forwards(__FUNCTION__, $text, $this->page + 1);
} }
...@@ -189,7 +189,7 @@ class Paginator { ...@@ -189,7 +189,7 @@ class Paginator {
* @param string $text * @param string $text
* @return string * @return string
*/ */
protected function last($text) public function last($text)
{ {
return $this->forwards(__FUNCTION__, $text, $this->last); return $this->forwards(__FUNCTION__, $text, $this->last);
} }
......
<?php namespace Laravel; <?php namespace Laravel;
define('CRLF', chr(13).chr(10));
class Redis { class Redis {
/** /**
......
...@@ -194,8 +194,7 @@ class Router { ...@@ -194,8 +194,7 @@ class Router {
} }
/** /**
* Search the controllers for the application and determine if an applicable * Search for a controller that can handle the current request.
* controller exists for the current request to the application.
* *
* If a controller is found, the array key for the controller name in the URI * If a controller is found, the array key for the controller name in the URI
* segments will be returned by the method, otherwise NULL will be returned. * segments will be returned by the method, otherwise NULL will be returned.
......
...@@ -65,20 +65,11 @@ class Crypter { ...@@ -65,20 +65,11 @@ class Crypter {
throw new \Exception('Decryption error. Input value is not valid base64 data.'); throw new \Exception('Decryption error. Input value is not valid base64 data.');
} }
list($iv, $value) = static::parse($value); $iv = substr($value, 0, static::iv_size());
return rtrim(mcrypt_decrypt(static::$cipher, static::key(), $value, static::$mode, $iv), "\0"); $value = substr($value, static::iv_size());
}
/** return rtrim(mcrypt_decrypt(static::$cipher, static::key(), $value, static::$mode, $iv), "\0");
* Parse an encrypted string into its input vector and value segments.
*
* @param string $value
* @return array
*/
protected static function parse($value)
{
return array(substr($value, 0, static::iv_size()), substr($value, static::iv_size()));
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment