Browse Source

refactoring.

Taylor Otwell 13 years ago
parent
commit
83d927c4f1

+ 1 - 1
application/config/application.php

@@ -83,7 +83,7 @@ return array(
 	|
 	*/
 
-	'packages' => array(),
+	'libraries' => array(),
 
 	/*
 	|--------------------------------------------------------------------------

+ 1 - 1
application/filters.php

@@ -52,7 +52,7 @@ return array(
 	{
 		if (Config::get('session.driver') !== '')
 		{
-			Session::flash(Input::old_input, Input::get());
+			Input::flash();
 		}
 	},
 

+ 17 - 13
laravel/autoloader.php

@@ -19,14 +19,20 @@ class Autoloader {
 	/**
 	 * 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
 	 * @return void
 	 */
 	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']))
 		{
 			return class_alias(Config::$items['application']['aliases'][$class], $class);
@@ -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
 	 * @return string
@@ -50,13 +56,11 @@ class Autoloader {
 
 		$namespace = substr($class, 0, strpos($class, '\\'));
 
-		// If the class namespace exists in the libraries array, it means that the
-		// library is PSR-0 compliant, and we will load it following those standards.
-		// This allows us to add many third-party libraries to an application and be
-		// able to auto-load them automatically.
+		// If the namespace has been detected as a PSR-0 compliant library,
+		// we will load the library according to those naming conventions.
 		if (array_key_exists($namespace, static::$libraries))
 		{
-			return LIBRARY_PATH.str_replace('_', '/', $file);
+			return str_replace('_', '/', $file).EXT;
 		}
 
 		foreach (static::$paths as $path)
@@ -67,10 +71,10 @@ class Autoloader {
 			}
 		}
 
-		// If the file exists as-is in the libraries directory, we will assume the
-		// library is PSR-0 compliant, and will add the namespace to the array of
-		// libraries and load the class accordingly.
-		if (file_exists($path = LIBRARY_PATH.str_replace('_', '/', $file)))
+		// If the file exists according to the PSR-0 naming conventions,
+		// we will add the namespace to the array of libraries and load
+		// the class according to the PSR-0 conventions.
+		if (file_exists($path = str_replace('_', '/', $file).EXT))
 		{
 			static::$libraries[] = $namespace;
 

+ 11 - 2
laravel/bootstrap/constants.php

@@ -1,8 +1,7 @@
 <?php
 
+define('EXT',       '.php');
 define('BLADE_EXT', '.blade.php');
-define('CRLF', chr(13).chr(10));
-define('EXT', '.php');
 
 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(
 	'APP_PATH'     => realpath($application).'/',
 	'BASE_PATH'    => realpath("$laravel/..").'/',
@@ -42,6 +46,11 @@ $constants = array(
 
 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'].'/' : '';
 
 constants(array('ENV_CONFIG_PATH' => $environment));

+ 0 - 2
laravel/bootstrap/core.php

@@ -14,8 +14,6 @@ Config::load('session');
 
 IoC::bootstrap();
 
-$loader = new Autoloader;
-
 spl_autoload_register(array('Laravel\\Autoloader', 'load'));
 
 function e($value)

+ 1 - 2
laravel/facades.php

@@ -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'; }

+ 10 - 0
laravel/input.php

@@ -74,6 +74,16 @@ class Input {
 		return ( ! is_null(static::old($key)) and trim((string) static::old($key)) !== '');
 	}
 
+	/**
+	 * 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.
 	 *

+ 5 - 5
laravel/paginator.php

@@ -145,7 +145,7 @@ class Paginator {
 	 * @param  string  $text
 	 * @return string
 	 */
-	protected function status($text)
+	public function status($text)
 	{
 		return str_replace(array(':current', ':last'), array($this->page, $this->last), $text);
 	}
@@ -156,7 +156,7 @@ class Paginator {
 	 * @param  string  $text
 	 * @return string
 	 */
-	protected function first($text)
+	public function first($text)
 	{
 		return $this->backwards(__FUNCTION__, $text, 1);
 	}
@@ -167,7 +167,7 @@ class Paginator {
 	 * @param  string  $text
 	 * @return string
 	 */
-	protected function previous($text)
+	public function previous($text)
 	{
 		return $this->backwards(__FUNCTION__, $text, $this->page - 1);
 	}
@@ -178,7 +178,7 @@ class Paginator {
 	 * @param  string  $text
 	 * @return string
 	 */
-	protected function next($text)
+	public function next($text)
 	{
 		return $this->forwards(__FUNCTION__, $text, $this->page + 1);
 	}
@@ -189,7 +189,7 @@ class Paginator {
 	 * @param  string  $text
 	 * @return string
 	 */
-	protected function last($text)
+	public function last($text)
 	{
 		return $this->forwards(__FUNCTION__, $text, $this->last);
 	}

+ 2 - 0
laravel/redis.php

@@ -1,5 +1,7 @@
 <?php namespace Laravel;
 
+define('CRLF', chr(13).chr(10));
+
 class Redis {
 
 	/**

+ 1 - 2
laravel/routing/router.php

@@ -194,8 +194,7 @@ class Router {
 	}
 
 	/**
-	 * Search the controllers for the application and determine if an applicable
-	 * controller exists for the current request to the application.
+	 * Search for a controller that can handle the current request.
 	 *
 	 * 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.

+ 3 - 12
laravel/security/crypter.php

@@ -65,20 +65,11 @@ class Crypter {
 			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());
 
-	/**
-	 * 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()));
+		return rtrim(mcrypt_decrypt(static::$cipher, static::key(), $value, static::$mode, $iv), "\0");
 	}
 
 	/**