From f58b9dea7f04d459208f1727f911e0cb5875c87a Mon Sep 17 00:00:00 2001 From: Dayle Rees Date: Fri, 25 May 2012 19:05:34 +0100 Subject: [PATCH 1/3] allow for overriding core tasks Signed-off-by: Dayle Rees --- laravel/cli/dependencies.php | 88 ++++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 30 deletions(-) diff --git a/laravel/cli/dependencies.php b/laravel/cli/dependencies.php index 3c6acc49..f0c59e81 100644 --- a/laravel/cli/dependencies.php +++ b/laravel/cli/dependencies.php @@ -6,36 +6,46 @@ * of the migration resolver and database classes, which are used * to perform various support functions for the migrator. */ -IoC::register('task: migrate', function() +if(! IoC::registered('task: migrate')) { - $database = new Tasks\Migrate\Database; + IoC::register('task: migrate', function() + { + $database = new Tasks\Migrate\Database; - $resolver = new Tasks\Migrate\Resolver($database); + $resolver = new Tasks\Migrate\Resolver($database); + + return new Tasks\Migrate\Migrator($resolver, $database); + }); +} - return new Tasks\Migrate\Migrator($resolver, $database); -}); /** * The bundle task is responsible for the installation of bundles * and their dependencies. It utilizes the bundles API to get the * meta-data for the available bundles. */ -IoC::register('task: bundle', function() +if(! IoC::registered('task: bundle')) { - $repository = IoC::resolve('bundle.repository'); + IoC::register('task: bundle', function() + { + $repository = IoC::resolve('bundle.repository'); - return new Tasks\Bundle\Bundler($repository); -}); + return new Tasks\Bundle\Bundler($repository); + }); +} /** * The key task is responsible for generating a secure, random * key for use by the application when encrypting strings or * setting the hash values on cookie signatures. */ -IoC::singleton('task: key', function() +if(! IoC::registered('task: key')) { - return new Tasks\Key; -}); + IoC::singleton('task: key', function() + { + return new Tasks\Key; + }); +} /** * The session task is responsible for performing tasks related @@ -43,50 +53,65 @@ * such as generating the session table or clearing expired * sessions from storage. */ -IoC::singleton('task: session', function() +if(! IoC::registered('task: session')) { - return new Tasks\Session\Manager; -}); + IoC::singleton('task: session', function() + { + return new Tasks\Session\Manager; + }); +} /** * The route task is responsible for calling routes within the * application and dumping the result. This allows for simple * testing of APIs and JSON based applications. */ -IoC::singleton('task: route', function() +if(! IoC::registered('task: route')) { - return new Tasks\Route; -}); + IoC::singleton('task: route', function() + { + return new Tasks\Route; + }); +} /** * The "test" task is responsible for running the unit tests for * the application, bundles, and the core framework itself. * It provides a nice wrapper around PHPUnit. */ -IoC::singleton('task: test', function() +if(! IoC::registered('task: test')) { - return new Tasks\Test\Runner; -}); + IoC::singleton('task: test', function() + { + return new Tasks\Test\Runner; + }); +} /** * The bundle repository is responsible for communicating with * the Laravel bundle sources to get information regarding any * bundles that are requested for installation. */ -IoC::singleton('bundle.repository', function() +if(! IoC::registered('bundle.repository')) { - return new Tasks\Bundle\Repository; -}); + IoC::singleton('bundle.repository', function() + { + return new Tasks\Bundle\Repository; + }); +} /** * The bundle publisher is responsible for publishing bundle * assets to their correct directories within the install, * such as the web accessible directory. */ -IoC::singleton('bundle.publisher', function() +if(! IoC::registered('bundle.publisher')) { - return new Tasks\Bundle\Publisher; -}); + IoC::singleton('bundle.publisher', function() + { + return new Tasks\Bundle\Publisher; + }); +} /** * The Github bundle provider installs bundles that live on @@ -94,7 +119,10 @@ * and will update the submodule so that the bundle is * installed into the bundle directory. */ -IoC::singleton('bundle.provider: github', function() +if(! IoC::registered('bundle.provider: github')) { - return new Tasks\Bundle\Providers\Github; -}); \ No newline at end of file + IoC::singleton('bundle.provider: github', function() + { + return new Tasks\Bundle\Providers\Github; + }); +} \ No newline at end of file From 992a5f74ca5e86be8a9570d438d62bfe62b03ad3 Mon Sep 17 00:00:00 2001 From: Dayle Rees Date: Fri, 25 May 2012 20:34:13 +0100 Subject: [PATCH 2/3] fix for forelse only matching $vars Signed-off-by: Dayle Rees --- laravel/blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/laravel/blade.php b/laravel/blade.php index 5961a530..416848f9 100644 --- a/laravel/blade.php +++ b/laravel/blade.php @@ -213,12 +213,12 @@ protected static function compile_forelse($value) foreach ($matches[0] as $forelse) { - preg_match('/\$[^\s]*/', $forelse, $variable); + preg_match('/\s*\(\s*(\S*)\s/', $forelse, $variable); // Once we have extracted the variable being looped against, we can add // an if statement to the start of the loop that checks if the count // of the variable being looped against is greater than zero. - $if = " 0): ?>"; + $if = " 0): ?>"; $search = '/(\s*)@forelse(\s*\(.*\))/'; From 495ff1b19784cfb73fd2737ba40e0de46e3db3fc Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Mon, 28 May 2012 10:44:22 +0200 Subject: [PATCH 3/3] eloquent model detection moved to eloquent driver --- laravel/auth/drivers/driver.php | 5 ----- laravel/auth/drivers/eloquent.php | 25 ++++++++++++++++++++++++- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/laravel/auth/drivers/driver.php b/laravel/auth/drivers/driver.php index 21a5f5ad..49df7c06 100644 --- a/laravel/auth/drivers/driver.php +++ b/laravel/auth/drivers/driver.php @@ -5,7 +5,6 @@ use Laravel\Config; use Laravel\Session; use Laravel\Crypter; -use Laravel\Database\Eloquent\Model as Eloquent; abstract class Driver { @@ -107,10 +106,6 @@ abstract public function attempt($arguments = array()); */ public function login($token, $remember = false) { - // if the token is an Eloquent model - // set the token from the id field - if ($token instanceof Eloquent) $token = $token->get_key(); - $this->token = $token; $this->store($token); diff --git a/laravel/auth/drivers/eloquent.php b/laravel/auth/drivers/eloquent.php index 5c0437d6..29416733 100644 --- a/laravel/auth/drivers/eloquent.php +++ b/laravel/auth/drivers/eloquent.php @@ -15,7 +15,7 @@ public function retrieve($id) if (filter_var($id, FILTER_VALIDATE_INT) !== false) { return $this->model()->find($id); - } + } } /** @@ -43,6 +43,29 @@ public function attempt($arguments = array()) return false; } + /** + * Login the user assigned to the given token. + * + * The token is typically a numeric ID for the user. + * + * @param mixed $token + * @param bool $remember + * @return bool + */ + public function login($token, $remember = false) + { + // if the token is an Eloquent model get the primary key + if ($token instanceof \Eloquent) $token = $token->get_key(); + + $this->token = $token; + + $this->store($token); + + if ($remember) $this->remember($token); + + return true; + } + /** * Get a fresh model instance. *