From 24dcb5cc547f75dfee932081cf5accd423e91536 Mon Sep 17 00:00:00 2001 From: Che Kun Date: Tue, 21 Jan 2014 16:41:07 +0800 Subject: [PATCH] support laravel4.1.x #2 --- .../Cloud/Sina/Patcher/Commands/Patch.php | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/Lavender/Cloud/Sina/Patcher/Commands/Patch.php b/src/Lavender/Cloud/Sina/Patcher/Commands/Patch.php index 2a117ab..449fe4e 100755 --- a/src/Lavender/Cloud/Sina/Patcher/Commands/Patch.php +++ b/src/Lavender/Cloud/Sina/Patcher/Commands/Patch.php @@ -16,7 +16,7 @@ class Patch extends Command { * * @var string */ - protected $description = "Optimize the framework for better performance"; + protected $description = "Patch files for laravel4 to run on SAE."; /** * Files need to Patch @@ -27,6 +27,14 @@ class Patch extends Command { 'vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php' ); + /** + * Replace files + * @var array + */ + private $replaceFiles = array( + 'vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php' => 'vendor/chekun/laravel4sae/src/Lavender/Cloud/Sina/Patcher/Foundation/ProviderRepository.php', + ); + public function fire() { $this->call('dump'); @@ -39,13 +47,25 @@ public function fire() $code = file_get_contents($file); - $code = str_replace('ini_set', '@ini_set', $code); + if (strpos($code, '@ini_set') === false) { + + $code = str_replace('ini_set', '@ini_set', $code); + + } file_put_contents($file, $code); } + foreach ($this->replaceFiles as $file => $replacedFile) { + + @unlink($file); + + @copy($replacedFile, $file); + + } + } -} \ No newline at end of file +}