Created
June 11, 2012 21:57
-
-
Save vespakoen/2912998 to your computer and use it in GitHub Desktop.
Diff.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[1mdiff --git a/application/bundles.php b/application/bundles.php[m | |
[1mindex 49d126b..e8b8f26 100755[m | |
[1m--- a/application/bundles.php[m | |
[1m+++ b/application/bundles.php[m | |
[36m@@ -33,4 +33,8 @@[m | |
|[m | |
*/[m | |
[31mreturn array();[m | |
No newline at end of file[m | |
[32mreturn array([m | |
[32m 'docs' => array('handles' => 'docs'),[m | |
[32m);[m | |
No newline at end of file[m | |
[1mdiff --git a/application/config/application.php b/application/config/application.php[m | |
[1mindex c5f5a3b..57b0829 100755[m | |
[1m--- a/application/config/application.php[m | |
[1m+++ b/application/config/application.php[m | |
[36m@@ -17,6 +17,19 @@[m [mreturn array([m | |
/*[m | |
|--------------------------------------------------------------------------[m | |
[32m| Asset URL[m | |
[32m |--------------------------------------------------------------------------[m | |
[32m |[m | |
[32m | The base URL used for your application's asset files. This is useful if[m | |
[32m | you are serving your assets through a different server or a CDN. If it[m | |
[32m | is not set, we'll default to the application URL above.[m | |
[32m |[m | |
[32m */[m | |
[32m 'asset_url' => '',[m | |
[32m /*[m | |
[32m |--------------------------------------------------------------------------[m | |
| Application Index[m | |
|--------------------------------------------------------------------------[m | |
|[m | |
[36m@@ -38,16 +51,26 @@[m [mreturn array([m | |
| remain secret and should not be shared with anyone. Make it about 32[m | |
| characters of random gibberish.[m | |
|[m | |
[31m | The "auto_key" option tells Laravel to automatically set this key value[m | |
[31m | if one has not already been set. This is generally done on the first[m | |
[31m | request to the Laravel splash screen.[m | |
[31m |[m | |
*/[m | |
'key' => 'YourSecretKeyGoesHere!',[m | |
/*[m | |
|--------------------------------------------------------------------------[m | |
[32m| Profiler Toolbar[m | |
[32m |--------------------------------------------------------------------------[m | |
[32m |[m | |
[32m | Laravel includes a beautiful profiler toolbar that gives you a heads[m | |
[32m | up display of the queries and logs performed by your application.[m | |
[32m | This is wonderful for development, but, of course, you should[m | |
[32m | disable the toolbar for production applications..[m | |
[32m |[m | |
[32m */[m | |
[32m 'profiler' => false,[m | |
[32m /*[m | |
[32m |--------------------------------------------------------------------------[m | |
| Application Character Encoding[m | |
|--------------------------------------------------------------------------[m | |
|[m | |
[36m@@ -140,6 +163,7 @@[m [mreturn array([m | |
'Log' => 'Laravel\\Log',[m | |
'Memcached' => 'Laravel\\Memcached',[m | |
'Paginator' => 'Laravel\\Paginator',[m | |
[32m'Profiler' => 'Laravel\\Profiling\\Profiler',[m | |
'URL' => 'Laravel\\URL',[m | |
'Redirect' => 'Laravel\\Redirect',[m | |
'Redis' => 'Laravel\\Redis',[m | |
[36m@@ -157,4 +181,4 @@[m [mreturn array([m | |
'View' => 'Laravel\\View',[m | |
),[m | |
[31m);[m | |
No newline at end of file[m | |
[32m);[m | |
[1mdiff --git a/application/config/auth.php b/application/config/auth.php[m | |
[1mindex d013758..0c07c47 100755[m | |
[1m--- a/application/config/auth.php[m | |
[1m+++ b/application/config/auth.php[m | |
[36m@@ -4,78 +4,57 @@[m [mreturn array([m | |
/*[m | |
|--------------------------------------------------------------------------[m | |
| [31mRetrieve The Current User[m[32mDefault Authentication Driver[m | |
|--------------------------------------------------------------------------[m | |
|[m | |
| [31mThis closure is called by the Auth class' "user" method when trying[m[32mLaravel uses a flexible driver-based system[m to [32mhandle authentication.[m | |
| [31mretrieve a user by[m[32mYou are free to register your own drivers using[m the [31mID that is stored in their session. If you find[m[32mAuth::extend[m | |
| [31mthe user, just return the user object, but make sure it has an "id"[m[32mmethod. Of course, a few great drivers are provided out of[m | |
| [31mproperty. If you can't find the user, just return null.[m[32mbox to handle basic authentication simply and easily.[m | |
|[m | |
| [31mOf course, a simple and elegant authentication solution has already[m | |
[31m | been provided for you using the query builder and hashing engine.[m | |
[31m | We love making your life as easy as possible.[m[32mDrivers: 'fluent', 'eloquent'.[m | |
|[m | |
*/[m | |
[31m'user'[m[32m'driver'[m => [31mfunction($id)[m | |
[31m {[m | |
[31m if (filter_var($id, FILTER_VALIDATE_INT) !== false)[m | |
[31m {[m | |
[31m return DB::table('users')->find($id);[m | |
[31m } [m | |
[31m },[m[32m'eloquent',[m | |
/*[m | |
|--------------------------------------------------------------------------[m | |
| [31mAuthenticate User Credentials[m[32mAuthentication Username[m | |
|--------------------------------------------------------------------------[m | |
|[m | |
| [31mThis closure is called by the Auth::attempt() method when attempting to[m | |
[31m | authenticate a user that is logging into your application. It's like a[m | |
[31m | super buff bouncer to your application.[m | |
[31m |[m | |
[31m | If[m[32mHere you may specify[m the [31mprovided credentials are correct, simply return an object[m[32mdatabase column[m that [31m| represents[m[32mshould be considered[m the[31muser being authenticated. As long as it has a property[m | |
| [32m"username"[m for [31mthe "id", any object[m[32myour users. Typically, this[m will [31mwork. If[m[32meither be "username"[m | |
[32m | or "email". Of course, you're free to change[m the [31mcredentials are not valid,[m | |
[31m | you don't meed[m[32mvalue[m to[31mreturn[m anything. | |
|[m | |
*/[m | |
[31m'attempt'[m[32m'username'[m => [31mfunction($username, $password)[m | |
[31m {[m | |
[31m $user = DB::table('users')->where_username($username)->first();[m | |
[31m if ( ! is_null($user) and Hash::check($password, $user->password))[m | |
[31m {[m | |
[31m return $user;[m | |
[31m }[m | |
[31m },[m[32m'email',[m | |
/*[m | |
|--------------------------------------------------------------------------[m | |
| [31mLogout The Current User[m[32mAuthentication Model[m | |
|--------------------------------------------------------------------------[m | |
|[m | |
| [31mHere[m[32mWhen using the "eloquent" authentication driver,[m you may [31mdo anything[m[32mspecify the[m | |
[32m | model[m that [31mneeds to[m[32mshould[m be [31mdone when a user logs out of[m | |
[31m | your application, such as call[m[32mconsidered[m the [31mlogout method on a third-party API[m[32m"User" model. This model will[m | |
| [31myou are using for authentication or anything else you desire.[m[32mbe used to authenticate and load the users of your application.[m | |
|[m | |
*/[m | |
[31m'logout'[m[32m'model'[m => [31mfunction($user) {},[m[32m'User',[m | |
/*[m | |
|--------------------------------------------------------------------------[m | |
| [31m"Remember Me" Cookie Name[m[32mAuthentication Table[m | |
|--------------------------------------------------------------------------[m | |
|[m | |
| [31mHere you may specify[m[32mWhen using the "fluent" authentication driver,[m the [31mcookie name that[m[32mdatabase table used[m | |
[32m | to load users may be specified here. This table[m will be used [31mfor the cookie[m[32min by[m | |
|[31mthat serves as[m the [31m"remember me" token. Of course, a sensible default[m | |
[31m | has been set for you, so you probably don't need[m[32mfluent query builder[m to [31mchange it.[m[32mauthenticate and load your users.[m | |
|[m | |
*/[m | |
[31m'cookie'[m[32m'table'[m => [31m'laravel_remember',[m[32m'users',[m | |
);[m | |
No newline at end of file[m | |
[1mdiff --git a/application/config/session.php b/application/config/session.php[m | |
[1mindex 6a5af5a..ea686f8 100755[m | |
[1m--- a/application/config/session.php[m | |
[1m+++ b/application/config/session.php[m | |
[36m@@ -16,7 +16,7 @@[m [mreturn array([m | |
|[m | |
*/[m | |
'driver' => [31m'',[m[32m'cookie',[m | |
/*[m | |
|--------------------------------------------------------------------------[m | |
[1mdiff --git a/application/config/strings.php b/application/config/strings.php[m | |
[1mindex 730f973..5d94f81 100755[m | |
[1m--- a/application/config/strings.php[m | |
[1m+++ b/application/config/strings.php[m | |
[36m@@ -95,6 +95,7 @@[m [mreturn array([m | |
'series',[m | |
'sheep',[m | |
'species',[m | |
[32m'moose',[m | |
),[m | |
/*[m | |
[1mdiff --git a/application/routes.php b/application/routes.php[m | |
[1mindex 91d17aa..2135969 100755[m | |
[1m--- a/application/routes.php[m | |
[1m+++ b/application/routes.php[m | |
[36m@@ -6,9 +6,8 @@[m | |
|--------------------------------------------------------------------------[m | |
|[m | |
| Simply tell Laravel the HTTP verbs and URIs it should respond to. It is a[m | |
| breeze to setup your [31mapplications[m[32mapplication[m using Laravel's RESTful [31mrouting,[m[32mrouting[m and it | |
| is perfectly suited for building[31mboth[m large applications and simple APIs.[31m| Enjoy the fresh air and simplicity of the framework.[m | |
|[m | |
| Let's respond to a simple GET request to http://example.com/hello:[m | |
|[m | |
[36m@@ -19,7 +18,7 @@[m | |
|[m | |
| You can even respond to more than one URI:[m | |
|[m | |
| [31mRoute::post('hello, world',[m[32mRoute::post(array('hello', 'world'),[m function() | |
| {[m | |
| return 'Hello World!';[m | |
| });[m | |
[36m@@ -69,9 +68,9 @@[m [mEvent::listen('500', function()[m | |
|--------------------------------------------------------------------------[m | |
|[m | |
| Filters provide a convenient method for attaching functionality to your[m | |
| routes. The built-in [31m"before"[m[32mbefore[m and [31m"after"[m[32mafter[m filters are called before and | |
| after every request to your application, and you may even create[31mother[m | |
| [32mother[m filters that can be attached to individual routes. | |
|[m | |
| Let's walk through an example...[m | |
|[m | |
[1mdiff --git a/application/start.php b/application/start.php[m | |
[1mindex 085dd09..6bb648b 100755[m | |
[1m--- a/application/start.php[m | |
[1m+++ b/application/start.php[m | |
[36m@@ -114,6 +114,22 @@[m [mEvent::listen(Lang::loader, function($bundle, $language, $file)[m | |
/*[m | |
|--------------------------------------------------------------------------[m | |
[32m| Attach The Laravel Profiler[m | |
[32m|--------------------------------------------------------------------------[m | |
[32m|[m | |
[32m| If the profiler is enabled, we will attach it to the Laravel events[m | |
[32m| for both queries and logs. This allows the profiler to intercept[m | |
[32m| any of the queries or logs performed by the application.[m | |
[32m|[m | |
[32m*/[m | |
[32mif (Config::get('application.profiler'))[m | |
[32m{[m | |
[32m Profiler::attach();[m | |
[32m}[m | |
[32m/*[m | |
[32m|--------------------------------------------------------------------------[m | |
| Enable The Blade View Engine[m | |
|--------------------------------------------------------------------------[m | |
|[m | |
[1mdiff --git a/application/views/error/404.php b/application/views/error/404.php[m | |
[1mindex 9b9bf55..ade2026 100755[m | |
[1m--- a/application/views/error/404.php[m | |
[1m+++ b/application/views/error/404.php[m | |
[36m@@ -1,92 +1,113 @@[m | |
<!doctype html>[m | |
[31m<html>[m[32m<html lang="en">[m | |
<head> | |
<meta charset="utf-8"> | |
[32m<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">[m | |
<title>Error 404 - Not Found</title> | |
[31m<style>[m[32m<meta name="viewport" content="width=device-width">[m | |
[32m <style type="text/css">[m | |
@import [31murl(http://fonts.googleapis.com/css?family=Ubuntu);[m | |
[31m body[m[32murl(http://fonts.googleapis.com/css?family=Droid+Sans);[m | |
[32m article, aside, details, figcaption, figure, footer, header, hgroup, nav, section[m { [31mbackground: #eee;[m | |
[31m color: #6d6d6d;[m | |
[31m font: normal normal normal 14px/1.253 Ubuntu,[m[32mdisplay: block; }[m | |
[32m audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; }[m | |
[32m audio:not([controls]) { display: none; }[m | |
[32m [hidden] { display: none; }[m | |
[32m html { font-size: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }[m | |
[32m html, button, input, select, textarea { font-family:[m sans-serif; [32mcolor: #222; }[m | |
[32m body {[m margin:[31m0 0 25px 0;[m | |
[31m min-width: 800px;[m | |
[31m padding:[m 0; [32mfont-size: 1em; line-height: 1.4;[m } | |
[31m#main[m[32m::-moz-selection[m { [31mbackground-clip: padding-box;[m | |
[31m background-color:[m[32mbackground: #E37B52; color: #fff; text-shadow: none; }[m | |
[32m ::selection { background: #E37B52; color:[m #fff; [31mborder:1px[m[32mtext-shadow: none; }[m | |
[32m a { color: #00e; }[m | |
[32m a:visited { color: #551a8b; }[m | |
[32m a:hover { color: #06e; }[m | |
[32m a:focus { outline: thin dotted; }[m | |
[32m a:hover, a:active { outline: 0; }[m | |
[32m abbr[title] { border-bottom: 1px dotted; }[m | |
[32m b, strong { font-weight: bold; }[m | |
[32m blockquote { margin: 1em 40px; }[m | |
[32m dfn { font-style: italic; }[m | |
[32m hr { display: block; height: 1px; border: 0; border-top: 1px[m solid #ccc;[31mborder-radius: 5px;[m | |
[31m box-shadow: 0 0 10px #cdcdcd;[m margin: [31m25px auto[m[32m1em[m 0; padding: [31m30px;[m | |
[31m width: 700px;[m | |
[31m position: relative;[m[32m0; }[m | |
[32m ins { background: #ff9; color: #000; text-decoration: none;[m } | |
[31m#main h1[m[32mmark { background: #ff0; color: #000; font-style: italic; font-weight: bold; }[m | |
[32m pre, code, kbd, samp[m { font-family: [31m'Ubuntu';[m[32mmonospace, serif; _font-family: 'courier new', monospace;[m font-size: [31m38px;[m | |
[31m letter-spacing: 2px;[m | |
[31m margin: 0 0 10px 0;[m | |
[31m padding: 0;[m[32m1em;[m } | |
[31m#main h2[m[32mpre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; }[m | |
[32m q { quotes: none; }[m | |
[32m q:before, q:after { content: ""; content: none; }[m | |
[32m small[m {[31mcolor: #999;[m font-size: [31m18px;[m | |
[31m letter-spacing: 3px;[m[32m85%; }[m | |
[32m sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }[m | |
[32m sup { top: -0.5em; }[m | |
[32m sub { bottom: -0.25em; }[m | |
[32m ul, ol {[m margin: [31m0 0 25px[m[32m1em[m 0; padding: 0 0 0 [31m0;[m[32m40px;[m } | |
[31m#main h3[m[32mdd[m { [31mcolor: #999;[m | |
[31m margin-top: 24px;[m | |
[31m padding:[m[32mmargin:[m 0 0 0 [32m40px; }[m | |
[32m nav ul, nav ol { list-style: none; list-style-image: none; margin: 0; padding:[m 0; } | |
[31m#main h3[m[32mimg[m { [31mfont-size: 18px;[m[32mborder: 0; -ms-interpolation-mode: bicubic; vertical-align: middle;[m } | |
[31m#main p[m[32msvg:not(:root) { overflow: hidden; }[m | |
[32m figure[m {[31mline-height: 25px;[m margin:[31m10px[m 0; } | |
[31m#main pre[m[32mform[m { [31mbackground-color: #333;[m | |
[31m border-left: 1px solid #d8d8d8;[m | |
[31m border-top: 1px solid #d8d8d8;[m | |
[31m border-radius: 5px;[m | |
[31m color: #eee;[m | |
[31m padding: 10px;[m[32mmargin: 0;[m } | |
[31m#main ul[m[32mfieldset[m { [32mborder: 0;[m margin:[31m10px[m 0; padding: [31m0 30px;[m[32m0; }[m | |
[32m label { cursor: pointer; }[m | |
[32m legend { border: 0; *margin-left: -7px; padding: 0; white-space: normal;[m } | |
[31m#main li[m[32mbutton, input, select, textarea[m { [32mfont-size: 100%;[m margin:[31m5px[m 0; [32mvertical-align: baseline; *vertical-align: middle; }[m | |
[32m button, input { line-height: normal; }[m | |
[32m button, input[type="button"], input[type="reset"], input[type="submit"] { cursor: pointer; -webkit-appearance: button; *overflow: visible; }[m | |
[32m button[disabled], input[disabled] { cursor: default; }[m | |
[32m input[type="checkbox"], input[type="radio"] { box-sizing: border-box; padding: 0; *width: 13px; *height: 13px; }[m | |
[32m input[type="search"] { -webkit-appearance: textfield; -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; }[m | |
[32m input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }[m | |
[32m button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; }[m | |
[32m textarea { overflow: auto; vertical-align: top; resize: vertical; }[m | |
[32m input:valid, textarea:valid { }[m | |
[32m input:invalid, textarea:invalid { background-color: #f0dddd; }[m | |
[32m table { border-collapse: collapse; border-spacing: 0; }[m | |
[32m td { vertical-align: top; }[m | |
[32m body[m | |
[32m {[m | |
[32m font-family:'Droid Sans', sans-serif;[m | |
[32m font-size:10pt;[m | |
[32m color:#555;[m | |
[32m line-height: 25px;[m | |
[32m }[m | |
[32m .wrapper[m | |
[32m {[m | |
[32m width:760px;[m | |
[32m margin:0 auto 5em auto;[m | |
[32m }[m | |
[32m .main[m | |
[32m {[m | |
[32m overflow:hidden;[m | |
[32m }[m | |
[32m .error-spacer[m | |
[32m {[m | |
[32m height:4em;[m | |
[32m }[m | |
[32m a, a:visited[m | |
[32m {[m | |
[32m color:#2972A3;[m | |
[32m }[m | |
[32m a:hover[m | |
[32m {[m | |
[32m color:#72ADD4;[m | |
} | |
</style> | |
</head> | |
<body> | |
<div [31mid="main">[m[32mclass="wrapper">[m | |
[32m <div class="error-spacer"></div>[m | |
[32m <div role="main" class="main">[m | |
<?php $messages = array('We need a map.', 'I think we\'re lost.', 'We took a wrong turn.'); ?>[m | |
<h1><?php echo $messages[mt_rand(0, 2)]; ?></h1>[m | |
<h2>Server Error: 404 (Not Found)</h2>[m | |
[32m<hr>[m | |
<h3>What does this mean?</h3>[m | |
<p>[m | |
[36m@@ -99,5 +120,6 @@[m | |
Perhaps you would like to go to our <?php echo HTML::link('/', 'home page'); ?>?[m | |
</p>[m | |
</div>[m | |
[32m</div>[m | |
</body> | |
</html>[m | |
No newline at end of file[m | |
[1mdiff --git a/application/views/error/500.php b/application/views/error/500.php[m | |
[1mindex 4dcd92a..4ce7c06 100755[m | |
[1m--- a/application/views/error/500.php[m | |
[1m+++ b/application/views/error/500.php[m | |
[36m@@ -1,92 +1,113 @@[m | |
<!doctype html>[m | |
[31m<html>[m[32m<html lang="en">[m | |
<head> | |
<meta charset="utf-8"> | |
[32m<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">[m | |
<title>Error 500 - Internal Server Error</title> | |
[31m<style>[m[32m<meta name="viewport" content="width=device-width">[m | |
[32m <style type="text/css">[m | |
@import [31murl(http://fonts.googleapis.com/css?family=Ubuntu);[m | |
[31m body[m[32murl(http://fonts.googleapis.com/css?family=Droid+Sans);[m | |
[32m article, aside, details, figcaption, figure, footer, header, hgroup, nav, section[m { [31mbackground: #eee;[m | |
[31m color: #6d6d6d;[m | |
[31m font: normal normal normal 14px/1.253 Ubuntu,[m[32mdisplay: block; }[m | |
[32m audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; }[m | |
[32m audio:not([controls]) { display: none; }[m | |
[32m [hidden] { display: none; }[m | |
[32m html { font-size: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }[m | |
[32m html, button, input, select, textarea { font-family:[m sans-serif; [32mcolor: #222; }[m | |
[32m body {[m margin:[31m0 0 25px 0;[m | |
[31m min-width: 800px;[m | |
[31m padding:[m 0; [32mfont-size: 1em; line-height: 1.4;[m } | |
[31m#main[m[32m::-moz-selection[m { [31mbackground-clip: padding-box;[m | |
[31m background-color:[m[32mbackground: #E37B52; color: #fff; text-shadow: none; }[m | |
[32m ::selection { background: #E37B52; color:[m #fff; [31mborder:1px[m[32mtext-shadow: none; }[m | |
[32m a { color: #00e; }[m | |
[32m a:visited { color: #551a8b; }[m | |
[32m a:hover { color: #06e; }[m | |
[32m a:focus { outline: thin dotted; }[m | |
[32m a:hover, a:active { outline: 0; }[m | |
[32m abbr[title] { border-bottom: 1px dotted; }[m | |
[32m b, strong { font-weight: bold; }[m | |
[32m blockquote { margin: 1em 40px; }[m | |
[32m dfn { font-style: italic; }[m | |
[32m hr { display: block; height: 1px; border: 0; border-top: 1px[m solid #ccc;[31mborder-radius: 5px;[m | |
[31m box-shadow: 0 0 10px #cdcdcd;[m margin: [31m25px auto[m[32m1em[m 0; padding: [31m30px;[m | |
[31m width: 700px;[m | |
[31m position: relative;[m[32m0; }[m | |
[32m ins { background: #ff9; color: #000; text-decoration: none;[m } | |
[31m#main h1[m[32mmark { background: #ff0; color: #000; font-style: italic; font-weight: bold; }[m | |
[32m pre, code, kbd, samp[m { font-family: [31m'Ubuntu';[m[32mmonospace, serif; _font-family: 'courier new', monospace;[m font-size: [31m38px;[m | |
[31m letter-spacing: 2px;[m | |
[31m margin: 0 0 10px 0;[m | |
[31m padding: 0;[m[32m1em;[m } | |
[31m#main h2[m[32mpre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; }[m | |
[32m q { quotes: none; }[m | |
[32m q:before, q:after { content: ""; content: none; }[m | |
[32m small[m {[31mcolor: #999;[m font-size: [31m18px;[m | |
[31m letter-spacing: 3px;[m[32m85%; }[m | |
[32m sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }[m | |
[32m sup { top: -0.5em; }[m | |
[32m sub { bottom: -0.25em; }[m | |
[32m ul, ol {[m margin: [31m0 0 25px[m[32m1em[m 0; padding: 0 0 0 [31m0;[m[32m40px;[m } | |
[31m#main h3[m[32mdd[m { [31mcolor: #999;[m | |
[31m margin-top: 24px;[m | |
[31m padding:[m[32mmargin:[m 0 0 0 [32m40px; }[m | |
[32m nav ul, nav ol { list-style: none; list-style-image: none; margin: 0; padding:[m 0; } | |
[31m#main h3[m[32mimg[m { [31mfont-size: 18px;[m[32mborder: 0; -ms-interpolation-mode: bicubic; vertical-align: middle;[m } | |
[31m#main p[m[32msvg:not(:root) { overflow: hidden; }[m | |
[32m figure[m {[31mline-height: 25px;[m margin:[31m10px[m 0; } | |
[31m#main pre[m[32mform[m { [31mbackground-color: #333;[m | |
[31m border-left: 1px solid #d8d8d8;[m | |
[31m border-top: 1px solid #d8d8d8;[m | |
[31m border-radius: 5px;[m | |
[31m color: #eee;[m | |
[31m padding: 10px;[m[32mmargin: 0;[m } | |
[31m#main ul[m[32mfieldset[m { [32mborder: 0;[m margin:[31m10px[m 0; padding: [31m0 30px;[m[32m0; }[m | |
[32m label { cursor: pointer; }[m | |
[32m legend { border: 0; *margin-left: -7px; padding: 0; white-space: normal;[m } | |
[31m#main li[m[32mbutton, input, select, textarea[m { [32mfont-size: 100%;[m margin:[31m5px[m 0; [32mvertical-align: baseline; *vertical-align: middle; }[m | |
[32m button, input { line-height: normal; }[m | |
[32m button, input[type="button"], input[type="reset"], input[type="submit"] { cursor: pointer; -webkit-appearance: button; *overflow: visible; }[m | |
[32m button[disabled], input[disabled] { cursor: default; }[m | |
[32m input[type="checkbox"], input[type="radio"] { box-sizing: border-box; padding: 0; *width: 13px; *height: 13px; }[m | |
[32m input[type="search"] { -webkit-appearance: textfield; -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; }[m | |
[32m input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }[m | |
[32m button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; }[m | |
[32m textarea { overflow: auto; vertical-align: top; resize: vertical; }[m | |
[32m input:valid, textarea:valid { }[m | |
[32m input:invalid, textarea:invalid { background-color: #f0dddd; }[m | |
[32m table { border-collapse: collapse; border-spacing: 0; }[m | |
[32m td { vertical-align: top; }[m | |
[32m body[m | |
[32m {[m | |
[32m font-family:'Droid Sans', sans-serif;[m | |
[32m font-size:10pt;[m | |
[32m color:#555;[m | |
[32m line-height: 25px;[m | |
[32m }[m | |
[32m .wrapper[m | |
[32m {[m | |
[32m width:760px;[m | |
[32m margin:0 auto 5em auto;[m | |
[32m }[m | |
[32m .main[m | |
[32m {[m | |
[32m overflow:hidden;[m | |
[32m }[m | |
[32m .error-spacer[m | |
[32m {[m | |
[32m height:4em;[m | |
[32m }[m | |
[32m a, a:visited[m | |
[32m {[m | |
[32m color:#2972A3;[m | |
[32m }[m | |
[32m a:hover[m | |
[32m {[m | |
[32m color:#72ADD4;[m | |
} | |
</style> | |
</head> | |
<body> | |
<div [31mid="main">[m[32mclass="wrapper">[m | |
[32m <div class="error-spacer"></div>[m | |
[32m <div role="main" class="main">[m | |
<?php $messages = array('Ouch.', 'Oh no!', 'Whoops!'); ?>[m | |
<h1><?php echo $messages[mt_rand(0, 2)]; ?></h1>[m | |
<h2>Server Error: 500 (Internal Server Error)</h2>[m | |
[32m<hr>[m | |
<h3>What does this mean?</h3>[m | |
<p>[m | |
[36m@@ -99,5 +120,6 @@[m | |
Perhaps you would like to go to our <?php echo HTML::link('/', 'home page'); ?>?[m | |
</p>[m | |
</div>[m | |
[32m</div>[m | |
</body> | |
</html>[m | |
No newline at end of file[m | |
[1mdiff --git a/application/views/home/index.php b/application/views/home/index.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 156c36a..0000000[m | |
[1m--- a/application/views/home/index.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,129 +0,0 @@[m | |
[31m<!doctype html>[m | |
[31m<html>[m | |
[31m <head>[m | |
[31m <meta charset="utf-8">[m | |
[31m <title>Laravel - A Framework For Web Artisans</title>[m | |
[31m <style>[m | |
[31m @import url(http://fonts.googleapis.com/css?family=Ubuntu);[m | |
[31m body {[m | |
[31m background: #eee;[m | |
[31m color: #6d6d6d;[m | |
[31m font: normal normal normal 14px/1.253 Ubuntu, sans-serif;[m | |
[31m margin: 0 0 25px 0;[m | |
[31m min-width: 800px;[m | |
[31m padding: 0;[m | |
[31m }[m | |
[31m #main {[m | |
[31m background-clip: padding-box;[m | |
[31m background-color: #fff;[m | |
[31m border:1px solid #ccc;[m | |
[31m border-radius: 5px;[m | |
[31m box-shadow: 0 0 10px #cdcdcd;[m | |
[31m margin: 25px auto 0;[m | |
[31m padding: 30px;[m | |
[31m width: 700px;[m | |
[31m position: relative;[m | |
[31m }[m | |
[31m #main h1 {[m | |
[31m font-family: 'Ubuntu';[m | |
[31m font-size: 38px;[m | |
[31m letter-spacing: 2px;[m | |
[31m margin: 0 0 10px 0;[m | |
[31m padding: 0;[m | |
[31m }[m | |
[31m #main h2 {[m | |
[31m color: #999;[m | |
[31m font-size: 18px;[m | |
[31m letter-spacing: 3px;[m | |
[31m margin: 0 0 25px 0;[m | |
[31m padding: 0 0 0 0;[m | |
[31m }[m | |
[31m #main h3 {[m | |
[31m color: #999;[m | |
[31m margin-top: 24px;[m | |
[31m padding: 0 0 0 0;[m | |
[31m }[m | |
[31m #main h3 {[m | |
[31m font-size: 18px;[m | |
[31m }[m | |
[31m #main p {[m | |
[31m line-height: 25px;[m | |
[31m margin: 10px 0;[m | |
[31m }[m | |
[31m #main pre {[m | |
[31m background-color: #333;[m | |
[31m border-left: 1px solid #d8d8d8;[m | |
[31m border-top: 1px solid #d8d8d8;[m | |
[31m border-radius: 5px;[m | |
[31m color: #eee;[m | |
[31m padding: 10px;[m | |
[31m }[m | |
[31m #main div.warning {[m | |
[31m background-color: #feefb3;[m | |
[31m border: 1px solid;[m | |
[31m border-radius: 5px;[m | |
[31m color: #9f6000;[m | |
[31m padding: 10px;[m | |
[31m }[m | |
[31m #main ul {[m | |
[31m margin: 10px 0;[m | |
[31m padding: 0 30px;[m | |
[31m }[m | |
[31m #main li {[m | |
[31m margin: 5px 0;[m | |
[31m }[m | |
[31m </style>[m | |
[31m </head>[m | |
[31m <body>[m | |
[31m <div id="main">[m | |
[31m <h1>Welcome To Laravel</h1>[m | |
[31m <h2>A Framework For Web Artisans</h2>[m | |
[31m <p>[m | |
[31m You have successfully installed the Laravel framework. Laravel is a simple framework[m | |
[31m that helps web artisans create beautiful, creative applications using elegant, expressive[m | |
[31m syntax. You'll love using it.[m | |
[31m </p>[m | |
[31m <h3>Learn the terrain.</h3>[m | |
[31m <p>[m | |
[31m You've landed yourself on our default home page. The route that[m | |
[31m is generating this page lives at:[m | |
[31m </p>[m | |
[31m <pre><code>APP_PATH/routes.php</code></pre>[m | |
[31m <p>And the view sitting before you can be found at:</p>[m | |
[31m <pre><code>APP_PATH/views/home/index.php</code></pre>[m | |
[31m <h3>Create something beautiful.</h3>[m | |
[31m <p>[m | |
[31m Now that you're up and running, it's time to start creating![m | |
[31m Here are some links to help you get started:[m | |
[31m </p>[m | |
[31m <ul>[m | |
[31m <li><a href="http://laravel.com">Official Website</a></li>[m | |
[31m <li><a href="http://forums.laravel.com">Laravel Forums</a></li>[m | |
[31m <li><a href="http://github.com/laravel/laravel">GitHub Repository</a></li>[m | |
[31m </ul>[m | |
[31m </div>[m | |
[31m </body>[m | |
[31m</html>[m | |
No newline at end of file[m | |
[1mdiff --git a/artisan b/artisan[m | |
[1mindex 4e82030..2bae56a 100755[m | |
[1m--- a/artisan[m | |
[1m+++ b/artisan[m | |
[36m@@ -3,7 +3,7 @@[m | |
* Laravel - A PHP Framework For Web Artisans[m | |
*[m | |
* @package Laravel[m | |
* @version [31m3.1.9[m[32m3.2.0[m | |
* @author Taylor Otwell <[email protected]>[m | |
* @link http://laravel.com[m | |
*/[m | |
[1mdiff --git a/changes.md b/changes.md[m | |
[1mdeleted file mode 100755[m | |
[1mindex be8d437..0000000[m | |
[1m--- a/changes.md[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,204 +0,0 @@[m | |
[31m## Laravel Change Log[m | |
[31m## Contents[m | |
[31m- [Laravel 3.1.9](#3.1.9)[m | |
[31m- [Upgrading From 3.1.8](#upgrade-3.1.9)[m | |
[31m- [Laravel 3.1.8](#3.1.8)[m | |
[31m- [Upgrading From 3.1.7](#upgrade-3.1.8)[m | |
[31m- [Laravel 3.1.7](#3.1.7)[m | |
[31m- [Upgrading From 3.1.6](#upgrade-3.1.7)[m | |
[31m- [Laravel 3.1.6](#3.1.6)[m | |
[31m- [Upgrading From 3.1.5](#upgrade-3.1.6)[m | |
[31m- [Laravel 3.1.5](#3.1.5)[m | |
[31m- [Upgrading From 3.1.4](#upgrade-3.1.5)[m | |
[31m- [Laravel 3.1.4](#3.1.4)[m | |
[31m- [Upgrading From 3.1.3](#upgrade-3.1.4)[m | |
[31m- [Laravel 3.1.3](#3.1.3)[m | |
[31m- [Upgrading From 3.1.2](#uprade-3.1.3)[m | |
[31m- [Laravel 3.1.2](#3.1.2)[m | |
[31m- [Upgrading From 3.1.1](#upgrade-3.1.2)[m | |
[31m- [Laravel 3.1.1](#3.1.1)[m | |
[31m- [Upgrading From 3.1](#upgrade-3.1.1)[m | |
[31m- [Laravel 3.1](#3.1)[m | |
[31m- [Upgrading From 3.0](#upgrade-3.1)[m | |
[31m<a name="3.1.9"></a>[m | |
[31m## Laravel 3.1.9[m | |
[31m- Fixes cookie session driver bug that caused infinite loop on some occasions.[m | |
[31m<a name="upgrade-3.1.9"></a>[m | |
[31m## Upgrading From 3.1.8[m | |
[31m- Replace the **laravel** folder.[m | |
[31m<a name="3.1.8"></a>[m | |
[31m## Laravel 3.1.8[m | |
[31m- Fixes possible WSOD when using Blade's @include expression.[m | |
[31m<a name="upgrade-3.1.8"></a>[m | |
[31m## Upgrading From 3.1.7[m | |
[31m- Replace the **laravel** folder.[m | |
[31m<a name="3.1.7"></a>[m | |
[31m## Laravel 3.1.7[m | |
[31m- Fixes custom validation language line loading from bundles.[m | |
[31m- Fixes double-loading of classes when overriding the core.[m | |
[31m- Classify migration names.[m | |
[31m<a name="upgrade-3.1.7"></a>[m | |
[31m## Upgrading From 3.1.6[m | |
[31m- Replace the **laravel** folder.[m | |
[31m<a name="3.1.6"></a>[m | |
[31m## Laravel 3.1.6[m | |
[31m- Fixes many-to-many eager loading in Eloquent.[m | |
[31m<a name="upgrade-3.1.6"></a>[m | |
[31m## Upgrading From 3.1.5[m | |
[31m- Replace the **laravel** folder.[m | |
[31m<a name="3.1.5"></a>[m | |
[31m## Laravel 3.1.5[m | |
[31m- Fixes bug that could allow secure cookies to be sent over HTTP.[m | |
[31m<a name="upgrade-3.1.5"></a>[m | |
[31m## Upgrading From 3.1.4[m | |
[31m- Replace the **laravel** folder.[m | |
[31m<a name="3.1.4"></a>[m | |
[31m## Laravel 3.1.4[m | |
[31m- Fixes Response header casing bug.[m | |
[31m- Fixes SQL "where in" (...) short-cut bug.[m | |
[31m<a name="upgrade-3.1.4"></a>[m | |
[31m## Upgrading From 3.1.3[m | |
[31m- Replace the **laravel** folder.[m | |
[31m<a name="3.1.3"></a>[m | |
[31m## Laravel 3.1.3[m | |
[31m- Fixes **delete** method in Eloquent models.[m | |
[31m<a name="upgrade-3.1.3"></a>[m | |
[31m## Upgrade From 3.1.2[m | |
[31m- Replace the **laravel** folder.[m | |
[31m<a name="3.1.2"></a>[m | |
[31m## Laravel 3.1.2[m | |
[31m- Fixes Eloquent query method constructor conflict.[m | |
[31m<a name="upgrade-3.1.2"></a>[m | |
[31m## Upgrade From 3.1.1[m | |
[31m- Replace the **laravel** folder.[m | |
[31m<a name="3.1.1"></a>[m | |
[31m## Laravel 3.1.1[m | |
[31m- Fixes Eloquent model hydration bug involving custom setters.[m | |
[31m<a name="upgrade-3.1.1"></a>[m | |
[31m## Upgrading From 3.1[m | |
[31m- Replace the **laravel** folder.[m | |
[31m<a name="3.1"></a>[m | |
[31m## Laravel 3.1[m | |
[31m- Added events to logger for more flexibility.[m | |
[31m- Added **database.fetch** configuration option.[m | |
[31m- Added controller factories for injecting any IoC.[m | |
[31m- Added **link_to_action** HTML helpers.[m | |
[31m- Added ability to set default value on Config::get.[m | |
[31m- Added the ability to add pattern based filters.[m | |
[31m- Improved session ID assignment.[m | |
[31m- Added support for "unsigned" integers in schema builder.[m | |
[31m- Added config, view, and lang loaders.[m | |
[31m- Added more logic to **application/start.php** for more flexibility.[m | |
[31m- Added foreign key support to schema builder.[m | |
[31m- Postgres "unique" indexes are now added with ADD CONSTRAINT.[m | |
[31m- Added "Event::until" method.[m | |
[31m- Added "memory" cache and session drivers.[m | |
[31m- Added Controller::detect method.[m | |
[31m- Added Cache::forever method.[m | |
[31m- Controller layouts now resolved in Laravel\Controller __construct.[m | |
[31m- Rewrote Eloquent and included in core.[m | |
[31m- Added "match" validation rule.[m | |
[31m- Fixed table prefix bug.[m | |
[31m- Added Form::macro method.[m | |
[31m- Added HTML::macro method.[m | |
[31m- Added Route::forward method.[m | |
[31m- Prepend table name to default index names in schema.[m | |
[31m- Added "forelse" to Blade.[m | |
[31m- Added View::render_each.[m | |
[31m- Able to specify full path to view (path: ).[m | |
[31m- Added support for Blade template inheritance.[m | |
[31m- Added "before" and "after" validation checks for dates.[m | |
[31m<a name="upgrade-3.1"></a>[m | |
[31m## Upgrading From 3.0[m | |
[31m### Replace your **application/start.php** file.[m | |
[31mThe default **start.php** file has been expanded in order to give you more flexibility over the loading of your language, configuration, and view files. To upgrade your file, copy your current file and paste it at the bottom of a copy of the new Laravel 3.1 start file. Next, scroll up in the **start** file until you see the default Autoloader registrations (line 61 and line 76). Delete both of these sections since you just pasted your previous auto-loader registrations at the bottom of the file.[m | |
[31m### Remove the **display** option from your **errors** configuration file.[m | |
[31mThis option is now set at the beginning of your **application/start** file.[m | |
[31m### Call the parent controller's constructor from your controller.[m | |
[31mSimply add a **parent::__construct();** to to any of your controllers that have a constructor.[m | |
[31m### Prefix Laravel migration created indexes with their table name.[m | |
[31mIf you have created indexes on tables using the Laravel migration system and you used to the default index naming scheme provided by Laravel, prefix the index names with their table name on your database. So, if the current index name is "id_unique" on the "users" table, make the index name "users_id_unique".[m | |
[31m### Add alias for Eloquent in your application configuration.[m | |
[31mAdd the following to the **aliases** array in your **application/config/application.php** file:[m | |
[31m 'Eloquent' => 'Laravel\\Database\\Eloquent\\Model',[m | |
[31m 'Blade' => 'Laravel\\Blade',[m | |
[31m### Update Eloquent many-to-many tables.[m | |
[31mEloquent now maintains **created_at** and **updated_at** column on many-to-many intermediate tables by default. Simply add these columns to your tables. Also, many-to-many tables are now the singular model names concatenated with an underscore. For example, if the relationship is between User and Role, the intermediate table name should be **role_user**.[m | |
[31m### Remove Eloquent bundle.[m | |
[31mIf you are using the Eloquent bundle with your installation, you can remove it from your bundles directory and your **application/bundles.php** file. Eloquent version 2 is included in the core in Laravel 3.1. Your models can also now extend simply **Eloquent** instead of **Eloquent\Model**.[m | |
[31m### Update your **config/strings.php** file.[m | |
[31mEnglish pluralization and singularization is now automatic. Just completely replace your **application/config/strings.php** file.[m | |
[31m### Add the **fetch** option to your database configuration file.[m | |
[31mA new **fetch** option allows you to specify in which format you receive your database results. Just copy and paste the option from the new **application/config/database.php** file.[m | |
[31m### Add **database** option to your Redis configuration.[m | |
[31mIf you are using Redis, add the "database" option to your Redis connection configurations. The "database" value can be zero by default.[m | |
[31m 'redis' => array([m | |
[31m 'default' => array([m | |
[31m 'host' => '127.0.0.1',[m | |
[31m 'port' => 6379,[m | |
[31m 'database' => 0[m | |
[31m ),[m | |
[31m ),[m | |
[1mdiff --git a/laravel/asset.php b/laravel/asset.php[m | |
[1mindex 8b6f930..6bc3647 100755[m | |
[1m--- a/laravel/asset.php[m | |
[1m+++ b/laravel/asset.php[m | |
[36m@@ -1,4 +1,4 @@[m | |
<?php namespace Laravel;[31mdefined('DS') or die('No direct script access.');[m | |
class Asset {[m | |
[1mdiff --git a/laravel/auth.php b/laravel/auth.php[m | |
[1mindex bacd086..ad4869c 100755[m | |
[1m--- a/laravel/auth.php[m | |
[1m+++ b/laravel/auth.php[m | |
[36m@@ -1,216 +1,93 @@[m | |
<?php namespace Laravel; [32muse Closure;[m | |
class Auth {[m | |
/**[m | |
* The [31mcurrent user of the application.[m[32mcurrently active authentication drivers.[m | |
*[m | |
* @var [31mobject[m[32marray[m | |
*/[m | |
public static [31m$user;[m[32m$drivers = array();[m | |
/**[m | |
* The [31mkey used when storing the user ID in the session.[m[32mthird-party driver registrar.[m | |
*[m | |
* @var [31mstring[m[32marray[m | |
*/[m | |
[31mconst user_key[m[32mpublic static $registrar[m = [31m'laravel_user_id';[m[32marray();[m | |
/**[m | |
* [31mDetermine if the user of the application is not logged in.[m[32mGet an authentication driver instance.[m | |
*[m | |
* [31mThis method is the inverse of the "check" method.[m | |
[31m *[m | |
[31m * @return bool[m | |
[31m */[m | |
[31m public static function guest()[m | |
[31m {[m | |
[31m return ! static::check();[m | |
[31m }[m | |
[31m /**[m | |
[31m * Determine if the user of the application is logged in.[m | |
[31m *[m | |
[31m * @return bool[m | |
[31m */[m | |
[31m public static function check()[m | |
[31m {[m | |
[31m return ! is_null(static::user());[m | |
[31m }[m | |
[31m /**[m | |
[31m * Get the current user of the application.[m | |
[31m *[m | |
[31m * <code>[m | |
[31m * // Get the current user of the application[m | |
[31m * $user = Auth::user();[m | |
[31m *[m | |
[31m * // Access a property on the current user of the application[m | |
[31m * $email = Auth::user()->email;[m | |
[31m * </code>[m | |
[31m *[m[32m@param string $driver[m | |
* @return [31mobject|null[m[32mDriver[m | |
*/[m | |
public static function [31muser()[m[32mdriver($driver = null)[m | |
{[m | |
if [31m( ! is_null(static::$user)) return static::$user;[m | |
[31m $id[m[32m(is_null($driver)) $driver[m = [31mSession::get(Auth::user_key);[m | |
[31m // To retrieve the user, we'll first attempt to use the "user" Closure[m | |
[31m // defined in the auth configuration file, passing in the ID. The user[m | |
[31m // Closure gives the developer a ton of freedom surrounding how the[m | |
[31m // user is actually retrieved.[m | |
[31m $config = Config::get('auth');[m[32mConfig::get('auth.driver');[m | |
[31mstatic::$user = call_user_func($config['user'], $id);[m | |
[31m // If the user wasn't found in the database but a "remember me" cookie[m | |
[31m // exists, we'll attempt to recall the user based on the cookie value.[m | |
[31m // Since all cookies contain a fingerprint hash verifying that they[m | |
[31m // haven't changed, we can trust it.[m | |
[31m $recaller = Cookie::get($config['cookie']);[m if [31m(is_null(static::$user) and[m[32m([m ! [31mis_null($recaller))[m[32misset(static::$drivers[$driver]))[m | |
{[m | |
[31mstatic::$user[m[32mstatic::$drivers[$driver][m = [31mstatic::recall($recaller);[m[32mstatic::factory($driver);[m | |
}[m | |
return [31mstatic::$user;[m[32mstatic::$drivers[$driver];[m | |
}[m | |
/**[m | |
* [31mAttempt to login[m[32mCreate[m a [31muser based on a long-lived "remember me" cookie.[m[32mnew authentication driver instance.[m | |
*[m | |
* @param string [31m$recaller[m[32m$driver[m | |
* @return [31mmixed[m[32mDriver[m | |
*/[m | |
protected static function [31mrecall($recaller)[m[32mfactory($driver)[m | |
{[m | |
[31m$recaller = explode('|', Crypter::decrypt($recaller));[m | |
[31m // We'll pass the ID that was stored in the cookie into the same user[m | |
[31m // Closure that is used by the "user" method. If the method returns[m | |
[31m // a user, we will log them into the application.[m | |
[31m $user = call_user_func(Config::get('auth.user'), $recaller[0]);[m if [31m( ! is_null($user))[m[32m(isset(static::$registrar[$driver]))[m | |
{[m | |
[31mstatic::login($user);[m[32m$resolver = static::$registrar[$driver];[m | |
return [31m$user;[m[32m$resolver();[m | |
}[m | |
[31m }[m | |
[31m /**[m | |
[31m * Attempt to log a user into the application.[m | |
[31m *[m | |
[31m * <code>[m | |
[31m * // Attempt to log a user into the application[m | |
[31m * $success = Auth::attempt('username', 'password');[m | |
[31m *[m | |
[31m * // Attempt to login a user and set the "remember me" cookie[m | |
[31m * Auth::attempt('username', 'password', true);[m | |
[31m * </code>[m | |
[31m *[m | |
[31m * @param string $username[m | |
[31m * @param string $password[m | |
[31m * @param bool $remember[m | |
[31m * @return bool[m | |
[31m */[m | |
[31m public static function attempt($username, $password = null, $remember = false)[m | |
[31m {[m | |
[31m $config = Config::get('auth');[m | |
[31m// When attempting to login the user, we will call the "attempt" closure[m | |
[31m // from the configuration file. This gives the developer the freedom to[m | |
[31m // authenticate based on the needs of their application, even allowing[m | |
[31m // the user of third-party providers.[m | |
[31m $user = call_user_func($config['attempt'], $username, $password);[m | |
[31m if (is_null($user))[m[32mswitch ($driver)[m | |
[32m {[m | |
[32m case 'fluent':[m | |
return [31mfalse;[m[32mnew Auth\Drivers\Fluent(Config::get('auth.table'));[m | |
[31mstatic::login($user, $remember);[m[32mcase 'eloquent':[m | |
[32m return new Auth\Drivers\Eloquent(Config::get('auth.model'));[m | |
[31mreturn true;[m[32mdefault:[m | |
[32m throw new \Exception("Auth driver {$driver} is not supported.");[m | |
[32m }[m | |
}[m | |
/**[m | |
* [31mLog[m[32mRegister[m a [31muser into the application.[m | |
[31m *[m | |
[31m * <code>[m | |
[31m * // Login the user with an ID of 15[m | |
[31m * Auth::login(15);[m | |
[31m *[m | |
[31m * // Login a user by passing a user object[m | |
[31m * Auth::login($user);[m[32mthird-party authentication driver.[m | |
*[m | |
*[31m// Login a user and set a "remember me" cookie[m | |
[31m * Auth::login($user, true);[m | |
[31m * </code>[m | |
[31m *[m | |
[31m *[m @param [31mobject|int $user[m[32mstring $driver[m | |
* @param [31mbool $remember[m[32mClosure $resolver[m | |
* @return void[m | |
*/[m | |
public static function [31mlogin($user, $remember = false)[m[32mextend($driver, Closure $resolver)[m | |
{[m | |
[31m$id[m[32mstatic::$registrar[$driver][m = [31m(is_object($user)) ? $user->id : (int) $user;[m | |
[31m if ($remember) static::remember($id);[m | |
[31m Session::put(Auth::user_key, $id);[m[32m$resolver;[m | |
}[m | |
/**[m | |
* [31mSet a cookie so that[m[32mMagic Method for calling[m the [31muser is "remembered".[m[32mmethods on the default cache driver.[m | |
*[m | |
* [31m@param string $id[m[32m<code>[m | |
*[31m@return void[m | |
[31m */[m | |
[31m protected static function remember($id)[m | |
[31m {[m | |
[31m $recaller = Crypter::encrypt($id.'|'.Str::random(40));[m | |
[31m // This method assumes the "remember me" cookie should have the same[m // [31mconfiguration as the session cookie. Since this cookie, like[m[32mCall[m the [31m// session cookie, should be kept very secure, it's probably safe.[m | |
[31m // to assume the cookie settings are[m[32m"user" method on[m the [31msame.[m | |
[31m $config = Config::get('session');[m | |
[31m extract($config, EXTR_SKIP);[m | |
[31m $cookie = Config::get('auth.cookie');[m | |
[31m Cookie::forever($cookie, $recaller, $path, $domain, $secure);[m | |
[31m }[m | |
[31m /**[m[32mdefault auth driver[m | |
* [31mLog the current user out of the application.[m[32m$user = Auth::user();[m | |
*[m | |
* [31m@return void[m[32m// Call the "check" method on the default auth driver[m | |
[32m * Auth::check();[m | |
[32m * </code>[m | |
*/[m | |
public static function [31mlogout()[m[32m__callStatic($method, $parameters)[m | |
{[m | |
[31m// We will call the "logout" closure first, which gives the developer[m | |
[31m // the chance to do any clean-up or before the user is logged out of[m | |
[31m // the application. No action is taken by default.[m | |
[31m call_user_func(Config::get('auth.logout'), static::user());[m | |
[31m static::$user = null;[m | |
[31m $config = Config::get('session');[m | |
[31m extract($config, EXTR_SKIP);[m | |
[31m // When forgetting the cookie, we need to also pass in the path and[m | |
[31m // domain that would have been used when the cookie was originally[m | |
[31m // set by the framework, otherwise it will not be deleted.[m | |
[31m $cookie = Config::get('auth.cookie');[m | |
[31m Cookie::forget($cookie, $path, $domain, $secure);[m | |
[31m Session::forget(Auth::user_key);[m[32mreturn call_user_func_array(array(static::driver(), $method), $parameters);[m | |
}[m | |
}[m | |
No newline at end of file[m | |
[1mdiff --git a/laravel/autoloader.php b/laravel/autoloader.php[m | |
[1mindex f2d4007..296b9db 100755[m | |
[1m--- a/laravel/autoloader.php[m | |
[1m+++ b/laravel/autoloader.php[m | |
[36m@@ -1,4 +1,4 @@[m | |
<?php namespace Laravel;[31mdefined('DS') or die('No direct script access.');[m | |
class Autoloader {[m | |
[36m@@ -52,7 +52,7 @@[m [mclass Autoloader {[m | |
// called again for the "real" class name to load its file.[m | |
if (isset(static::$aliases[$class]))[m | |
{[m | |
[32mreturn[m class_alias(static::$aliases[$class], $class); | |
}[m | |
// All classes in Laravel are staticly mapped. There is no crazy search[m | |
[36m@@ -76,20 +76,6 @@[m [mclass Autoloader {[m | |
}[m | |
}[m | |
[31m // If the class uses PEAR-ish style underscores for indicating its[m | |
[31m // directory structure we'll load the class using PSR-0 standards[m | |
[31m // standards from that directory, trimming the root.[m | |
[31m foreach (static::$underscored as $prefix => $directory)[m | |
[31m {[m | |
[31m if (starts_with($class, $prefix))[m | |
[31m {[m | |
[31m return static::load_namespaced($class, $prefix, $directory);[m | |
[31m }[m | |
[31m }[m | |
[31m // If all else fails we will just iterator through the mapped[m | |
[31m // PSR-0 directories looking for the class. This is the last[m | |
[31m // resort and slowest loading option for the class.[m | |
static::load_psr($class);[m | |
}[m | |
[36m@@ -177,29 +163,28 @@[m [mclass Autoloader {[m | |
}[m | |
/**[m | |
* [31mRegister underscored "namespaces"[m[32mMap namespaces[m to [31mdirectory mappings.[m[32mdirectories.[m | |
*[m | |
* @param array $mappings | |
[32m* @param string $append[m | |
* @return void[m | |
*/[m | |
public static function [31munderscored($mappings)[m[32mnamespaces($mappings, $append = '\\')[m | |
{[m | |
$mappings = static::format_mappings($mappings, [31m'_');[m[32m$append);[m | |
[31mstatic::$underscored[m[32mstatic::$namespaces[m = array_merge($mappings, [31mstatic::$underscored);[m[32mstatic::$namespaces);[m | |
}[m | |
/**[m | |
* [31mMap namespaces[m[32mRegister underscored "namespaces"[m to [31mdirectories.[m[32mdirectory mappings.[m | |
*[m | |
* @param array $mappings[m | |
* @return void[m | |
*/[m | |
public static function [31mnamespaces($mappings)[m[32munderscored($mappings)[m | |
{[m | |
[31m$mappings = static::format_mappings($mappings, '\\');[m | |
[31m static::$namespaces = array_merge($mappings, static::$namespaces);[m[32mstatic::namespaces($mappings, '_');[m | |
}[m | |
/**[m | |
[1mdiff --git a/laravel/blade.php b/laravel/blade.php[m | |
[1mindex e3111d0..5961a53 100755[m | |
[1m--- a/laravel/blade.php[m | |
[1m+++ b/laravel/blade.php[m | |
[36m@@ -1,4 +1,4 @@[m | |
<?php namespace Laravel; use FilesystemIterator as fIterator; [32muse Closure;[m | |
class Blade {[m | |
[36m@@ -8,7 +8,9 @@[m [mclass Blade {[m | |
* @var array[m | |
*/[m | |
protected static $compilers = array([m | |
[32m'extensions',[m | |
'layouts',[m | |
[32m'comments',[m | |
'echos',[m | |
'forelse',[m | |
'empty',[m | |
[36m@@ -16,6 +18,8 @@[m [mclass Blade {[m | |
'structure_openings',[m | |
'structure_closings',[m | |
'else',[m | |
[32m'unless',[m | |
[32m 'endunless',[m | |
'includes',[m | |
'render_each',[m | |
'render',[m | |
[36m@@ -26,6 +30,13 @@[m [mclass Blade {[m | |
);[m | |
/**[m | |
[32m* An array of user defined compilers.[m | |
[32m *[m | |
[32m * @var array[m | |
[32m */[m | |
[32m protected static $extensions = array();[m | |
[32m /**[m | |
* Register the Blade view engine with Laravel.[m | |
*[m | |
* @return void[m | |
[36m@@ -39,7 +50,7 @@[m [mclass Blade {[m | |
// return false so the View can be rendered as normal.[m | |
if ( ! str_contains($view->path, BLADE_EXT))[m | |
{[m | |
[31mreturn false;[m[32mreturn;[m | |
}[m | |
$compiled = path('storage').'views/'.md5($view->path);[m | |
[36m@@ -62,6 +73,24 @@[m [mclass Blade {[m | |
}[m | |
/**[m | |
[32m* Register a custom Blade compiler.[m | |
[32m *[m | |
[32m * <code>[m | |
[32m * Blade::extend(function($view)[m | |
[32m * {[m | |
[32m * return str_replace('foo', 'bar', $view);[m | |
[32m * });[m | |
[32m * </code>[m | |
[32m *[m | |
[32m * @param Closure $compiler[m | |
[32m * @return void[m | |
[32m */[m | |
[32m public static function extend(Closure $compiler)[m | |
[32m {[m | |
[32m static::$extensions[] = $compiler;[m | |
[32m }[m | |
[32m /**[m | |
* Determine if a view is "expired" and needs to be re-compiled.[m | |
*[m | |
* @param string $view[m | |
[36m@@ -71,8 +100,6 @@[m [mclass Blade {[m | |
*/[m | |
public static function expired($view, $path)[m | |
{[m | |
[31m $compiled = static::compiled($path);[m | |
return filemtime($path) > filemtime(static::compiled($path));[m | |
}[m | |
[36m@@ -115,7 +142,7 @@[m [mclass Blade {[m | |
protected static function compile_layouts($value)[m | |
{[m | |
// If the Blade template is not using "layouts", we'll just return it[m | |
//[31mit[m unchanged since there is nothing to do with layouts and [31mwe'll[m[32mwe will[m | |
// just let the other Blade compilers handle the rest.[m | |
if ( ! starts_with($value, '@layout'))[m | |
{[m | |
[36m@@ -123,8 +150,8 @@[m [mclass Blade {[m | |
}[m | |
// First we'll split out the lines of the template so we can get the[m | |
//[31mthe[m layout from the top of the template. By convention it must[31m//[m be | |
[32m//[m located on the first line of the template contents. | |
$lines = preg_split("/(\r?\n)/", $value);[m | |
$pattern = static::matcher('layout');[m | |
[36m@@ -132,7 +159,7 @@[m [mclass Blade {[m | |
$lines[] = preg_replace($pattern, '$1@include$2', $lines[0]);[m | |
// We will add a "render" statement to the end of the templates and[m | |
//[31mand[m then slice off the [31m@layout[m[32m"@layout"[m shortcut from the start so the | |
// sections register before the parent template renders.[m | |
return implode(CRLF, array_slice($lines, 1));[m | |
}[m | |
[36m@@ -151,6 +178,19 @@[m [mclass Blade {[m | |
}[m | |
/**[m | |
[32m* Rewrites Blade comments into PHP comments.[m | |
[32m *[m | |
[32m * @param string $value[m | |
[32m * @return string[m | |
[32m */[m | |
[32m protected static function compile_comments($value)[m | |
[32m {[m | |
[32m $value = preg_replace('/\{\{--(.+?)(--\}\})?\n/', "<?php // $1 ?>", $value);[m | |
[32m return preg_replace('/\{\{--((.|\s)*?)--\}\}/', "<?php /* $1 */ ?>\n", $value);[m | |
[32m }[m | |
[32m /**[m | |
* Rewrites Blade echo statements into PHP echo statements.[m | |
*[m | |
* @param string $value[m | |
[36m@@ -176,7 +216,7 @@[m [mclass Blade {[m | |
preg_match('/\$[^\s]*/', $forelse, $variable);[m | |
// Once we have extracted the variable being looped against, we can add[m | |
// an if [31mstatmeent[m[32mstatement[m to the start of the loop that checks if the count | |
// of the variable being looped against is greater than zero.[m | |
$if = "<?php if (count({$variable[0]}) > 0): ?>";[m | |
[36m@@ -187,8 +227,8 @@[m [mclass Blade {[m | |
$blade = preg_replace($search, $replace, $forelse);[m | |
// Finally, once we have the check prepended to the loop we'll replace[m | |
// all instances of this [31m"forelse"[m[32mforelse[m syntax in the view content of the | |
// view being compiled to Blade syntax with real [32mPHP[m syntax. | |
$value = str_replace($forelse, $blade, $value);[m | |
}[m | |
[36m@@ -255,6 +295,30 @@[m [mclass Blade {[m | |
}[m | |
/**[m | |
[32m* Rewrites Blade "unless" statements into valid PHP.[m | |
[32m *[m | |
[32m * @param string $value[m | |
[32m * @return string[m | |
[32m */[m | |
[32m protected static function compile_unless($value)[m | |
[32m {[m | |
[32m $pattern = '/(\s*)@unless(\s*\(.*\))/';[m | |
[32m return preg_replace($pattern, '$1<?php if( ! ($2)): ?>', $value);[m | |
[32m }[m | |
[32m /**[m | |
[32m * Rewrites Blade "unless" endings into valid PHP.[m | |
[32m *[m | |
[32m * @param string $value[m | |
[32m * @return string[m | |
[32m */[m | |
[32m protected static function compile_endunless($value)[m | |
[32m {[m | |
[32m return str_replace('@endunless', '<?php endif; ?>', $value);[m | |
[32m }[m | |
[32m /**[m | |
* Rewrites Blade @include statements into valid PHP.[m | |
*[m | |
* @param string $value[m | |
[36m@@ -349,12 +413,28 @@[m [mclass Blade {[m | |
}[m | |
/**[m | |
[32m* Execute user defined compilers.[m | |
[32m *[m | |
[32m * @param string $value[m | |
[32m * @return string[m | |
[32m */[m | |
[32m protected static function compile_extensions($value)[m | |
[32m {[m | |
[32m foreach (static::$extensions as $compiler)[m | |
[32m {[m | |
[32m $value = $compiler($value);[m | |
[32m }[m | |
[32m return $value;[m | |
[32m } [m | |
[32m /**[m | |
* Get the regular expression for a generic Blade function.[m | |
*[m | |
* @param string $function[m | |
* @return string[m | |
*/[m | |
[31mprotected[m[32mpublic[m static function matcher($function) | |
{[m | |
return '/(\s*)@'.$function.'(\s*\(.*\))/';[m | |
}[m | |
[1mdiff --git a/laravel/bundle.php b/laravel/bundle.php[m | |
[1mindex dd58213..2259228 100755[m | |
[1m--- a/laravel/bundle.php[m | |
[1m+++ b/laravel/bundle.php[m | |
[36m@@ -64,7 +64,7 @@[m [mclass Bundle {[m | |
static::$bundles[$bundle] = array_merge($defaults, $config);[m | |
// It is possible for the [31mdeveloepr[m[32mdeveloper[m to specify auto-loader mappings | |
// directly on the bundle registration. This provides a convenient[m | |
// way to register mappings withuot a bootstrap.[m | |
if (isset($config['autoloads']))[m | |
[36m@@ -92,8 +92,12 @@[m [mclass Bundle {[m | |
// Each bundle may have a start script which is responsible for preparing[m | |
// the bundle for use by the application. The start script may register[m | |
// any classes the bundle uses with the [31mauto-loader,[m[32mauto-loader class,[m etc. | |
if [32m( ! is_null($starter = static::option($bundle, 'starter')))[m | |
[32m {[m | |
[32m $starter();[m | |
[32m }[m | |
[32m elseif[m (file_exists($path = static::path($bundle).'start'.EXT)) | |
{[m | |
require $path;[m | |
}[m | |
[36m@@ -271,9 +275,19 @@[m [mclass Bundle {[m | |
{[m | |
return path('app');[m | |
}[m | |
[31melse if[m[32melseif[m ($location = array_get(static::$bundles, $bundle.'.location')) | |
{[m | |
[32m// If the bundle location starts with "path: ", we will assume that a raw[m | |
[32m // path has been specified and will simply return it. Otherwise, we'll[m | |
[32m // prepend the bundle directory path onto the location and return.[m | |
[32m if (starts_with($location, 'path: '))[m | |
[32m {[m | |
[32m return str_finish(substr($location, 6), DS);[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
return str_finish(path('bundle').$location, DS); | |
[32m}[m | |
}[m | |
}[m | |
[36m@@ -287,7 +301,7 @@[m [mclass Bundle {[m | |
{[m | |
if (is_null($bundle)) return static::assets(DEFAULT_BUNDLE);[m | |
return ($bundle != DEFAULT_BUNDLE) ? [31mURL::base()."/bundles/{$bundle}/"[m[32m"/bundles/{$bundle}/"[m : [31mURL::base().'/';[m[32m'/';[m | |
}[m | |
/**[m | |
[36m@@ -374,8 +388,8 @@[m [mclass Bundle {[m | |
public static function parse($identifier)[m | |
{[m | |
// The parsed elements are cached so we don't have to reparse them on each[m | |
// subsequent request for the parsed element. [31mSo,[m[32mSo[m if we've already parsed | |
// the given element, we'll just return the cached [31mcopy.[m[32mcopy as the value.[m | |
if (isset(static::$elements[$identifier]))[m | |
{[m | |
return static::$elements[$identifier];[m | |
[36m@@ -387,7 +401,7 @@[m [mclass Bundle {[m | |
}[m | |
// If no bundle is in the identifier, we will insert the default bundle[m | |
// since classes like Config and Lang organize their items by bundle.[m | |
// The [31m"application"[m[32mapplication[m folder essentially behaves as a [32mdefault[m bundle. | |
else[m | |
{[m | |
$element = array(DEFAULT_BUNDLE, strtolower($identifier));[m | |
[36m@@ -412,13 +426,19 @@[m [mclass Bundle {[m | |
*[m | |
* @param string $bundle[m | |
* @param string $option[m | |
[32m* @param mixed $default[m | |
* @return mixed[m | |
*/[m | |
public static function option($bundle, [31m$option)[m[32m$option, $default = null)[m | |
{[m | |
$bundle = static::get($bundle);[m | |
if [31m( ! is_null($bundle))[m[32m(is_null($bundle))[m | |
[32m {[m | |
[32m return value($default);[m | |
[32m }[m | |
return array_get($bundle, [31m$option);[m[32m$option, $default);[m | |
}[m | |
/**[m | |
[1mdiff --git a/laravel/cache.php b/laravel/cache.php[m | |
[1mindex 723aa6e..02b86e4 100755[m | |
[1m--- a/laravel/cache.php[m | |
[1m+++ b/laravel/cache.php[m | |
[36m@@ -1,4 +1,4 @@[m | |
<?php namespace Laravel; [31mdefined('DS') or die('No direct script access.');[m[32muse Closure;[m | |
class Cache {[m | |
[36m@@ -10,6 +10,13 @@[m [mclass Cache {[m | |
public static $drivers = array();[m | |
/**[m | |
[32m* The third-party driver registrar.[m | |
[32m *[m | |
[32m * @var array[m | |
[32m */[m | |
[32m public static $registrar = array();[m | |
[32m /**[m | |
* Get a cache driver instance.[m | |
*[m | |
* If no driver name is specified, the default will be returned.[m | |
[36m@@ -45,6 +52,13 @@[m [mclass Cache {[m | |
*/[m | |
protected static function factory($driver)[m | |
{[m | |
[32mif (isset(static::$registrar[$driver]))[m | |
[32m {[m | |
[32m $resolver = static::$registrar[$driver];[m | |
[32m return $resolver();[m | |
[32m }[m | |
switch ($driver)[m | |
{[m | |
case 'apc':[m | |
[36m@@ -71,6 +85,18 @@[m [mclass Cache {[m | |
}[m | |
/**[m | |
[32m* Register a third-party cache driver.[m | |
[32m *[m | |
[32m * @param string $driver[m | |
[32m * @param Closure $resolver[m | |
[32m * @return void[m | |
[32m */[m | |
[32m public static function extend($driver, Closure $resolver)[m | |
[32m {[m | |
[32m static::$registrar[$driver] = $resolver;[m | |
[32m }[m | |
[32m /**[m | |
* Magic Method for calling the methods on the default cache driver.[m | |
*[m | |
* <code>[m | |
[1mdiff --git a/laravel/cache/drivers/database.php b/laravel/cache/drivers/database.php[m | |
[1mindex 3983e93..44bf478 100755[m | |
[1m--- a/laravel/cache/drivers/database.php[m | |
[1m+++ b/laravel/cache/drivers/database.php[m | |
[36m@@ -75,7 +75,7 @@[m [mclass Database extends Driver {[m | |
$expiration = $this->expiration($minutes);[m | |
// To update the value, we'll first attempt an insert against the[m | |
// database and if we catch an [31mexception,[m[32mexception[m we'll assume that the | |
// primary key already exists in the table and update.[m | |
try[m | |
{[m | |
[1mdiff --git a/laravel/cache/drivers/driver.php b/laravel/cache/drivers/driver.php[m | |
[1mindex b74ebe0..c6abcb2 100755[m | |
[1m--- a/laravel/cache/drivers/driver.php[m | |
[1m+++ b/laravel/cache/drivers/driver.php[m | |
[36m@@ -1,4 +1,4 @@[m | |
<?php namespace Laravel\Cache\Drivers;[31muse Closure;[m | |
abstract class Driver {[m | |
[36m@@ -69,16 +69,28 @@[m [mabstract class Driver {[m | |
* @param int $minutes[m | |
* @return mixed[m | |
*/[m | |
public function remember($key, $default, [31m$minutes)[m[32m$minutes, $function = 'put')[m | |
{[m | |
if ( ! is_null($item = $this->get($key, null))) return $item;[m | |
[31m$this->put($key,[m[32m$this->$function($key,[m $default = value($default), $minutes); | |
return $default;[m | |
}[m | |
/**[m | |
[32m* Get an item from the cache, or cache the default value forever.[m | |
[32m *[m | |
[32m * @param string $key[m | |
[32m * @param mixed $default[m | |
[32m * @return mixed[m | |
[32m */[m | |
[32m public function sear($key, $default)[m | |
[32m {[m | |
[32m return $this->remember($key, $default, null, 'forever');[m | |
[32m }[m | |
[32m /**[m | |
* Delete an item from the cache.[m | |
*[m | |
* @param string $key[m | |
[1mdiff --git a/laravel/cache/drivers/file.php b/laravel/cache/drivers/file.php[m | |
[1mindex ee54aa3..c37520e 100755[m | |
[1m--- a/laravel/cache/drivers/file.php[m | |
[1m+++ b/laravel/cache/drivers/file.php[m | |
[36m@@ -42,9 +42,8 @@[m [mclass File extends Driver {[m | |
if ( ! file_exists($this->path.$key)) return null;[m | |
// File based caches store have the expiration timestamp stored in[m | |
// UNIX format prepended to their contents. [31mThis timestamp is then[m[32mWe'll compare the[m | |
// [31mextracted and removed when[m[32mtimestamp to[m the [31mcache is[m[32mcurrent time when we[m read[31mto determine if[m | |
[31m //[m the [31mfile is still valid.[m[32mfile.[m | |
if (time() >= substr($cache = file_get_contents($this->path.$key), 0, 10))[m | |
{[m | |
return $this->forget($key);[m | |
[36m@@ -68,6 +67,8 @@[m [mclass File extends Driver {[m | |
*/[m | |
public function put($key, $value, $minutes)[m | |
{[m | |
[32mif ($minutes <= 0) return;[m | |
$value = $this->expiration($minutes).serialize($value);[m | |
file_put_contents($this->path.$key, $value, LOCK_EX);[m | |
[1mdiff --git a/laravel/cache/drivers/memcached.php b/laravel/cache/drivers/memcached.php[m | |
[1mindex 4601e38..3e6a454 100755[m | |
[1m--- a/laravel/cache/drivers/memcached.php[m | |
[1m+++ b/laravel/cache/drivers/memcached.php[m | |
[36m@@ -1,13 +1,13 @@[m | |
<?php namespace Laravel\Cache\Drivers;[31muse Memcache;[m | |
class Memcached extends [31mDriver[m[32mSectionable[m { | |
/**[m | |
* The Memcache instance.[m | |
*[m | |
* @var [31mMemcache[m[32mMemcached[m | |
*/[m | |
[31mprotected[m[32mpublic[m $memcache; | |
/**[m | |
* The cache key from the cache configuration file.[m | |
[36m@@ -19,10 +19,10 @@[m [mclass Memcached extends Driver {[m | |
/**[m | |
* Create a new Memcached cache driver instance.[m | |
*[m | |
* @param [31mMemcache[m[32mMemcached[m $memcache | |
* @return void[m | |
*/[m | |
public function [31m__construct(Memcache[m[32m__construct(\Memcached[m $memcache, $key) | |
{[m | |
$this->key = $key;[m | |
$this->memcache = $memcache;[m | |
[36m@@ -47,7 +47,13 @@[m [mclass Memcached extends Driver {[m | |
*/[m | |
protected function retrieve($key)[m | |
{[m | |
if [32m($this->sectionable($key))[m | |
[32m {[m | |
[32m list($section, $key) = $this->parse($key);[m | |
[32m return $this->get_from_section($section, $key);[m | |
[32m }[m | |
[32m elseif[m (($cache = $this->memcache->get($this->key.$key)) !== false) | |
{[m | |
return $cache;[m | |
}[m | |
[36m@@ -68,7 +74,16 @@[m [mclass Memcached extends Driver {[m | |
*/[m | |
public function put($key, $value, $minutes)[m | |
{[m | |
[32mif ($this->sectionable($key))[m | |
[32m {[m | |
[32m list($section, $key) = $this->parse($key);[m | |
[32m return $this->put_in_section($section, $key, $value, $minutes);[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
$this->memcache->set($this->key.$key, $value,[31m0,[m $minutes * 60); | |
[32m}[m | |
}[m | |
/**[m | |
[36m@@ -80,7 +95,16 @@[m [mclass Memcached extends Driver {[m | |
*/[m | |
public function forever($key, $value)[m | |
{[m | |
[32mif ($this->sectionable($key))[m | |
[32m {[m | |
[32m list($section, $key) = $this->parse($key);[m | |
[32m return $this->forever_in_section($section, $key, $value);[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
return $this->put($key, $value, 0); | |
[32m}[m | |
}[m | |
/**[m | |
[36m@@ -91,7 +115,71 @@[m [mclass Memcached extends Driver {[m | |
*/[m | |
public function forget($key)[m | |
{[m | |
[32mif ($this->sectionable($key))[m | |
[32m {[m | |
[32m list($section, $key) = $this->parse($key);[m | |
[32m if ($key == '*')[m | |
[32m {[m | |
[32m $this->forget_section($section);[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
[32m $this->forget_in_section($section, $key);[m | |
[32m }[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
$this->memcache->delete($this->key.$key); | |
[32m}[m | |
[32m }[m | |
[32m /**[m | |
[32m * Delete an entire section from the cache.[m | |
[32m *[m | |
[32m * @param string $section[m | |
[32m * @return int|bool[m | |
[32m */[m | |
[32m public function forget_section($section)[m | |
[32m {[m | |
[32m return $this->memcache->increment($this->key.$this->section_key($section));[m | |
[32m }[m | |
[32m /**[m | |
[32m * Get the current section ID for a given section.[m | |
[32m *[m | |
[32m * @param string $section[m | |
[32m * @return int[m | |
[32m */[m | |
[32m protected function section_id($section)[m | |
[32m {[m | |
[32m return $this->sear($this->section_key($section), function()[m | |
[32m {[m | |
[32m return rand(1, 10000);[m | |
[32m });[m | |
[32m }[m | |
[32m /**[m | |
[32m * Get a section key name for a given section.[m | |
[32m *[m | |
[32m * @param string $section[m | |
[32m * @return string[m | |
[32m */[m | |
[32m protected function section_key($section)[m | |
[32m {[m | |
[32m return $section.'_section_key';[m | |
[32m }[m | |
[32m /**[m | |
[32m * Get a section item key for a given section and key.[m | |
[32m *[m | |
[32m * @param string $section[m | |
[32m * @param string $key[m | |
[32m * @return string[m | |
[32m */[m | |
[32m protected function section_item_key($section, $key)[m | |
[32m {[m | |
[32m return $section.'#'.$this->section_id($section).'#'.$key;[m | |
}[m | |
}[m | |
No newline at end of file[m | |
[1mdiff --git a/laravel/cache/drivers/memory.php b/laravel/cache/drivers/memory.php[m | |
[1mindex 3e23334..9f57592 100755[m | |
[1m--- a/laravel/cache/drivers/memory.php[m | |
[1m+++ b/laravel/cache/drivers/memory.php[m | |
[36m@@ -1,13 +1,13 @@[m | |
<?php namespace Laravel\Cache\Drivers;[m | |
class Memory extends [31mDriver[m[32mSectionable[m { | |
/**[m | |
* The in-memory array of cached items.[m | |
*[m | |
* @var string[m | |
*/[m | |
[31mprotected[m[32mpublic[m $storage = array(); | |
/**[m | |
* Determine if an item exists in the cache.[m | |
[36m@@ -28,9 +28,15 @@[m [mclass Memory extends Driver {[m | |
*/[m | |
protected function retrieve($key)[m | |
{[m | |
if [31m(array_key_exists($key, $this->storage))[m[32m($this->sectionable($key))[m | |
{[m | |
[32mlist($section, $key) = $this->parse($key);[m | |
return [31m$this->storage[$key];[m[32m$this->get_from_section($section, $key);[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
[32m return array_get($this->storage, $key);[m | |
}[m | |
}[m | |
[36m@@ -49,7 +55,16 @@[m [mclass Memory extends Driver {[m | |
*/[m | |
public function put($key, $value, $minutes)[m | |
{[m | |
[31m$this->storage[$key][m[32mif ($this->sectionable($key))[m | |
[32m {[m | |
[32m list($section, $key)[m = [31m$value;[m[32m$this->parse($key);[m | |
[32m return $this->put_in_section($section, $key, $value, $minutes);[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
[32m array_set($this->storage, $key, $value);[m | |
[32m }[m | |
}[m | |
/**[m | |
[36m@@ -61,7 +76,16 @@[m [mclass Memory extends Driver {[m | |
*/[m | |
public function forever($key, $value)[m | |
{[m | |
[32mif ($this->sectionable($key))[m | |
[32m {[m | |
[32m list($section, $key) = $this->parse($key);[m | |
[32m return $this->forever_in_section($section, $key, $value);[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
$this->put($key, $value, 0); | |
[32m}[m | |
}[m | |
/**[m | |
[36m@@ -72,7 +96,34 @@[m [mclass Memory extends Driver {[m | |
*/[m | |
public function forget($key)[m | |
{[m | |
[31munset($this->storage[$key]);[m[32mif ($this->sectionable($key))[m | |
[32m {[m | |
[32m list($section, $key) = $this->parse($key);[m | |
[32m if ($key == '*')[m | |
[32m {[m | |
[32m $this->forget_section($section);[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
[32m $this->forget_in_section($section, $key);[m | |
[32m }[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
[32m array_forget($this->storage, $key);[m | |
[32m }[m | |
[32m }[m | |
[32m /**[m | |
[32m * Delete an entire section from the cache.[m | |
[32m *[m | |
[32m * @param string $section[m | |
[32m * @return int|bool[m | |
[32m */[m | |
[32m public function forget_section($section)[m | |
[32m {[m | |
[32m array_forget($this->storage, 'section#'.$section);[m | |
}[m | |
/**[m | |
[36m@@ -85,4 +136,16 @@[m [mclass Memory extends Driver {[m | |
$this->storage = array();[m | |
}[m | |
[32m/**[m | |
[32m * Get a section item key for a given section and key.[m | |
[32m *[m | |
[32m * @param string $section[m | |
[32m * @param string $key[m | |
[32m * @return string[m | |
[32m */[m | |
[32m protected function section_item_key($section, $key)[m | |
[32m {[m | |
[32m return "section#{$section}.{$key}";[m | |
[32m }[m | |
}[m | |
No newline at end of file[m | |
[1mdiff --git a/laravel/cli/artisan.php b/laravel/cli/artisan.php[m | |
[1mindex a838f8e..46886dc 100755[m | |
[1m--- a/laravel/cli/artisan.php[m | |
[1m+++ b/laravel/cli/artisan.php[m | |
[36m@@ -2,6 +2,7 @@[m | |
use Laravel\Bundle;[m | |
use Laravel\Config;[m | |
[32muse Laravel\Request;[m | |
/**[m | |
* Fire up the default bundle. This will ensure any dependencies that[m | |
[36m@@ -15,9 +16,10 @@[m [mBundle::start(DEFAULT_BUNDLE);[m | |
* for the "database" CLI option. This allows migrations to be run[m | |
* conveniently for a test or staging database.[m | |
*/[m | |
if [31m(isset($_SERVER['CLI']['DB']))[m[32m( ! is_null($database = get_cli_option('db')))[m | |
{[m | |
Config::set('database.default', [31m$_SERVER['CLI']['DB']);[m[32m$database);[m | |
}[m | |
/**[m | |
[1mdiff --git a/laravel/cli/tasks/bundle/providers/provider.php b/laravel/cli/tasks/bundle/providers/provider.php[m | |
[1mindex bdf3b8c..bf6401f 100755[m | |
[1m--- a/laravel/cli/tasks/bundle/providers/provider.php[m | |
[1m+++ b/laravel/cli/tasks/bundle/providers/provider.php[m | |
[36m@@ -54,6 +54,7 @@[m [mabstract class Provider {[m | |
File::rmdir($work.'zip');[m | |
[32m$zip->close();[m | |
@unlink($target);[m | |
}[m | |
[1mdiff --git a/laravel/config.php b/laravel/config.php[m | |
[1mindex 9ea6894..50bd7dc 100755[m | |
[1m--- a/laravel/config.php[m | |
[1m+++ b/laravel/config.php[m | |
[36m@@ -1,7 +1,5 @@[m | |
<?php namespace Laravel; defined('DS') or die('No direct script access.');[m | |
[31muse Closure;[m | |
class Config {[m | |
/**[m | |
[36m@@ -226,9 +224,9 @@[m [mclass Config {[m | |
// Configuration files can be made specific for a given environment. If an[m | |
// environment has been set, we will merge the environment configuration[m | |
// in last, so that it overrides all other options.[m | |
if [31m(isset($_SERVER['LARAVEL_ENV']))[m[32m( ! is_null(Request::env()))[m | |
{[m | |
$paths[] = $paths[count($paths) - [31m1].$_SERVER['LARAVEL_ENV'].'/';[m[32m1].Request::env().'/';[m | |
}[m | |
return $paths;[m | |
[1mdiff --git a/laravel/cookie.php b/laravel/cookie.php[m | |
[1mindex 0f92818..8896740 100755[m | |
[1m--- a/laravel/cookie.php[m | |
[1m+++ b/laravel/cookie.php[m | |
[36m@@ -1,10 +1,15 @@[m | |
<?php namespace Laravel;[31mdefined('DS') or die('No direct script access.');[m | |
[31muse Closure;[m | |
class Cookie {[m | |
/**[m | |
[32m* How long is forever (in minutes).[m | |
[32m *[m | |
[32m * @var int[m | |
[32m */[m | |
[32m const forever = 525600;[m | |
[32m /**[m | |
* The cookies that have been set.[m | |
*[m | |
* @var array[m | |
[36m@@ -23,67 +28,13 @@[m [mclass Cookie {[m | |
}[m | |
/**[m | |
[31m * Send all of the cookies to the browser.[m | |
[31m *[m | |
[31m * @return void[m | |
[31m */[m | |
[31m public static function send()[m | |
[31m {[m | |
[31m if (headers_sent()) return false;[m | |
[31m // All cookies are stored in the "jar" when set and not sent directly to[m | |
[31m // the browser. This simply makes testing all of the cookie stuff very[m | |
[31m // easy since the jar can be inspected by tests.[m | |
[31m foreach (static::$jar as $cookie)[m | |
[31m {[m | |
[31m static::set($cookie);[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Send a cookie from the cookie jar back to the browser.[m | |
[31m *[m | |
[31m * @param array $cookie[m | |
[31m * @return void[m | |
[31m */[m | |
[31m protected static function set($cookie)[m | |
[31m {[m | |
[31m extract($cookie);[m | |
[31m $time = ($minutes !== 0) ? time() + ($minutes * 60) : 0;[m | |
[31m $value = static::sign($name, $value);[m | |
[31m // A cookie payload can't exceed 4096 bytes, so if the cookie payload[m | |
[31m // is greater than that, we'll raise an error to warn the developer[m | |
[31m // since it could cause cookie session problems.[m | |
[31m if (strlen($value) > 4000)[m | |
[31m {[m | |
[31m throw new \Exception("Payload too large for cookie.");[m | |
[31m }[m | |
[31m else[m | |
[31m {[m | |
[31m // We don't want to send secure cookies over HTTP unless the developer has[m | |
[31m // turned off the "SSL" application configuration option, which is used[m | |
[31m // while developing the application but should be true in production.[m | |
[31m if ($secure and ! Request::secure() and Config::get('application.ssl'))[m | |
[31m {[m | |
[31m return;[m | |
[31m }[m | |
[31m setcookie($name, $value, $time, $path, $domain, $secure);[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
* Get the value of a cookie.[m | |
*[m | |
* <code>[m | |
* // Get the value of the "favorite" cookie[m | |
* $favorite = Cookie::get('favorite');[m | |
*[m | |
* // Get the value of a cookie or return a default value | |
* $favorite = Cookie::get('framework', 'Laravel');[m | |
* </code>[m | |
*[m | |
[36m@@ -93,27 +44,9 @@[m [mclass Cookie {[m | |
*/[m | |
public static function get($name, $default = null)[m | |
{[m | |
if (isset(static::$jar[$name])) return [31mstatic::$jar[$name]['value'];[m | |
[31m $value = array_get($_COOKIE, $name);[m | |
[31m if ( ! is_null($value) and isset($value[40]) and $value[40] == '~')[m | |
[31m {[m | |
[31m // The hash signature and the cookie value are separated by a tilde[m | |
[31m // character for convenience. To separate the hash and the payload[m | |
[31m // we can simply expode on that character.[m | |
[31m list($hash, $value) = explode('~', $value, 2);[m[32mstatic::$jar[$name];[m | |
[31m// By re-feeding the cookie value into the "hash" method we should[m | |
[31m // be able to generate a hash that matches the one taken from the[m | |
[31m // cookie. If they don't, we[m return [31mnull.[m | |
[31m if (static::hash($name, $value) === $hash)[m | |
[31m {[m | |
[31m return $value;[m | |
[31m }[m | |
[31m }[m | |
[31m return value($default);[m[32marray_get(Request::foundation()->cookies->all(), $name, $default);[m | |
}[m | |
/**[m | |
[36m@@ -129,15 +62,28 @@[m [mclass Cookie {[m | |
*[m | |
* @param string $name[m | |
* @param string $value[m | |
* @param int [31m$minutes[m[32m$expiration[m | |
* @param string $path[m | |
* @param string $domain[m | |
* @param bool $secure[m | |
* @return void[m | |
*/[m | |
public static function put($name, $value, [31m$minutes[m[32m$expiration[m = 0, $path = '/', $domain = null, $secure = false) | |
{[m | |
[32mif ($expiration !== 0)[m | |
[32m {[m | |
[32m $expiration = time() + ($expiration * 60);[m | |
[32m }[m | |
[32m // If the secure option is set to true, yet the request is not over HTTPS[m | |
[32m // we'll throw an exception to let the developer know that they are[m | |
[32m // attempting to send a secure cookie over the unsecure HTTP.[m | |
[32m if ($secure and ! Request::secure())[m | |
[32m {[m | |
[32m throw new \Exception("Attempting to set secure cookie over HTTP.");[m | |
[32m }[m | |
static::$jar[$name] = compact('name', 'value', [31m'minutes',[m[32m'expiration',[m 'path', 'domain', 'secure'); | |
}[m | |
/**[m | |
[36m@@ -157,31 +103,7 @@[m [mclass Cookie {[m | |
*/[m | |
public static function forever($name, $value, $path = '/', $domain = null, $secure = false)[m | |
{[m | |
return static::put($name, $value, [31m525600,[m[32mstatic::forever,[m $path, $domain, $secure);[31m}[m | |
[31m /**[m | |
[31m * Generate a cookie signature based on the contents.[m | |
[31m *[m | |
[31m * @param string $name[m | |
[31m * @param string $value[m | |
[31m * @return string[m | |
[31m */[m | |
[31m public static function sign($name, $value)[m | |
[31m {[m | |
[31m return static::hash($name, $value).'~'.$value;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Generate a cookie hash based on the contents.[m | |
[31m *[m | |
[31m * @param string $name[m | |
[31m * @param string $value[m | |
[31m * @return string[m | |
[31m */[m | |
[31m protected static function hash($name, $value)[m | |
[31m {[m | |
[31m return sha1($name.$value.Config::get('application.key'));[m | |
}[m | |
/**[m | |
[1mdiff --git a/laravel/core.php b/laravel/core.php[m | |
[1mindex aeec701..0dcaaca 100755[m | |
[1m--- a/laravel/core.php[m | |
[1m+++ b/laravel/core.php[m | |
[36m@@ -92,53 +92,116 @@[m [mAutoloader::map(array([m | |
| Register The Symfony Components[m | |
|--------------------------------------------------------------------------[m | |
|[m | |
| [31mLaravel's "Artisan" CLI[m[32mLaravel[m makes use of the Symfony [31mConsole component[m[32mcomponents where the situation is[m | |
[32m| applicable and it is possible to do so. This allows us[m to [32mfocus[m | |
| [31mbuild a wonderful CLI environment[m[32mon the parts of the framework[m that [31mis both robust[m[32mare unique[m and [31mtestable.[m[32mnot re-do[m | |
| [31mWe'll register the component's namespace here.[m[32mplumbing code that others have written.[m | |
|[m | |
*/[m | |
Autoloader::namespaces(array([m | |
'Symfony\Component\Console' | |
=> [31mpath('base').'vendor/Symfony/Component/Console',[m[32mpath('sys').'vendor/Symfony/Component/Console',[m | |
[32m 'Symfony\Component\HttpFoundation'[m | |
[32m => path('sys').'vendor/Symfony/Component/HttpFoundation',[m | |
));[m | |
/*[m | |
|--------------------------------------------------------------------------[m | |
| [31mSet The CLI Options Array[m[32mMagic Quotes Strip Slashes[m | |
|--------------------------------------------------------------------------[m | |
|[m | |
| [31mIf the current request is from[m[32mEven though "Magic Quotes" are deprecated in PHP 5.3.x, they may still[m | |
[32m| be enabled on[m the [31mArtisan command-line interface,[m[32mserver. To account for this,[m we[31m|[m will [31mparse the command line arguments and options and set them the[m[32mstrip slashes[m | |
| [31marray of options in the $_SERVER global array[m[32mon all input arrays if magic quotes are enabled[m for [31mconvenience.[m[32mthe server.[m | |
|[m | |
*/[m | |
if [31m(defined('STDIN'))[m[32m(magic_quotes())[m | |
{[m | |
[31m$console[m[32m$magics[m = [31mCLI\Command::options($_SERVER['argv']);[m[32marray(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);[m | |
[31mlist($arguments, $options)[m[32mforeach ($magics as &$magic)[m | |
[32m {[m | |
[32m $magic[m = [31m$console;[m[32marray_strip_slashes($magic);[m | |
[32m }[m | |
[32m}[m | |
[31m$options = array_change_key_case($options, CASE_UPPER);[m[32m/*[m | |
[32m|--------------------------------------------------------------------------[m | |
[32m| Create The HttpFoundation Request[m | |
[32m|--------------------------------------------------------------------------[m | |
[32m|[m | |
[32m| Laravel uses the HttpFoundation Symfony component to handle the request[m | |
[32m| and response functionality for the framework. This allows us to not[m | |
[32m| worry about that boilerplate code and focus on what matters.[m | |
[32m|[m | |
[32m*/[m | |
[31m$_SERVER['CLI'][m[32muse Symfony\Component\HttpFoundation\LaravelRequest as RequestFoundation;[m | |
[32mRequest::$foundation[m = [31m$options;[m[32mRequestFoundation::createFromGlobals();[m | |
[32m/*[m | |
[32m|--------------------------------------------------------------------------[m | |
[32m| Determine The Application Environment[m | |
[32m|--------------------------------------------------------------------------[m | |
[32m|[m | |
[32m| Next we're ready to determine the application environment. This may be[m | |
[32m| set either via the command line options, or, if the request is from[m | |
[32m| the web, via the mapping of URIs to environments that lives in[m | |
[32m| the "paths.php" file for the application and is parsed.[m | |
[32m|[m | |
[32m*/[m | |
[32mif (Request::cli())[m | |
[32m{[m | |
[32m $environment = get_cli_option('env');[m | |
[32m}[m | |
[32melse[m | |
[32m{[m | |
[32m $root = Request::foundation()->getRootUrl();[m | |
[32m $environment = Request::detect_env($environments, $root);[m | |
}[m | |
/*[m | |
|--------------------------------------------------------------------------[m | |
| Set The [31mCLI Laravel[m[32mApplication[m Environment | |
|--------------------------------------------------------------------------[m | |
|[m | |
| [31mNext we'll set the LARAVEL_ENV variable if[m[32mOnce we have determined[m the [31mcurrent request is from[m[32mapplication environment, we will set it on[m | |
| the [31mArtisan command-line interface. Since[m[32mglobal server array of[m the [31menvironment is often[m | |
[31m| specified within an Apache .htaccess file, we need to set[m[32mHttpFoundation request. This makes[m it[31mhere[m | |
| [31mwhen[m[32mavailable throughout[m the [31mrequest[m[32mapplication, thought it[m is [31mnot coming through Apache.[m[32mmainly only[m | |
[32m| used to determine which configuration files to merge in.[m | |
|[m | |
*/[m | |
if [31m(isset($_SERVER['CLI']['ENV']))[m[32m(isset($environment))[m | |
{[m | |
[31m$_SERVER['LARAVEL_ENV'][m[32mRequest::set_env($environment);[m | |
[32m}[m | |
[32m/*[m | |
[32m|--------------------------------------------------------------------------[m | |
[32m| Set The CLI Options Array[m | |
[32m|--------------------------------------------------------------------------[m | |
[32m|[m | |
[32m| If the current request is from the Artisan command-line interface, we[m | |
[32m| will parse the command line arguments and options and set them the[m | |
[32m| array of options in the $_SERVER global array for convenience.[m | |
[32m|[m | |
[32m*/[m | |
[32mif (defined('STDIN'))[m | |
[32m{[m | |
[32m $console[m = [31m$_SERVER['CLI']['ENV'];[m[32mCLI\Command::options($_SERVER['argv']);[m | |
[32m list($arguments, $options) = $console;[m | |
[32m $options = array_change_key_case($options, CASE_UPPER);[m | |
[32m $_SERVER['CLI'] = $options;[m | |
}[m | |
/*[m | |
[36m@@ -147,7 +210,7 @@[m [mif (isset($_SERVER['CLI']['ENV']))[m | |
|--------------------------------------------------------------------------[m | |
|[m | |
| Finally we will register all of the bundles that have been defined for[m | |
| the application. None of them will be [31mstarted, yet[m[32mstarted yet,[m but will be setup | |
| so that they may be started by the developer at any time.[m | |
|[m | |
*/[m | |
[1mdiff --git a/laravel/crypter.php b/laravel/crypter.php[m | |
[1mindex f5113f3..18bac81 100755[m | |
[1m--- a/laravel/crypter.php[m | |
[1m+++ b/laravel/crypter.php[m | |
[36m@@ -74,7 +74,7 @@[m [mclass Crypter {[m | |
*[m | |
* @return int[m | |
*/[m | |
[31mprotected[m[32mpublic[m static function randomizer() | |
{[m | |
// There are various sources from which we can get random numbers[m | |
// but some are more random than others. We'll choose the most[m | |
[1mdiff --git a/laravel/database.php b/laravel/database.php[m | |
[1mindex 447fa76..e403616 100755[m | |
[1m--- a/laravel/database.php[m | |
[1m+++ b/laravel/database.php[m | |
[36m@@ -13,6 +13,13 @@[m [mclass Database {[m | |
public static $connections = array();[m | |
/**[m | |
[32m* The third-party driver registrar.[m | |
[32m *[m | |
[32m * @var array[m | |
[32m */[m | |
[32m public static $registrar = array();[m | |
[32m /**[m | |
* Get a database connection.[m | |
*[m | |
* If no database name is specified, the default connection will be returned.[m | |
[36m@@ -66,6 +73,13 @@[m [mclass Database {[m | |
*/[m | |
protected static function connector($driver)[m | |
{[m | |
[32mif (isset(static::$registrar[$driver]))[m | |
[32m {[m | |
[32m $resolver = static::$registrar[$driver]['connector'];[m | |
[32m return $resolver();[m | |
[32m }[m | |
switch ($driver)[m | |
{[m | |
case 'sqlite':[m | |
[36m@@ -121,6 +135,22 @@[m [mclass Database {[m | |
}[m | |
/**[m | |
[32m* Register a database connector and grammars.[m | |
[32m *[m | |
[32m * @param string $name[m | |
[32m * @param Closure $connector[m | |
[32m * @param Closure $query[m | |
[32m * @param Closure $schema[m | |
[32m * @return void[m | |
[32m */[m | |
[32m public static function extend($name, Closure $connector, $query = null, $schema = null)[m | |
[32m {[m | |
[32m if (is_null($query)) $query = '\Laravel\Database\Query\Grammars\Grammar';[m | |
[32m static::$registrar[$name] = compact('connector', 'query', 'schema');[m | |
[32m }[m | |
[32m /**[m | |
* Magic Method for calling methods on the default database connection.[m | |
*[m | |
* <code>[m | |
[1mdiff --git a/laravel/database/connection.php b/laravel/database/connection.php[m | |
[1mindex 5b2ec0e..dd1d8de 100755[m | |
[1m--- a/laravel/database/connection.php[m | |
[1m+++ b/laravel/database/connection.php[m | |
[36m@@ -1,4 +1,6 @@[m | |
<?php namespace Laravel\Database; | |
use PDO, PDOStatement, Laravel\Config, Laravel\Event; | |
class Connection {[m | |
[36m@@ -71,11 +73,19 @@[m [mclass Connection {[m | |
{[m | |
if (isset($this->grammar)) return $this->grammar;[m | |
[32mif (isset(\Laravel\Database::$registrar[$this->driver()]))[m | |
[32m {[m | |
[32m \Laravel\Database::$registrar[$this->driver()]['query']();[m | |
[32m }[m | |
switch [31m(isset($this->config['grammar']) ? $this->config['grammar'] : $this->driver())[m[32m($this->driver())[m | |
{[m | |
case 'mysql':[m | |
return $this->grammar = new Query\Grammars\MySQL($this);[m | |
[32mcase 'sqlite':[m | |
[32m return $this->grammar = new Query\Grammars\SQLite($this);[m | |
case 'sqlsrv':[m | |
return $this->grammar = new Query\Grammars\SQLServer($this);[m | |
[36m@@ -87,14 +97,14 @@[m [mclass Connection {[m | |
/**[m | |
* Execute a callback wrapped in a database transaction.[m | |
*[m | |
* @param [31mClosure[m[32mcallback[m $callback | |
* @return void[m | |
*/[m | |
public function transaction($callback)[m | |
{[m | |
$this->pdo->beginTransaction();[m | |
// After beginning the database transaction, we will call the [31mClosure[m[32mcallback[m | |
// so that it can do its database work. If an exception occurs we'll[m | |
// rollback the transaction and re-throw back to the developer.[m | |
try[m | |
[36m@@ -165,6 +175,8 @@[m [mclass Connection {[m | |
*/[m | |
public function query($sql, $bindings = array())[m | |
{[m | |
[32m$sql = trim($sql);[m | |
list($statement, $result) = $this->execute($sql, $bindings);[m | |
// The result we return depends on the type of query executed against the[m | |
[36m@@ -209,6 +221,19 @@[m [mclass Connection {[m | |
$sql = $this->grammar()->shortcut($sql, $bindings);[m | |
[32m// Next we need to translate all DateTime bindings to their date-time[m | |
[32m // strings that are compatible with the database. Each grammar may[m | |
[32m // define it's own date-time format according to its needs.[m | |
[32m $datetime = $this->grammar()->datetime;[m | |
[32m for ($i = 0; $i < count($bindings); $i++)[m | |
[32m {[m | |
[32m if ($bindings[$i] instanceof \DateTime)[m | |
[32m {[m | |
[32m $bindings[$i] = $bindings[$i]->format($datetime);[m | |
[32m }[m | |
[32m }[m | |
// Each database operation is wrapped in a try / catch so we can wrap[m | |
// any database exceptions in our custom exception class, which will[m | |
// set the message to include the SQL and query bindings.[m | |
[36m@@ -287,7 +312,7 @@[m [mclass Connection {[m | |
*/[m | |
public function driver()[m | |
{[m | |
return [31m$this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME);[m[32m$this->config['driver'];[m | |
}[m | |
/**[m | |
[36m@@ -298,4 +323,4 @@[m [mclass Connection {[m | |
return $this->table($method);[m | |
}[m | |
[31m}[m | |
No newline at end of file[m | |
[32m}[m | |
[1mdiff --git a/laravel/database/eloquent/model.php b/laravel/database/eloquent/model.php[m | |
[1mindex 966a00c..3af4905 100755[m | |
[1m--- a/laravel/database/eloquent/model.php[m | |
[1m+++ b/laravel/database/eloquent/model.php[m | |
[36m@@ -1,6 +1,7 @@[m | |
<?php namespace Laravel\Database\Eloquent;[m | |
use Laravel\Str;[m | |
[32muse Laravel\Event;[m | |
use Laravel\Database;[m | |
use Laravel\Database\Eloquent\Relationships\Has_Many_And_Belongs_To;[m | |
[36m@@ -56,6 +57,13 @@[m [mabstract class Model {[m | |
public static $accessible;[m | |
/**[m | |
[32m* The attributes that should be excluded from to_array.[m | |
[32m *[m | |
[32m * @var array[m | |
[32m */[m | |
[32m public static $hidden = array();[m | |
[32m /**[m | |
* Indicates if the model has update and creation timestamps.[m | |
*[m | |
* @var bool[m | |
[36m@@ -108,14 +116,23 @@[m [mabstract class Model {[m | |
* Hydrate the model with an array of attributes.[m | |
*[m | |
* @param array $attributes[m | |
[32m* @param bool $raw[m | |
* @return Model[m | |
*/[m | |
public function [31mfill($attributes)[m[32mfill(array $attributes, $raw = false)[m | |
{[m | |
[31m $attributes = (array) $attributes;[m | |
foreach ($attributes as $key => $value)[m | |
{[m | |
[32m// If the "raw" flag is set, it means that we'll just load every value from[m | |
[32m // the array directly into the attributes, without any accessibility or[m | |
[32m // mutators being accounted for. What you pass in is what you get.[m | |
[32m if ($raw)[m | |
[32m {[m | |
[32m $this->set_attribute($key, $value);[m | |
[32m continue;[m | |
[32m }[m | |
// If the "accessible" property is an array, the developer is limiting the[m | |
// attributes that may be mass assigned, and we need to verify that the[m | |
// current attribute is included in that list of allowed attributes.[m | |
[36m@@ -148,13 +165,28 @@[m [mabstract class Model {[m | |
}[m | |
/**[m | |
[32m* Fill the model with the contents of the array.[m | |
[32m *[m | |
[32m * No mutators or accessibility checks will be accounted for.[m | |
[32m *[m | |
[32m * @param array $attributes[m | |
[32m * @return Model[m | |
[32m */[m | |
[32m public function fill_raw(array $attributes)[m | |
[32m {[m | |
[32m return $this->fill($attributes, true);[m | |
[32m }[m | |
[32m /**[m | |
* Set the accessible attributes for the given model.[m | |
*[m | |
* @param array $attributes[m | |
* @return void[m | |
*/[m | |
public static function [31maccessible($attributes)[m[32maccessible($attributes = null)[m | |
{[m | |
[32mif (is_null($attributes)) return static::$accessible;[m | |
static::$accessible = $attributes;[m | |
}[m | |
[36m@@ -186,7 +218,7 @@[m [mabstract class Model {[m | |
{[m | |
$model = new static(array(), true);[m | |
if (static::$timestamps) $attributes['updated_at'] = [31m$model->get_timestamp();[m[32mnew \DateTime;[m | |
return $model->query()->where($model->key(), '=', $id)->update($attributes);[m | |
}[m | |
[36m@@ -348,6 +380,8 @@[m [mabstract class Model {[m | |
$this->timestamp();[m | |
}[m | |
[32m$this->fire_event('saving');[m | |
// If the model exists, we only need to update it in the database, and the update[m | |
// will be considered successful if there is one affected row returned from the[m | |
// fluent query instance. We'll set the where condition automatically.[m | |
[36m@@ -356,6 +390,8 @@[m [mabstract class Model {[m | |
$query = $this->query()->where(static::$key, '=', $this->get_key());[m | |
$result = $query->update($this->get_dirty()) === 1;[m | |
[32mif ($result) $this->fire_event('updated');[m | |
}[m | |
// If the model does not exist, we will insert the record and retrieve the last[m | |
[36m@@ -368,6 +404,8 @@[m [mabstract class Model {[m | |
$this->set_key($id);[m | |
$this->exists = $result = is_numeric($this->get_key());[m | |
[32mif ($result) $this->fire_event('created');[m | |
}[m | |
// After the model has been "saved", we will set the original attributes to[m | |
[36m@@ -375,6 +413,11 @@[m [mabstract class Model {[m | |
// dirty and subsequent calls won't hit the database.[m | |
$this->original = $this->attributes;[m | |
[32mif ($result)[m | |
[32m {[m | |
[32m $this->fire_event('saved');[m | |
[32m }[m | |
return $result;[m | |
}[m | |
[36m@@ -387,7 +430,13 @@[m [mabstract class Model {[m | |
{[m | |
if ($this->exists)[m | |
{[m | |
[31mreturn[m[32m$this->fire_event('deleting');[m | |
[32m $result =[m $this->query()->where(static::$key, '=', $this->get_key())->delete(); | |
[32m$this->fire_event('deleted');[m | |
[32m return $result;[m | |
}[m | |
}[m | |
[36m@@ -398,22 +447,12 @@[m [mabstract class Model {[m | |
*/[m | |
protected function timestamp()[m | |
{[m | |
$this->updated_at = [31m$this->get_timestamp();[m[32mnew \DateTime;[m | |
if ( ! $this->exists) $this->created_at = $this->updated_at;[m | |
}[m | |
/**[m | |
[31m * Get the current timestamp in its storable form.[m | |
[31m *[m | |
[31m * @return mixed[m | |
[31m */[m | |
[31m public function get_timestamp()[m | |
[31m {[m | |
[31m return date('Y-m-d H:i:s');[m | |
[31m }[m | |
[31m /**[m | |
* Get a new fluent query builder instance for the model.[m | |
*[m | |
* @return Query[m | |
[36m@@ -475,7 +514,17 @@[m [mabstract class Model {[m | |
*/[m | |
public function get_dirty()[m | |
{[m | |
[32m$dirty = array();[m | |
[32m foreach ($this->attributes as $key => $value)[m | |
[32m {[m | |
[32m if ( ! isset($this->original[$key]) or $value !== $this->original[$key])[m | |
[32m {[m | |
[32m $dirty[$key] = $value;[m | |
[32m }[m | |
[32m }[m | |
return [31marray_diff_assoc($this->attributes, $this->original);[m[32m$dirty;[m | |
}[m | |
/**[m | |
[36m@@ -534,6 +583,68 @@[m [mabstract class Model {[m | |
}[m | |
/**[m | |
[32m* Get the model attributes and relationships in array form.[m | |
[32m *[m | |
[32m * @return array[m | |
[32m */[m | |
[32m public function to_array()[m | |
[32m {[m | |
[32m $attributes = array();[m | |
[32m // First we need to gather all of the regular attributes. If the attribute[m | |
[32m // exists in the array of "hidden" attributes, it will not be added to[m | |
[32m // the array so we can easily exclude things like passwords, etc.[m | |
[32m foreach (array_keys($this->attributes) as $attribute)[m | |
[32m {[m | |
[32m if ( ! in_array($attribute, static::$hidden))[m | |
[32m {[m | |
[32m $attributes[$attribute] = $this->$attribute;[m | |
[32m }[m | |
[32m }[m | |
[32m foreach ($this->relationships as $name => $models)[m | |
[32m {[m | |
[32m // If the relationship is not a "to-many" relationship, we can just[m | |
[32m // to_array the related model and add it as an attribute to the[m | |
[32m // array of existing regular attributes we gathered.[m | |
[32m if ($models instanceof Model)[m | |
[32m {[m | |
[32m $attributes[$name] = $models->to_array();[m | |
[32m }[m | |
[32m // If the relationship is a "to-many" relationship we need to spin[m | |
[32m // through each of the related models and add each one with the[m | |
[32m // to_array method, keying them both by name and ID.[m | |
[32m elseif (is_array($models))[m | |
[32m {[m | |
[32m foreach ($models as $id => $model)[m | |
[32m {[m | |
[32m $attributes[$name][$id] = $model->to_array();[m | |
[32m }[m | |
[32m }[m | |
[32m elseif (is_null($models))[m | |
[32m {[m | |
[32m $attributes[$name] = $models;[m | |
[32m }[m | |
[32m }[m | |
[32m return $attributes;[m | |
[32m }[m | |
[32m /**[m | |
[32m * Fire a given event for the model.[m | |
[32m *[m | |
[32m * @param string $event[m | |
[32m * @return array[m | |
[32m */[m | |
[32m protected function fire_event($event)[m | |
[32m {[m | |
[32m $events = array("eloquent.{$event}", "eloquent.{$event}: ".get_class($this));[m | |
[32m Event::fire($events, array($this));[m | |
[32m }[m | |
[32m /**[m | |
* Handle the dynamic retrieval of attributes and associations.[m | |
*[m | |
* @param string $key[m | |
[36m@@ -598,6 +709,8 @@[m [mabstract class Model {[m | |
{[m | |
if (array_key_exists($key, $this->$source)) return true;[m | |
}[m | |
[32mif (method_exists($this, $key)) return true;[m | |
}[m | |
/**[m | |
[36m@@ -623,10 +736,12 @@[m [mabstract class Model {[m | |
*/[m | |
public function __call($method, $parameters)[m | |
{[m | |
[32m$meta = array('key', 'table', 'connection', 'sequence', 'per_page', 'timestamps');[m | |
// If the method is actually the name of a static property on the model we'll[m | |
// return the value of the static property. This makes it convenient for[m | |
// relationships to access these values off of the instances.[m | |
if (in_array($method, [31marray('key', 'table', 'connection', 'sequence', 'per_page')))[m[32m$meta))[m | |
{[m | |
return static::$$method;[m | |
}[m | |
[36m@@ -644,11 +759,11 @@[m [mabstract class Model {[m | |
// to perform the appropriate action based on the method.[m | |
if (starts_with($method, 'get_'))[m | |
{[m | |
return [31m$this->attributes[substr($method, 4)];[m[32m$this->get_attribute(substr($method, 4));[m | |
}[m | |
elseif (starts_with($method, 'set_'))[m | |
{[m | |
[31m$this->attributes[substr($method, 4)] = $parameters[0];[m[32m$this->set_attribute(substr($method, 4), $parameters[0]);[m | |
}[m | |
// Finally we will assume that the method is actually the beginning of a[m | |
[1mdiff --git a/laravel/database/eloquent/pivot.php b/laravel/database/eloquent/pivot.php[m | |
[1mindex b98fc22..d2878bb 100755[m | |
[1m--- a/laravel/database/eloquent/pivot.php[m | |
[1m+++ b/laravel/database/eloquent/pivot.php[m | |
[36m@@ -20,11 +20,13 @@[m [mclass Pivot extends Model {[m | |
* Create a new pivot table instance.[m | |
*[m | |
* @param string $table[m | |
[32m* @param string $connection[m | |
* @return void[m | |
*/[m | |
public function [31m__construct($table)[m[32m__construct($table, $connection = null)[m | |
{[m | |
$this->pivot_table = $table;[m | |
[32m$this->connection = $connection;[m | |
parent::__construct(array(), true);[m | |
}[m | |
[36m@@ -39,4 +41,14 @@[m [mclass Pivot extends Model {[m | |
return $this->pivot_table;[m | |
}[m | |
[32m/**[m | |
[32m * Get the connection used by the pivot table.[m | |
[32m *[m | |
[32m * @return string[m | |
[32m */[m | |
[32m public function connection()[m | |
[32m {[m | |
[32m return $this->connection;[m | |
[32m }[m | |
}[m | |
No newline at end of file[m | |
[1mdiff --git a/laravel/database/eloquent/query.php b/laravel/database/eloquent/query.php[m | |
[1mindex e55e6a4..3aee79c 100755[m | |
[1m--- a/laravel/database/eloquent/query.php[m | |
[1m+++ b/laravel/database/eloquent/query.php[m | |
[36m@@ -1,5 +1,6 @@[m | |
<?php namespace Laravel\Database\Eloquent;[m | |
[32muse Laravel\Event;[m | |
use Laravel\Database;[m | |
use Laravel\Database\Eloquent\Relationships\Has_Many_And_Belongs_To;[m | |
[36m@@ -33,7 +34,7 @@[m [mclass Query {[m | |
*/[m | |
public $passthru = array([m | |
'lists', 'only', 'insert', 'insert_get_id', 'update', 'increment',[m | |
[32m'delete',[m 'decrement', 'count', 'min', 'max', 'avg', 'sum', | |
);[m | |
/**[m | |
[36m@@ -66,12 +67,11 @@[m [mclass Query {[m | |
* Get all of the model results for the query.[m | |
*[m | |
* @param array $columns[m | |
[31m * @param bool $keyed[m | |
* @return array[m | |
*/[m | |
public function get($columns = [31marray('*'), $keyed = true)[m[32marray('*'))[m | |
{[m | |
return $this->hydrate($this->model, [31m$this->table->get($columns), $keyed);[m[32m$this->table->get($columns));[m | |
}[m | |
/**[m | |
[36m@@ -100,10 +100,9 @@[m [mclass Query {[m | |
*[m | |
* @param Model $model[m | |
* @param array $results[m | |
[31m * @param bool $keyed[m | |
* @return array[m | |
*/[m | |
public function hydrate($model, [31m$results, $keyed = true)[m[32m$results)[m | |
{[m | |
$class = get_class($model);[m | |
[36m@@ -121,33 +120,18 @@[m [mclass Query {[m | |
// We need to set the attributes manually in case the accessible property is[m | |
// set on the array which will prevent the mass assignemnt of attributes if[m | |
// we were to pass them in using the constructor or fill methods.[m | |
[31mforeach ($result as $key => $value)[m | |
[31m {[m | |
[31m $new->set_attribute($key, $value);[m | |
[31m }[m | |
[31m $new->original = $new->attributes;[m[32m$new->fill_raw($result);[m | |
[31m// Typically, the resulting models are keyed by their primary key, but it[m | |
[31m // may be useful to not do this in some circumstances such as when we[m | |
[31m // are eager loading a *-to-* relationships which has duplicates.[m | |
[31m if ($keyed)[m | |
[31m {[m | |
[31m $models[$result[$this->model->key()]] = $new;[m | |
[31m }[m | |
[31m else[m | |
[31m {[m $models[] = $new;[31m}[m | |
}[m | |
if (count($results) > 0)[m | |
{[m | |
foreach ($this->model_includes() as $relationship => $constraints)[m | |
{[m | |
// If the relationship is nested, we will skip [31mlaoding[m[32mloading[m it here and let | |
// the load method parse and set the nested eager loads on the right[m | |
// relationship when it is getting ready to eager [31mlaod.[m[32mload.[m | |
if (str_contains($relationship, '.'))[m | |
{[m | |
continue;[m | |
[36m@@ -199,17 +183,7 @@[m [mclass Query {[m | |
$query->initialize($results, $relationship);[m | |
[31m// If we're eager loading a many-to-many relationship we will disable[m | |
[31m // the primary key indexing on the hydration since there could be[m | |
[31m // roles shared across users and we don't want to overwrite.[m | |
[31m if ( ! $query instanceof Has_Many_And_Belongs_To)[m | |
[31m {[m $query->match($relationship, $results, $query->get());[31m}[m | |
[31m else[m | |
[31m {[m | |
[31m $query->match($relationship, $results, $query->get(array('*'), false));[m | |
[31m }[m | |
}[m | |
/**[m | |
[36m@@ -293,8 +267,8 @@[m [mclass Query {[m | |
$result = call_user_func_array(array($this->table, $method), $parameters);[m | |
// Some methods may get their results straight from the fluent query[m | |
// [31mbuilder,[m[32mbuilder[m such as the aggregate methods. If the called method is | |
// one of these, we will [32mjust[m return the result straight away. | |
if (in_array($method, $this->passthru))[m | |
{[m | |
return $result;[m | |
[1mdiff --git a/laravel/database/eloquent/relationships/belongs_to.php b/laravel/database/eloquent/relationships/belongs_to.php[m | |
[1mindex b73c57b..6ec8acd 100755[m | |
[1m--- a/laravel/database/eloquent/relationships/belongs_to.php[m | |
[1m+++ b/laravel/database/eloquent/relationships/belongs_to.php[m | |
[36m@@ -32,7 +32,7 @@[m [mclass Belongs_To extends Relationship {[m | |
*/[m | |
protected function constrain()[m | |
{[m | |
[31m$this->table->where($this->base->key(),[m[32m$this->table->where($this->model->key(),[m '=', $this->foreign_value()); | |
}[m | |
/**[m | |
[36m@@ -65,9 +65,14 @@[m [mclass Belongs_To extends Relationship {[m | |
// are looking for the parent of a child model in this relationship.[m | |
foreach ($results as $result)[m | |
{[m | |
[32mif ( ! is_null($key = $result->{$this->foreign_key()}))[m | |
[32m {[m | |
$keys[] = [31m$result->{$this->foreign_key()};[m[32m$key;[m | |
[32m }[m | |
}[m | |
[32mif (count($keys) == 0) $keys = array(0);[m | |
$this->table->where_in($this->model->key(), array_unique($keys));[m | |
}[m | |
[36m@@ -84,9 +89,14 @@[m [mclass Belongs_To extends Relationship {[m | |
foreach ($children as &$child)[m | |
{[m | |
[32m$parent = array_first($parents, function($k, $v) use ($child, $foreign)[m | |
[32m {[m | |
[32m return $v->get_key() == $child->$foreign;[m | |
[32m });[m | |
if [31m(array_key_exists($child->$foreign, $parents))[m[32m( ! is_null($parent))[m | |
{[m | |
$child->relationships[$relationship] = [31m$parents[$child->$foreign];[m[32m$parent;[m | |
}[m | |
}[m | |
}[m | |
[1mdiff --git a/laravel/database/eloquent/relationships/has_many.php b/laravel/database/eloquent/relationships/has_many.php[m | |
[1mindex b80d384..92a9e49 100755[m | |
[1m--- a/laravel/database/eloquent/relationships/has_many.php[m | |
[1m+++ b/laravel/database/eloquent/relationships/has_many.php[m | |
[36m@@ -13,6 +13,59 @@[m [mclass Has_Many extends Has_One_Or_Many {[m | |
}[m | |
/**[m | |
[32m* Sync the association table with an array of models.[m | |
[32m *[m | |
[32m * @param mixed $models[m | |
[32m * @return bool[m | |
[32m */[m | |
[32m public function save($models)[m | |
[32m {[m | |
[32m // If the given "models" are not an array, we'll force them into an array so[m | |
[32m // we can conveniently loop through them and insert all of them into the[m | |
[32m // related database table assigned to the associated model instance.[m | |
[32m if ( ! is_array($models)) $models = array($models);[m | |
[32m $current = $this->table->lists($this->model->key());[m | |
[32m foreach ($models as $attributes)[m | |
[32m {[m | |
[32m $class = get_class($this->model);[m | |
[32m // If the "attributes" are actually an array of the related model we'll[m | |
[32m // just use the existing instance instead of creating a fresh model[m | |
[32m // instance for the attributes. This allows for validation.[m | |
[32m if ($attributes instanceof $class)[m | |
[32m {[m | |
[32m $model = $attributes;[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
[32m $model = $this->fresh_model($attributes);[m | |
[32m }[m | |
[32m // We'll need to associate the model with its parent, so we'll set the[m | |
[32m // foreign key on the model to the key of the parent model, making[m | |
[32m // sure that the two models are associated in the database.[m | |
[32m $foreign = $this->foreign_key();[m | |
[32m $model->$foreign = $this->base->get_key();[m | |
[32m $id = $model->get_key();[m | |
[32m $model->exists = ( ! is_null($id) and in_array($id, $current));[m | |
[32m // Before saving we'll force the entire model to be "dirty" so all of[m | |
[32m // the attributes are saved. It shouldn't affect the updates as[m | |
[32m // saving all the attributes shouldn't hurt anything.[m | |
[32m $model->original = array();[m | |
[32m $model->save();[m | |
[32m }[m | |
[32m return true;[m | |
[32m }[m | |
[32m /**[m | |
* Initialize a relationship on an array of parent models.[m | |
*[m | |
* @param array $parents[m | |
[36m@@ -38,9 +91,14 @@[m [mclass Has_Many extends Has_One_Or_Many {[m | |
{[m | |
$foreign = $this->foreign_key();[m | |
foreach [31m($children[m[32m($parents[m as [31m$key => $child)[m[32m&$parent)[m | |
{[m | |
[31m$parents[$child->$foreign]->relationships[$relationship][$child->get_key()][m[32m$matching[m = [31m$child;[m[32marray_filter($children, function($v) use ($parent, $foreign)[m | |
[32m {[m | |
[32m return $v->$foreign == $parent->get_key();[m | |
[32m });[m | |
[32m $parent->relationships[$relationship] = array_values($matching);[m | |
}[m | |
}[m | |
[1mdiff --git a/laravel/database/eloquent/relationships/has_many_and_belongs_to.php b/laravel/database/eloquent/relationships/has_many_and_belongs_to.php[m | |
[1mindex 9fecb66..587e504 100755[m | |
[1m--- a/laravel/database/eloquent/relationships/has_many_and_belongs_to.php[m | |
[1m+++ b/laravel/database/eloquent/relationships/has_many_and_belongs_to.php[m | |
[36m@@ -25,7 +25,7 @@[m [mclass Has_Many_And_Belongs_To extends Relationship {[m | |
*[m | |
* @var array[m | |
*/[m | |
protected $with = [31marray('id', 'created_at', 'updated_at');[m[32marray('id');[m | |
/**[m | |
* Create a new many to many relationship instance.[m | |
[36m@@ -43,6 +43,16 @@[m [mclass Has_Many_And_Belongs_To extends Relationship {[m | |
$this->joining = $table ?: $this->joining($model, $associated);[m | |
[32m// If the Pivot table is timestamped, we'll set the timestamp columns to be[m | |
[32m // fetched when the pivot table models are fetched by the developer else[m | |
[32m // the ID will be the only "extra" column fetched in by default.[m | |
[32m if (Pivot::$timestamps)[m | |
[32m {[m | |
[32m $this->with[] = 'created_at';[m | |
[32m $this->with[] = 'updated_at';[m | |
[32m }[m | |
parent::__construct($model, $associated, $foreign);[m | |
}[m | |
[36m@@ -87,6 +97,51 @@[m [mclass Has_Many_And_Belongs_To extends Relationship {[m | |
}[m | |
/**[m | |
[32m* Detach a record from the joining table of the association.[m | |
[32m *[m | |
[32m * @param int $ids[m | |
[32m * @return bool[m | |
[32m */[m | |
[32m public function detach($ids)[m | |
[32m {[m | |
[32m if ( ! is_array($ids)) $ids = array($ids);[m | |
[32m return $this->pivot()->where_in($this->other_key(), $ids)->delete();[m | |
[32m }[m | |
[32m /**[m | |
[32m * Sync the joining table with the array of given IDs.[m | |
[32m *[m | |
[32m * @param array $ids[m | |
[32m * @return bool[m | |
[32m */[m | |
[32m public function sync($ids)[m | |
[32m {[m | |
[32m $current = $this->pivot()->lists($this->other_key());[m | |
[32m // First we need to attach any of the associated models that are not currently[m | |
[32m // in the joining table. We'll spin through the given IDs, checking to see[m | |
[32m // if they exist in the array of current ones, and if not we insert.[m | |
[32m foreach ($ids as $id)[m | |
[32m {[m | |
[32m if ( ! in_array($id, $current))[m | |
[32m {[m | |
[32m $this->attach($id);[m | |
[32m }[m | |
[32m }[m | |
[32m // Next we will take the difference of the current and given IDs and detach[m | |
[32m // all of the entities that exists in the current array but are not in[m | |
[32m // the array of IDs given to the method, finishing the sync.[m | |
[32m $detach = array_diff($current, $ids);[m | |
[32m if (count($detach) > 0)[m | |
[32m {[m | |
[32m $this->detach(array_diff($current, $ids));[m | |
[32m }[m | |
[32m }[m | |
[32m /**[m | |
* Insert a new record for the association.[m | |
*[m | |
* @param Model|array $attributes[m | |
[36m@@ -147,9 +202,12 @@[m [mclass Has_Many_And_Belongs_To extends Relationship {[m | |
*/[m | |
protected function insert_joining($attributes)[m | |
{[m | |
[32mif (Pivot::$timestamps)[m | |
[32m {[m | |
$attributes['created_at'] = [31m$this->model->get_timestamp();[m[32mnew \DateTime;[m | |
$attributes['updated_at'] = $attributes['created_at']; | |
[32m}[m | |
return $this->joining_table()->insert($attributes);[m | |
}[m | |
[36m@@ -192,7 +250,7 @@[m [mclass Has_Many_And_Belongs_To extends Relationship {[m | |
$this->with = array_merge($this->with, array($foreign, $other));[m | |
// Since pivot tables may have extra information on them that the developer[m | |
// [31mneeds,[m[32mneeds[m we allow an extra array of columns to be specified that will be | |
// fetched from the pivot table and hydrate into the pivot model.[m | |
foreach ($this->with as $column)[m | |
{[m | |
[36m@@ -253,7 +311,7 @@[m [mclass Has_Many_And_Belongs_To extends Relationship {[m | |
*/[m | |
public function eagerly_constrain($results)[m | |
{[m | |
$this->table->where_in($this->joining.'.'.$this->foreign_key(), [31marray_keys($results));[m[32m$this->keys($results));[m | |
}[m | |
/**[m | |
[36m@@ -267,9 +325,14 @@[m [mclass Has_Many_And_Belongs_To extends Relationship {[m | |
{[m | |
$foreign = $this->foreign_key();[m | |
foreach [31m($children[m[32m($parents[m as [31m$key => $child)[m[32m&$parent)[m | |
{[m | |
[31m$parents[$child->pivot->$foreign]->relationships[$relationship][$child->{$child->key()}][m[32m$matching[m = [31m$child;[m[32marray_filter($children, function($v) use ($parent, $foreign)[m | |
[32m {[m | |
[32m return $v->pivot->$foreign == $parent->get_key();[m | |
[32m });[m | |
[32m $parent->relationships[$relationship] = array_values($matching);[m | |
}[m | |
}[m | |
[36m@@ -286,11 +349,11 @@[m [mclass Has_Many_And_Belongs_To extends Relationship {[m | |
// Every model result for a many-to-many relationship needs a Pivot instance[m | |
// to represent the pivot table's columns. Sometimes extra columns are on[m | |
// the pivot table that may need to be accessed by the developer.[m | |
$pivot = new [31mPivot($this->joining);[m[32mPivot($this->joining, $this->model->connection());[m | |
// If the attribute key starts with "pivot_", we know this is a column on[m | |
// the pivot table, so we will move it to the Pivot model and purge it[m | |
// from the model since it actually belongs to the [31mpivot.[m[32mpivot model.[m | |
foreach ($result->attributes as $key => $value)[m | |
{[m | |
if (starts_with($key, 'pivot_'))[m | |
[36m@@ -320,9 +383,9 @@[m [mclass Has_Many_And_Belongs_To extends Relationship {[m | |
{[m | |
$columns = (is_array($columns)) ? $columns : func_get_args();[m | |
// The "with" array contains a couple of columns by default, so we will[31m//[m just | |
[32m//[m merge in the developer specified columns here, and [31mwe'll[m[32mwe will[m make[31m//[m sure | |
[32m//[m the values of the array are [31munique.[m[32munique to avoid duplicates.[m | |
$this->with = array_unique(array_merge($this->with, $columns));[m | |
$this->set_select($this->foreign_key(), $this->other_key());[m | |
[36m@@ -331,17 +394,15 @@[m [mclass Has_Many_And_Belongs_To extends Relationship {[m | |
}[m | |
/**[m | |
* Get a [31mmodel[m[32mrelationship[m instance of the pivot [31mtable for the relationship.[m[32mtable.[m | |
*[m | |
* @return [31mPivot[m[32mHas_Many[m | |
*/[m | |
public function pivot()[m | |
{[m | |
[31m$key[m[32m$pivot[m = [31m$this->base->get_key();[m | |
[31m $foreign = $this->foreign_key();[m[32mnew Pivot($this->joining, $this->model->connection());[m | |
return [31mwith(new Pivot($this->joining))->where($foreign, '=', $key);[m[32mnew Has_Many($this->base, $pivot, $this->foreign_key());[m | |
}[m | |
/**[m | |
[1mdiff --git a/laravel/database/eloquent/relationships/has_one.php b/laravel/database/eloquent/relationships/has_one.php[m | |
[1mindex 077c3ad..7addabb 100755[m | |
[1m--- a/laravel/database/eloquent/relationships/has_one.php[m | |
[1m+++ b/laravel/database/eloquent/relationships/has_one.php[m | |
[36m@@ -38,9 +38,14 @@[m [mclass Has_One extends Has_One_Or_Many {[m | |
{[m | |
$foreign = $this->foreign_key();[m | |
foreach [31m($children[m[32m($parents[m as [31m$key => $child)[m[32m&$parent)[m | |
{[m | |
[31m$parents[$child->$foreign]->relationships[$relationship][m[32m$matching[m = [31m$child;[m[32marray_first($children, function($k, $v) use ($parent, $foreign)[m | |
[32m {[m | |
[32m return $v->$foreign == $parent->get_key();[m | |
[32m });[m | |
[32m $parent->relationships[$relationship] = $matching;[m | |
}[m | |
}[m | |
[1mdiff --git a/laravel/database/eloquent/relationships/has_one_or_many.php b/laravel/database/eloquent/relationships/has_one_or_many.php[m | |
[1mindex 2cdac83..a8268de 100755[m | |
[1m--- a/laravel/database/eloquent/relationships/has_one_or_many.php[m | |
[1m+++ b/laravel/database/eloquent/relationships/has_one_or_many.php[m | |
[36m@@ -20,6 +20,22 @@[m [mclass Has_One_Or_Many extends Relationship {[m | |
}[m | |
/**[m | |
[32m* Update a record for the association.[m | |
[32m *[m | |
[32m * @param array $attributes[m | |
[32m * @return bool[m | |
[32m */[m | |
[32m public function update(array $attributes)[m | |
[32m {[m | |
[32m if ($this->model->timestamps())[m | |
[32m {[m | |
[32m $attributes['updated_at'] = new \DateTime;[m | |
[32m }[m | |
[32m return $this->table->update($attributes);[m | |
[32m }[m | |
[32m /**[m | |
* Set the proper constraints on the relationship table.[m | |
*[m | |
* @return void[m | |
[36m@@ -37,7 +53,7 @@[m [mclass Has_One_Or_Many extends Relationship {[m | |
*/[m | |
public function eagerly_constrain($results)[m | |
{[m | |
$this->table->where_in($this->foreign_key(), [31marray_keys($results));[m[32m$this->keys($results));[m | |
}[m | |
}[m | |
No newline at end of file[m | |
[1mdiff --git a/laravel/database/eloquent/relationships/relationship.php b/laravel/database/eloquent/relationships/relationship.php[m | |
[1mindex 2ec10aa..34c03f6 100755[m | |
[1m--- a/laravel/database/eloquent/relationships/relationship.php[m | |
[1m+++ b/laravel/database/eloquent/relationships/relationship.php[m | |
[36m@@ -101,4 +101,22 @@[m [mabstract class Relationship extends Query {[m | |
return static::foreign($this->base, $this->foreign);[m | |
}[m | |
[32m/**[m | |
[32m * Gather all the primary keys from a result set.[m | |
[32m *[m | |
[32m * @param array $results[m | |
[32m * @return array[m | |
[32m */[m | |
[32m public function keys($results)[m | |
[32m {[m | |
[32m $keys = array();[m | |
[32m foreach ($results as $result)[m | |
[32m {[m | |
[32m $keys[] = $result->get_key();[m | |
[32m }[m | |
[32m return array_unique($keys);[m | |
[32m }[m | |
}[m | |
No newline at end of file[m | |
[1mdiff --git a/laravel/database/query.php b/laravel/database/query.php[m | |
[1mindex 9d22117..607a862 100755[m | |
[1m--- a/laravel/database/query.php[m | |
[1m+++ b/laravel/database/query.php[m | |
[36m@@ -71,6 +71,13 @@[m [mclass Query {[m | |
public $groupings;[m | |
/**[m | |
[32m* The HAVING clauses.[m | |
[32m *[m | |
[32m * @var array[m | |
[32m */[m | |
[32m public $havings;[m | |
[32m /**[m | |
* The ORDER BY clauses.[m | |
*[m | |
* @var array[m | |
[36m@@ -407,7 +414,10 @@[m [mclass Query {[m | |
// Once the callback has been run on the query, we will store the nested[m | |
// query instance on the where clause array so that it's passed to the[m | |
// query's query grammar instance when building.[m | |
[32mif ($query->wheres !== null)[m | |
[32m {[m | |
$this->wheres[] = compact('type', 'query', 'connector'); | |
[32m}[m | |
$this->bindings = array_merge($this->bindings, $query->bindings);[m | |
[36m@@ -476,6 +486,22 @@[m [mclass Query {[m | |
}[m | |
/**[m | |
[32m* Add a having to the query.[m | |
[32m *[m | |
[32m * @param string $column[m | |
[32m * @param string $operator[m | |
[32m * @param mixed $value[m | |
[32m */[m | |
[32m public function having($column, $operator, $value)[m | |
[32m {[m | |
[32m $this->havings[] = compact('column', 'operator', 'value');[m | |
[32m $this->bindings[] = $value;[m | |
[32m return $this;[m | |
[32m }[m | |
[32m /**[m | |
* Add an ordering to the query.[m | |
*[m | |
* @param string $column[m | |
[1mdiff --git a/laravel/database/query/grammars/grammar.php b/laravel/database/query/grammars/grammar.php[m | |
[1mindex 50d2b20..e7d9e28 100755[m | |
[1m--- a/laravel/database/query/grammars/grammar.php[m | |
[1m+++ b/laravel/database/query/grammars/grammar.php[m | |
[36m@@ -6,13 +6,20 @@[m [muse Laravel\Database\Expression;[m | |
class Grammar extends \Laravel\Database\Grammar {[m | |
/**[m | |
[32m* The format for properly saving a DateTime.[m | |
[32m *[m | |
[32m * @var string[m | |
[32m */[m | |
[32m public $datetime = 'Y-m-d H:i:s';[m | |
[32m /**[m | |
* All of the query componenets in the order they should be built.[m | |
*[m | |
* @var array[m | |
*/[m | |
protected $components = array([m | |
'aggregate', 'selects', 'from', 'joins', 'wheres',[m | |
'groupings', [32m'havings',[m 'orderings', 'limit', 'offset', | |
);[m | |
/**[m | |
[36m@@ -280,6 +287,24 @@[m [mclass Grammar extends \Laravel\Database\Grammar {[m | |
}[m | |
/**[m | |
[32m* Compile the HAVING clause for a query.[m | |
[32m *[m | |
[32m * @param Query $query[m | |
[32m * @return string[m | |
[32m */[m | |
[32m protected function havings(Query $query)[m | |
[32m {[m | |
[32m if (is_null($query->havings)) return '';[m | |
[32m foreach ($query->havings as $having)[m | |
[32m {[m | |
[32m $sql[] = 'AND '.$this->wrap($having['column']).' '.$having['operator'].' '.$this->parameter($having['value']);[m | |
[32m }[m | |
[32m return 'HAVING '.preg_replace('/AND /', '', implode(' ', $sql), 1);[m | |
[32m }[m | |
[32m /**[m | |
* Compile the ORDER BY clause for a query.[m | |
*[m | |
* @param Query $query[m | |
[1mdiff --git a/laravel/database/query/grammars/sqlserver.php b/laravel/database/query/grammars/sqlserver.php[m | |
[1mindex 8edb30c..def519a 100755[m | |
[1m--- a/laravel/database/query/grammars/sqlserver.php[m | |
[1m+++ b/laravel/database/query/grammars/sqlserver.php[m | |
[36m@@ -12,6 +12,13 @@[m [mclass SQLServer extends Grammar {[m | |
protected $wrapper = '[%s]';[m | |
/**[m | |
[32m* The format for properly saving a DateTime.[m | |
[32m *[m | |
[32m * @var string[m | |
[32m */[m | |
[32m public $datetime = 'Y-m-d H:i:s.000';[m | |
[32m /**[m | |
* Compile a SQL SELECT statement from a Query instance.[m | |
*[m | |
* @param Query $query[m | |
[1mdiff --git a/laravel/database/schema.php b/laravel/database/schema.php[m | |
[1mindex 3787e33..c7e5630 100755[m | |
[1m--- a/laravel/database/schema.php[m | |
[1m+++ b/laravel/database/schema.php[m | |
[36m@@ -44,12 +44,15 @@[m [mclass Schema {[m | |
* Drop a database table from the schema.[m | |
*[m | |
* @param string $table[m | |
[32m* @param string $connection[m | |
* @return void[m | |
*/[m | |
public static function [31mdrop($table)[m[32mdrop($table, $connection = null)[m | |
{[m | |
$table = new Schema\Table($table);[m | |
[32m$table->on($connection);[m | |
// To indicate that the table needs to be dropped, we will run the[m | |
// "drop" command on the table instance and pass the instance to[m | |
// the execute method as calling a Closure isn't needed.[m | |
[36m@@ -145,6 +148,11 @@[m [mclass Schema {[m | |
{[m | |
$driver = $connection->driver();[m | |
[32mif (isset(\Laravel\Database::$registrar[$driver]))[m | |
[32m {[m | |
[32m return \Laravel\Database::$registrar[$driver]['schema']();[m | |
[32m }[m | |
switch ($driver)[m | |
{[m | |
case 'mysql':[m | |
[1mdiff --git a/laravel/database/schema/grammars/postgres.php b/laravel/database/schema/grammars/postgres.php[m | |
[1mindex 760af1a..e0492ba 100755[m | |
[1m--- a/laravel/database/schema/grammars/postgres.php[m | |
[1m+++ b/laravel/database/schema/grammars/postgres.php[m | |
[36m@@ -368,7 +368,7 @@[m [mclass Postgres extends Grammar {[m | |
*/[m | |
protected function type_date(Fluent $column)[m | |
{[m | |
return [31m'TIMESTAMP';[m[32m'TIMESTAMP(0) WITHOUT TIME ZONE';[m | |
}[m | |
/**[m | |
[1mdiff --git a/laravel/error.php b/laravel/error.php[m | |
[1mindex bf668d8..bfb2fcd 100755[m | |
[1m--- a/laravel/error.php[m | |
[1m+++ b/laravel/error.php[m | |
[36m@@ -6,13 +6,14 @@[m [mclass Error {[m | |
* Handle an exception and display the exception report.[m | |
*[m | |
* @param Exception $exception[m | |
[32m* @param bool $trace[m | |
* @return void[m | |
*/[m | |
public static function [31mexception($exception)[m[32mexception($exception, $trace = true)[m | |
{[m | |
static::log($exception);[m | |
[31mob_get_level()[m[32m//ob_get_level()[m and ob_end_clean(); | |
// If detailed errors are enabled, we'll just format the exception into[m | |
// a simple error message and display it on the screen. We don't use a[m | |
[36m@@ -23,9 +24,14 @@[m [mclass Error {[m | |
<h3>Message:</h3>[m | |
<pre>".$exception->getMessage()."</pre>[m | |
<h3>Location:</h3>[m | |
<pre>".$exception->getFile()." on line [31m".$exception->getLine()."</pre>[m[32m".$exception->getLine()."</pre>";[m | |
[32m if ($trace)[m | |
[32m {[m | |
[32m echo "[m | |
<h3>Stack Trace:</h3>[m | |
<pre>".$exception->getTraceAsString()."</pre></html>";[m | |
[32m}[m | |
}[m | |
// If we're not using detailed error messages, we'll use the event[m | |
[36m@@ -62,8 +68,6 @@[m [mclass Error {[m | |
if (in_array($code, Config::get('error.ignore')))[m | |
{[m | |
return static::log($exception);[m | |
[31m return true;[m | |
}[m | |
static::exception($exception);[m | |
[36m@@ -85,7 +89,7 @@[m [mclass Error {[m | |
{[m | |
extract($error, EXTR_SKIP);[m | |
static::exception(new \ErrorException($message, $type, 0, $file, [31m$line));[m[32m$line), false);[m | |
}[m | |
}[m | |
[1mdiff --git a/laravel/event.php b/laravel/event.php[m | |
[1mindex 7fdc136..1f88d99 100755[m | |
[1m--- a/laravel/event.php[m | |
[1m+++ b/laravel/event.php[m | |
[36m@@ -10,6 +10,20 @@[m [mclass Event {[m | |
public static $events = array();[m | |
/**[m | |
[32m* The queued events waiting for flushing.[m | |
[32m *[m | |
[32m * @var array[m | |
[32m */[m | |
[32m public static $queued = array();[m | |
[32m /**[m | |
[32m * All of the registered queue flusher callbacks.[m | |
[32m *[m | |
[32m * @var array[m | |
[32m */[m | |
[32m public static $flushers = array();[m | |
[32m /**[m | |
* Determine if an event has any registered listeners.[m | |
*[m | |
* @param string $event[m | |
[36m@@ -55,6 +69,31 @@[m [mclass Event {[m | |
}[m | |
/**[m | |
[32m* Add an item to an event queue for processing.[m | |
[32m *[m | |
[32m * @param string $queue[m | |
[32m * @param string $key[m | |
[32m * @param mixed $data[m | |
[32m * @return void[m | |
[32m */[m | |
[32m public static function queue($queue, $key, $data = array())[m | |
[32m {[m | |
[32m static::$queued[$queue][$key] = $data;[m | |
[32m }[m | |
[32m /**[m | |
[32m * Register a queue flusher callback.[m | |
[32m *[m | |
[32m * @param string $queue[m | |
[32m * @param mixed $callback[m | |
[32m * @return void[m | |
[32m */[m | |
[32m public static function flusher($queue, $callback)[m | |
[32m {[m | |
[32m static::$flushers[$queue][] = $callback;[m | |
[32m }[m | |
[32m /**[m | |
* Clear all event listeners for a given event.[m | |
*[m | |
* @param string $event[m | |
[36m@@ -100,6 +139,30 @@[m [mclass Event {[m | |
}[m | |
/**[m | |
[32m* Flush an event queue, firing the flusher for each payload.[m | |
[32m *[m | |
[32m * @param string $queue[m | |
[32m * @return void[m | |
[32m */[m | |
[32m public static function flush($queue)[m | |
[32m {[m | |
[32m foreach (static::$flushers[$queue] as $flusher)[m | |
[32m {[m | |
[32m // We will simply spin through each payload registered for the event and[m | |
[32m // fire the flusher, passing each payloads as we go. This allows all[m | |
[32m // the events on the queue to be processed by the flusher easily.[m | |
[32m if ( ! isset(static::$queued[$queue])) continue;[m | |
[32m foreach (static::$queued[$queue] as $key => $payload)[m | |
[32m {[m | |
[32m array_unshift($payload, $key);[m | |
[32m call_user_func_array($flusher, $payload);[m | |
[32m }[m | |
[32m }[m | |
[32m }[m | |
[32m /**[m | |
* Fire an event so that all listeners are called.[m | |
*[m | |
* <code>[m | |
[36m@@ -108,14 +171,17 @@[m [mclass Event {[m | |
*[m | |
* // Fire the "start" event passing an array of parameters[m | |
* $responses = Event::fire('start', array('Laravel', 'Framework'));[m | |
[32m*[m | |
[32m * // Fire multiple events with the same parameters[m | |
[32m * $responses = Event::fire(array('start', 'loading'), $parameters);[m | |
* </code>[m | |
*[m | |
* @param [31mstring[m[32mstring|array[m $event | |
* @param array $parameters | |
* @param bool $halt | |
* @return array[m | |
*/[m | |
public static function [31mfire($event,[m[32mfire($events,[m $parameters = array(), $halt = false) | |
{[m | |
$responses = array();[m | |
[36m@@ -124,28 +190,31 @@[m [mclass Event {[m | |
// If the event has listeners, we will simply iterate through them and call[m | |
// each listener, passing in the parameters. We will add the responses to[m | |
// an array of event responses and return the array.[m | |
[31mif (static::listeners($event))[m[32mforeach ((array) $events as $event)[m | |
{[m | |
[31mforeach (static::$events[$event] as $callback)[m[32mif (static::listeners($event))[m | |
{[m | |
[31m$response = call_user_func_array($callback, $parameters);[m | |
[31m // If the event is set to halt, we will return the first response[m | |
[31m // that is not null. This allows the developer to easily stack[m | |
[31m // events but still get the first valid response.[m | |
[31m if ($halt and ! is_null($response))[m[32mforeach (static::$events[$event] as $callback)[m | |
{[m | |
[32m$response = call_user_func_array($callback, $parameters);[m | |
[32m // If the event is set to halt, we will[m return [32mthe first response[m | |
[32m // that is not null. This allows the developer to easily stack[m | |
[32m // events but still get the first valid response.[m | |
[32m if ($halt and ! is_null($response))[m | |
[32m {[m | |
[32m return $response;[m | |
[32m }[m | |
[32m // After the handler has been called, we'll add the response to[m | |
[32m // an array of responses and return the array to the caller so[m | |
[32m // all of the responses can be easily examined.[m | |
[32m $responses[] =[m $response; | |
}[m | |
[31m // After the handler has been called, we'll add the response to[m | |
[31m // an array of responses and return the array to the caller so[m | |
[31m // all of the responses can be easily examined.[m | |
[31m $responses[] = $response;[m | |
}[m | |
}[m | |
return [32m$halt ? null :[m $responses; | |
}[m | |
}[m | |
No newline at end of file[m | |
[1mdiff --git a/laravel/file.php b/laravel/file.php[m | |
[1mindex 0346c83..efb46de 100755[m | |
[1m--- a/laravel/file.php[m | |
[1m+++ b/laravel/file.php[m | |
[36m@@ -1,4 +1,4 @@[m | |
<?php namespace Laravel; use[31mClosure,[m FilesystemIterator as fIterator; | |
class File {[m | |
[36m@@ -61,11 +61,11 @@[m [mclass File {[m | |
* Delete a file.[m | |
*[m | |
* @param string $path[m | |
* @return [31mvoid[m[32mbool[m | |
*/[m | |
public static function delete($path)[m | |
{[m | |
if (static::exists($path)) [32mreturn[m @unlink($path); | |
}[m | |
/**[m | |
[36m@@ -94,7 +94,7 @@[m [mclass File {[m | |
/**[m | |
* Extract the file extension from a file path.[m | |
* | |
* @param string $path[m | |
* @return string[m | |
*/[m | |
[36m@@ -273,8 +273,9 @@[m [mclass File {[m | |
}[m | |
}[m | |
[32munset($items);[m | |
if ($delete) [31mrmdir($source);[m[32m@rmdir($source);[m | |
return true;[m | |
}[m | |
[36m@@ -306,6 +307,7 @@[m [mclass File {[m | |
}[m | |
}[m | |
[32munset($items);[m | |
if ( ! $preserve) @rmdir($directory);[m | |
}[m | |
[1mdiff --git a/laravel/form.php b/laravel/form.php[m | |
[1mindex a768f50..619043e 100755[m | |
[1m--- a/laravel/form.php[m | |
[1m+++ b/laravel/form.php[m | |
[36m@@ -397,13 +397,40 @@[m [mclass Form {[m | |
foreach ($options as $value => $display)[m | |
{[m | |
[32mif (is_array($display)) [m | |
[32m {[m | |
[32m $html[] = static::optgroup($display, $value, $selected);[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
$html[] = static::option($value, $display, $selected); | |
[32m}[m | |
}[m | |
return '<select'.HTML::attributes($attributes).'>'.implode('', $html).'</select>';[m | |
}[m | |
/**[m | |
[32m* Create a HTML select element optgroup.[m | |
[32m *[m | |
[32m * @param array $options[m | |
[32m * @param string $label[m | |
[32m * @param string $selected[m | |
[32m * @return string[m | |
[32m */[m | |
[32m protected static function optgroup($options, $label, $selected)[m | |
[32m {[m | |
[32m $html = array();[m | |
[32m foreach ($options as $value => $display)[m | |
[32m {[m | |
[32m $html[] = static::option($value, $display, $selected);[m | |
[32m }[m | |
[32m return '<optgroup label="'.HTML::entities($label).'">'.implode('', $html).'</option>';[m | |
[32m }[m | |
[32m /**[m | |
* Create a HTML select element option.[m | |
*[m | |
* @param string $value[m | |
[1mdiff --git a/laravel/helpers.php b/laravel/helpers.php[m | |
[1mindex b04a8c4..db5ff43 100755[m | |
[1m--- a/laravel/helpers.php[m | |
[1m+++ b/laravel/helpers.php[m | |
[36m@@ -27,6 +27,17 @@[m [mfunction __($key, $replacements = array(), $language = null)[m | |
}[m | |
/**[m | |
[32m* Dump the given value and kill the script.[m | |
[32m *[m | |
[32m * @param mixed $value[m | |
[32m * @return void[m | |
[32m */[m | |
[32mfunction dd($value)[m | |
[32m{[m | |
[32m die(var_dump($value));[m | |
[32m}[m | |
[32m/**[m | |
* Get an item from an array using "dot" notation.[m | |
*[m | |
* <code>[m | |
[36m@@ -219,6 +230,62 @@[m [mfunction array_divide($array)[m | |
}[m | |
/**[m | |
[32m* Pluck an array of values from an array.[m | |
[32m *[m | |
[32m * @param array $array[m | |
[32m * @param string $key[m | |
[32m * @return array[m | |
[32m */[m | |
[32mfunction array_pluck($array, $key)[m | |
[32m{[m | |
[32m return array_map(function($v) use ($key)[m | |
[32m {[m | |
[32m return is_object($v) ? $v->$key : $v[$key];[m | |
[32m }, $array);[m | |
[32m}[m | |
[32m/**[m | |
[32m * Get a subset of the items from the given array.[m | |
[32m *[m | |
[32m * @param array $array[m | |
[32m * @param array $keys[m | |
[32m * @return array[m | |
[32m */[m | |
[32mfunction array_only($array, $keys)[m | |
[32m{[m | |
[32m return array_intersect_key( $array, array_flip((array) $keys) );[m | |
[32m}[m | |
[32m/**[m | |
[32m * Get all of the given array except for a specified array of items.[m | |
[32m *[m | |
[32m * @param array $array[m | |
[32m * @param array $keys[m | |
[32m * @return array[m | |
[32m */[m | |
[32mfunction array_except($array, $keys)[m | |
[32m{[m | |
[32m return array_diff_key( $array, array_flip((array) $keys) );[m | |
[32m}[m | |
[32m/**[m | |
[32m * Transform Eloquent models to a JSON object.[m | |
[32m *[m | |
[32m * @param Eloquent|array $models[m | |
[32m * @return object[m | |
[32m */[m | |
[32mfunction eloquent_to_json($models)[m | |
[32m{[m | |
[32m if ($models instanceof Laravel\Database\Eloquent\Model)[m | |
[32m {[m | |
[32m return json_encode($models->to_array());[m | |
[32m }[m | |
[32m return json_encode(array_map(function($m) { return $m->to_array(); }, $models));[m | |
[32m}[m | |
[32m/**[m | |
* Determine if "Magic Quotes" are enabled on the server.[m | |
*[m | |
* @return bool[m | |
[36m@@ -340,13 +407,18 @@[m [mfunction ends_with($haystack, $needle)[m | |
/**[m | |
* Determine if a given string contains a given sub-string.[m | |
*[m | |
* @param string $haystack | |
* @param [31mstring[m[32mstring|array[m $needle | |
* @return bool[m | |
*/[m | |
function str_contains($haystack, $needle)[m | |
{[m | |
[31mreturn strpos($haystack, $needle)[m[32mforeach ((array) $needle as $n)[m | |
[32m {[m | |
[32m if (strpos($haystack, $n)[m !== [32mfalse) return true;[m | |
[32m }[m | |
[32m return[m false; | |
}[m | |
/**[m | |
[36m@@ -362,6 +434,17 @@[m [mfunction str_finish($value, $cap)[m | |
}[m | |
/**[m | |
[32m* Determine if the given object has a toString method.[m | |
[32m *[m | |
[32m * @param object $value[m | |
[32m * @return bool[m | |
[32m */[m | |
[32mfunction str_object($value)[m | |
[32m{[m | |
[32m return is_object($value) and method_exists($value, '__toString');[m | |
[32m}[m | |
[32m/**[m | |
* Get the root namespace of a given class.[m | |
*[m | |
* @param string $class[m | |
[36m@@ -401,7 +484,7 @@[m [mfunction class_basename($class)[m | |
*/[m | |
function value($value)[m | |
{[m | |
return [31m($value instanceof Closure)[m[32m(is_callable($value) and ! is_string($value))[m ? call_user_func($value) : $value; | |
}[m | |
/**[m | |
[36m@@ -477,4 +560,24 @@[m [mfunction render_each($partial, array $data, $iterator, $empty = 'raw|')[m | |
function yield($section)[m | |
{[m | |
return Laravel\Section::yield($section);[m | |
[32m}[m | |
[32m/**[m | |
[32m * Get a CLI option from the argv $_SERVER variable.[m | |
[32m *[m | |
[32m * @param string $option[m | |
[32m * @param mixed $default[m | |
[32m * @return string[m | |
[32m */[m | |
[32mfunction get_cli_option($option, $default = null)[m | |
[32m{[m | |
[32m foreach (Laravel\Request::foundation()->server->get('argv') as $argument)[m | |
[32m {[m | |
[32m if (starts_with($argument, "--{$option}="))[m | |
[32m {[m | |
[32m return substr($argument, strlen($option) + 3);[m | |
[32m }[m | |
[32m }[m | |
[32m return value($default);[m | |
}[m | |
No newline at end of file[m | |
[1mdiff --git a/laravel/html.php b/laravel/html.php[m | |
[1mindex bcb6962..b6cd3ee 100755[m | |
[1m--- a/laravel/html.php[m | |
[1m+++ b/laravel/html.php[m | |
[36m@@ -62,7 +62,7 @@[m [mclass HTML {[m | |
*/[m | |
public static function script($url, $attributes = array())[m | |
{[m | |
$url = [31mstatic::entities(URL::to_asset($url));[m[32mURL::to_asset($url);[m | |
return '<script src="'.$url.'"'.static::attributes($attributes).'></script>'.PHP_EOL;[m | |
}[m | |
[36m@@ -90,7 +90,7 @@[m [mclass HTML {[m | |
$attributes = $attributes + $defaults;[m | |
$url = [31mstatic::entities(URL::to_asset($url));[m[32mURL::to_asset($url);[m | |
return '<link href="'.$url.'"'.static::attributes($attributes).'>'.PHP_EOL;[m | |
}[m | |
[36m@@ -126,7 +126,7 @@[m [mclass HTML {[m | |
*/[m | |
public static function link($url, $title, $attributes = array(), $https = false)[m | |
{[m | |
$url = [31mstatic::entities(URL::to($url, $https));[m[32mURL::to($url, $https);[m | |
return '<a href="'.$url.'"'.static::attributes($attributes).'>'.static::entities($title).'</a>';[m | |
}[m | |
[36m@@ -157,7 +157,7 @@[m [mclass HTML {[m | |
*/[m | |
public static function link_to_asset($url, $title, $attributes = array(), $https = null)[m | |
{[m | |
$url = [31mstatic::entities(URL::to_asset($url, $https));[m[32mURL::to_asset($url, $https);[m | |
return '<a href="'.$url.'"'.static::attributes($attributes).'>'.static::entities($title).'</a>';[m | |
}[m | |
[36m@@ -267,7 +267,7 @@[m [mclass HTML {[m | |
{[m | |
$attributes['alt'] = $alt;[m | |
return '<img [31msrc="'.static::entities(URL::to_asset($url)).'"'.static::attributes($attributes).'>';[m[32msrc="'.URL::to_asset($url).'"'.static::attributes($attributes).'>';[m | |
}[m | |
/**[m | |
[36m@@ -306,6 +306,8 @@[m [mclass HTML {[m | |
{[m | |
$html = '';[m | |
[32mif (count($list) == 0) return $html;[m | |
foreach ($list as $key => $value)[m | |
{[m | |
// If the value is an array, we will recurse the function so that we can[m | |
[1mdiff --git a/laravel/input.php b/laravel/input.php[m | |
[1mindex 8524957..6a28b17 100755[m | |
[1m--- a/laravel/input.php[m | |
[1m+++ b/laravel/input.php[m | |
[36m@@ -3,11 +3,11 @@[m | |
class Input {[m | |
/**[m | |
* The [31mapplicable input[m[32mJSON payload[m for [31mthe request.[m[32mapplications using Backbone.js or similar.[m | |
*[m | |
* @var [31marray[m[32mobject[m | |
*/[m | |
public static [31m$input;[m[32m$json;[m | |
/**[m | |
* The key used to store old input in the session.[m | |
[36m@@ -23,7 +23,11 @@[m [mclass Input {[m | |
*/[m | |
public static function all()[m | |
{[m | |
[31mreturn[m[32m$input =[m array_merge(static::get(), [32mstatic::query(),[m static::file()); | |
[32munset($input[Request::spoofer]);[m | |
[32m return $input;[m | |
}[m | |
/**[m | |
[36m@@ -58,7 +62,53 @@[m [mclass Input {[m | |
*/[m | |
public static function get($key = null, $default = null)[m | |
{[m | |
[32m$input = Request::foundation()->request->all();[m | |
[32m if (is_null($key))[m | |
[32m {[m | |
return [31marray_get(static::$input,[m[32marray_merge($input, static::query());[m | |
[32m }[m | |
[32m $value = array_get($input, $key);[m | |
[32m if (is_null($value))[m | |
[32m {[m | |
[32m return array_get(static::query(),[m $key, $default); | |
[32m}[m | |
[32m return $value;[m | |
[32m }[m | |
[32m /**[m | |
[32m * Get an item from the query string.[m | |
[32m *[m | |
[32m * <code>[m | |
[32m * // Get the "email" item from the query string[m | |
[32m * $email = Input::query('email');[m | |
[32m *[m | |
[32m * // Return a default value if the specified item doesn't exist[m | |
[32m * $email = Input::query('name', 'Taylor');[m | |
[32m * </code>[m | |
[32m *[m | |
[32m * @param string $key[m | |
[32m * @param mixed $default[m | |
[32m * @return mixed[m | |
[32m */[m | |
[32m public static function query($key = null, $default = null)[m | |
[32m {[m | |
[32m return array_get(Request::foundation()->query->all(), $key, $default);[m | |
[32m }[m | |
[32m /**[m | |
[32m * Get the JSON payload for the request.[m | |
[32m *[m | |
[32m * @return object[m | |
[32m */[m | |
[32m public static function json()[m | |
[32m {[m | |
[32m if ( ! is_null(static::$json)) return static::$json;[m | |
[32m return static::$json = json_decode(Request::foundation()->getContent());[m | |
}[m | |
/**[m | |
[36m@@ -77,7 +127,7 @@[m [mclass Input {[m | |
*/[m | |
public static function only($keys)[m | |
{[m | |
return [31marray_intersect_key(static::get(), array_flip((array) $keys));[m[32marray_only(static::get(), $keys);[m | |
}[m | |
/**[m | |
[36m@@ -96,7 +146,7 @@[m [mclass Input {[m | |
*/[m | |
public static function except($keys)[m | |
{[m | |
return [31marray_diff_key(static::get(), array_flip($keys));[m[32marray_except(static::get(), $keys);[m | |
}[m | |
/**[m | |
[36m@@ -136,14 +186,11 @@[m [mclass Input {[m | |
* <code>[m | |
* // Get the array of information for the "picture" upload[m | |
* $picture = Input::file('picture');[m | |
[31m *[m | |
[31m * // Get a specific element from within the file's data array[m | |
[31m * $size = Input::file('picture.size');[m | |
* </code>[m | |
*[m | |
* @param string $key | |
* @param mixed $default | |
* @return [31marray[m[32mUploadedFile[m | |
*/[m | |
public static function file($key = null, $default = null)[m | |
{[m | |
[36m@@ -151,24 +198,36 @@[m [mclass Input {[m | |
}[m | |
/**[m | |
[32m* Determine if the uploaded data contains a file.[m | |
[32m *[m | |
[32m * @param string $key[m | |
[32m * @return bool[m | |
[32m */[m | |
[32m public static function has_file($key)[m | |
[32m {[m | |
[32m return ! is_null(static::file("{$key}.tmp_name"));[m | |
[32m }[m | |
[32m /**[m | |
* Move an uploaded file to permanent storage.[m | |
*[m | |
* This method is simply a convenient wrapper around move_uploaded_file.[m | |
*[m | |
* <code>[m | |
* // Move the "picture" file to a [32mnew[m permanent location on disk | |
* Input::upload('picture', [31m'path/to/photos/picture.jpg');[m[32m'path/to/photos', 'picture.jpg');[m | |
* </code>[m | |
*[m | |
* @param string $key[m | |
* @param string [31m$path[m[32m$directory[m | |
[32m * @param string $name[m | |
* @return bool[m | |
*/[m | |
public static function upload($key, [31m$path)[m[32m$directory, $name = null)[m | |
{[m | |
if (is_null(static::file($key))) return false;[m | |
return [31mmove_uploaded_file(static::file("{$key}.tmp_name"), $path);[m[32mRequest::foundation()->files->get($key)->move($directory, $name);[m | |
}[m | |
/**[m | |
[36m@@ -206,4 +265,26 @@[m [mclass Input {[m | |
Session::flash(Input::old_input, array());[m | |
}[m | |
[32m/**[m | |
[32m * Merge new input into the current request's input array.[m | |
[32m *[m | |
[32m * @param array $input[m | |
[32m * @return void[m | |
[32m */[m | |
[32m public static function merge(array $input)[m | |
[32m {[m | |
[32m Request::foundation()->request->add($input);[m | |
[32m }[m | |
[32m /**[m | |
[32m * Replace the input for the current request.[m | |
[32m *[m | |
[32m * @param array $input[m | |
[32m * @return void[m | |
[32m */[m | |
[32m public static function replace(array $input)[m | |
[32m {[m | |
[32m Request::foundation()->request->replace($input);[m | |
[32m }[m | |
}[m | |
No newline at end of file[m | |
[1mdiff --git a/laravel/ioc.php b/laravel/ioc.php[m | |
[1mindex b02280f..e752635 100755[m | |
[1m--- a/laravel/ioc.php[m | |
[1m+++ b/laravel/ioc.php[m | |
[36m@@ -20,12 +20,14 @@[m [mclass IoC {[m | |
* Register an object and its resolver.[m | |
*[m | |
* @param string $name[m | |
* @param [31mClosure[m[32mmixed[m $resolver | |
* @param bool $singleton[m | |
* @return void[m | |
*/[m | |
public static function register($name, [31mClosure $resolver,[m[32m$resolver = null,[m $singleton = false) | |
{[m | |
[32mif (is_null($resolver)) $resolver = $name;[m | |
static::$registry[$name] = compact('resolver', 'singleton');[m | |
}[m | |
[36m@@ -49,7 +51,7 @@[m [mclass IoC {[m | |
* @param Closure $resolver[m | |
* @return void[m | |
*/[m | |
public static function singleton($name, [31m$resolver)[m[32m$resolver = null)[m | |
{[m | |
static::register($name, $resolver, true);[m | |
}[m | |
[36m@@ -72,70 +74,132 @@[m [mclass IoC {[m | |
}[m | |
/**[m | |
*[31mRegister a controller with the IoC container.[m | |
[31m *[m | |
[31m * @param string $name[m | |
[31m * @param Closure $resolver[m | |
[31m * @return void[m | |
[31m */[m | |
[31m public static function controller($name, $resolver)[m | |
[31m {[m | |
[31m static::register("controller: {$name}", $resolver);[m | |
[31m }[m | |
[31m /**[m | |
[31m *[m Resolve a [31mcore Laravel class from the container.[m[32mgiven type to an instance.[m | |
*[m | |
* <code>[m | |
* // [31mResolve[m[32mGet an instance of[m the [31m"laravel.router" class from[m[32m"mailer" object registered in[m the container | |
* [31m$input[m[32m$mailer[m = [31mIoC::core('router');[m[32mIoC::resolve('mailer');[m | |
*[m | |
* // [31mEquivalent resolution[m[32mGet an instance[m of the [31mrouter using[m[32m"mailer" object and pass parameters to[m the [31m"resolve" method[m[32mresolver[m | |
* [31m$input[m[32m$mailer[m = [31mIoC::resolve('laravel.router');[m[32mIoC::resolve('mailer', array('test'));[m | |
* </code>[m | |
*[m | |
* @param string [31m$name[m | |
[31m * @param array $parameters[m[32m$type[m | |
* @return mixed[m | |
*/[m | |
public static function [31mcore($name,[m[32mresolve($type,[m $parameters = array()) | |
{[m | |
[32m// If an instance of the type is currently being managed as a singleton, we will[m | |
[32m // just[m return [31mstatic::resolve("laravel.{$name}", $parameters);[m[32mthe existing instance instead of instantiating a fresh instance[m | |
[32m // so the developer can keep re-using the exact same object instance from us.[m | |
[32m if (isset(static::$singletons[$type]))[m | |
[32m {[m | |
[32m return static::$singletons[$type];[m | |
[32m }[m | |
[32m // If we don't have a registered resolver or concrete for the type, we'll just[m | |
[32m // assume the type is the concrete name and will attempt to resolve it as is[m | |
[32m // since the container should be able to resolve concretes automatically.[m | |
[32m if ( ! isset(static::$registry[$type]))[m | |
[32m {[m | |
[32m $concrete = $type;[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
[32m $concrete = array_get(static::$registry[$type], 'resolver', $type);[m | |
[32m }[m | |
[32m // We're ready to instantiate an instance of the concrete type registered for[m | |
[32m // the binding. This will instantiate the type, as well as resolve any of[m | |
[32m // its nested dependencies recursively until they are each resolved.[m | |
[32m if ($concrete == $type or $concrete instanceof Closure)[m | |
[32m {[m | |
[32m $object = static::build($concrete);[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
[32m $object = static::resolve($concrete);[m | |
[32m }[m | |
[32m // If the requested type is registered as a singleton, we want to cache off[m | |
[32m // the instance in memory so we can return it later without creating an[m | |
[32m // entirely new instances of the object on each subsequent request.[m | |
[32m if (isset(static::$registry[$type]['singleton']))[m | |
[32m {[m | |
[32m static::$singletons[$type] = $object;[m | |
[32m }[m | |
[32m return $object;[m | |
}[m | |
/**[m | |
* [31mResolve an object instance from the container.[m | |
[31m *[m | |
[31m * <code>[m | |
[31m * // Get[m[32mInstantiate[m an instance of the [31m"mailer" object registered in the container[m | |
[31m * $mailer = IoC::resolve('mailer');[m[32mgiven type.[m | |
*[m | |
*[31m// Get an instance of the "mailer" object and pass parameters to the resolver[m | |
[31m * $mailer = IoC::resolve('mailer', array('test'));[m | |
[31m * </code>[m | |
[31m *[m | |
[31m *[m @param string [31m$name[m[32m$type[m | |
* @param array $parameters[m | |
* @return mixed[m | |
*/[m | |
[31mpublic[m[32mprotected[m static function [31mresolve($name,[m[32mbuild($type,[m $parameters = array()) | |
{[m | |
[32m// If the concrete type is actually a Closure, we will just execute it and[m | |
[32m // hand back the results of the function, which allows functions to be[m | |
[32m // used as resolvers for more fine-tuned resolution of the objects.[m | |
if [31m(array_key_exists($name, static::$singletons))[m[32m($type instanceof Closure)[m | |
{[m | |
return [31mstatic::$singletons[$name];[m[32mcall_user_func_array($type, $parameters);[m | |
}[m | |
[31m$object[m[32m$reflector[m = [31mcall_user_func(static::$registry[$name]['resolver'], $parameters);[m[32mnew \ReflectionClass($type);[m | |
// If the [31mresolver[m[32mtype[m is [31mregistering as a singleton resolver, we will cache[m | |
[31m //[m[32mnot instantiable,[m the [31minstance[m[32mdeveloper is attempting to resolve[m | |
[32m // an abstract type such as an Interface[m of [32mAbstract Class and there is[m | |
[32m // no binding registered for[m the [31mobject in the container[m[32mabstraction[m so we [31mcan resolve it next[m | |
[31m // time without having[m[32mneed[m to [31minstantiate a brand new instance.[m[32mbail out.[m | |
if [31m(static::$registry[$name]['singleton'])[m[32m( ! $reflector->isInstantiable())[m | |
{[m | |
[31mreturn static::$singletons[$name] = $object;[m[32mthrow new Exception("Resolution target [$type] is not instantiable.");[m | |
}[m | |
[32m$constructor = $reflector->getConstructor();[m | |
[32m // If there is no constructor, that means there are no dependencies and[m | |
[32m // we can just resolve an instance of the object right away without[m | |
[32m // resolving any other types or dependencies from the container.[m | |
[32m if (is_null($constructor))[m | |
[32m {[m | |
return [31m$object;[m[32mnew $type;[m | |
[32m }[m | |
[32m $dependencies = static::dependencies($constructor->getParameters());[m | |
[32m return $reflector->newInstanceArgs($dependencies);[m | |
[32m }[m | |
[32m /**[m | |
[32m * Resolve all of the dependencies from the ReflectionParameters.[m | |
[32m *[m | |
[32m * @param array $parameterrs[m | |
[32m * @return array[m | |
[32m */[m | |
[32m protected static function dependencies($parameters)[m | |
[32m {[m | |
[32m $dependencies = array();[m | |
[32m foreach ($parameters as $parameter)[m | |
[32m {[m | |
[32m $dependency = $parameter->getClass();[m | |
[32m // If the class is null, it means the dependency is a string or some other[m | |
[32m // primitive type, which we can not esolve since it is not a class and[m | |
[32m // we'll just bomb out with an error since we have nowhere to go.[m | |
[32m if (is_null($dependency))[m | |
[32m {[m | |
[32m throw new Exception("Unresolvable dependency resolving [$parameter].");[m | |
[32m }[m | |
[32m $dependencies[] = static::resolve($dependency->name);[m | |
[32m }[m | |
[32m return (array) $dependencies;[m | |
}[m | |
}[m | |
No newline at end of file[m | |
[1mdiff --git a/laravel/lang.php b/laravel/lang.php[m | |
[1mindex 87be5f3..8fd5f7b 100755[m | |
[1m--- a/laravel/lang.php[m | |
[1m+++ b/laravel/lang.php[m | |
[36m@@ -1,4 +1,4 @@[m | |
<?php namespace Laravel;[31muse Closure;[m | |
class Lang {[m | |
[36m@@ -51,7 +51,7 @@[m [mclass Lang {[m | |
{[m | |
$this->key = $key;[m | |
$this->language = $language;[m | |
$this->replacements = [32m(array)[m $replacements; | |
}[m | |
/**[m | |
[36m@@ -89,7 +89,7 @@[m [mclass Lang {[m | |
*/[m | |
public static function has($key, $language = null)[m | |
{[m | |
return [31m! is_null(static::line($key,[m[32mstatic::line($key,[m array(), [31m$language)->get());[m[32m$language)->get() !== $key;[m | |
}[m | |
/**[m | |
[36m@@ -103,7 +103,7 @@[m [mclass Lang {[m | |
* $line = Lang::line('validation.required')->get('sp');[m | |
*[m | |
* // Return a default value if the line doesn't exist[m | |
* $line = [31mLang::line('validation.required', null,[m[32mLang::line('validation.required')->get(null,[m 'Default'); | |
* </code>[m | |
*[m | |
* @param string $language[m | |
[36m@@ -112,13 +112,18 @@[m [mclass Lang {[m | |
*/[m | |
public function get($language = null, $default = null)[m | |
{[m | |
[32m// If no default value is specified by the developer, we'll just return the[m | |
[32m // key of the language line. This should indicate which language line we[m | |
[32m // were attempting to render and is better than giving nothing back.[m | |
[32m if (is_null($default)) $default = $this->key;[m | |
if (is_null($language)) $language = $this->language;[m | |
list($bundle, $file, $line) = $this->parse($this->key);[m | |
// If the file [31mdoesn't[m[32mdoes not[m exist, we'll just return the default value that was | |
// given to the method. The default value is also returned even when the[m | |
// file exists and [31mthe[m[32mthat[m file does not actually contain any lines. | |
if ( ! static::load($bundle, $language, $file))[m | |
{[m | |
return value($default);[m | |
[36m@@ -244,4 +249,4 @@[m [mclass Lang {[m | |
return (string) $this->get();[m | |
}[m | |
[31m}[m | |
No newline at end of file[m | |
[32m}[m | |
[1mdiff --git a/laravel/laravel.php b/laravel/laravel.php[m | |
[1mindex b54ca57..a1ca206 100755[m | |
[1m--- a/laravel/laravel.php[m | |
[1m+++ b/laravel/laravel.php[m | |
[36m@@ -27,18 +27,24 @@[m [mrequire 'core.php';[m | |
set_exception_handler(function($e)[m | |
{[m | |
[32mrequire_once path('sys').'error'.EXT;[m | |
Error::exception($e);[m | |
});[m | |
set_error_handler(function($code, $error, $file, $line)[m | |
{[m | |
[32mrequire_once path('sys').'error'.EXT;[m | |
Error::native($code, $error, $file, $line);[m | |
});[m | |
register_shutdown_function(function()[m | |
{[m | |
[32mrequire_once path('sys').'error'.EXT;[m | |
Error::shutdown();[m | |
});[m | |
[36m@@ -57,80 +63,6 @@[m [merror_reporting(-1);[m | |
/*[m | |
|--------------------------------------------------------------------------[m | |
[31m| Magic Quotes Strip Slashes[m | |
[31m|--------------------------------------------------------------------------[m | |
[31m|[m | |
[31m| Even though "Magic Quotes" are deprecated in PHP 5.3.x, they may still[m | |
[31m| be enabled on the server. To account for this, we will strip slashes[m | |
[31m| on all input arrays if magic quotes are enabled for the server.[m | |
[31m|[m | |
[31m*/[m | |
[31mif (magic_quotes())[m | |
[31m{[m | |
[31m $magics = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);[m | |
[31m foreach ($magics as &$magic)[m | |
[31m {[m | |
[31m $magic = array_strip_slashes($magic);[m | |
[31m }[m | |
[31m}[m | |
[31m/*[m | |
[31m|--------------------------------------------------------------------------[m | |
[31m| Sniff The Input For The Request[m | |
[31m|--------------------------------------------------------------------------[m | |
[31m|[m | |
[31m| Next we'll gather the input to the application based on the global input[m | |
[31m| variables for the current request. The input will be gathered based on[m | |
[31m| the current request method and will be set on the Input manager class[m | |
[31m| as a simple static $input property which can be easily accessed.[m | |
[31m|[m | |
[31m*/[m | |
[31m$input = array();[m | |
[31mswitch (Request::method())[m | |
[31m{[m | |
[31m case 'GET':[m | |
[31m $input = $_GET;[m | |
[31m break;[m | |
[31m case 'POST':[m | |
[31m $input = $_POST;[m | |
[31m break;[m | |
[31m default:[m | |
[31m if (Request::spoofed())[m | |
[31m {[m | |
[31m $input = $_POST;[m | |
[31m }[m | |
[31m else[m | |
[31m {[m | |
[31m parse_str(file_get_contents('php://input'), $input);[m | |
[31m if (magic_quotes()) $input = array_strip_slashes($input);[m | |
[31m }[m | |
[31m}[m | |
[31m/*[m | |
[31m|--------------------------------------------------------------------------[m | |
[31m| Remove The Spoofer Input[m | |
[31m|--------------------------------------------------------------------------[m | |
[31m|[m | |
[31m| The spoofed request method is removed from the input so it is not in[m | |
[31m| the Input::all() or Input::get() results. Leaving it in the array[m | |
[31m| could cause unexpected results since the developer won't be[m | |
[31m| expecting it to be present.[m | |
[31m|[m | |
[31m*/[m | |
[31munset($input[Request::spoofer]);[m | |
[31mInput::$input = $input;[m | |
[31m/*[m | |
[31m|--------------------------------------------------------------------------[m | |
| Start The Application Bundle[m | |
|--------------------------------------------------------------------------[m | |
|[m | |
[36m@@ -194,32 +126,32 @@[m [m$response = Request::$route->call();[m | |
/*[m | |
|--------------------------------------------------------------------------[m | |
| [31mPersist[m[32m"Render"[m The [31mSession To Storage[m[32mResponse[m | |
|--------------------------------------------------------------------------[m | |
|[m | |
| [31mIf a session driver has been configured, we will save[m[32mThe render method evaluates[m the [31msession to[m | |
[31m| storage so it is avaiable for[m[32mcontent of[m the [31mnext request. This will also set[m[32mresponse and converts it[m | |
| [32mto a string. This evaluates any views and sub-responses within[m the | |
[31msession cookie in[m[32m| content and sets[m the [31mcookie jar to be sent to[m[32mraw string result as[m the [31muser.[m[32mnew response.[m | |
|[m | |
*/[m | |
[31mif (Config::get('session.driver') !== '')[m | |
[31m{[m | |
[31m Session::save();[m | |
[31m}[m[32m$response->render();[m | |
/*[m | |
|--------------------------------------------------------------------------[m | |
| [31mLet's Eat Cookies[m[32mPersist The Session To Storage[m | |
|--------------------------------------------------------------------------[m | |
|[m | |
| [31mAll cookies[m[32mIf a session driver has been configured, we will save the session to[m | |
[32m| storage so it is avaiable for the next request. This will also[m set | |
[31mduring[m[32m|[m the [31mrequest are actually stored[m[32msession cookie[m in [31ma[m[32mthe[m cookie jar [31m| until the end of the request so they can[m[32mto[m be [31mexpected by unit tests or[m | |
[31m| the developer. Here, we'll push them out[m[32msent[m to the [31mbrowser.[m[32muser.[m | |
|[m | |
*/[m | |
[31mCookie::send();[m[32mif (Config::get('session.driver') !== '')[m | |
[32m{[m | |
[32m Session::save();[m | |
[32m}[m | |
/*[m | |
|--------------------------------------------------------------------------[m | |
[1mdiff --git a/laravel/memcached.php b/laravel/memcached.php[m | |
[1mindex 548e298..91e7270 100755[m | |
[1m--- a/laravel/memcached.php[m | |
[1m+++ b/laravel/memcached.php[m | |
[36m@@ -35,16 +35,16 @@[m [mclass Memcached {[m | |
/**[m | |
* Create a new Memcached connection instance.[m | |
*[m | |
* @param array $servers | |
* @return Memcached[m | |
*/[m | |
protected static function connect($servers)[m | |
{[m | |
$memcache = new [31m\Memcache;[m[32m\Memcached;[m | |
foreach ($servers as $server)[m | |
{[m | |
$memcache->addServer($server['host'], $server['port'],[31mtrue,[m $server['weight']); | |
}[m | |
if ($memcache->getVersion() === false)[m | |
[1mdiff --git a/laravel/request.php b/laravel/request.php[m | |
[1mindex 59d0ec7..510f64e 100755[m | |
[1m--- a/laravel/request.php[m | |
[1m+++ b/laravel/request.php[m | |
[36m@@ -1,4 +1,4 @@[m | |
<?php namespace Laravel;[31muse Closure;[m | |
class Request {[m | |
[36m@@ -10,11 +10,18 @@[m [mclass Request {[m | |
public static $route;[m | |
/**[m | |
[32m* The Symfony HttpFoundation Request instance.[m | |
[32m *[m | |
[32m * @var HttpFoundation\Request[m | |
[32m */[m | |
[32m public static $foundation;[m | |
[32m /**[m | |
* The request data key that is used to indicate a spoofed request method.[m | |
*[m | |
* @var string[m | |
*/[m | |
const spoofer = [31m'__spoofer';[m[32m'_method';[m | |
/**[m | |
* Get the URI for the current request.[m | |
[36m@@ -33,12 +40,36 @@[m [mclass Request {[m | |
*/[m | |
public static function method()[m | |
{[m | |
[31mif ($_SERVER['REQUEST_METHOD'][m[32m$method = static::foundation()->getMethod();[m | |
[32m return ($method[m == 'HEAD') [31m{[m | |
[31m return 'GET';[m[32m? 'GET' : $method;[m | |
} | |
[32m/**[m | |
[32m * Get a header from the request.[m | |
[32m *[m | |
[32m * <code>[m | |
[32m * // Get a header from the request[m | |
[32m * $referer = Request::header('referer');[m | |
[32m * </code>[m | |
[32m *[m | |
[32m * @param string $key[m | |
[32m * @param mixed $default[m | |
[32m * @return mixed[m | |
[32m */[m | |
[32m public static function header($key, $default = null)[m | |
[32m {[m | |
return [31m(static::spoofed()) ? $_POST[Request::spoofer] : $_SERVER['REQUEST_METHOD'];[m[32marray_get(static::foundation()->headers->all(), $key, $default);[m | |
[32m }[m | |
[32m /**[m | |
[32m * Get all of the HTTP request headers.[m | |
[32m *[m | |
[32m * @return array[m | |
[32m */[m | |
[32m public static function headers()[m | |
[32m {[m | |
[32m return static::foundation()->headers->all();[m | |
}[m | |
/**[m | |
[36m@@ -50,7 +81,7 @@[m [mclass Request {[m | |
*/[m | |
public static function server($key = null, $default = null)[m | |
{[m | |
return [31marray_get($_SERVER,[m[32marray_get(static::foundation()->server->all(),[m strtoupper($key), $default); | |
}[m | |
/**[m | |
[36m@@ -60,7 +91,7 @@[m [mclass Request {[m | |
*/[m | |
public static function spoofed()[m | |
{[m | |
return [31mis_array($_POST) and array_key_exists(Request::spoofer, $_POST);[m[32m! is_null(static::foundation()->get(Request::spoofer));[m | |
}[m | |
/**[m | |
[36m@@ -71,30 +102,37 @@[m [mclass Request {[m | |
*/[m | |
public static function ip($default = '0.0.0.0')[m | |
{[m | |
[31mif (isset($_SERVER['HTTP_X_FORWARDED_FOR']))[m | |
[31m {[m return [31m$_SERVER['HTTP_X_FORWARDED_FOR'];[m | |
[31m }[m | |
[31m elseif (isset($_SERVER['HTTP_CLIENT_IP']))[m | |
[31m {[m | |
[31m return $_SERVER['HTTP_CLIENT_IP'];[m | |
[31m }[m | |
[31m elseif (isset($_SERVER['REMOTE_ADDR']))[m | |
[31m {[m | |
[31m return $_SERVER['REMOTE_ADDR'];[m[32mvalue(static::foundation()->getClientIp(), $default);[m | |
} | |
[32m/**[m | |
[32m * Get the list of acceptable content types for the request.[m | |
[32m *[m | |
[32m * @return array[m | |
[32m */[m | |
[32m public static function accept()[m | |
[32m {[m | |
return [31mvalue($default);[m[32mstatic::foundation()->getAcceptableContentTypes();[m | |
}[m | |
/**[m | |
* [31mGet[m[32mDetermine if[m the [31mHTTP protocol for the request.[m[32mrequest accepts a given content type.[m | |
*[m | |
* @return [31mstring[m[32mbool[m | |
*/[m | |
public static function [31mprotocol()[m[32maccepts($type)[m | |
{[m | |
return [31marray_get($_SERVER, 'SERVER_PROTOCOL', 'HTTP/1.1');[m[32min_array($type, static::accept());[m | |
[32m }[m | |
[32m /**[m | |
[32m * Get the languages accepted by the client's browser.[m | |
[32m *[m | |
[32m * @return array[m | |
[32m */[m | |
[32m public static function languages()[m | |
[32m {[m | |
[32m return static::foundation()->getLanguages();[m | |
}[m | |
/**[m | |
[36m@@ -104,7 +142,7 @@[m [mclass Request {[m | |
*/[m | |
public static function secure()[m | |
{[m | |
return [31misset($_SERVER['HTTPS'])[m[32mstatic::foundation()->isSecure()[m and [31mstrtolower($_SERVER['HTTPS']) !== 'off';[m[32mConfig::get('application.ssl');[m | |
}[m | |
/**[m | |
[36m@@ -126,9 +164,7 @@[m [mclass Request {[m | |
*/[m | |
public static function ajax()[m | |
{[m | |
[31mif ( ! isset($_SERVER['HTTP_X_REQUESTED_WITH']))[m return [31mfalse;[m | |
[31m return strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest';[m[32mstatic::foundation()->isXmlHttpRequest();[m | |
}[m | |
/**[m | |
[36m@@ -138,7 +174,7 @@[m [mclass Request {[m | |
*/[m | |
public static function referrer()[m | |
{[m | |
return [31marray_get($_SERVER, 'HTTP_REFERER');[m[32mstatic::foundation()->headers->get('referer');[m | |
}[m | |
/**[m | |
[36m@@ -158,7 +194,18 @@[m [mclass Request {[m | |
*/[m | |
public static function env()[m | |
{[m | |
[31mif (isset($_SERVER['LARAVEL_ENV']))[m return [31m$_SERVER['LARAVEL_ENV'];[m[32mstatic::foundation()->server->get('LARAVEL_ENV');[m | |
[32m }[m | |
[32m /**[m | |
[32m * Set the Laravel environment for the current request.[m | |
[32m *[m | |
[32m * @param string $env[m | |
[32m * @return void[m | |
[32m */[m | |
[32m public static function set_env($env)[m | |
[32m {[m | |
[32m static::foundation()->server->set('LARAVEL_ENV', $env);[m | |
}[m | |
/**[m | |
[36m@@ -173,6 +220,30 @@[m [mclass Request {[m | |
}[m | |
/**[m | |
[32m* Detect the current environment from an environment configuration.[m | |
[32m *[m | |
[32m * @param array $environments[m | |
[32m * @param string $uri[m | |
[32m * @return string|null[m | |
[32m */[m | |
[32m public static function detect_env(array $environments, $uri)[m | |
[32m {[m | |
[32m foreach ($environments as $environment => $patterns)[m | |
[32m {[m | |
[32m // Essentially we just want to loop through each environment pattern[m | |
[32m // and determine if the current URI matches the pattern and if so[m | |
[32m // we will simply return the environment for that URI pattern.[m | |
[32m foreach ($patterns as $pattern)[m | |
[32m {[m | |
[32m if (Str::is($pattern, $uri))[m | |
[32m {[m | |
[32m return $environment;[m | |
[32m }[m | |
[32m }[m | |
[32m }[m | |
[32m }[m | |
[32m /**[m | |
* Get the main route handling the request.[m | |
*[m | |
* @return Route[m | |
[36m@@ -182,4 +253,26 @@[m [mclass Request {[m | |
return static::$route;[m | |
}[m | |
[32m/**[m | |
[32m * Get the Symfony HttpFoundation Request instance.[m | |
[32m *[m | |
[32m * @return HttpFoundation\Request[m | |
[32m */[m | |
[32m public static function foundation()[m | |
[32m {[m | |
[32m return static::$foundation;[m | |
[32m }[m | |
[32m /**[m | |
[32m * Pass any other methods to the Symfony request.[m | |
[32m *[m | |
[32m * @param string $method[m | |
[32m * @param array $parameters[m | |
[32m * @return mixed[m | |
[32m */[m | |
[32m public static function __callStatic($method, $parameters)[m | |
[32m {[m | |
[32m return call_user_func_array(array(static::foundation(), $method), $parameters);[m | |
[32m }[m | |
}[m | |
No newline at end of file[m | |
[1mdiff --git a/laravel/response.php b/laravel/response.php[m | |
[1mindex c984140..e547243 100755[m | |
[1m--- a/laravel/response.php[m | |
[1m+++ b/laravel/response.php[m | |
[36m@@ -1,5 +1,8 @@[m | |
<?php namespace Laravel;[m | |
[32muse Symfony\Component\HttpFoundation\ResponseHeaderBag;[m | |
[32muse Symfony\Component\HttpFoundation\Response as FoundationResponse;[m | |
class Response {[m | |
/**[m | |
[36m@@ -10,72 +13,11 @@[m [mclass Response {[m | |
public $content;[m | |
/**[m | |
* The [31mHTTP status code of the response.[m | |
[31m *[m | |
[31m * @var int[m | |
[31m */[m | |
[31m public $status = 200;[m | |
[31m /**[m | |
[31m * The response headers.[m | |
[31m *[m | |
[31m * @var array[m | |
[31m */[m | |
[31m public $headers = array();[m | |
[31m /**[m | |
[31m * HTTP status codes.[m[32mSymfony HttpFoundation Response instance.[m | |
*[m | |
* @var [31marray[m[32mHttpFoundation\Response[m | |
*/[m | |
public [31mstatic $statuses = array([m | |
[31m 100 => 'Continue',[m | |
[31m 101 => 'Switching Protocols',[m | |
[31m 200 => 'OK',[m | |
[31m 201 => 'Created',[m | |
[31m 202 => 'Accepted',[m | |
[31m 203 => 'Non-Authoritative Information',[m | |
[31m 204 => 'No Content',[m | |
[31m 205 => 'Reset Content',[m | |
[31m 206 => 'Partial Content',[m | |
[31m 207 => 'Multi-Status',[m | |
[31m 300 => 'Multiple Choices',[m | |
[31m 301 => 'Moved Permanently',[m | |
[31m 302 => 'Found',[m | |
[31m 303 => 'See Other',[m | |
[31m 304 => 'Not Modified',[m | |
[31m 305 => 'Use Proxy',[m | |
[31m 307 => 'Temporary Redirect',[m | |
[31m 400 => 'Bad Request',[m | |
[31m 401 => 'Unauthorized',[m | |
[31m 402 => 'Payment Required',[m | |
[31m 403 => 'Forbidden',[m | |
[31m 404 => 'Not Found',[m | |
[31m 405 => 'Method Not Allowed',[m | |
[31m 406 => 'Not Acceptable',[m | |
[31m 407 => 'Proxy Authentication Required',[m | |
[31m 408 => 'Request Timeout',[m | |
[31m 409 => 'Conflict',[m | |
[31m 410 => 'Gone',[m | |
[31m 411 => 'Length Required',[m | |
[31m 412 => 'Precondition Failed',[m | |
[31m 413 => 'Request Entity Too Large',[m | |
[31m 414 => 'Request-URI Too Long',[m | |
[31m 415 => 'Unsupported Media Type',[m | |
[31m 416 => 'Requested Range Not Satisfiable',[m | |
[31m 417 => 'Expectation Failed',[m | |
[31m 422 => 'Unprocessable Entity',[m | |
[31m 423 => 'Locked',[m | |
[31m 424 => 'Failed Dependency',[m | |
[31m 500 => 'Internal Server Error',[m | |
[31m 501 => 'Not Implemented',[m | |
[31m 502 => 'Bad Gateway',[m | |
[31m 503 => 'Service Unavailable',[m | |
[31m 504 => 'Gateway Timeout',[m | |
[31m 505 => 'HTTP Version Not Supported',[m | |
[31m 507 => 'Insufficient Storage',[m | |
[31m 509 => 'Bandwidth Limit Exceeded'[m | |
[31m );[m[32m$foundation;[m | |
/**[m | |
* Create a new response instance.[m | |
[36m@@ -87,9 +29,9 @@[m [mclass Response {[m | |
*/[m | |
public function __construct($content, $status = 200, $headers = array())[m | |
{[m | |
[31m $this->status = $status;[m | |
$this->content = $content;[m | |
[31m$this->headers[m[32m$this->foundation[m = [31marray_change_key_case($headers);[m[32mnew FoundationResponse('', $status, $headers);[m | |
}[m | |
/**[m | |
[36m@@ -137,6 +79,46 @@[m [mclass Response {[m | |
}[m | |
/**[m | |
[32m* Create a new JSON response.[m | |
[32m *[m | |
[32m * <code>[m | |
[32m * // Create a response instance with JSON[m | |
[32m * return Response::json($data, 200, array('header' => 'value'));[m | |
[32m * </code>[m | |
[32m *[m | |
[32m * @param mixed $data[m | |
[32m * @param int $status[m | |
[32m * @param array $headers[m | |
[32m * @return Response[m | |
[32m */[m | |
[32m public static function json($data, $status = 200, $headers = array())[m | |
[32m {[m | |
[32m $headers['Content-Type'] = 'application/json';[m | |
[32m return new static(json_encode($data), $status, $headers);[m | |
[32m }[m | |
[32m /**[m | |
[32m * Create a new response of JSON'd Eloquent models.[m | |
[32m *[m | |
[32m * <code>[m | |
[32m * // Create a new response instance with Eloquent models[m | |
[32m * return Response::eloquent($data, 200, array('header' => 'value'));[m | |
[32m * </code>[m | |
[32m *[m | |
[32m * @param Eloquenet|array $data[m | |
[32m * @param int $status[m | |
[32m * @param array $headers[m | |
[32m * @return Response[m | |
[32m */[m | |
[32m public static function eloquent($data, $status = 200, $headers = array())[m | |
[32m {[m | |
[32m $headers['Content-Type'] = 'application/json';[m | |
[32m return new static(eloquent_to_json($data), $status, $headers);[m | |
[32m }[m | |
[32m /**[m | |
* Create a new error response instance.[m | |
*[m | |
* The response status code will be set using the specified code.[m | |
[36m@@ -180,56 +162,86 @@[m [mclass Response {[m | |
{[m | |
if (is_null($name)) $name = basename($path);[m | |
[32m// We'll set some sensible default headers, but merge the array given to[m | |
[32m // us so that the developer has the chance to override any of these[m | |
[32m // default headers with header values of their own liking.[m | |
$headers = array_merge(array([m | |
[31m'content-description'[m[32m'Content-Description'[m => 'File Transfer', | |
[31m'content-type'[m[32m'Content-Type'[m => File::mime(File::extension($path)), | |
[31m'content-disposition' => 'attachment; filename="'.$name.'"',[m | |
[31m 'content-transfer-encoding'[m[32m'Content-Transfer-Encoding'[m => 'binary', | |
[31m'expires'[m[32m'Expires'[m => 0, | |
[31m'cache-control'[m[32m'Cache-Control'[m => 'must-revalidate, post-check=0, pre-check=0', | |
[31m'pragma'[m[32m'Pragma'[m => 'public', | |
[31m'content-length'[m[32m'Content-Length'[m => File::size($path), | |
), $headers);[m | |
[31mreturn[m[32m// Once we create the response, we need to set the content disposition[m | |
[32m // header on the response based on the file's name. We'll pass this[m | |
[32m // off to the HttpFoundation and let it create the header text.[m | |
[32m $response =[m new static(File::get($path), 200, $headers); | |
[32m$d = $response->disposition($name);[m | |
[32m return $response->header('Content-Disposition', $d);[m | |
}[m | |
/**[m | |
* [31mPrepare a response from[m[32mCreate[m the [31mgiven value.[m[32mproper Content-Disposition header.[m | |
*[m | |
* [31mIf the value is not a response, it will be converted into[m[32m@param string $file[m | |
[32m * @return string[m | |
[32m */[m | |
[32m public function disposition($file)[m | |
[32m {[m | |
[32m $type = ResponseHeaderBag::DISPOSITION_ATTACHMENT;[m | |
[32m return $this->foundation->headers->makeDisposition($type, $file);[m | |
[32m }[m | |
[32m /**[m | |
[32m * Prepare[m a response [31m* instance and[m[32mfrom[m the [31mcontent will be cast to a string.[m[32mgiven value.[m | |
*[m | |
* @param mixed $response[m | |
* @return Response[m | |
*/[m | |
public static function prepare($response)[m | |
{[m | |
[32m// We will need to force the response to be a string before closing[m | |
[32m // the session since the developer may be utilizing the session[m | |
[32m // within the view, and we can't age it until rendering.[m | |
if ( ! $response instanceof Response)[m | |
{[m | |
$response = new static($response);[m | |
}[m | |
[31m // We'll need to force the response to be a string before closing the session,[m | |
[31m // since the developer may be using the session within a view, and we can't[m | |
[31m // age the flash data until the view is rendered.[m | |
[31m //[m | |
[31m // Since this method is used by both the Route and Controller classes, it is[m | |
[31m // a convenient spot to cast the application response to a string before it[m | |
[31m // is returned to the main request handler.[m | |
[31m $response->render();[m | |
return $response;[m | |
}[m | |
/**[m | |
[32m* Send the headers and content of the response to the browser.[m | |
[32m *[m | |
[32m * @return void[m | |
[32m */[m | |
[32m public function send()[m | |
[32m {[m | |
[32m $this->cookies();[m | |
[32m $this->foundation->prepare(Request::foundation());[m | |
[32m $this->foundation->send();[m | |
[32m }[m | |
[32m /**[m | |
* Convert the content of the Response to a string and return it.[m | |
*[m | |
* @return string[m | |
*/[m | |
public function render()[m | |
{[m | |
[31mif (is_object($this->content)[m[32m// If the content is a stringable object, we'll go ahead[m and [31mmethod_exists($this->content, '__toString'))[m[32mcall[m | |
[32m // to toString method so that we can get the string content of[m | |
[32m // the content object. Otherwise we'll just cast to string.[m | |
[32m if (str_object($this->content))[m | |
{[m | |
$this->content = $this->content->__toString();[m | |
}[m | |
[36m@@ -238,74 +250,47 @@[m [mclass Response {[m | |
$this->content = (string) $this->content;[m | |
}[m | |
[32m// Once we obtain the string content, we can set the content on[m | |
[32m // the HttpFoundation's Response instance in preparation for[m | |
[32m // sending it back to client browser when all is finished.[m | |
[32m $this->foundation->setContent($this->content);[m | |
return $this->content;[m | |
}[m | |
/**[m | |
* Send [31mthe headers and content[m[32mall[m of the response [32mheaders[m to the browser. | |
*[m | |
* @return void[m | |
*/[m | |
public function [31msend()[m[32msend_headers()[m | |
{[m | |
[31mif ( ! headers_sent()) $this->send_headers();[m[32m$this->foundation->prepare(Request::foundation());[m | |
[31mecho (string) $this->content;[m[32m$this->foundation->sendHeaders();[m | |
}[m | |
/**[m | |
* [31mSend all of[m[32mSet[m the [31mresponse headers to[m[32mcookies on[m the [31mbrowser.[m[32mHttpFoundation Response.[m | |
*[m | |
* @return void[m | |
*/[m | |
[31mpublic[m[32mprotected[m function [31msend_headers()[m[32mcookies()[m | |
{[m | |
[31m// If the server is using FastCGI, we need to send a slightly different[m | |
[31m // protocol and status header than we normally would. Otherwise it will[m | |
[31m // not call any custom scripts setup to handle 404 responses.[m | |
[31m //[m | |
[31m // The status header will contain both the code and the status message,[m | |
[31m // such as "OK" or "Not Found". For typical servers, the HTTP protocol[m | |
[31m // will also be included with the status.[m | |
[31m if (isset($_SERVER['FCGI_SERVER_VERSION']))[m | |
[31m {[m | |
[31m header('Status: '.$this->status.' '.$this->message());[m | |
[31m }[m | |
[31m else[m | |
[31m {[m | |
[31m header(Request::protocol().' '.$this->status.' '.$this->message());[m | |
[31m }[m[32m$ref = new \ReflectionClass('Symfony\Component\HttpFoundation\Cookie');[m | |
// [31mIf[m[32mAll of[m the [31mcontent type was not set by[m[32mcookies for[m the [31mdeveloper, we will set[m[32mresponse are actually stored on[m the | |
// [31mheader[m[32mCookie class until we're ready[m to [31ma default value that indicates to the browser that[m[32msend[m the[31m//[m response [31mis HTML and that it uses[m[32mback to[m | |
[32m //[m the [31mdefault encoding.[m | |
[31m if ( ! isset($this->headers['content-type']))[m[32mbrowser. This allows our cookies to be set easily.[m | |
[32m foreach (Cookie::$jar as $name => $cookie)[m | |
{[m | |
[31m$encoding[m[32m$config[m = [31mConfig::get('application.encoding');[m[32marray_values($cookie);[m | |
[31m$this->header('content-type', 'text/html; charset='.$encoding);[m | |
[31m }[m | |
[31m // Once the framework controlled headers have been sentm, we can[m | |
[31m // simply iterate over the developer's headers and send each one[m | |
[31m // back to the browser for the response.[m | |
[31m foreach ($this->headers as $name => $value)[m | |
[31m {[m | |
[31m header("{$name}: {$value}", true);[m[32m$this->headers()->setCookie($ref->newInstanceArgs($config));[m | |
}[m | |
}[m | |
/**[m | |
[31m * Get the status code message for the response.[m | |
[31m *[m | |
[31m * @return string[m | |
[31m */[m | |
[31m public function message()[m | |
[31m {[m | |
[31m return static::$statuses[$this->status];[m | |
[31m }[m | |
[31m /**[m | |
* Add a header to the array of response headers.[m | |
*[m | |
* @param string $name[m | |
[36m@@ -314,20 +299,39 @@[m [mclass Response {[m | |
*/[m | |
public function header($name, $value)[m | |
{[m | |
[31m$this->headers[strtolower($name)] = $value;[m[32m$this->foundation->headers->set($name, $value);[m | |
return $this;[m | |
}[m | |
/**[m | |
* [31mSet[m[32mGet[m the [31mresponse status code.[m[32mHttpFoundation Response headers.[m | |
*[m | |
*[31m@param int $status[m | |
[31m *[m @return [31mResponse[m[32mResponseParameterBag[m | |
*/[m | |
public function [31mstatus($status)[m[32mheaders()[m | |
{[m | |
[31m$this->status[m[32mreturn $this->foundation->headers;[m | |
[32m }[m | |
[32m /**[m | |
[32m * Get / set the response status code.[m | |
[32m *[m | |
[32m * @param int $status[m | |
[32m * @return mixed[m | |
[32m */[m | |
[32m public function status($status[m = [31m$status;[m[32mnull)[m | |
[32m {[m | |
[32m if (is_null($status))[m | |
[32m {[m | |
[32m return $this->foundation->getStatusCode();[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
[32m $this->foundation->setStatusCode($status);[m | |
return $this; | |
[32m}[m | |
}[m | |
}[m | |
No newline at end of file[m | |
[1mdiff --git a/laravel/routing/controller.php b/laravel/routing/controller.php[m | |
[1mindex f75ef4b..0a780bb 100755[m | |
[1m--- a/laravel/routing/controller.php[m | |
[1m+++ b/laravel/routing/controller.php[m | |
[36m@@ -140,9 +140,19 @@[m [mabstract class Controller {[m | |
// improve speed since the bundle is not loaded on every request.[m | |
Bundle::start($bundle);[m | |
[31mlist($controller,[m[32mlist($name,[m $method) = explode('@', $destination); | |
$controller = static::resolve($bundle, [31m$controller);[m[32m$name);[m | |
[32m // For convenience we will set the current controller and action on the[m | |
[32m // Request's route instance so they can be easily accessed from the[m | |
[32m // application. This is sometimes useful for dynamic situations.[m | |
[32m if ( ! is_null($route = Request::route()))[m | |
[32m {[m | |
[32m $route->controller = $name;[m | |
[32m $route->controller_action = $method;[m | |
[32m }[m | |
// If the controller could not be resolved, we're out of options and[m | |
// will return the 404 error response. If we found the controller,[m | |
[1mdiff --git a/laravel/routing/route.php b/laravel/routing/route.php[m | |
[1mindex 6349a0e..73b7952 100755[m | |
[1m--- a/laravel/routing/route.php[m | |
[1m+++ b/laravel/routing/route.php[m | |
[36m@@ -1,6 +1,7 @@[m | |
<?php namespace Laravel\Routing;[m | |
use Closure;[m | |
[32muse Laravel\Str;[m | |
use Laravel\URI;[m | |
use Laravel\Bundle;[m | |
use Laravel\Request;[m | |
[36m@@ -30,6 +31,20 @@[m [mclass Route {[m | |
public $bundle;[m | |
/**[m | |
[32m* The name of the controller used by the route.[m | |
[32m *[m | |
[32m * @var string[m | |
[32m */[m | |
[32m public $controller;[m | |
[32m /**[m | |
[32m * The name of the controller action used by the route.[m | |
[32m *[m | |
[32m * @var string[m | |
[32m */[m | |
[32m public $controller_action;[m | |
[32m /**[m | |
* The action that is assigned to the route.[m | |
*[m | |
* @var mixed[m | |
[36m@@ -46,11 +61,10 @@[m [mclass Route {[m | |
/**[m | |
* Create a new Route instance.[m | |
*[m | |
* @param string $method | |
* @param string $uri | |
* @param array $action | |
* @param array $parameters[31m* @return void[m | |
*/[m | |
public function __construct($method, $uri, $action, $parameters = array())[m | |
{[m | |
[36m@@ -66,18 +80,17 @@[m [mclass Route {[m | |
// We'll set the parameters based on the number of parameters passed[m | |
// compared to the parameters that were needed. If more parameters[m | |
// are needed, we'll merge in defaults.[m | |
[31m$this->parameters($uri, $action,[m[32m$this->parameters($action,[m $parameters); | |
}[m | |
/**[m | |
* Set the parameters array to the correct value.[m | |
*[m | |
[31m * @param string $uri[m | |
* @param array $action[m | |
* @param array $parameters[m | |
* @return void[m | |
*/[m | |
protected function [31mparameters($uri, $action,[m[32mparameters($action,[m $parameters) | |
{[m | |
$defaults = (array) array_get($action, 'defaults');[m | |
[36m@@ -113,7 +126,7 @@[m [mclass Route {[m | |
// We always return a Response instance from the route calls, so[m | |
// we'll use the prepare method on the Response class to make[m | |
// sure we have a valid Response [31misntance.[m[32minstance.[m | |
$response = Response::prepare($response);[m | |
Filter::run($this->filters('after'), array($response));[m | |
[36m@@ -198,7 +211,7 @@[m [mclass Route {[m | |
// if they match we'll attach the filter.[m | |
foreach (Filter::$patterns as $pattern => $filter)[m | |
{[m | |
if [31m(URI::is($pattern,[m[32m(Str::is($pattern,[m $this->uri)) | |
{[m | |
$filters[] = $filter;[m | |
}[m | |
[36m@@ -251,7 +264,7 @@[m [mclass Route {[m | |
/**[m | |
* Register a controller with the router.[m | |
*[m | |
* @param string|array [31m$controller[m[32m$controllers[m | |
* @param string|array $defaults[m | |
* @return void[m | |
*/[m | |
[36m@@ -393,4 +406,4 @@[m [mclass Route {[m | |
return Router::route(strtoupper($method), $uri)->call();[m | |
}[m | |
[31m}[m | |
No newline at end of file[m | |
[32m}[m | |
[1mdiff --git a/laravel/routing/router.php b/laravel/routing/router.php[m | |
[1mindex a6577b3..9fc946b 100755[m | |
[1m--- a/laravel/routing/router.php[m | |
[1m+++ b/laravel/routing/router.php[m | |
[36m@@ -119,7 +119,7 @@[m [mclass Router {[m | |
*[m | |
* <code>[m | |
* // Register a group of URIs for an action[m | |
* [31mRouter::share(array('GET',[m[32mRouter::share(array(array('GET',[m '/'), array('POST', [31m'/'),[m[32m'/')),[m 'home@index'); | |
* </code>[m | |
*[m | |
* @param array $routes[m | |
[36m@@ -174,6 +174,8 @@[m [mclass Router {[m | |
*/[m | |
public static function register($method, $route, $action)[m | |
{[m | |
[32mif (ctype_digit($route)) $route = "({$route})";[m | |
if (is_string($route)) $route = explode(', ', $route);[m | |
// If the developer is registering multiple request methods to handle[m | |
[1mdiff --git a/laravel/section.php b/laravel/section.php[m | |
[1mindex ff12889..9638880 100755[m | |
[1m--- a/laravel/section.php[m | |
[1m+++ b/laravel/section.php[m | |
[36m@@ -39,7 +39,7 @@[m [mclass Section {[m | |
}[m | |
else[m | |
{[m | |
[31mstatic::append($section,[m[32mstatic::extend($section,[m $content); | |
}[m | |
}[m | |
[36m@@ -79,19 +79,19 @@[m [mclass Section {[m | |
*/[m | |
public static function stop()[m | |
{[m | |
[31mstatic::append($last[m[32mstatic::extend($last[m = array_pop(static::$last), ob_get_clean()); | |
return $last;[m | |
}[m | |
/**[m | |
* [31mAppend[m[32mExtend the[m content [31mto[m[32min[m a given section. | |
*[m | |
* @param string $section[m | |
* @param string $content[m | |
* @return void[m | |
*/[m | |
protected static function [31mappend($section,[m[32mextend($section,[m $content) | |
{[m | |
if (isset(static::$sections[$section]))[m | |
{[m | |
[36m@@ -104,6 +104,25 @@[m [mclass Section {[m | |
}[m | |
/**[m | |
[32m* Append content to a given section.[m | |
[32m *[m | |
[32m * @param string $section[m | |
[32m * @param string $content[m | |
[32m * @return void[m | |
[32m */[m | |
[32m public static function append($section, $content)[m | |
[32m {[m | |
[32m if (isset(static::$sections[$section]))[m | |
[32m {[m | |
[32m static::$sections[$section] .= $content;[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
[32m static::$sections[$section] = $content;[m | |
[32m }[m | |
[32m }[m | |
[32m /**[m | |
* Get the string contents of a section.[m | |
*[m | |
* @param string $section[m | |
[1mdiff --git a/laravel/session.php b/laravel/session.php[m | |
[1mindex bdc549a..b5b833f 100755[m | |
[1m--- a/laravel/session.php[m | |
[1m+++ b/laravel/session.php[m | |
[36m@@ -10,6 +10,13 @@[m [mclass Session {[m | |
public static $instance;[m | |
/**[m | |
[32m* The third-party driver registrar.[m | |
[32m *[m | |
[32m * @var array[m | |
[32m */[m | |
[32m public static $registrar = array();[m | |
[32m /**[m | |
* The string name of the CSRF token stored in the session.[m | |
*[m | |
* @var string[m | |
[36m@@ -47,6 +54,13 @@[m [mclass Session {[m | |
*/[m | |
public static function factory($driver)[m | |
{[m | |
[32mif (isset(static::$registrar[$driver]))[m | |
[32m {[m | |
[32m $resolver = static::$registrar[$driver];[m | |
[32m return $resolver();[m | |
[32m }[m | |
switch ($driver)[m | |
{[m | |
case 'apc':[m | |
[36m@@ -106,6 +120,18 @@[m [mclass Session {[m | |
}[m | |
/**[m | |
[32m* Register a third-party cache driver.[m | |
[32m *[m | |
[32m * @param string $driver[m | |
[32m * @param Closure $resolver[m | |
[32m * @return void[m | |
[32m */[m | |
[32m public static function extend($driver, Closure $resolver)[m | |
[32m {[m | |
[32m static::$registrar[$driver] = $resolver;[m | |
[32m }[m | |
[32m /**[m | |
* Magic Method for calling the methods on the session singleton instance.[m | |
*[m | |
* <code>[m | |
[1mdiff --git a/laravel/session/drivers/cookie.php b/laravel/session/drivers/cookie.php[m | |
[1mindex d15d706..63a60ee 100755[m | |
[1m--- a/laravel/session/drivers/cookie.php[m | |
[1m+++ b/laravel/session/drivers/cookie.php[m | |
[36m@@ -1,6 +1,4 @@[m | |
<?php namespace Laravel\Session\Drivers; use [31mLaravel\Crypter;[m[32mLaravel\Crypter, Laravel\Cookie as C;[m | |
class Cookie extends Driver {[m | |
[36m@@ -21,9 +19,9 @@[m [mclass Cookie extends Driver {[m | |
*/[m | |
public function load($id)[m | |
{[m | |
if [31m(\Laravel\Cookie::has(Cookie::payload))[m[32m(C::has(Cookie::payload))[m | |
{[m | |
return [31munserialize(Crypter::decrypt(\Laravel\Cookie::get(Cookie::payload)));[m[32munserialize(Crypter::decrypt(C::get(Cookie::payload)));[m | |
}[m | |
}[m | |
[36m@@ -41,7 +39,7 @@[m [mclass Cookie extends Driver {[m | |
$payload = Crypter::encrypt(serialize($session));[m | |
[31m\Laravel\Cookie::put(Cookie::payload,[m[32mC::put(Cookie::payload,[m $payload, $lifetime, $path, $domain); | |
}[m | |
/**[m | |
[36m@@ -52,7 +50,7 @@[m [mclass Cookie extends Driver {[m | |
*/[m | |
public function delete($id)[m | |
{[m | |
[31m\Laravel\Cookie::forget(Cookie::payload);[m[32mC::forget(Cookie::payload);[m | |
}[m | |
}[m | |
No newline at end of file[m | |
[1mdiff --git a/laravel/session/drivers/driver.php b/laravel/session/drivers/driver.php[m | |
[1mindex a8b9d4d..8a54ac9 100755[m | |
[1m--- a/laravel/session/drivers/driver.php[m | |
[1m+++ b/laravel/session/drivers/driver.php[m | |
[36m@@ -31,7 +31,7 @@[m [mabstract class Driver {[m | |
abstract public function delete($id);[m | |
/**[m | |
* [31mInsert[m[32mCreate[m a fresh session [31mand return the payload array.[m[32marray with a unique ID.[m | |
*[m | |
* @return array[m | |
*/[m | |
[1mdiff --git a/laravel/session/payload.php b/laravel/session/payload.php[m | |
[1mindex bf23b94..5b45a53 100755[m | |
[1m--- a/laravel/session/payload.php[m | |
[1m+++ b/laravel/session/payload.php[m | |
[36m@@ -1,6 +1,5 @@[m | |
<?php namespace Laravel\Session;[m | |
[31muse Closure;[m | |
use Laravel\Str;[m | |
use Laravel\Config;[m | |
use Laravel\Cookie;[m | |
[36m@@ -298,10 +297,9 @@[m [mclass Payload {[m | |
// session on the user's subsequent requests to the application.[m | |
$this->cookie($config);[m | |
// Some session drivers implement the Sweeper [31minterface,[m[32minterface[m meaning that | |
// they must clean up expired sessions manually. If the driver is a[m | |
// sweeper, [32mwe'll calculate if[m we need to[31mdetermine if garbage collection should be[m | |
[31m //[m run [31mfor the request.[m[32mgarbage collection.[m | |
$sweepage = $config['sweepage'];[m | |
if ($this->driver instanceof Sweeper and (mt_rand(1, $sweepage[1]) <= $sweepage[0]))[m | |
[1mdiff --git a/laravel/str.php b/laravel/str.php[m | |
[1mindex 78a554e..964b5d5 100755[m | |
[1m--- a/laravel/str.php[m | |
[1m+++ b/laravel/str.php[m | |
[36m@@ -148,7 +148,9 @@[m [mclass Str {[m | |
*/[m | |
public static function words($value, $words = 100, $end = '...')[m | |
{[m | |
[31mpreg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/',[m[32mif (trim($value) == '') return '';[m | |
[32m preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u',[m $value, $matches); | |
if (static::length($value) == static::length($matches[0]))[m | |
{[m | |
[36m@@ -301,6 +303,30 @@[m [mclass Str {[m | |
}[m | |
/**[m | |
[32m* Determine if a given string matches a given pattern.[m | |
[32m *[m | |
[32m * @param string $pattern[m | |
[32m * @param string $value[m | |
[32m * @return bool[m | |
[32m */[m | |
[32m public static function is($pattern, $value)[m | |
[32m {[m | |
[32m // Asterisks are translated into zero-or-more regular expression wildcards[m | |
[32m // to make it convenient to check if the URI starts with a given pattern[m | |
[32m // such as "library/*". This is only done when not root.[m | |
[32m if ($pattern !== '/')[m | |
[32m {[m | |
[32m $pattern = str_replace('*', '(.*)', $pattern).'\z';[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
[32m $pattern = '^/$';[m | |
[32m }[m | |
[32m return preg_match('#'.$pattern.'#', $value);[m | |
[32m }[m | |
[32m /**[m | |
* Get the character pool for a given type of random string.[m | |
*[m | |
* @param string $type[m | |
[1mdiff --git a/laravel/uri.php b/laravel/uri.php[m | |
[1mindex d342f56..2477fe6 100755[m | |
[1m--- a/laravel/uri.php[m | |
[1m+++ b/laravel/uri.php[m | |
[36m@@ -17,23 +17,13 @@[m [mclass URI {[m | |
public static $segments = array();[m | |
/**[m | |
[31m * The server variables to check for the URI.[m | |
[31m *[m | |
[31m * @var array[m | |
[31m */[m | |
[31m protected static $attempt = array([m | |
[31m 'PATH_INFO', 'REQUEST_URI',[m | |
[31m 'PHP_SELF', 'REDIRECT_URL'[m | |
[31m );[m | |
[31m /**[m | |
* Get the full URI including the query string.[m | |
*[m | |
* @return string[m | |
*/[m | |
public static function full()[m | |
{[m | |
return [31mstatic::current().static::query();[m[32mRequest::getUri();[m | |
}[m | |
/**[m | |
[36m@@ -45,45 +35,14 @@[m [mclass URI {[m | |
{[m | |
if ( ! is_null(static::$uri)) return static::$uri;[m | |
// [31mTo[m[32mWe'll simply[m get the [31mURI, we'll first call the detect method which will spin[m | |
[31m // through each of the server variables that we check for[m[32mpath info from[m the [31mURI in[m | |
[31m //[m[32mSymfony Request instance[m and [31muse the first one we encounter for the URI.[m | |
[31m static::$uri = static::detect();[m | |
[31m // If you ever encounter this error, please inform the nerdy Laravel[m[32mthen[m | |
// [31mdev team with information about your server. We want[m[32mformat[m to [31msupport[m | |
[31m // Laravel an as many servers as we possibly can![m | |
[31m if (is_null(static::$uri))[m | |
[31m {[m | |
[31m throw new \Exception("Could not detect request URI.");[m | |
[31m }[m | |
[31m static::segments(static::$uri);[m | |
[31m return static::$uri;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Detect the URI from[m[32mmeet our needs in[m the [31mserver variables.[m | |
[31m *[m | |
[31m * @return string|null[m | |
[31m */[m | |
[31m protected static function detect()[m | |
[31m {[m | |
[31m foreach (static::$attempt as $variable)[m | |
[31m {[m | |
[31m // Each variable we search for[m[32mrouter. If[m the URI[31mhas its own parser function[m | |
[31m // which[m is [31mresponsible for doing any formatting before the value[m[32mroot, we'll give[m | |
// [31mis fed into[m[32mback a single slash, otherwise we'll strip all of[m the [31mmain formatting function.[m | |
[31m $method[m[32mslashes off.[m | |
[32m $uri[m = [31m"parse_{$variable}";[m[32mstatic::format(Request::getPathInfo());[m | |
[31mif (isset($_SERVER[$variable]))[m | |
[31m {[m | |
[31m $uri = static::$method($_SERVER[$variable]);[m[32mstatic::segments($uri);[m | |
return [31mstatic::format($uri);[m | |
[31m }[m | |
[31m }[m[32mstatic::$uri = $uri;[m | |
}[m | |
/**[m | |
[36m@@ -94,21 +53,6 @@[m [mclass URI {[m | |
*/[m | |
protected static function format($uri)[m | |
{[m | |
[31m // First we want to remove the application's base URL from the URI if it is[m | |
[31m // in the string. It is possible for some of the parsed server variables to[m | |
[31m // include the entire document root in the string.[m | |
[31m $uri = static::remove_base($uri);[m | |
[31m $index = '/'.Config::get('application.index');[m | |
[31m // Next we'll remove the index file from the URI if it is there and then[m | |
[31m // finally trim down the URI. If the URI is left with spaces, we'll use[m | |
[31m // a single slash for the root URI.[m | |
[31m if ($index !== '/')[m | |
[31m {[m | |
[31m $uri = static::remove($uri, $index);[m | |
[31m }[m | |
return trim($uri, '/') ?: '/';[m | |
}[m | |
[36m@@ -116,81 +60,11 @@[m [mclass URI {[m | |
* Determine if the current URI matches a given pattern.[m | |
*[m | |
* @param string $pattern[m | |
[31m * @param string $uri[m | |
* @return bool[m | |
*/[m | |
public static function [31mis($pattern, $uri = null)[m[32mis($pattern)[m | |
{[m | |
[31m$uri = $uri ?: static::current();[m | |
[31m // Asterisks are translated into zero-or-more regular expression wildcards[m | |
[31m // to make it convenient to check if the URI starts with a given pattern[m | |
[31m // such as "library/*". This is only done when not root.[m | |
[31m if ($pattern !== '/')[m | |
[31m {[m | |
[31m $pattern = str_replace('*', '(.*)', $pattern).'\z';[m | |
[31m }[m | |
[31m else[m | |
[31m {[m | |
[31m $pattern = '^/$';[m | |
[31m }[m return [31mpreg_match('#'.$pattern.'#', $uri);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Parse the PATH_INFO server variable.[m | |
[31m *[m | |
[31m * @param string $value[m | |
[31m * @return string[m | |
[31m */[m | |
[31m protected static function parse_path_info($value)[m | |
[31m {[m | |
[31m return $value;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Parse the REQUEST_URI server variable.[m | |
[31m *[m | |
[31m * @param string $value[m | |
[31m * @return string[m | |
[31m */[m | |
[31m protected static function parse_request_uri($value)[m | |
[31m {[m | |
[31m return parse_url($value, PHP_URL_PATH);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Parse the PHP_SELF server variable.[m | |
[31m *[m | |
[31m * @param string $value[m | |
[31m * @return string[m | |
[31m */[m | |
[31m protected static function parse_php_self($value)[m | |
[31m {[m | |
[31m return $value;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Parse the REDIRECT_URL server variable.[m | |
[31m *[m | |
[31m * @param string $value[m | |
[31m * @return string[m | |
[31m */[m | |
[31m protected static function parse_redirect_url($value)[m | |
[31m {[m | |
[31m return $value;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Remove the base URL off of the request URI.[m | |
[31m *[m | |
[31m * @param string $uri[m | |
[31m * @return string[m | |
[31m */[m | |
[31m protected static function remove_base($uri)[m | |
[31m {[m | |
[31m return static::remove($uri, parse_url(URL::base(), PHP_URL_PATH));[m[32mStr::is($pattern, static::current());[m | |
}[m | |
/**[m | |
[36m@@ -228,26 +102,4 @@[m [mclass URI {[m | |
static::$segments = array_diff($segments, array(''));[m | |
}[m | |
[31m /**[m | |
[31m * Remove a given value from the URI.[m | |
[31m *[m | |
[31m * @param string $uri[m | |
[31m * @param string $value[m | |
[31m * @return string[m | |
[31m */[m | |
[31m protected static function remove($uri, $value)[m | |
[31m {[m | |
[31m return (strpos($uri, $value) === 0) ? substr($uri, strlen($value)) : $uri;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Get the query string for the current request.[m | |
[31m *[m | |
[31m * @return string[m | |
[31m */[m | |
[31m protected static function query()[m | |
[31m {[m | |
[31m return (count((array) $_GET) > 0) ? '?'.http_build_query($_GET) : '';[m | |
[31m }[m | |
}[m | |
No newline at end of file[m | |
[1mdiff --git a/laravel/url.php b/laravel/url.php[m | |
[1mindex d523abb..59c4f9c 100755[m | |
[1m--- a/laravel/url.php[m | |
[1m+++ b/laravel/url.php[m | |
[36m@@ -61,46 +61,22 @@[m [mclass URL {[m | |
$base = 'http://localhost';[m | |
// If the [31mapplication[m[32mapplication's[m URL configuration is set, we will just use that | |
// instead of trying to guess the URL from the $_SERVER array's host[m | |
// and script variables as this is [32ma[m more [31mreliable.[m[32mreliable method.[m | |
if (($url = Config::get('application.url')) !== '')[m | |
{[m | |
$base = $url;[m | |
}[m | |
[31melseif (isset($_SERVER['HTTP_HOST']))[m[32melse[m | |
{[m | |
$base = [31mstatic::guess();[m[32mRequest::foundation()->getRootUrl();[m | |
}[m | |
return static::$base = $base;[m | |
}[m | |
/**[m | |
[31m * Guess the application URL based on the $_SERVER variables.[m | |
[31m *[m | |
[31m * @return string[m | |
[31m */[m | |
[31m protected static function guess()[m | |
[31m {[m | |
[31m $protocol = (Request::secure()) ? 'https://' : 'http://';[m | |
[31m // Basically, by removing the basename, we are removing everything after[m | |
[31m // the and including the front controller from the URI. Leaving us with[m | |
[31m // the installation path for the application.[m | |
[31m $script = $_SERVER['SCRIPT_NAME'];[m | |
[31m $path = str_replace(basename($script), '', $script);[m | |
[31m // Now that we have the URL, all we need to do is attach the protocol[m | |
[31m // protocol and HTTP_HOST to build the URL for the application, and[m | |
[31m // we also trim off trailing slashes for cleanliness.[m | |
[31m $uri = $protocol.$_SERVER['HTTP_HOST'].$path;[m | |
[31m return rtrim($uri, '/');[m | |
[31m }[m | |
[31m /**[m | |
* Generate an application URL.[m | |
*[m | |
* <code>[m | |
[36m@@ -117,7 +93,13 @@[m [mclass URL {[m | |
*/[m | |
public static function to($url = '', $https = false)[m | |
{[m | |
[32m// If the given URL is already valid or begins with a hash, we'll just return[m | |
[32m // the URL unchanged since it is already well formed. Otherwise we will add[m | |
[32m // the base URL of the application and return the full URL.[m | |
if [31m(filter_var($url, FILTER_VALIDATE_URL) !== false)[m[32m(static::valid($url) or starts_with($url, '#'))[m | |
[32m {[m | |
return $url; | |
[32m}[m | |
$root = static::base().'/'.Config::get('application.index');[m | |
[36m@@ -128,6 +110,10 @@[m [mclass URL {[m | |
{[m | |
$root = preg_replace('~http://~', 'https://', $root, 1);[m | |
}[m | |
[32melse[m | |
[32m {[m | |
[32m $root = preg_replace('~https://~', 'http://', $root, 1);[m | |
[32m }[m | |
return rtrim($root, '/').'/'.ltrim($url, '/');[m | |
}[m | |
[36m@@ -171,7 +157,7 @@[m [mclass URL {[m | |
}[m | |
// If no route was found that handled the given action, we'll just[m | |
// generate the URL using the typical controller routing setup[m | |
// for URIs and turn SSL to [31mfalse.[m[32mfalse by default.[m | |
else[m | |
{[m | |
return static::convention($action, $parameters);[m | |
[36m@@ -234,6 +220,16 @@[m [mclass URL {[m | |
*/[m | |
public static function to_asset($url, $https = null)[m | |
{[m | |
[32mif (static::valid($url)) return $url;[m | |
[32m // If a base asset URL is defined in the configuration, use that and don't[m | |
[32m // try and change the HTTP protocol. This allows the delivery of assets[m | |
[32m // through a different server or third-party content delivery network.[m | |
[32m if ($root = Config::get('application.asset_url', false))[m | |
[32m {[m | |
[32m return rtrim($root, '/').'/'.ltrim($url, '/');[m | |
[32m }[m | |
if (is_null($https)) $https = Request::secure();[m | |
$url = static::to($url, $https);[m | |
[36m@@ -304,10 +300,21 @@[m [mclass URL {[m | |
// If there are any remaining optional place-holders, we'll just replace[m | |
// them with empty strings since not every optional parameter has to be[m | |
// in the array of parameters that were [31mpassed.[m[32mpassed to us.[m | |
$uri = [31mstr_replace(array_keys(Router::$optional),[m[32mpreg_replace('/\(.+?\)/',[m '', $uri); | |
return trim($uri, '/');[m | |
}[m | |
[32m/**[m | |
[32m * Determine if the given URL is valid.[m | |
[32m *[m | |
[32m * @param string $url[m | |
[32m * @return bool[m | |
[32m */[m | |
[32m public static function valid($url)[m | |
[32m {[m | |
[32m return filter_var($url, FILTER_VALIDATE_URL) !== false;[m | |
[32m }[m | |
}[m | |
No newline at end of file[m | |
[1mdiff --git a/laravel/validator.php b/laravel/validator.php[m | |
[1mindex b18bf51..dd3a15f 100755[m | |
[1m--- a/laravel/validator.php[m | |
[1m+++ b/laravel/validator.php[m | |
[36m@@ -946,17 +946,18 @@[m [mclass Validator {[m | |
// of the attribute name in the message.[m | |
$line = "{$bundle}validation.attributes.{$attribute}";[m | |
[31m$display =[m[32mif (Lang::has($line, $this->language))[m | |
[32m {[m | |
[32m return[m Lang::line($line)->get($this->language); | |
[32m}[m | |
// If no language line has been specified for the attribute, all of[m | |
// the underscores are removed from the attribute name and that[m | |
// will be used as the attribtue name.[m | |
[31mif (is_null($display))[m[32melse[m | |
{[m | |
return str_replace('_', ' ', $attribute);[m | |
}[m | |
[31m return $display;[m | |
}[m | |
/**[m | |
[1mdiff --git a/laravel/view.php b/laravel/view.php[m | |
[1mindex 76d8d40..f97b3de 100755[m | |
[1m--- a/laravel/view.php[m | |
[1m+++ b/laravel/view.php[m | |
[36m@@ -38,6 +38,13 @@[m [mclass View implements ArrayAccess {[m | |
public static $names = array();[m | |
/**[m | |
[32m* The cache content of loaded view files.[m | |
[32m *[m | |
[32m * @var array[m | |
[32m */[m | |
[32m public static $cache = array();[m | |
[32m /**[m | |
* The Laravel view loader event name.[m | |
*[m | |
* @var string[m | |
[36m@@ -103,12 +110,13 @@[m [mclass View implements ArrayAccess {[m | |
}[m | |
/**[m | |
* [31mGet[m[32mDetermine if[m the[31mpath to a[m given view [31mon disk.[m[32mexists.[m | |
*[m | |
* @param string $view | |
* [32m@param boolean $return_path[m | |
[32m *[m @return [31mstring[m[32mstring|bool[m | |
*/[m | |
[31mprotected[m[32mpublic static[m function [31mpath($view)[m[32mexists($view, $return_path = false)[m | |
{[m | |
list($bundle, $view) = Bundle::parse($view);[m | |
[36m@@ -117,10 +125,26 @@[m [mclass View implements ArrayAccess {[m | |
// We delegate the determination of view paths to the view loader event[m | |
// so that the developer is free to override and manage the loading[m | |
// of views in any way they see fit for their application.[m | |
$path = [31mEvent::first(static::loader,[m[32mEvent::until(static::loader,[m array($bundle, $view)); | |
if ( ! is_null($path))[m | |
{[m | |
[32mreturn $return_path ? $path : true;[m | |
[32m }[m | |
[32m return false;[m | |
[32m }[m | |
[32m /**[m | |
[32m * Get the path to a given view on disk.[m | |
[32m *[m | |
[32m * @param string $view[m | |
[32m * @return string[m | |
[32m */[m | |
[32m protected function path($view)[m | |
[32m {[m | |
[32m if ($path = $this->exists($view,true))[m | |
[32m {[m | |
return $path;[m | |
}[m | |
[36m@@ -226,13 +250,18 @@[m [mclass View implements ArrayAccess {[m | |
* });[m | |
* </code>[m | |
*[m | |
* @param [31mstring[m[32mstring|array[m $view | |
* @param Closure $composer | |
* @return void[m | |
*/[m | |
public static function [31mcomposer($view,[m[32mcomposer($views,[m $composer) | |
{[m | |
[32m$views = (array) $views;[m | |
[32m foreach ($views as $view)[m | |
[32m {[m | |
Event::listen("laravel.composing: {$view}", $composer); | |
[32m}[m | |
}[m | |
/**[m | |
[36m@@ -286,21 +315,16 @@[m [mclass View implements ArrayAccess {[m | |
*/[m | |
public function render()[m | |
{[m | |
[31m// To allow bundles or other pieces of the application to modify the[m | |
[31m // view before it is rendered, we'll fire an event, passing in the[m | |
[31m // view instance so it can modified.[m | |
[31m $composer = "laravel.composing: {$this->view}";[m | |
[31m Event::fire($composer,[m[32mEvent::fire("laravel.composing: {$this->view}",[m array($this)); | |
// If there are listeners to the view engine event, we'll pass them[m | |
// the view so they can render it according to their needs, which[m | |
// allows easy attachment of other view parsers.[m | |
if (Event::listeners(static::engine))[m | |
{[m | |
$result = [31mEvent::first(static::engine,[m[32mEvent::until(static::engine,[m array($this)); | |
if [31m($result !== false)[m[32m( ! is_null($result))[m return $result; | |
}[m | |
return $this->get();[m | |
[36m@@ -315,6 +339,11 @@[m [mclass View implements ArrayAccess {[m | |
{[m | |
$__data = $this->data();[m | |
[32m// The contents of each view file is cached in an array for the[m | |
[32m // request since partial views may be rendered inside of for[m | |
[32m // loops which could incur performance penalties.[m | |
[32m $__contents = $this->load();[m | |
ob_start() and extract($__data, EXTR_SKIP);[m | |
// We'll include the view contents for parsing within a catcher[m | |
[36m@@ -322,12 +351,12 @@[m [mclass View implements ArrayAccess {[m | |
// will throw it out to the exception handler.[m | |
try[m | |
{[m | |
[31minclude $this->path;[m[32meval('?>'.$__contents);[m | |
}[m | |
// If we caught an exception, we'll silently flush the output[m | |
// buffer so that no partially rendered views get thrown out[m | |
// to the client and confuse the [31muser.[m[32muser with junk.[m | |
catch (\Exception $e)[m | |
{[m | |
ob_get_clean(); throw $e;[m | |
[36m@@ -337,6 +366,23 @@[m [mclass View implements ArrayAccess {[m | |
}[m | |
/**[m | |
[32m* Get the contents of the view file from disk.[m | |
[32m *[m | |
[32m * @return string[m | |
[32m */[m | |
[32m protected function load()[m | |
[32m {[m | |
[32m if (isset(static::$cache[$this->path]))[m | |
[32m {[m | |
[32m return static::$cache[$this->path];[m | |
[32m }[m | |
[32m else[m | |
[32m {[m | |
[32m return static::$cache[$this->path] = file_get_contents($this->path);[m | |
[32m }[m | |
[32m }[m | |
[32m /**[m | |
* Get the array of view data for the view instance.[m | |
*[m | |
* The shared view data will be combined with the view data.[m | |
[1mdiff --git a/paths.php b/paths.php[m | |
[1mindex 7d0a3b5..909d3b4 100755[m | |
[1m--- a/paths.php[m | |
[1m+++ b/paths.php[m | |
[36m@@ -3,28 +3,29 @@[m | |
* Laravel - A PHP Framework For Web Artisans[m | |
*[m | |
* @package Laravel[m | |
* @version [31m3.1.9[m[32m3.2.0[m | |
* @author Taylor Otwell <[email protected]>[m | |
* @link http://laravel.com[m | |
*/[m | |
[31m// --------------------------------------------------------------[m | |
[31m// Initialize the web variable if it doesn't exist.[m | |
[31m// --------------------------------------------------------------[m | |
[31mif ( ! isset($web)) $web = false;[m[32m/*[m | |
[32m|----------------------------------------------------------------[m | |
[32m| Application Environemtns[m | |
[32m|----------------------------------------------------------------[m | |
[32m|[m | |
[32m| Laravel takes a dead simple approach to environments, and we[m | |
[32m| think you'll love it. Just specify which URLs belongs to a[m | |
[32m| given environment, and when you access your application[m | |
[32m| from a URL matching that pattern, we'll be sure to[m | |
[32m| merge in that environment's configuration files.[m | |
[32m|[m | |
[32m*/[m | |
[31m// --------------------------------------------------------------[m | |
[31m// Define the directory separator for the environment.[m | |
[31m// --------------------------------------------------------------[m | |
[31mif ( ! defined('DS'))[m | |
[31m{[m | |
[31m define('DS', DIRECTORY_SEPARATOR);[m | |
[31m}[m[32m$environments = array([m | |
[31m// --------------------------------------------------------------[m | |
[31m// Define the path to the base directory.[m | |
[31m// --------------------------------------------------------------[m | |
[31m$GLOBALS['laravel_paths']['base'] = __DIR__.DS;[m[32m'local' => array('http://localhost*', '*.dev'),[m | |
[32m);[m | |
// --------------------------------------------------------------[m | |
// The path to the application directory.[m | |
[36m@@ -49,22 +50,35 @@[m [m$paths['storage'] = 'storage';[m | |
// --------------------------------------------------------------[m | |
// The path to the public directory.[m | |
// --------------------------------------------------------------[m | |
[31mif ($web)[m | |
[31m{[m | |
[31m $GLOBALS['laravel_paths']['public'][m[32m$paths['public'][m = [31mrealpath('').DS;[m | |
[31m}[m | |
[31melse[m[32m'public';[m | |
[32m// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-[m | |
[32m// END OF USER CONFIGURATION. HERE BE DRAGONS![m | |
[32m// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-[m | |
[32m// --------------------------------------------------------------[m | |
[32m// Change to the current working directory.[m | |
[32m// --------------------------------------------------------------[m | |
[32mchdir(__DIR__);[m | |
[32m// --------------------------------------------------------------[m | |
[32m// Define the directory separator for the environment.[m | |
[32m// --------------------------------------------------------------[m | |
[32mif ( ! defined('DS'))[m | |
{[m | |
[31m$paths['public'] = 'public';[m[32mdefine('DS', DIRECTORY_SEPARATOR);[m | |
}[m | |
// --------------------------------------------------------------[m | |
[32m// Define the path to the base directory.[m | |
[32m// --------------------------------------------------------------[m | |
[32m$GLOBALS['laravel_paths']['base'] = __DIR__.DS;[m | |
[32m// --------------------------------------------------------------[m | |
// Define each constant if it hasn't been defined.[m | |
// --------------------------------------------------------------[m | |
foreach ($paths as $name => $path)[m | |
{[m | |
[31m if ($web) $path = "../{$path}";[m | |
if ( ! isset($GLOBALS['laravel_paths'][$name]))[m | |
{[m | |
$GLOBALS['laravel_paths'][$name] = realpath($path).DS;[m | |
[1mdiff --git a/public/index.php b/public/index.php[m | |
[1mindex 3437557..463d227 100755[m | |
[1m--- a/public/index.php[m | |
[1m+++ b/public/index.php[m | |
[36m@@ -3,7 +3,7 @@[m | |
* Laravel - A PHP Framework For Web Artisans[m | |
*[m | |
* @package Laravel[m | |
* @version [31m3.1.9[m[32m3.2.0[m | |
* @author Taylor Otwell <[email protected]>[m | |
* @link http://laravel.com[m | |
*/[m | |
[1mdiff --git a/readme.md b/readme.md[m | |
[1mindex e05ef39..37ac603 100755[m | |
[1m--- a/readme.md[m | |
[1m+++ b/readme.md[m | |
[36m@@ -19,29 +19,43 @@[m [mLaravel is a clean and classy framework for PHP web development. Freeing you fro[m | |
**Hello World:**[m | |
[32m```php[m | |
[32m<?php[m | |
Route::get('/', function() | |
{ | |
return "Hello World!": | |
}); | |
[32m```[m | |
**Passing Data To Views:**[m | |
[32m```php[m | |
[32m<?php[m | |
Route::get('user/(:num)', function($id) | |
{ | |
$user = DB::table('users')->find($id); | |
return View::make('profile')->with('user', $user); | |
}); | |
[32m```[m | |
**Redirecting & Flashing Data To The Session:**[m | |
[32m```php[m | |
[32m<?php[m | |
return Redirect::to('profile')->with('message', 'Welcome Back!'); | |
[32m```[m | |
### Contributing to Laravel[m | |
Contributions are encouraged and welcome; however, please review the Developer Certificate of Origin in the "license.txt" file included in the repository. All commits must be signed off using the "-s" switch.[m | |
[32m```bash[m | |
git commit -s -m "this commit will be signed off automatically!" | |
[32m```[m | |
### License[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Application.php b/vendor/Symfony/Component/Console/Application.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex e04940a..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Application.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,1007 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console;[m | |
[31muse Symfony\Component\Console\Input\InputInterface;[m | |
[31muse Symfony\Component\Console\Input\ArgvInput;[m | |
[31muse Symfony\Component\Console\Input\ArrayInput;[m | |
[31muse Symfony\Component\Console\Input\InputDefinition;[m | |
[31muse Symfony\Component\Console\Input\InputOption;[m | |
[31muse Symfony\Component\Console\Input\InputArgument;[m | |
[31muse Symfony\Component\Console\Output\OutputInterface;[m | |
[31muse Symfony\Component\Console\Output\Output;[m | |
[31muse Symfony\Component\Console\Output\ConsoleOutput;[m | |
[31muse Symfony\Component\Console\Output\ConsoleOutputInterface;[m | |
[31muse Symfony\Component\Console\Command\Command;[m | |
[31muse Symfony\Component\Console\Command\HelpCommand;[m | |
[31muse Symfony\Component\Console\Command\ListCommand;[m | |
[31muse Symfony\Component\Console\Helper\HelperSet;[m | |
[31muse Symfony\Component\Console\Helper\FormatterHelper;[m | |
[31muse Symfony\Component\Console\Helper\DialogHelper;[m | |
[31m/**[m | |
[31m * An Application is the container for a collection of commands.[m | |
[31m *[m | |
[31m * It is the main entry point of a Console application.[m | |
[31m *[m | |
[31m * This class is optimized for a standard CLI environment.[m | |
[31m *[m | |
[31m * Usage:[m | |
[31m *[m | |
[31m * $app = new Application('myapp', '1.0 (stable)');[m | |
[31m * $app->add(new SimpleCommand());[m | |
[31m * $app->run();[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31mclass Application[m | |
[31m{[m | |
[31m private $commands;[m | |
[31m private $wantHelps = false;[m | |
[31m private $runningCommand;[m | |
[31m private $name;[m | |
[31m private $version;[m | |
[31m private $catchExceptions;[m | |
[31m private $autoExit;[m | |
[31m private $definition;[m | |
[31m private $helperSet;[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * @param string $name The name of the application[m | |
[31m * @param string $version The version of the application[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')[m | |
[31m {[m | |
[31m $this->name = $name;[m | |
[31m $this->version = $version;[m | |
[31m $this->catchExceptions = true;[m | |
[31m $this->autoExit = true;[m | |
[31m $this->commands = array();[m | |
[31m $this->helperSet = $this->getDefaultHelperSet();[m | |
[31m $this->definition = $this->getDefaultInputDefinition();[m | |
[31m foreach ($this->getDefaultCommands() as $command) {[m | |
[31m $this->add($command);[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Runs the current application.[m | |
[31m *[m | |
[31m * @param InputInterface $input An Input instance[m | |
[31m * @param OutputInterface $output An Output instance[m | |
[31m *[m | |
[31m * @return integer 0 if everything went fine, or an error code[m | |
[31m *[m | |
[31m * @throws \Exception When doRun returns Exception[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function run(InputInterface $input = null, OutputInterface $output = null)[m | |
[31m {[m | |
[31m if (null === $input) {[m | |
[31m $input = new ArgvInput();[m | |
[31m }[m | |
[31m if (null === $output) {[m | |
[31m $output = new ConsoleOutput();[m | |
[31m }[m | |
[31m try {[m | |
[31m $statusCode = $this->doRun($input, $output);[m | |
[31m } catch (\Exception $e) {[m | |
[31m if (!$this->catchExceptions) {[m | |
[31m throw $e;[m | |
[31m }[m | |
[31m if ($output instanceof ConsoleOutputInterface) {[m | |
[31m $this->renderException($e, $output->getErrorOutput());[m | |
[31m } else {[m | |
[31m $this->renderException($e, $output);[m | |
[31m }[m | |
[31m $statusCode = $e->getCode();[m | |
[31m $statusCode = is_numeric($statusCode) && $statusCode ? $statusCode : 1;[m | |
[31m }[m | |
[31m if ($this->autoExit) {[m | |
[31m if ($statusCode > 255) {[m | |
[31m $statusCode = 255;[m | |
[31m }[m | |
[31m // @codeCoverageIgnoreStart[m | |
[31m exit($statusCode);[m | |
[31m // @codeCoverageIgnoreEnd[m | |
[31m }[m | |
[31m return $statusCode;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Runs the current application.[m | |
[31m *[m | |
[31m * @param InputInterface $input An Input instance[m | |
[31m * @param OutputInterface $output An Output instance[m | |
[31m *[m | |
[31m * @return integer 0 if everything went fine, or an error code[m | |
[31m */[m | |
[31m public function doRun(InputInterface $input, OutputInterface $output)[m | |
[31m {[m | |
[31m $name = $this->getCommandName($input);[m | |
[31m if (true === $input->hasParameterOption(array('--ansi'))) {[m | |
[31m $output->setDecorated(true);[m | |
[31m } elseif (true === $input->hasParameterOption(array('--no-ansi'))) {[m | |
[31m $output->setDecorated(false);[m | |
[31m }[m | |
[31m if (true === $input->hasParameterOption(array('--help', '-h'))) {[m | |
[31m if (!$name) {[m | |
[31m $name = 'help';[m | |
[31m $input = new ArrayInput(array('command' => 'help'));[m | |
[31m } else {[m | |
[31m $this->wantHelps = true;[m | |
[31m }[m | |
[31m }[m | |
[31m if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {[m | |
[31m $input->setInteractive(false);[m | |
[31m }[m | |
[31m if (function_exists('posix_isatty') && $this->getHelperSet()->has('dialog')) {[m | |
[31m $inputStream = $this->getHelperSet()->get('dialog')->getInputStream();[m | |
[31m if (!posix_isatty($inputStream)) {[m | |
[31m $input->setInteractive(false);[m | |
[31m }[m | |
[31m }[m | |
[31m if (true === $input->hasParameterOption(array('--quiet', '-q'))) {[m | |
[31m $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);[m | |
[31m } elseif (true === $input->hasParameterOption(array('--verbose', '-v'))) {[m | |
[31m $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);[m | |
[31m }[m | |
[31m if (true === $input->hasParameterOption(array('--version', '-V'))) {[m | |
[31m $output->writeln($this->getLongVersion());[m | |
[31m return 0;[m | |
[31m }[m | |
[31m if (!$name) {[m | |
[31m $name = 'list';[m | |
[31m $input = new ArrayInput(array('command' => 'list'));[m | |
[31m }[m | |
[31m // the command name MUST be the first element of the input[m | |
[31m $command = $this->find($name);[m | |
[31m $this->runningCommand = $command;[m | |
[31m $statusCode = $command->run($input, $output);[m | |
[31m $this->runningCommand = null;[m | |
[31m return is_numeric($statusCode) ? $statusCode : 0;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Set a helper set to be used with the command.[m | |
[31m *[m | |
[31m * @param HelperSet $helperSet The helper set[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setHelperSet(HelperSet $helperSet)[m | |
[31m {[m | |
[31m $this->helperSet = $helperSet;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Get the helper set associated with the command.[m | |
[31m *[m | |
[31m * @return HelperSet The HelperSet instance associated with this command[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getHelperSet()[m | |
[31m {[m | |
[31m return $this->helperSet;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the InputDefinition related to this Application.[m | |
[31m *[m | |
[31m * @return InputDefinition The InputDefinition instance[m | |
[31m */[m | |
[31m public function getDefinition()[m | |
[31m {[m | |
[31m return $this->definition;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the help message.[m | |
[31m *[m | |
[31m * @return string A help message.[m | |
[31m */[m | |
[31m public function getHelp()[m | |
[31m {[m | |
[31m $messages = array([m | |
[31m $this->getLongVersion(),[m | |
[31m '',[m | |
[31m '<comment>Usage:</comment>',[m | |
[31m sprintf(" [options] command [arguments]\n"),[m | |
[31m '<comment>Options:</comment>',[m | |
[31m );[m | |
[31m foreach ($this->getDefinition()->getOptions() as $option) {[m | |
[31m $messages[] = sprintf(' %-29s %s %s',[m | |
[31m '<info>--'.$option->getName().'</info>',[m | |
[31m $option->getShortcut() ? '<info>-'.$option->getShortcut().'</info>' : ' ',[m | |
[31m $option->getDescription()[m | |
[31m );[m | |
[31m }[m | |
[31m return implode(PHP_EOL, $messages);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets whether to catch exceptions or not during commands execution.[m | |
[31m *[m | |
[31m * @param Boolean $boolean Whether to catch exceptions or not during commands execution[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setCatchExceptions($boolean)[m | |
[31m {[m | |
[31m $this->catchExceptions = (Boolean) $boolean;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets whether to automatically exit after a command execution or not.[m | |
[31m *[m | |
[31m * @param Boolean $boolean Whether to automatically exit after a command execution or not[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setAutoExit($boolean)[m | |
[31m {[m | |
[31m $this->autoExit = (Boolean) $boolean;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the name of the application.[m | |
[31m *[m | |
[31m * @return string The application name[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getName()[m | |
[31m {[m | |
[31m return $this->name;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the application name.[m | |
[31m *[m | |
[31m * @param string $name The application name[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setName($name)[m | |
[31m {[m | |
[31m $this->name = $name;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the application version.[m | |
[31m *[m | |
[31m * @return string The application version[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getVersion()[m | |
[31m {[m | |
[31m return $this->version;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the application version.[m | |
[31m *[m | |
[31m * @param string $version The application version[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setVersion($version)[m | |
[31m {[m | |
[31m $this->version = $version;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the long version of the application.[m | |
[31m *[m | |
[31m * @return string The long application version[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getLongVersion()[m | |
[31m {[m | |
[31m if ('UNKNOWN' !== $this->getName() && 'UNKNOWN' !== $this->getVersion()) {[m | |
[31m return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());[m | |
[31m }[m | |
[31m return '<info>Console Tool</info>';[m | |
[31m }[m | |
[31m /**[m | |
[31m * Registers a new command.[m | |
[31m *[m | |
[31m * @param string $name The command name[m | |
[31m *[m | |
[31m * @return Command The newly created command[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function register($name)[m | |
[31m {[m | |
[31m return $this->add(new Command($name));[m | |
[31m }[m | |
[31m /**[m | |
[31m * Adds an array of command objects.[m | |
[31m *[m | |
[31m * @param Command[] $commands An array of commands[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function addCommands(array $commands)[m | |
[31m {[m | |
[31m foreach ($commands as $command) {[m | |
[31m $this->add($command);[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Adds a command object.[m | |
[31m *[m | |
[31m * If a command with the same name already exists, it will be overridden.[m | |
[31m *[m | |
[31m * @param Command $command A Command object[m | |
[31m *[m | |
[31m * @return Command The registered command[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function add(Command $command)[m | |
[31m {[m | |
[31m $command->setApplication($this);[m | |
[31m if (!$command->isEnabled()) {[m | |
[31m $command->setApplication(null);[m | |
[31m return;[m | |
[31m }[m | |
[31m $this->commands[$command->getName()] = $command;[m | |
[31m foreach ($command->getAliases() as $alias) {[m | |
[31m $this->commands[$alias] = $command;[m | |
[31m }[m | |
[31m return $command;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns a registered command by name or alias.[m | |
[31m *[m | |
[31m * @param string $name The command name or alias[m | |
[31m *[m | |
[31m * @return Command A Command object[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When command name given does not exist[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function get($name)[m | |
[31m {[m | |
[31m if (!isset($this->commands[$name])) {[m | |
[31m throw new \InvalidArgumentException(sprintf('The command "%s" does not exist.', $name));[m | |
[31m }[m | |
[31m $command = $this->commands[$name];[m | |
[31m if ($this->wantHelps) {[m | |
[31m $this->wantHelps = false;[m | |
[31m $helpCommand = $this->get('help');[m | |
[31m $helpCommand->setCommand($command);[m | |
[31m return $helpCommand;[m | |
[31m }[m | |
[31m return $command;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if the command exists, false otherwise.[m | |
[31m *[m | |
[31m * @param string $name The command name or alias[m | |
[31m *[m | |
[31m * @return Boolean true if the command exists, false otherwise[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function has($name)[m | |
[31m {[m | |
[31m return isset($this->commands[$name]);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns an array of all unique namespaces used by currently registered commands.[m | |
[31m *[m | |
[31m * It does not returns the global namespace which always exists.[m | |
[31m *[m | |
[31m * @return array An array of namespaces[m | |
[31m */[m | |
[31m public function getNamespaces()[m | |
[31m {[m | |
[31m $namespaces = array();[m | |
[31m foreach ($this->commands as $command) {[m | |
[31m $namespaces[] = $this->extractNamespace($command->getName());[m | |
[31m foreach ($command->getAliases() as $alias) {[m | |
[31m $namespaces[] = $this->extractNamespace($alias);[m | |
[31m }[m | |
[31m }[m | |
[31m return array_values(array_unique(array_filter($namespaces)));[m | |
[31m }[m | |
[31m /**[m | |
[31m * Finds a registered namespace by a name or an abbreviation.[m | |
[31m *[m | |
[31m * @param string $namespace A namespace or abbreviation to search for[m | |
[31m *[m | |
[31m * @return string A registered namespace[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When namespace is incorrect or ambiguous[m | |
[31m */[m | |
[31m public function findNamespace($namespace)[m | |
[31m {[m | |
[31m $allNamespaces = array();[m | |
[31m foreach ($this->getNamespaces() as $n) {[m | |
[31m $allNamespaces[$n] = explode(':', $n);[m | |
[31m }[m | |
[31m $found = array();[m | |
[31m foreach (explode(':', $namespace) as $i => $part) {[m | |
[31m $abbrevs = static::getAbbreviations(array_unique(array_values(array_filter(array_map(function ($p) use ($i) { return isset($p[$i]) ? $p[$i] : ''; }, $allNamespaces)))));[m | |
[31m if (!isset($abbrevs[$part])) {[m | |
[31m $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);[m | |
[31m if (1 <= $i) {[m | |
[31m $part = implode(':', $found).':'.$part;[m | |
[31m }[m | |
[31m if ($alternatives = $this->findAlternativeNamespace($part, $abbrevs)) {[m | |
[31m $message .= "\n\nDid you mean one of these?\n ";[m | |
[31m $message .= implode("\n ", $alternatives);[m | |
[31m }[m | |
[31m throw new \InvalidArgumentException($message);[m | |
[31m }[m | |
[31m if (count($abbrevs[$part]) > 1) {[m | |
[31m throw new \InvalidArgumentException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions($abbrevs[$part])));[m | |
[31m }[m | |
[31m $found[] = $abbrevs[$part][0];[m | |
[31m }[m | |
[31m return implode(':', $found);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Finds a command by name or alias.[m | |
[31m *[m | |
[31m * Contrary to get, this command tries to find the best[m | |
[31m * match if you give it an abbreviation of a name or alias.[m | |
[31m *[m | |
[31m * @param string $name A command name or a command alias[m | |
[31m *[m | |
[31m * @return Command A Command instance[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When command name is incorrect or ambiguous[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function find($name)[m | |
[31m {[m | |
[31m // namespace[m | |
[31m $namespace = '';[m | |
[31m $searchName = $name;[m | |
[31m if (false !== $pos = strrpos($name, ':')) {[m | |
[31m $namespace = $this->findNamespace(substr($name, 0, $pos));[m | |
[31m $searchName = $namespace.substr($name, $pos);[m | |
[31m }[m | |
[31m // name[m | |
[31m $commands = array();[m | |
[31m foreach ($this->commands as $command) {[m | |
[31m if ($this->extractNamespace($command->getName()) == $namespace) {[m | |
[31m $commands[] = $command->getName();[m | |
[31m }[m | |
[31m }[m | |
[31m $abbrevs = static::getAbbreviations(array_unique($commands));[m | |
[31m if (isset($abbrevs[$searchName]) && 1 == count($abbrevs[$searchName])) {[m | |
[31m return $this->get($abbrevs[$searchName][0]);[m | |
[31m }[m | |
[31m if (isset($abbrevs[$searchName]) && count($abbrevs[$searchName]) > 1) {[m | |
[31m $suggestions = $this->getAbbreviationSuggestions($abbrevs[$searchName]);[m | |
[31m throw new \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions));[m | |
[31m }[m | |
[31m // aliases[m | |
[31m $aliases = array();[m | |
[31m foreach ($this->commands as $command) {[m | |
[31m foreach ($command->getAliases() as $alias) {[m | |
[31m if ($this->extractNamespace($alias) == $namespace) {[m | |
[31m $aliases[] = $alias;[m | |
[31m }[m | |
[31m }[m | |
[31m }[m | |
[31m $aliases = static::getAbbreviations(array_unique($aliases));[m | |
[31m if (!isset($aliases[$searchName])) {[m | |
[31m $message = sprintf('Command "%s" is not defined.', $name);[m | |
[31m if ($alternatives = $this->findAlternativeCommands($searchName, $abbrevs)) {[m | |
[31m $message .= "\n\nDid you mean one of these?\n ";[m | |
[31m $message .= implode("\n ", $alternatives);[m | |
[31m }[m | |
[31m throw new \InvalidArgumentException($message);[m | |
[31m }[m | |
[31m if (count($aliases[$searchName]) > 1) {[m | |
[31m throw new \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $name, $this->getAbbreviationSuggestions($aliases[$searchName])));[m | |
[31m }[m | |
[31m return $this->get($aliases[$searchName][0]);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the commands (registered in the given namespace if provided).[m | |
[31m *[m | |
[31m * The array keys are the full names and the values the command instances.[m | |
[31m *[m | |
[31m * @param string $namespace A namespace name[m | |
[31m *[m | |
[31m * @return array An array of Command instances[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function all($namespace = null)[m | |
[31m {[m | |
[31m if (null === $namespace) {[m | |
[31m return $this->commands;[m | |
[31m }[m | |
[31m $commands = array();[m | |
[31m foreach ($this->commands as $name => $command) {[m | |
[31m if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {[m | |
[31m $commands[$name] = $command;[m | |
[31m }[m | |
[31m }[m | |
[31m return $commands;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns an array of possible abbreviations given a set of names.[m | |
[31m *[m | |
[31m * @param array $names An array of names[m | |
[31m *[m | |
[31m * @return array An array of abbreviations[m | |
[31m */[m | |
[31m static public function getAbbreviations($names)[m | |
[31m {[m | |
[31m $abbrevs = array();[m | |
[31m foreach ($names as $name) {[m | |
[31m for ($len = strlen($name) - 1; $len > 0; --$len) {[m | |
[31m $abbrev = substr($name, 0, $len);[m | |
[31m if (!isset($abbrevs[$abbrev])) {[m | |
[31m $abbrevs[$abbrev] = array($name);[m | |
[31m } else {[m | |
[31m $abbrevs[$abbrev][] = $name;[m | |
[31m }[m | |
[31m }[m | |
[31m }[m | |
[31m // Non-abbreviations always get entered, even if they aren't unique[m | |
[31m foreach ($names as $name) {[m | |
[31m $abbrevs[$name] = array($name);[m | |
[31m }[m | |
[31m return $abbrevs;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns a text representation of the Application.[m | |
[31m *[m | |
[31m * @param string $namespace An optional namespace name[m | |
[31m * @param boolean $raw Whether to return raw command list[m | |
[31m *[m | |
[31m * @return string A string representing the Application[m | |
[31m */[m | |
[31m public function asText($namespace = null, $raw = false)[m | |
[31m {[m | |
[31m $commands = $namespace ? $this->all($this->findNamespace($namespace)) : $this->commands;[m | |
[31m $width = 0;[m | |
[31m foreach ($commands as $command) {[m | |
[31m $width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width;[m | |
[31m }[m | |
[31m $width += 2;[m | |
[31m if ($raw) {[m | |
[31m $messages = array();[m | |
[31m foreach ($this->sortCommands($commands) as $space => $commands) {[m | |
[31m foreach ($commands as $name => $command) {[m | |
[31m $messages[] = sprintf("%-${width}s %s", $name, $command->getDescription());[m | |
[31m }[m | |
[31m }[m | |
[31m return implode(PHP_EOL, $messages);[m | |
[31m }[m | |
[31m $messages = array($this->getHelp(), '');[m | |
[31m if ($namespace) {[m | |
[31m $messages[] = sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $namespace);[m | |
[31m } else {[m | |
[31m $messages[] = '<comment>Available commands:</comment>';[m | |
[31m }[m | |
[31m // add commands by namespace[m | |
[31m foreach ($this->sortCommands($commands) as $space => $commands) {[m | |
[31m if (!$namespace && '_global' !== $space) {[m | |
[31m $messages[] = '<comment>'.$space.'</comment>';[m | |
[31m }[m | |
[31m foreach ($commands as $name => $command) {[m | |
[31m $messages[] = sprintf(" <info>%-${width}s</info> %s", $name, $command->getDescription());[m | |
[31m }[m | |
[31m }[m | |
[31m return implode(PHP_EOL, $messages);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns an XML representation of the Application.[m | |
[31m *[m | |
[31m * @param string $namespace An optional namespace name[m | |
[31m * @param Boolean $asDom Whether to return a DOM or an XML string[m | |
[31m *[m | |
[31m * @return string|DOMDocument An XML string representing the Application[m | |
[31m */[m | |
[31m public function asXml($namespace = null, $asDom = false)[m | |
[31m {[m | |
[31m $commands = $namespace ? $this->all($this->findNamespace($namespace)) : $this->commands;[m | |
[31m $dom = new \DOMDocument('1.0', 'UTF-8');[m | |
[31m $dom->formatOutput = true;[m | |
[31m $dom->appendChild($xml = $dom->createElement('symfony'));[m | |
[31m $xml->appendChild($commandsXML = $dom->createElement('commands'));[m | |
[31m if ($namespace) {[m | |
[31m $commandsXML->setAttribute('namespace', $namespace);[m | |
[31m } else {[m | |
[31m $namespacesXML = $dom->createElement('namespaces');[m | |
[31m $xml->appendChild($namespacesXML);[m | |
[31m }[m | |
[31m // add commands by namespace[m | |
[31m foreach ($this->sortCommands($commands) as $space => $commands) {[m | |
[31m if (!$namespace) {[m | |
[31m $namespaceArrayXML = $dom->createElement('namespace');[m | |
[31m $namespacesXML->appendChild($namespaceArrayXML);[m | |
[31m $namespaceArrayXML->setAttribute('id', $space);[m | |
[31m }[m | |
[31m foreach ($commands as $name => $command) {[m | |
[31m if ($name !== $command->getName()) {[m | |
[31m continue;[m | |
[31m }[m | |
[31m if (!$namespace) {[m | |
[31m $commandXML = $dom->createElement('command');[m | |
[31m $namespaceArrayXML->appendChild($commandXML);[m | |
[31m $commandXML->appendChild($dom->createTextNode($name));[m | |
[31m }[m | |
[31m $node = $command->asXml(true)->getElementsByTagName('command')->item(0);[m | |
[31m $node = $dom->importNode($node, true);[m | |
[31m $commandsXML->appendChild($node);[m | |
[31m }[m | |
[31m }[m | |
[31m return $asDom ? $dom : $dom->saveXml();[m | |
[31m }[m | |
[31m /**[m | |
[31m * Renders a catched exception.[m | |
[31m *[m | |
[31m * @param Exception $e An exception instance[m | |
[31m * @param OutputInterface $output An OutputInterface instance[m | |
[31m */[m | |
[31m public function renderException($e, $output)[m | |
[31m {[m | |
[31m $strlen = function ($string) {[m | |
[31m if (!function_exists('mb_strlen')) {[m | |
[31m return strlen($string);[m | |
[31m }[m | |
[31m if (false === $encoding = mb_detect_encoding($string)) {[m | |
[31m return strlen($string);[m | |
[31m }[m | |
[31m return mb_strlen($string, $encoding);[m | |
[31m };[m | |
[31m do {[m | |
[31m $title = sprintf(' [%s] ', get_class($e));[m | |
[31m $len = $strlen($title);[m | |
[31m $lines = array();[m | |
[31m foreach (explode("\n", $e->getMessage()) as $line) {[m | |
[31m $lines[] = sprintf(' %s ', $line);[m | |
[31m $len = max($strlen($line) + 4, $len);[m | |
[31m }[m | |
[31m $messages = array(str_repeat(' ', $len), $title.str_repeat(' ', $len - $strlen($title)));[m | |
[31m foreach ($lines as $line) {[m | |
[31m $messages[] = $line.str_repeat(' ', $len - $strlen($line));[m | |
[31m }[m | |
[31m $messages[] = str_repeat(' ', $len);[m | |
[31m $output->writeln("");[m | |
[31m $output->writeln("");[m | |
[31m foreach ($messages as $message) {[m | |
[31m $output->writeln('<error>'.$message.'</error>');[m | |
[31m }[m | |
[31m $output->writeln("");[m | |
[31m $output->writeln("");[m | |
[31m if (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity()) {[m | |
[31m $output->writeln('<comment>Exception trace:</comment>');[m | |
[31m // exception related properties[m | |
[31m $trace = $e->getTrace();[m | |
[31m array_unshift($trace, array([m | |
[31m 'function' => '',[m | |
[31m 'file' => $e->getFile() != null ? $e->getFile() : 'n/a',[m | |
[31m 'line' => $e->getLine() != null ? $e->getLine() : 'n/a',[m | |
[31m 'args' => array(),[m | |
[31m ));[m | |
[31m for ($i = 0, $count = count($trace); $i < $count; $i++) {[m | |
[31m $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';[m | |
[31m $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';[m | |
[31m $function = $trace[$i]['function'];[m | |
[31m $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';[m | |
[31m $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';[m | |
[31m $output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line));[m | |
[31m }[m | |
[31m $output->writeln("");[m | |
[31m $output->writeln("");[m | |
[31m }[m | |
[31m } while ($e = $e->getPrevious());[m | |
[31m if (null !== $this->runningCommand) {[m | |
[31m $output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())));[m | |
[31m $output->writeln("");[m | |
[31m $output->writeln("");[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the name of the command based on input.[m | |
[31m *[m | |
[31m * @param InputInterface $input The input interface[m | |
[31m *[m | |
[31m * @return string The command name[m | |
[31m */[m | |
[31m protected function getCommandName(InputInterface $input)[m | |
[31m {[m | |
[31m return $input->getFirstArgument('command');[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the default input definition.[m | |
[31m *[m | |
[31m * @return InputDefinition An InputDefinition instance[m | |
[31m */[m | |
[31m protected function getDefaultInputDefinition()[m | |
[31m {[m | |
[31m return new InputDefinition(array([m | |
[31m new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),[m | |
[31m new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message.'),[m | |
[31m new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message.'),[m | |
[31m new InputOption('--verbose', '-v', InputOption::VALUE_NONE, 'Increase verbosity of messages.'),[m | |
[31m new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version.'),[m | |
[31m new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output.'),[m | |
[31m new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output.'),[m | |
[31m new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question.'),[m | |
[31m ));[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the default commands that should always be available.[m | |
[31m *[m | |
[31m * @return array An array of default Command instances[m | |
[31m */[m | |
[31m protected function getDefaultCommands()[m | |
[31m {[m | |
[31m return array(new HelpCommand(), new ListCommand());[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the default helper set with the helpers that should always be available.[m | |
[31m *[m | |
[31m * @return HelperSet A HelperSet instance[m | |
[31m */[m | |
[31m protected function getDefaultHelperSet()[m | |
[31m {[m | |
[31m return new HelperSet(array([m | |
[31m new FormatterHelper(),[m | |
[31m new DialogHelper(),[m | |
[31m ));[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sorts commands in alphabetical order.[m | |
[31m *[m | |
[31m * @param array $commands An associative array of commands to sort[m | |
[31m *[m | |
[31m * @return array A sorted array of commands[m | |
[31m */[m | |
[31m private function sortCommands($commands)[m | |
[31m {[m | |
[31m $namespacedCommands = array();[m | |
[31m foreach ($commands as $name => $command) {[m | |
[31m $key = $this->extractNamespace($name, 1);[m | |
[31m if (!$key) {[m | |
[31m $key = '_global';[m | |
[31m }[m | |
[31m $namespacedCommands[$key][$name] = $command;[m | |
[31m }[m | |
[31m ksort($namespacedCommands);[m | |
[31m foreach ($namespacedCommands as &$commands) {[m | |
[31m ksort($commands);[m | |
[31m }[m | |
[31m return $namespacedCommands;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns abbreviated suggestions in string format.[m | |
[31m *[m | |
[31m * @param array $abbrevs Abbreviated suggestions to convert[m | |
[31m *[m | |
[31m * @return string A formatted string of abbreviated suggestions[m | |
[31m */[m | |
[31m private function getAbbreviationSuggestions($abbrevs)[m | |
[31m {[m | |
[31m return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], count($abbrevs) > 2 ? sprintf(' and %d more', count($abbrevs) - 2) : '');[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the namespace part of the command name.[m | |
[31m *[m | |
[31m * @param string $name The full name of the command[m | |
[31m * @param string $limit The maximum number of parts of the namespace[m | |
[31m *[m | |
[31m * @return string The namespace of the command[m | |
[31m */[m | |
[31m private function extractNamespace($name, $limit = null)[m | |
[31m {[m | |
[31m $parts = explode(':', $name);[m | |
[31m array_pop($parts);[m | |
[31m return implode(':', null === $limit ? $parts : array_slice($parts, 0, $limit));[m | |
[31m }[m | |
[31m /**[m | |
[31m * Finds alternative commands of $name[m | |
[31m *[m | |
[31m * @param string $name The full name of the command[m | |
[31m * @param array $abbrevs The abbreviations[m | |
[31m *[m | |
[31m * @return array A sorted array of similar commands[m | |
[31m */[m | |
[31m private function findAlternativeCommands($name, $abbrevs)[m | |
[31m {[m | |
[31m $callback = function($item) {[m | |
[31m return $item->getName();[m | |
[31m };[m | |
[31m return $this->findAlternatives($name, $this->commands, $abbrevs, $callback);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Finds alternative namespace of $name[m | |
[31m *[m | |
[31m * @param string $name The full name of the namespace[m | |
[31m * @param array $abbrevs The abbreviations[m | |
[31m *[m | |
[31m * @return array A sorted array of similar namespace[m | |
[31m */[m | |
[31m private function findAlternativeNamespace($name, $abbrevs)[m | |
[31m {[m | |
[31m return $this->findAlternatives($name, $this->getNamespaces(), $abbrevs);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Finds alternative of $name among $collection,[m | |
[31m * if nothing is found in $collection, try in $abbrevs[m | |
[31m *[m | |
[31m * @param string $name The string[m | |
[31m * @param array|Traversable $collection The collecion[m | |
[31m * @param array $abbrevs The abbreviations[m | |
[31m * @param Closure|string|array $callback The callable to transform collection item before comparison[m | |
[31m *[m | |
[31m * @return array A sorted array of similar string[m | |
[31m */[m | |
[31m private function findAlternatives($name, $collection, $abbrevs, $callback = null) {[m | |
[31m $alternatives = array();[m | |
[31m foreach ($collection as $item) {[m | |
[31m if (null !== $callback) {[m | |
[31m $item = call_user_func($callback, $item);[m | |
[31m }[m | |
[31m $lev = levenshtein($name, $item);[m | |
[31m if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) {[m | |
[31m $alternatives[$item] = $lev;[m | |
[31m }[m | |
[31m }[m | |
[31m if (!$alternatives) {[m | |
[31m foreach ($abbrevs as $key => $values) {[m | |
[31m $lev = levenshtein($name, $key);[m | |
[31m if ($lev <= strlen($name) / 3 || false !== strpos($key, $name)) {[m | |
[31m foreach ($values as $value) {[m | |
[31m $alternatives[$value] = $lev;[m | |
[31m }[m | |
[31m }[m | |
[31m }[m | |
[31m }[m | |
[31m asort($alternatives);[m | |
[31m return array_keys($alternatives);[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Command/Command.php b/vendor/Symfony/Component/Console/Command/Command.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 033a95c..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Command/Command.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,612 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Command;[m | |
[31muse Symfony\Component\Console\Input\InputDefinition;[m | |
[31muse Symfony\Component\Console\Input\InputOption;[m | |
[31muse Symfony\Component\Console\Input\InputArgument;[m | |
[31muse Symfony\Component\Console\Input\InputInterface;[m | |
[31muse Symfony\Component\Console\Output\OutputInterface;[m | |
[31muse Symfony\Component\Console\Application;[m | |
[31muse Symfony\Component\Console\Helper\HelperSet;[m | |
[31m/**[m | |
[31m * Base class for all commands.[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31mclass Command[m | |
[31m{[m | |
[31m private $application;[m | |
[31m private $name;[m | |
[31m private $aliases;[m | |
[31m private $definition;[m | |
[31m private $help;[m | |
[31m private $description;[m | |
[31m private $ignoreValidationErrors;[m | |
[31m private $applicationDefinitionMerged;[m | |
[31m private $code;[m | |
[31m private $synopsis;[m | |
[31m private $helperSet;[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * @param string $name The name of the command[m | |
[31m *[m | |
[31m * @throws \LogicException When the command name is empty[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function __construct($name = null)[m | |
[31m {[m | |
[31m $this->definition = new InputDefinition();[m | |
[31m $this->ignoreValidationErrors = false;[m | |
[31m $this->applicationDefinitionMerged = false;[m | |
[31m $this->aliases = array();[m | |
[31m if (null !== $name) {[m | |
[31m $this->setName($name);[m | |
[31m }[m | |
[31m $this->configure();[m | |
[31m if (!$this->name) {[m | |
[31m throw new \LogicException('The command name cannot be empty.');[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Ignores validation errors.[m | |
[31m *[m | |
[31m * This is mainly useful for the help command.[m | |
[31m */[m | |
[31m public function ignoreValidationErrors()[m | |
[31m {[m | |
[31m $this->ignoreValidationErrors = true;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the application instance for this command.[m | |
[31m *[m | |
[31m * @param Application $application An Application instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setApplication(Application $application = null)[m | |
[31m {[m | |
[31m $this->application = $application;[m | |
[31m if ($application) {[m | |
[31m $this->setHelperSet($application->getHelperSet());[m | |
[31m } else {[m | |
[31m $this->helperSet = null;[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the helper set.[m | |
[31m *[m | |
[31m * @param HelperSet $helperSet A HelperSet instance[m | |
[31m */[m | |
[31m public function setHelperSet(HelperSet $helperSet)[m | |
[31m {[m | |
[31m $this->helperSet = $helperSet;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the helper set.[m | |
[31m *[m | |
[31m * @return HelperSet A HelperSet instance[m | |
[31m */[m | |
[31m public function getHelperSet()[m | |
[31m {[m | |
[31m return $this->helperSet;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the application instance for this command.[m | |
[31m *[m | |
[31m * @return Application An Application instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getApplication()[m | |
[31m {[m | |
[31m return $this->application;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Checks whether the command is enabled or not in the current environment[m | |
[31m *[m | |
[31m * Override this to check for x or y and return false if the command can not[m | |
[31m * run properly under the current conditions.[m | |
[31m *[m | |
[31m * @return Boolean[m | |
[31m */[m | |
[31m public function isEnabled()[m | |
[31m {[m | |
[31m return true;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Configures the current command.[m | |
[31m */[m | |
[31m protected function configure()[m | |
[31m {[m | |
[31m }[m | |
[31m /**[m | |
[31m * Executes the current command.[m | |
[31m *[m | |
[31m * This method is not abstract because you can use this class[m | |
[31m * as a concrete class. In this case, instead of defining the[m | |
[31m * execute() method, you set the code to execute by passing[m | |
[31m * a Closure to the setCode() method.[m | |
[31m *[m | |
[31m * @param InputInterface $input An InputInterface instance[m | |
[31m * @param OutputInterface $output An OutputInterface instance[m | |
[31m *[m | |
[31m * @return integer 0 if everything went fine, or an error code[m | |
[31m *[m | |
[31m * @throws \LogicException When this abstract method is not implemented[m | |
[31m * @see setCode()[m | |
[31m */[m | |
[31m protected function execute(InputInterface $input, OutputInterface $output)[m | |
[31m {[m | |
[31m throw new \LogicException('You must override the execute() method in the concrete command class.');[m | |
[31m }[m | |
[31m /**[m | |
[31m * Interacts with the user.[m | |
[31m *[m | |
[31m * @param InputInterface $input An InputInterface instance[m | |
[31m * @param OutputInterface $output An OutputInterface instance[m | |
[31m */[m | |
[31m protected function interact(InputInterface $input, OutputInterface $output)[m | |
[31m {[m | |
[31m }[m | |
[31m /**[m | |
[31m * Initializes the command just after the input has been validated.[m | |
[31m *[m | |
[31m * This is mainly useful when a lot of commands extends one main command[m | |
[31m * where some things need to be initialized based on the input arguments and options.[m | |
[31m *[m | |
[31m * @param InputInterface $input An InputInterface instance[m | |
[31m * @param OutputInterface $output An OutputInterface instance[m | |
[31m */[m | |
[31m protected function initialize(InputInterface $input, OutputInterface $output)[m | |
[31m {[m | |
[31m }[m | |
[31m /**[m | |
[31m * Runs the command.[m | |
[31m *[m | |
[31m * The code to execute is either defined directly with the[m | |
[31m * setCode() method or by overriding the execute() method[m | |
[31m * in a sub-class.[m | |
[31m *[m | |
[31m * @param InputInterface $input An InputInterface instance[m | |
[31m * @param OutputInterface $output An OutputInterface instance[m | |
[31m *[m | |
[31m * @see setCode()[m | |
[31m * @see execute()[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function run(InputInterface $input, OutputInterface $output)[m | |
[31m {[m | |
[31m // force the creation of the synopsis before the merge with the app definition[m | |
[31m $this->getSynopsis();[m | |
[31m // add the application arguments and options[m | |
[31m $this->mergeApplicationDefinition();[m | |
[31m // bind the input against the command specific arguments/options[m | |
[31m try {[m | |
[31m $input->bind($this->definition);[m | |
[31m } catch (\Exception $e) {[m | |
[31m if (!$this->ignoreValidationErrors) {[m | |
[31m throw $e;[m | |
[31m }[m | |
[31m }[m | |
[31m $this->initialize($input, $output);[m | |
[31m if ($input->isInteractive()) {[m | |
[31m $this->interact($input, $output);[m | |
[31m }[m | |
[31m $input->validate();[m | |
[31m if ($this->code) {[m | |
[31m return call_user_func($this->code, $input, $output);[m | |
[31m }[m | |
[31m return $this->execute($input, $output);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the code to execute when running this command.[m | |
[31m *[m | |
[31m * If this method is used, it overrides the code defined[m | |
[31m * in the execute() method.[m | |
[31m *[m | |
[31m * @param \Closure $code A \Closure[m | |
[31m *[m | |
[31m * @return Command The current instance[m | |
[31m *[m | |
[31m * @see execute()[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setCode(\Closure $code)[m | |
[31m {[m | |
[31m $this->code = $code;[m | |
[31m return $this;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Merges the application definition with the command definition.[m | |
[31m */[m | |
[31m private function mergeApplicationDefinition()[m | |
[31m {[m | |
[31m if (null === $this->application || true === $this->applicationDefinitionMerged) {[m | |
[31m return;[m | |
[31m }[m | |
[31m $currentArguments = $this->definition->getArguments();[m | |
[31m $this->definition->setArguments($this->application->getDefinition()->getArguments());[m | |
[31m $this->definition->addArguments($currentArguments);[m | |
[31m $this->definition->addOptions($this->application->getDefinition()->getOptions());[m | |
[31m $this->applicationDefinitionMerged = true;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets an array of argument and option instances.[m | |
[31m *[m | |
[31m * @param array|InputDefinition $definition An array of argument and option instances or a definition instance[m | |
[31m *[m | |
[31m * @return Command The current instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setDefinition($definition)[m | |
[31m {[m | |
[31m if ($definition instanceof InputDefinition) {[m | |
[31m $this->definition = $definition;[m | |
[31m } else {[m | |
[31m $this->definition->setDefinition($definition);[m | |
[31m }[m | |
[31m $this->applicationDefinitionMerged = false;[m | |
[31m return $this;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the InputDefinition attached to this Command.[m | |
[31m *[m | |
[31m * @return InputDefinition An InputDefinition instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getDefinition()[m | |
[31m {[m | |
[31m return $this->definition;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the InputDefinition to be used to create XML and Text representations of this Command.[m | |
[31m *[m | |
[31m * Can be overridden to provide the original command representation when it would otherwise[m | |
[31m * be changed by merging with the application InputDefinition.[m | |
[31m *[m | |
[31m * @return InputDefinition An InputDefinition instance[m | |
[31m */[m | |
[31m protected function getNativeDefinition()[m | |
[31m {[m | |
[31m return $this->getDefinition();[m | |
[31m }[m | |
[31m /**[m | |
[31m * Adds an argument.[m | |
[31m *[m | |
[31m * @param string $name The argument name[m | |
[31m * @param integer $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL[m | |
[31m * @param string $description A description text[m | |
[31m * @param mixed $default The default value (for InputArgument::OPTIONAL mode only)[m | |
[31m *[m | |
[31m * @return Command The current instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function addArgument($name, $mode = null, $description = '', $default = null)[m | |
[31m {[m | |
[31m $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));[m | |
[31m return $this;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Adds an option.[m | |
[31m *[m | |
[31m * @param string $name The option name[m | |
[31m * @param string $shortcut The shortcut (can be null)[m | |
[31m * @param integer $mode The option mode: One of the InputOption::VALUE_* constants[m | |
[31m * @param string $description A description text[m | |
[31m * @param mixed $default The default value (must be null for InputOption::VALUE_REQUIRED or InputOption::VALUE_NONE)[m | |
[31m *[m | |
[31m * @return Command The current instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)[m | |
[31m {[m | |
[31m $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));[m | |
[31m return $this;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the name of the command.[m | |
[31m *[m | |
[31m * This method can set both the namespace and the name if[m | |
[31m * you separate them by a colon (:)[m | |
[31m *[m | |
[31m * $command->setName('foo:bar');[m | |
[31m *[m | |
[31m * @param string $name The command name[m | |
[31m *[m | |
[31m * @return Command The current instance[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When command name given is empty[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setName($name)[m | |
[31m {[m | |
[31m $this->validateName($name);[m | |
[31m $this->name = $name;[m | |
[31m return $this;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the command name.[m | |
[31m *[m | |
[31m * @return string The command name[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getName()[m | |
[31m {[m | |
[31m return $this->name;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the description for the command.[m | |
[31m *[m | |
[31m * @param string $description The description for the command[m | |
[31m *[m | |
[31m * @return Command The current instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setDescription($description)[m | |
[31m {[m | |
[31m $this->description = $description;[m | |
[31m return $this;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the description for the command.[m | |
[31m *[m | |
[31m * @return string The description for the command[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getDescription()[m | |
[31m {[m | |
[31m return $this->description;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the help for the command.[m | |
[31m *[m | |
[31m * @param string $help The help for the command[m | |
[31m *[m | |
[31m * @return Command The current instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setHelp($help)[m | |
[31m {[m | |
[31m $this->help = $help;[m | |
[31m return $this;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the help for the command.[m | |
[31m *[m | |
[31m * @return string The help for the command[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getHelp()[m | |
[31m {[m | |
[31m return $this->help;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the processed help for the command replacing the %command.name% and[m | |
[31m * %command.full_name% patterns with the real values dynamically.[m | |
[31m *[m | |
[31m * @return string The processed help for the command[m | |
[31m */[m | |
[31m public function getProcessedHelp()[m | |
[31m {[m | |
[31m $name = $this->name;[m | |
[31m $placeholders = array([m | |
[31m '%command.name%',[m | |
[31m '%command.full_name%'[m | |
[31m );[m | |
[31m $replacements = array([m | |
[31m $name,[m | |
[31m $_SERVER['PHP_SELF'].' '.$name[m | |
[31m );[m | |
[31m return str_replace($placeholders, $replacements, $this->getHelp());[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the aliases for the command.[m | |
[31m *[m | |
[31m * @param array $aliases An array of aliases for the command[m | |
[31m *[m | |
[31m * @return Command The current instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setAliases($aliases)[m | |
[31m {[m | |
[31m foreach ($aliases as $alias) {[m | |
[31m $this->validateName($alias);[m | |
[31m }[m | |
[31m $this->aliases = $aliases;[m | |
[31m return $this;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the aliases for the command.[m | |
[31m *[m | |
[31m * @return array An array of aliases for the command[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getAliases()[m | |
[31m {[m | |
[31m return $this->aliases;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the synopsis for the command.[m | |
[31m *[m | |
[31m * @return string The synopsis[m | |
[31m */[m | |
[31m public function getSynopsis()[m | |
[31m {[m | |
[31m if (null === $this->synopsis) {[m | |
[31m $this->synopsis = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis()));[m | |
[31m }[m | |
[31m return $this->synopsis;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets a helper instance by name.[m | |
[31m *[m | |
[31m * @param string $name The helper name[m | |
[31m *[m | |
[31m * @return mixed The helper value[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException if the helper is not defined[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getHelper($name)[m | |
[31m {[m | |
[31m return $this->helperSet->get($name);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns a text representation of the command.[m | |
[31m *[m | |
[31m * @return string A string representing the command[m | |
[31m */[m | |
[31m public function asText()[m | |
[31m {[m | |
[31m $messages = array([m | |
[31m '<comment>Usage:</comment>',[m | |
[31m ' '.$this->getSynopsis(),[m | |
[31m '',[m | |
[31m );[m | |
[31m if ($this->getAliases()) {[m | |
[31m $messages[] = '<comment>Aliases:</comment> <info>'.implode(', ', $this->getAliases()).'</info>';[m | |
[31m }[m | |
[31m $messages[] = $this->getNativeDefinition()->asText();[m | |
[31m if ($help = $this->getProcessedHelp()) {[m | |
[31m $messages[] = '<comment>Help:</comment>';[m | |
[31m $messages[] = ' '.str_replace("\n", "\n ", $help)."\n";[m | |
[31m }[m | |
[31m return implode("\n", $messages);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns an XML representation of the command.[m | |
[31m *[m | |
[31m * @param Boolean $asDom Whether to return a DOM or an XML string[m | |
[31m *[m | |
[31m * @return string|DOMDocument An XML string representing the command[m | |
[31m */[m | |
[31m public function asXml($asDom = false)[m | |
[31m {[m | |
[31m $dom = new \DOMDocument('1.0', 'UTF-8');[m | |
[31m $dom->formatOutput = true;[m | |
[31m $dom->appendChild($commandXML = $dom->createElement('command'));[m | |
[31m $commandXML->setAttribute('id', $this->name);[m | |
[31m $commandXML->setAttribute('name', $this->name);[m | |
[31m $commandXML->appendChild($usageXML = $dom->createElement('usage'));[m | |
[31m $usageXML->appendChild($dom->createTextNode(sprintf($this->getSynopsis(), '')));[m | |
[31m $commandXML->appendChild($descriptionXML = $dom->createElement('description'));[m | |
[31m $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $this->getDescription())));[m | |
[31m $commandXML->appendChild($helpXML = $dom->createElement('help'));[m | |
[31m $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $this->getProcessedHelp())));[m | |
[31m $commandXML->appendChild($aliasesXML = $dom->createElement('aliases'));[m | |
[31m foreach ($this->getAliases() as $alias) {[m | |
[31m $aliasesXML->appendChild($aliasXML = $dom->createElement('alias'));[m | |
[31m $aliasXML->appendChild($dom->createTextNode($alias));[m | |
[31m }[m | |
[31m $definition = $this->getNativeDefinition()->asXml(true);[m | |
[31m $commandXML->appendChild($dom->importNode($definition->getElementsByTagName('arguments')->item(0), true));[m | |
[31m $commandXML->appendChild($dom->importNode($definition->getElementsByTagName('options')->item(0), true));[m | |
[31m return $asDom ? $dom : $dom->saveXml();[m | |
[31m }[m | |
[31m private function validateName($name)[m | |
[31m {[m | |
[31m if (!preg_match('/^[^\:]+(\:[^\:]+)*$/', $name)) {[m | |
[31m throw new \InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));[m | |
[31m }[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Command/HelpCommand.php b/vendor/Symfony/Component/Console/Command/HelpCommand.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 93c8104..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Command/HelpCommand.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,84 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Command;[m | |
[31muse Symfony\Component\Console\Input\InputArgument;[m | |
[31muse Symfony\Component\Console\Input\InputOption;[m | |
[31muse Symfony\Component\Console\Input\InputInterface;[m | |
[31muse Symfony\Component\Console\Output\OutputInterface;[m | |
[31muse Symfony\Component\Console\Output\Output;[m | |
[31muse Symfony\Component\Console\Command\Command;[m | |
[31m/**[m | |
[31m * HelpCommand displays the help for a given command.[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m */[m | |
[31mclass HelpCommand extends Command[m | |
[31m{[m | |
[31m private $command;[m | |
[31m /**[m | |
[31m * {@inheritdoc}[m | |
[31m */[m | |
[31m protected function configure()[m | |
[31m {[m | |
[31m $this->ignoreValidationErrors();[m | |
[31m $this[m | |
[31m ->setName('help')[m | |
[31m ->setDefinition(array([m | |
[31m new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),[m | |
[31m new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),[m | |
[31m ))[m | |
[31m ->setDescription('Displays help for a command')[m | |
[31m ->setHelp(<<<EOF[m | |
[31mThe <info>%command.name%</info> command displays help for a given command:[m | |
[31m <info>php %command.full_name% list</info>[m | |
[31mYou can also output the help as XML by using the <comment>--xml</comment> option:[m | |
[31m <info>php %command.full_name% --xml list</info>[m | |
[31mEOF[m | |
[31m )[m | |
[31m ;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the command[m | |
[31m *[m | |
[31m * @param Command $command The command to set[m | |
[31m */[m | |
[31m public function setCommand(Command $command)[m | |
[31m {[m | |
[31m $this->command = $command;[m | |
[31m }[m | |
[31m /**[m | |
[31m * {@inheritdoc}[m | |
[31m */[m | |
[31m protected function execute(InputInterface $input, OutputInterface $output)[m | |
[31m {[m | |
[31m if (null === $this->command) {[m | |
[31m $this->command = $this->getApplication()->get($input->getArgument('command_name'));[m | |
[31m }[m | |
[31m if ($input->getOption('xml')) {[m | |
[31m $output->writeln($this->command->asXml(), OutputInterface::OUTPUT_RAW);[m | |
[31m } else {[m | |
[31m $output->writeln($this->command->asText());[m | |
[31m }[m | |
[31m $this->command = null;[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Command/ListCommand.php b/vendor/Symfony/Component/Console/Command/ListCommand.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 032de16..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Command/ListCommand.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,87 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Command;[m | |
[31muse Symfony\Component\Console\Input\InputArgument;[m | |
[31muse Symfony\Component\Console\Input\InputOption;[m | |
[31muse Symfony\Component\Console\Input\InputInterface;[m | |
[31muse Symfony\Component\Console\Output\OutputInterface;[m | |
[31muse Symfony\Component\Console\Output\Output;[m | |
[31muse Symfony\Component\Console\Command\Command;[m | |
[31muse Symfony\Component\Console\Input\InputDefinition;[m | |
[31m/**[m | |
[31m * ListCommand displays the list of all available commands for the application.[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m */[m | |
[31mclass ListCommand extends Command[m | |
[31m{[m | |
[31m /**[m | |
[31m * {@inheritdoc}[m | |
[31m */[m | |
[31m protected function configure()[m | |
[31m {[m | |
[31m $this[m | |
[31m ->setName('list')[m | |
[31m ->setDefinition($this->createDefinition())[m | |
[31m ->setDescription('Lists commands')[m | |
[31m ->setHelp(<<<EOF[m | |
[31mThe <info>%command.name%</info> command lists all commands:[m | |
[31m <info>php %command.full_name%</info>[m | |
[31mYou can also display the commands for a specific namespace:[m | |
[31m <info>php %command.full_name% test</info>[m | |
[31mYou can also output the information as XML by using the <comment>--xml</comment> option:[m | |
[31m <info>php %command.full_name% --xml</info>[m | |
[31mIt's also possible to get raw list of commands (useful for embedding command runner):[m | |
[31m <info>php %command.full_name% --raw</info>[m | |
[31mEOF[m | |
[31m )[m | |
[31m ;[m | |
[31m }[m | |
[31m /**[m | |
[31m * {@inheritdoc}[m | |
[31m */[m | |
[31m protected function getNativeDefinition()[m | |
[31m {[m | |
[31m return $this->createDefinition();[m | |
[31m }[m | |
[31m /**[m | |
[31m * {@inheritdoc}[m | |
[31m */[m | |
[31m protected function execute(InputInterface $input, OutputInterface $output)[m | |
[31m {[m | |
[31m if ($input->getOption('xml')) {[m | |
[31m $output->writeln($this->getApplication()->asXml($input->getArgument('namespace')), OutputInterface::OUTPUT_RAW);[m | |
[31m } else {[m | |
[31m $output->writeln($this->getApplication()->asText($input->getArgument('namespace'), $input->getOption('raw')));[m | |
[31m }[m | |
[31m }[m | |
[31m private function createDefinition()[m | |
[31m {[m | |
[31m return new InputDefinition(array([m | |
[31m new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),[m | |
[31m new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),[m | |
[31m new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),[m | |
[31m ));[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Formatter/OutputFormatter.php b/vendor/Symfony/Component/Console/Formatter/OutputFormatter.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 8d60c74..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Formatter/OutputFormatter.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,192 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Formatter;[m | |
[31m/**[m | |
[31m * Formatter class for console output.[m | |
[31m *[m | |
[31m * @author Konstantin Kudryashov <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31mclass OutputFormatter implements OutputFormatterInterface[m | |
[31m{[m | |
[31m /**[m | |
[31m * The pattern to phrase the format.[m | |
[31m */[m | |
[31m const FORMAT_PATTERN = '#<([a-z][a-z0-9_=;-]+)>(.*?)</\\1?>#is';[m | |
[31m private $decorated;[m | |
[31m private $styles = array();[m | |
[31m /**[m | |
[31m * Initializes console output formatter.[m | |
[31m *[m | |
[31m * @param Boolean $decorated Whether this formatter should actually decorate strings[m | |
[31m * @param array $styles Array of "name => FormatterStyle" instances[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function __construct($decorated = null, array $styles = array())[m | |
[31m {[m | |
[31m $this->decorated = (Boolean) $decorated;[m | |
[31m $this->setStyle('error', new OutputFormatterStyle('white', 'red'));[m | |
[31m $this->setStyle('info', new OutputFormatterStyle('green'));[m | |
[31m $this->setStyle('comment', new OutputFormatterStyle('yellow'));[m | |
[31m $this->setStyle('question', new OutputFormatterStyle('black', 'cyan'));[m | |
[31m foreach ($styles as $name => $style) {[m | |
[31m $this->setStyle($name, $style);[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the decorated flag.[m | |
[31m *[m | |
[31m * @param Boolean $decorated Whether to decorate the messages or not[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setDecorated($decorated)[m | |
[31m {[m | |
[31m $this->decorated = (Boolean) $decorated;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the decorated flag.[m | |
[31m *[m | |
[31m * @return Boolean true if the output will decorate messages, false otherwise[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function isDecorated()[m | |
[31m {[m | |
[31m return $this->decorated;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets a new style.[m | |
[31m *[m | |
[31m * @param string $name The style name[m | |
[31m * @param OutputFormatterStyleInterface $style The style instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setStyle($name, OutputFormatterStyleInterface $style)[m | |
[31m {[m | |
[31m $this->styles[strtolower($name)] = $style;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Checks if output formatter has style with specified name.[m | |
[31m *[m | |
[31m * @param string $name[m | |
[31m *[m | |
[31m * @return Boolean[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function hasStyle($name)[m | |
[31m {[m | |
[31m return isset($this->styles[strtolower($name)]);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets style options from style with specified name.[m | |
[31m *[m | |
[31m * @param string $name[m | |
[31m *[m | |
[31m * @return OutputFormatterStyleInterface[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When style isn't defined[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getStyle($name)[m | |
[31m {[m | |
[31m if (!$this->hasStyle($name)) {[m | |
[31m throw new \InvalidArgumentException('Undefined style: '.$name);[m | |
[31m }[m | |
[31m return $this->styles[strtolower($name)];[m | |
[31m }[m | |
[31m /**[m | |
[31m * Formats a message according to the given styles.[m | |
[31m *[m | |
[31m * @param string $message The message to style[m | |
[31m *[m | |
[31m * @return string The styled message[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function format($message)[m | |
[31m {[m | |
[31m return preg_replace_callback(self::FORMAT_PATTERN, array($this, 'replaceStyle'), $message);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Replaces style of the output.[m | |
[31m *[m | |
[31m * @param array $match[m | |
[31m *[m | |
[31m * @return string The replaced style[m | |
[31m */[m | |
[31m private function replaceStyle($match)[m | |
[31m {[m | |
[31m if (!$this->isDecorated()) {[m | |
[31m return $match[2];[m | |
[31m }[m | |
[31m if (isset($this->styles[strtolower($match[1])])) {[m | |
[31m $style = $this->styles[strtolower($match[1])];[m | |
[31m } else {[m | |
[31m $style = $this->createStyleFromString($match[1]);[m | |
[31m if (false === $style) {[m | |
[31m return $match[0];[m | |
[31m }[m | |
[31m }[m | |
[31m return $style->apply($this->format($match[2]));[m | |
[31m }[m | |
[31m /**[m | |
[31m * Tries to create new style instance from string.[m | |
[31m *[m | |
[31m * @param string $string[m | |
[31m *[m | |
[31m * @return Symfony\Component\Console\Format\FormatterStyle|Boolean false if string is not format string[m | |
[31m */[m | |
[31m private function createStyleFromString($string)[m | |
[31m {[m | |
[31m if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) {[m | |
[31m return false;[m | |
[31m }[m | |
[31m $style = new OutputFormatterStyle();[m | |
[31m foreach ($matches as $match) {[m | |
[31m array_shift($match);[m | |
[31m if ('fg' == $match[0]) {[m | |
[31m $style->setForeground($match[1]);[m | |
[31m } elseif ('bg' == $match[0]) {[m | |
[31m $style->setBackground($match[1]);[m | |
[31m } else {[m | |
[31m $style->setOption($match[1]);[m | |
[31m }[m | |
[31m }[m | |
[31m return $style;[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Formatter/OutputFormatterInterface.php b/vendor/Symfony/Component/Console/Formatter/OutputFormatterInterface.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex f14657c..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Formatter/OutputFormatterInterface.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,83 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Formatter;[m | |
[31m/**[m | |
[31m * Formatter interface for console output.[m | |
[31m *[m | |
[31m * @author Konstantin Kudryashov <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31minterface OutputFormatterInterface[m | |
[31m{[m | |
[31m /**[m | |
[31m * Sets the decorated flag.[m | |
[31m *[m | |
[31m * @param Boolean $decorated Whether to decorate the messages or not[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function setDecorated($decorated);[m | |
[31m /**[m | |
[31m * Gets the decorated flag.[m | |
[31m *[m | |
[31m * @return Boolean true if the output will decorate messages, false otherwise[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function isDecorated();[m | |
[31m /**[m | |
[31m * Sets a new style.[m | |
[31m *[m | |
[31m * @param string $name The style name[m | |
[31m * @param OutputFormatterStyleInterface $style The style instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function setStyle($name, OutputFormatterStyleInterface $style);[m | |
[31m /**[m | |
[31m * Checks if output formatter has style with specified name.[m | |
[31m *[m | |
[31m * @param string $name[m | |
[31m *[m | |
[31m * @return Boolean[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function hasStyle($name);[m | |
[31m /**[m | |
[31m * Gets style options from style with specified name.[m | |
[31m *[m | |
[31m * @param string $name[m | |
[31m *[m | |
[31m * @return OutputFormatterStyleInterface[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function getStyle($name);[m | |
[31m /**[m | |
[31m * Formats a message according to the given styles.[m | |
[31m *[m | |
[31m * @param string $message The message to style[m | |
[31m *[m | |
[31m * @return string The styled message[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function format($message);[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyle.php b/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyle.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex dc88f2a..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyle.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,218 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Formatter;[m | |
[31m/**[m | |
[31m * Formatter style class for defining styles.[m | |
[31m *[m | |
[31m * @author Konstantin Kudryashov <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31mclass OutputFormatterStyle implements OutputFormatterStyleInterface[m | |
[31m{[m | |
[31m static private $availableForegroundColors = array([m | |
[31m 'black' => 30,[m | |
[31m 'red' => 31,[m | |
[31m 'green' => 32,[m | |
[31m 'yellow' => 33,[m | |
[31m 'blue' => 34,[m | |
[31m 'magenta' => 35,[m | |
[31m 'cyan' => 36,[m | |
[31m 'white' => 37[m | |
[31m );[m | |
[31m static private $availableBackgroundColors = array([m | |
[31m 'black' => 40,[m | |
[31m 'red' => 41,[m | |
[31m 'green' => 42,[m | |
[31m 'yellow' => 43,[m | |
[31m 'blue' => 44,[m | |
[31m 'magenta' => 45,[m | |
[31m 'cyan' => 46,[m | |
[31m 'white' => 47[m | |
[31m );[m | |
[31m static private $availableOptions = array([m | |
[31m 'bold' => 1,[m | |
[31m 'underscore' => 4,[m | |
[31m 'blink' => 5,[m | |
[31m 'reverse' => 7,[m | |
[31m 'conceal' => 8[m | |
[31m );[m | |
[31m private $foreground;[m | |
[31m private $background;[m | |
[31m private $options = array();[m | |
[31m /**[m | |
[31m * Initializes output formatter style.[m | |
[31m *[m | |
[31m * @param string $foreground style foreground color name[m | |
[31m * @param string $background style background color name[m | |
[31m * @param array $options style options[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function __construct($foreground = null, $background = null, array $options = array())[m | |
[31m {[m | |
[31m if (null !== $foreground) {[m | |
[31m $this->setForeground($foreground);[m | |
[31m }[m | |
[31m if (null !== $background) {[m | |
[31m $this->setBackground($background);[m | |
[31m }[m | |
[31m if (count($options)) {[m | |
[31m $this->setOptions($options);[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets style foreground color.[m | |
[31m *[m | |
[31m * @param string $color color name[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When the color name isn't defined[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setForeground($color = null)[m | |
[31m {[m | |
[31m if (null === $color) {[m | |
[31m $this->foreground = null;[m | |
[31m return;[m | |
[31m }[m | |
[31m if (!isset(static::$availableForegroundColors[$color])) {[m | |
[31m throw new \InvalidArgumentException(sprintf([m | |
[31m 'Invalid foreground color specified: "%s". Expected one of (%s)',[m | |
[31m $color,[m | |
[31m implode(', ', array_keys(static::$availableForegroundColors))[m | |
[31m ));[m | |
[31m }[m | |
[31m $this->foreground = static::$availableForegroundColors[$color];[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets style background color.[m | |
[31m *[m | |
[31m * @param string $color color name[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When the color name isn't defined[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setBackground($color = null)[m | |
[31m {[m | |
[31m if (null === $color) {[m | |
[31m $this->background = null;[m | |
[31m return;[m | |
[31m }[m | |
[31m if (!isset(static::$availableBackgroundColors[$color])) {[m | |
[31m throw new \InvalidArgumentException(sprintf([m | |
[31m 'Invalid background color specified: "%s". Expected one of (%s)',[m | |
[31m $color,[m | |
[31m implode(', ', array_keys(static::$availableBackgroundColors))[m | |
[31m ));[m | |
[31m }[m | |
[31m $this->background = static::$availableBackgroundColors[$color];[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets some specific style option.[m | |
[31m *[m | |
[31m * @param string $option option name[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When the option name isn't defined[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setOption($option)[m | |
[31m {[m | |
[31m if (!isset(static::$availableOptions[$option])) {[m | |
[31m throw new \InvalidArgumentException(sprintf([m | |
[31m 'Invalid option specified: "%s". Expected one of (%s)',[m | |
[31m $option,[m | |
[31m implode(', ', array_keys(static::$availableOptions))[m | |
[31m ));[m | |
[31m }[m | |
[31m if (false === array_search(static::$availableOptions[$option], $this->options)) {[m | |
[31m $this->options[] = static::$availableOptions[$option];[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Unsets some specific style option.[m | |
[31m *[m | |
[31m * @param string $option option name[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When the option name isn't defined[m | |
[31m *[m | |
[31m */[m | |
[31m public function unsetOption($option)[m | |
[31m {[m | |
[31m if (!isset(static::$availableOptions[$option])) {[m | |
[31m throw new \InvalidArgumentException(sprintf([m | |
[31m 'Invalid option specified: "%s". Expected one of (%s)',[m | |
[31m $option,[m | |
[31m implode(', ', array_keys(static::$availableOptions))[m | |
[31m ));[m | |
[31m }[m | |
[31m $pos = array_search(static::$availableOptions[$option], $this->options);[m | |
[31m if (false !== $pos) {[m | |
[31m unset($this->options[$pos]);[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets multiple style options at once.[m | |
[31m *[m | |
[31m * @param array $options[m | |
[31m */[m | |
[31m public function setOptions(array $options)[m | |
[31m {[m | |
[31m $this->options = array();[m | |
[31m foreach ($options as $option) {[m | |
[31m $this->setOption($option);[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Applies the style to a given text.[m | |
[31m *[m | |
[31m * @param string $text The text to style[m | |
[31m *[m | |
[31m * @return string[m | |
[31m */[m | |
[31m public function apply($text)[m | |
[31m {[m | |
[31m $codes = array();[m | |
[31m if (null !== $this->foreground) {[m | |
[31m $codes[] = $this->foreground;[m | |
[31m }[m | |
[31m if (null !== $this->background) {[m | |
[31m $codes[] = $this->background;[m | |
[31m }[m | |
[31m if (count($this->options)) {[m | |
[31m $codes = array_merge($codes, $this->options);[m | |
[31m }[m | |
[31m return sprintf("\033[%sm%s\033[0m", implode(';', $codes), $text);[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php b/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 212cb86..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,72 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Formatter;[m | |
[31m/**[m | |
[31m * Formatter style interface for defining styles.[m | |
[31m *[m | |
[31m * @author Konstantin Kudryashov <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31minterface OutputFormatterStyleInterface[m | |
[31m{[m | |
[31m /**[m | |
[31m * Sets style foreground color.[m | |
[31m *[m | |
[31m * @param string $color color name[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function setForeground($color = null);[m | |
[31m /**[m | |
[31m * Sets style background color.[m | |
[31m *[m | |
[31m * @param string $color color name[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function setBackground($color = null);[m | |
[31m /**[m | |
[31m * Sets some specific style option.[m | |
[31m *[m | |
[31m * @param string $option option name[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function setOption($option);[m | |
[31m /**[m | |
[31m * Unsets some specific style option.[m | |
[31m *[m | |
[31m * @param string $option option name[m | |
[31m */[m | |
[31m function unsetOption($option);[m | |
[31m /**[m | |
[31m * Sets multiple style options at once.[m | |
[31m *[m | |
[31m * @param array $options[m | |
[31m */[m | |
[31m function setOptions(array $options);[m | |
[31m /**[m | |
[31m * Applies the style to a given text.[m | |
[31m *[m | |
[31m * @param string $text The text to style[m | |
[31m *[m | |
[31m * @return string[m | |
[31m */[m | |
[31m function apply($text);[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Helper/DialogHelper.php b/vendor/Symfony/Component/Console/Helper/DialogHelper.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex e15fdd1..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Helper/DialogHelper.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,139 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Helper;[m | |
[31muse Symfony\Component\Console\Output\OutputInterface;[m | |
[31m/**[m | |
[31m * The Dialog class provides helpers to interact with the user.[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m */[m | |
[31mclass DialogHelper extends Helper[m | |
[31m{[m | |
[31m private $inputStream;[m | |
[31m /**[m | |
[31m * Asks a question to the user.[m | |
[31m *[m | |
[31m * @param OutputInterface $output An Output instance[m | |
[31m * @param string|array $question The question to ask[m | |
[31m * @param string $default The default answer if none is given by the user[m | |
[31m *[m | |
[31m * @return string The user answer[m | |
[31m *[m | |
[31m * @throws \RuntimeException If there is no data to read in the input stream[m | |
[31m */[m | |
[31m public function ask(OutputInterface $output, $question, $default = null)[m | |
[31m {[m | |
[31m $output->write($question);[m | |
[31m $ret = fgets($this->inputStream ?: STDIN, 4096);[m | |
[31m if (false === $ret) {[m | |
[31m throw new \RuntimeException('Aborted');[m | |
[31m }[m | |
[31m $ret = trim($ret);[m | |
[31m return strlen($ret) > 0 ? $ret : $default;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Asks a confirmation to the user.[m | |
[31m *[m | |
[31m * The question will be asked until the user answers by nothing, yes, or no.[m | |
[31m *[m | |
[31m * @param OutputInterface $output An Output instance[m | |
[31m * @param string|array $question The question to ask[m | |
[31m * @param Boolean $default The default answer if the user enters nothing[m | |
[31m *[m | |
[31m * @return Boolean true if the user has confirmed, false otherwise[m | |
[31m */[m | |
[31m public function askConfirmation(OutputInterface $output, $question, $default = true)[m | |
[31m {[m | |
[31m $answer = 'z';[m | |
[31m while ($answer && !in_array(strtolower($answer[0]), array('y', 'n'))) {[m | |
[31m $answer = $this->ask($output, $question);[m | |
[31m }[m | |
[31m if (false === $default) {[m | |
[31m return $answer && 'y' == strtolower($answer[0]);[m | |
[31m }[m | |
[31m return !$answer || 'y' == strtolower($answer[0]);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Asks for a value and validates the response.[m | |
[31m *[m | |
[31m * The validator receives the data to validate. It must return the[m | |
[31m * validated data when the data is valid and throw an exception[m | |
[31m * otherwise.[m | |
[31m *[m | |
[31m * @param OutputInterface $output An Output instance[m | |
[31m * @param string|array $question The question to ask[m | |
[31m * @param callback $validator A PHP callback[m | |
[31m * @param integer $attempts Max number of times to ask before giving up (false by default, which means infinite)[m | |
[31m * @param string $default The default answer if none is given by the user[m | |
[31m *[m | |
[31m * @return mixed[m | |
[31m *[m | |
[31m * @throws \Exception When any of the validators return an error[m | |
[31m */[m | |
[31m public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null)[m | |
[31m {[m | |
[31m $error = null;[m | |
[31m while (false === $attempts || $attempts--) {[m | |
[31m if (null !== $error) {[m | |
[31m $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));[m | |
[31m }[m | |
[31m $value = $this->ask($output, $question, $default);[m | |
[31m try {[m | |
[31m return call_user_func($validator, $value);[m | |
[31m } catch (\Exception $error) {[m | |
[31m }[m | |
[31m }[m | |
[31m throw $error;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the input stream to read from when interacting with the user.[m | |
[31m *[m | |
[31m * This is mainly useful for testing purpose.[m | |
[31m *[m | |
[31m * @param resource $stream The input stream[m | |
[31m */[m | |
[31m public function setInputStream($stream)[m | |
[31m {[m | |
[31m $this->inputStream = $stream;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the helper's input stream[m | |
[31m *[m | |
[31m * @return string[m | |
[31m */[m | |
[31m public function getInputStream()[m | |
[31m {[m | |
[31m return $this->inputStream;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the helper's canonical name.[m | |
[31m */[m | |
[31m public function getName()[m | |
[31m {[m | |
[31m return 'dialog';[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Helper/FormatterHelper.php b/vendor/Symfony/Component/Console/Helper/FormatterHelper.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex d3f613b..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Helper/FormatterHelper.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,97 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Helper;[m | |
[31m/**[m | |
[31m * The Formatter class provides helpers to format messages.[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m */[m | |
[31mclass FormatterHelper extends Helper[m | |
[31m{[m | |
[31m /**[m | |
[31m * Formats a message within a section.[m | |
[31m *[m | |
[31m * @param string $section The section name[m | |
[31m * @param string $message The message[m | |
[31m * @param string $style The style to apply to the section[m | |
[31m */[m | |
[31m public function formatSection($section, $message, $style = 'info')[m | |
[31m {[m | |
[31m return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Formats a message as a block of text.[m | |
[31m *[m | |
[31m * @param string|array $messages The message to write in the block[m | |
[31m * @param string $style The style to apply to the whole block[m | |
[31m * @param Boolean $large Whether to return a large block[m | |
[31m *[m | |
[31m * @return string The formatter message[m | |
[31m */[m | |
[31m public function formatBlock($messages, $style, $large = false)[m | |
[31m {[m | |
[31m $messages = (array) $messages;[m | |
[31m $len = 0;[m | |
[31m $lines = array();[m | |
[31m foreach ($messages as $message) {[m | |
[31m $lines[] = sprintf($large ? ' %s ' : ' %s ', $message);[m | |
[31m $len = max($this->strlen($message) + ($large ? 4 : 2), $len);[m | |
[31m }[m | |
[31m $messages = $large ? array(str_repeat(' ', $len)) : array();[m | |
[31m foreach ($lines as $line) {[m | |
[31m $messages[] = $line.str_repeat(' ', $len - $this->strlen($line));[m | |
[31m }[m | |
[31m if ($large) {[m | |
[31m $messages[] = str_repeat(' ', $len);[m | |
[31m }[m | |
[31m foreach ($messages as &$message) {[m | |
[31m $message = sprintf('<%s>%s</%s>', $style, $message, $style);[m | |
[31m }[m | |
[31m return implode("\n", $messages);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the length of a string, using mb_strlen if it is available.[m | |
[31m *[m | |
[31m * @param string $string The string to check its length[m | |
[31m *[m | |
[31m * @return integer The length of the string[m | |
[31m */[m | |
[31m private function strlen($string)[m | |
[31m {[m | |
[31m if (!function_exists('mb_strlen')) {[m | |
[31m return strlen($string);[m | |
[31m }[m | |
[31m if (false === $encoding = mb_detect_encoding($string)) {[m | |
[31m return strlen($string);[m | |
[31m }[m | |
[31m return mb_strlen($string, $encoding);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the helper's canonical name.[m | |
[31m *[m | |
[31m * @return string The canonical name of the helper[m | |
[31m */[m | |
[31m public function getName()[m | |
[31m {[m | |
[31m return 'formatter';[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Helper/Helper.php b/vendor/Symfony/Component/Console/Helper/Helper.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 28488ca..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Helper/Helper.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,42 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Helper;[m | |
[31m/**[m | |
[31m * Helper is the base class for all helper classes.[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m */[m | |
[31mabstract class Helper implements HelperInterface[m | |
[31m{[m | |
[31m protected $helperSet = null;[m | |
[31m /**[m | |
[31m * Sets the helper set associated with this helper.[m | |
[31m *[m | |
[31m * @param HelperSet $helperSet A HelperSet instance[m | |
[31m */[m | |
[31m public function setHelperSet(HelperSet $helperSet = null)[m | |
[31m {[m | |
[31m $this->helperSet = $helperSet;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the helper set associated with this helper.[m | |
[31m *[m | |
[31m * @return HelperSet A HelperSet instance[m | |
[31m */[m | |
[31m public function getHelperSet()[m | |
[31m {[m | |
[31m return $this->helperSet;[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Helper/HelperInterface.php b/vendor/Symfony/Component/Console/Helper/HelperInterface.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 25ee513..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Helper/HelperInterface.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,49 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Helper;[m | |
[31m/**[m | |
[31m * HelperInterface is the interface all helpers must implement.[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31minterface HelperInterface[m | |
[31m{[m | |
[31m /**[m | |
[31m * Sets the helper set associated with this helper.[m | |
[31m *[m | |
[31m * @param HelperSet $helperSet A HelperSet instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function setHelperSet(HelperSet $helperSet = null);[m | |
[31m /**[m | |
[31m * Gets the helper set associated with this helper.[m | |
[31m *[m | |
[31m * @return HelperSet A HelperSet instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function getHelperSet();[m | |
[31m /**[m | |
[31m * Returns the canonical name of this helper.[m | |
[31m *[m | |
[31m * @return string The canonical name[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function getName();[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Helper/HelperSet.php b/vendor/Symfony/Component/Console/Helper/HelperSet.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 0092c4c..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Helper/HelperSet.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,104 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Helper;[m | |
[31muse Symfony\Component\Console\Command\Command;[m | |
[31m/**[m | |
[31m * HelperSet represents a set of helpers to be used with a command.[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m */[m | |
[31mclass HelperSet[m | |
[31m{[m | |
[31m private $helpers;[m | |
[31m private $command;[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * @param Helper[] $helpers An array of helper.[m | |
[31m */[m | |
[31m public function __construct(array $helpers = array())[m | |
[31m {[m | |
[31m $this->helpers = array();[m | |
[31m foreach ($helpers as $alias => $helper) {[m | |
[31m $this->set($helper, is_int($alias) ? null : $alias);[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets a helper.[m | |
[31m *[m | |
[31m * @param HelperInterface $helper The helper instance[m | |
[31m * @param string $alias An alias[m | |
[31m */[m | |
[31m public function set(HelperInterface $helper, $alias = null)[m | |
[31m {[m | |
[31m $this->helpers[$helper->getName()] = $helper;[m | |
[31m if (null !== $alias) {[m | |
[31m $this->helpers[$alias] = $helper;[m | |
[31m }[m | |
[31m $helper->setHelperSet($this);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if the helper if defined.[m | |
[31m *[m | |
[31m * @param string $name The helper name[m | |
[31m *[m | |
[31m * @return Boolean true if the helper is defined, false otherwise[m | |
[31m */[m | |
[31m public function has($name)[m | |
[31m {[m | |
[31m return isset($this->helpers[$name]);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets a helper value.[m | |
[31m *[m | |
[31m * @param string $name The helper name[m | |
[31m *[m | |
[31m * @return HelperInterface The helper instance[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException if the helper is not defined[m | |
[31m */[m | |
[31m public function get($name)[m | |
[31m {[m | |
[31m if (!$this->has($name)) {[m | |
[31m throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));[m | |
[31m }[m | |
[31m return $this->helpers[$name];[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the command associated with this helper set.[m | |
[31m *[m | |
[31m * @param Command $command A Command instance[m | |
[31m */[m | |
[31m public function setCommand(Command $command = null)[m | |
[31m {[m | |
[31m $this->command = $command;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the command associated with this helper set.[m | |
[31m *[m | |
[31m * @return Command A Command instance[m | |
[31m */[m | |
[31m public function getCommand()[m | |
[31m {[m | |
[31m return $this->command;[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Input/ArgvInput.php b/vendor/Symfony/Component/Console/Input/ArgvInput.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex f0cfb14..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Input/ArgvInput.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,311 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Input;[m | |
[31m/**[m | |
[31m * ArgvInput represents an input coming from the CLI arguments.[m | |
[31m *[m | |
[31m * Usage:[m | |
[31m *[m | |
[31m * $input = new ArgvInput();[m | |
[31m *[m | |
[31m * By default, the `$_SERVER['argv']` array is used for the input values.[m | |
[31m *[m | |
[31m * This can be overridden by explicitly passing the input values in the constructor:[m | |
[31m *[m | |
[31m * $input = new ArgvInput($_SERVER['argv']);[m | |
[31m *[m | |
[31m * If you pass it yourself, don't forget that the first element of the array[m | |
[31m * is the name of the running application.[m | |
[31m *[m | |
[31m * When passing an argument to the constructor, be sure that it respects[m | |
[31m * the same rules as the argv one. It's almost always better to use the[m | |
[31m * `StringInput` when you want to provide your own input.[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * @see http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html[m | |
[31m * @see http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html#tag_12_02[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31mclass ArgvInput extends Input[m | |
[31m{[m | |
[31m private $tokens;[m | |
[31m private $parsed;[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * @param array $argv An array of parameters from the CLI (in the argv format)[m | |
[31m * @param InputDefinition $definition A InputDefinition instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function __construct(array $argv = null, InputDefinition $definition = null)[m | |
[31m {[m | |
[31m if (null === $argv) {[m | |
[31m $argv = $_SERVER['argv'];[m | |
[31m }[m | |
[31m // strip the application name[m | |
[31m array_shift($argv);[m | |
[31m $this->tokens = $argv;[m | |
[31m parent::__construct($definition);[m | |
[31m }[m | |
[31m protected function setTokens(array $tokens)[m | |
[31m {[m | |
[31m $this->tokens = $tokens;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Processes command line arguments.[m | |
[31m */[m | |
[31m protected function parse()[m | |
[31m {[m | |
[31m $parseOptions = true;[m | |
[31m $this->parsed = $this->tokens;[m | |
[31m while (null !== $token = array_shift($this->parsed)) {[m | |
[31m if ($parseOptions && '--' == $token) {[m | |
[31m $parseOptions = false;[m | |
[31m } elseif ($parseOptions && 0 === strpos($token, '--')) {[m | |
[31m $this->parseLongOption($token);[m | |
[31m } elseif ($parseOptions && '-' === $token[0]) {[m | |
[31m $this->parseShortOption($token);[m | |
[31m } else {[m | |
[31m $this->parseArgument($token);[m | |
[31m }[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Parses a short option.[m | |
[31m *[m | |
[31m * @param string $token The current token.[m | |
[31m */[m | |
[31m private function parseShortOption($token)[m | |
[31m {[m | |
[31m $name = substr($token, 1);[m | |
[31m if (strlen($name) > 1) {[m | |
[31m if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {[m | |
[31m // an option with a value (with no space)[m | |
[31m $this->addShortOption($name[0], substr($name, 1));[m | |
[31m } else {[m | |
[31m $this->parseShortOptionSet($name);[m | |
[31m }[m | |
[31m } else {[m | |
[31m $this->addShortOption($name, null);[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Parses a short option set.[m | |
[31m *[m | |
[31m * @param string $name The current token[m | |
[31m *[m | |
[31m * @throws \RuntimeException When option given doesn't exist[m | |
[31m */[m | |
[31m private function parseShortOptionSet($name)[m | |
[31m {[m | |
[31m $len = strlen($name);[m | |
[31m for ($i = 0; $i < $len; $i++) {[m | |
[31m if (!$this->definition->hasShortcut($name[$i])) {[m | |
[31m throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $name[$i]));[m | |
[31m }[m | |
[31m $option = $this->definition->getOptionForShortcut($name[$i]);[m | |
[31m if ($option->acceptValue()) {[m | |
[31m $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));[m | |
[31m break;[m | |
[31m } else {[m | |
[31m $this->addLongOption($option->getName(), true);[m | |
[31m }[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Parses a long option.[m | |
[31m *[m | |
[31m * @param string $token The current token[m | |
[31m */[m | |
[31m private function parseLongOption($token)[m | |
[31m {[m | |
[31m $name = substr($token, 2);[m | |
[31m if (false !== $pos = strpos($name, '=')) {[m | |
[31m $this->addLongOption(substr($name, 0, $pos), substr($name, $pos + 1));[m | |
[31m } else {[m | |
[31m $this->addLongOption($name, null);[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Parses an argument.[m | |
[31m *[m | |
[31m * @param string $token The current token[m | |
[31m *[m | |
[31m * @throws \RuntimeException When too many arguments are given[m | |
[31m */[m | |
[31m private function parseArgument($token)[m | |
[31m {[m | |
[31m $c = count($this->arguments);[m | |
[31m // if input is expecting another argument, add it[m | |
[31m if ($this->definition->hasArgument($c)) {[m | |
[31m $arg = $this->definition->getArgument($c);[m | |
[31m $this->arguments[$arg->getName()] = $arg->isArray()? array($token) : $token;[m | |
[31m // if last argument isArray(), append token to last argument[m | |
[31m } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {[m | |
[31m $arg = $this->definition->getArgument($c - 1);[m | |
[31m $this->arguments[$arg->getName()][] = $token;[m | |
[31m // unexpected argument[m | |
[31m } else {[m | |
[31m throw new \RuntimeException('Too many arguments.');[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Adds a short option value.[m | |
[31m *[m | |
[31m * @param string $shortcut The short option key[m | |
[31m * @param mixed $value The value for the option[m | |
[31m *[m | |
[31m * @throws \RuntimeException When option given doesn't exist[m | |
[31m */[m | |
[31m private function addShortOption($shortcut, $value)[m | |
[31m {[m | |
[31m if (!$this->definition->hasShortcut($shortcut)) {[m | |
[31m throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));[m | |
[31m }[m | |
[31m $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Adds a long option value.[m | |
[31m *[m | |
[31m * @param string $name The long option key[m | |
[31m * @param mixed $value The value for the option[m | |
[31m *[m | |
[31m * @throws \RuntimeException When option given doesn't exist[m | |
[31m */[m | |
[31m private function addLongOption($name, $value)[m | |
[31m {[m | |
[31m if (!$this->definition->hasOption($name)) {[m | |
[31m throw new \RuntimeException(sprintf('The "--%s" option does not exist.', $name));[m | |
[31m }[m | |
[31m $option = $this->definition->getOption($name);[m | |
[31m if (null === $value && $option->acceptValue()) {[m | |
[31m // if option accepts an optional or mandatory argument[m | |
[31m // let's see if there is one provided[m | |
[31m $next = array_shift($this->parsed);[m | |
[31m if ('-' !== $next[0]) {[m | |
[31m $value = $next;[m | |
[31m } else {[m | |
[31m array_unshift($this->parsed, $next);[m | |
[31m }[m | |
[31m }[m | |
[31m if (null === $value) {[m | |
[31m if ($option->isValueRequired()) {[m | |
[31m throw new \RuntimeException(sprintf('The "--%s" option requires a value.', $name));[m | |
[31m }[m | |
[31m $value = $option->isValueOptional() ? $option->getDefault() : true;[m | |
[31m }[m | |
[31m if ($option->isArray()) {[m | |
[31m $this->options[$name][] = $value;[m | |
[31m } else {[m | |
[31m $this->options[$name] = $value;[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the first argument from the raw parameters (not parsed).[m | |
[31m *[m | |
[31m * @return string The value of the first argument or null otherwise[m | |
[31m */[m | |
[31m public function getFirstArgument()[m | |
[31m {[m | |
[31m foreach ($this->tokens as $token) {[m | |
[31m if ($token && '-' === $token[0]) {[m | |
[31m continue;[m | |
[31m }[m | |
[31m return $token;[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if the raw parameters (not parsed) contain a value.[m | |
[31m *[m | |
[31m * This method is to be used to introspect the input parameters[m | |
[31m * before they have been validated. It must be used carefully.[m | |
[31m *[m | |
[31m * @param string|array $values The value(s) to look for in the raw parameters (can be an array)[m | |
[31m *[m | |
[31m * @return Boolean true if the value is contained in the raw parameters[m | |
[31m */[m | |
[31m public function hasParameterOption($values)[m | |
[31m {[m | |
[31m $values = (array) $values;[m | |
[31m foreach ($this->tokens as $v) {[m | |
[31m if (in_array($v, $values)) {[m | |
[31m return true;[m | |
[31m }[m | |
[31m }[m | |
[31m return false;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the value of a raw option (not parsed).[m | |
[31m *[m | |
[31m * This method is to be used to introspect the input parameters[m | |
[31m * before they have been validated. It must be used carefully.[m | |
[31m *[m | |
[31m * @param string|array $values The value(s) to look for in the raw parameters (can be an array)[m | |
[31m * @param mixed $default The default value to return if no result is found[m | |
[31m *[m | |
[31m * @return mixed The option value[m | |
[31m */[m | |
[31m public function getParameterOption($values, $default = false)[m | |
[31m {[m | |
[31m $values = (array) $values;[m | |
[31m $tokens = $this->tokens;[m | |
[31m while ($token = array_shift($tokens)) {[m | |
[31m foreach ($values as $value) {[m | |
[31m if (0 === strpos($token, $value)) {[m | |
[31m if (false !== $pos = strpos($token, '=')) {[m | |
[31m return substr($token, $pos + 1);[m | |
[31m }[m | |
[31m return array_shift($tokens);[m | |
[31m }[m | |
[31m }[m | |
[31m }[m | |
[31m return $default;[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Input/ArrayInput.php b/vendor/Symfony/Component/Console/Input/ArrayInput.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex c9d8ee9..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Input/ArrayInput.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,190 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Input;[m | |
[31m/**[m | |
[31m * ArrayInput represents an input provided as an array.[m | |
[31m *[m | |
[31m * Usage:[m | |
[31m *[m | |
[31m * $input = new ArrayInput(array('name' => 'foo', '--bar' => 'foobar'));[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31mclass ArrayInput extends Input[m | |
[31m{[m | |
[31m private $parameters;[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * @param array $parameters An array of parameters[m | |
[31m * @param InputDefinition $definition A InputDefinition instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function __construct(array $parameters, InputDefinition $definition = null)[m | |
[31m {[m | |
[31m $this->parameters = $parameters;[m | |
[31m parent::__construct($definition);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the first argument from the raw parameters (not parsed).[m | |
[31m *[m | |
[31m * @return string The value of the first argument or null otherwise[m | |
[31m */[m | |
[31m public function getFirstArgument()[m | |
[31m {[m | |
[31m foreach ($this->parameters as $key => $value) {[m | |
[31m if ($key && '-' === $key[0]) {[m | |
[31m continue;[m | |
[31m }[m | |
[31m return $value;[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if the raw parameters (not parsed) contain a value.[m | |
[31m *[m | |
[31m * This method is to be used to introspect the input parameters[m | |
[31m * before they have been validated. It must be used carefully.[m | |
[31m *[m | |
[31m * @param string|array $values The values to look for in the raw parameters (can be an array)[m | |
[31m *[m | |
[31m * @return Boolean true if the value is contained in the raw parameters[m | |
[31m */[m | |
[31m public function hasParameterOption($values)[m | |
[31m {[m | |
[31m $values = (array) $values;[m | |
[31m foreach ($this->parameters as $k => $v) {[m | |
[31m if (!is_int($k)) {[m | |
[31m $v = $k;[m | |
[31m }[m | |
[31m if (in_array($v, $values)) {[m | |
[31m return true;[m | |
[31m }[m | |
[31m }[m | |
[31m return false;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the value of a raw option (not parsed).[m | |
[31m *[m | |
[31m * This method is to be used to introspect the input parameters[m | |
[31m * before they have been validated. It must be used carefully.[m | |
[31m *[m | |
[31m * @param string|array $values The value(s) to look for in the raw parameters (can be an array)[m | |
[31m * @param mixed $default The default value to return if no result is found[m | |
[31m *[m | |
[31m * @return mixed The option value[m | |
[31m */[m | |
[31m public function getParameterOption($values, $default = false)[m | |
[31m {[m | |
[31m $values = (array) $values;[m | |
[31m foreach ($this->parameters as $k => $v) {[m | |
[31m if (is_int($k) && in_array($v, $values)) {[m | |
[31m return true;[m | |
[31m } elseif (in_array($k, $values)) {[m | |
[31m return $v;[m | |
[31m }[m | |
[31m }[m | |
[31m return $default;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Processes command line arguments.[m | |
[31m */[m | |
[31m protected function parse()[m | |
[31m {[m | |
[31m foreach ($this->parameters as $key => $value) {[m | |
[31m if (0 === strpos($key, '--')) {[m | |
[31m $this->addLongOption(substr($key, 2), $value);[m | |
[31m } elseif ('-' === $key[0]) {[m | |
[31m $this->addShortOption(substr($key, 1), $value);[m | |
[31m } else {[m | |
[31m $this->addArgument($key, $value);[m | |
[31m }[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Adds a short option value.[m | |
[31m *[m | |
[31m * @param string $shortcut The short option key[m | |
[31m * @param mixed $value The value for the option[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When option given doesn't exist[m | |
[31m */[m | |
[31m private function addShortOption($shortcut, $value)[m | |
[31m {[m | |
[31m if (!$this->definition->hasShortcut($shortcut)) {[m | |
[31m throw new \InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));[m | |
[31m }[m | |
[31m $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Adds a long option value.[m | |
[31m *[m | |
[31m * @param string $name The long option key[m | |
[31m * @param mixed $value The value for the option[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When option given doesn't exist[m | |
[31m * @throws \InvalidArgumentException When a required value is missing[m | |
[31m */[m | |
[31m private function addLongOption($name, $value)[m | |
[31m {[m | |
[31m if (!$this->definition->hasOption($name)) {[m | |
[31m throw new \InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));[m | |
[31m }[m | |
[31m $option = $this->definition->getOption($name);[m | |
[31m if (null === $value) {[m | |
[31m if ($option->isValueRequired()) {[m | |
[31m throw new \InvalidArgumentException(sprintf('The "--%s" option requires a value.', $name));[m | |
[31m }[m | |
[31m $value = $option->isValueOptional() ? $option->getDefault() : true;[m | |
[31m }[m | |
[31m $this->options[$name] = $value;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Adds an argument value.[m | |
[31m *[m | |
[31m * @param string $name The argument name[m | |
[31m * @param mixed $value The value for the argument[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When argument given doesn't exist[m | |
[31m */[m | |
[31m private function addArgument($name, $value)[m | |
[31m {[m | |
[31m if (!$this->definition->hasArgument($name)) {[m | |
[31m throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));[m | |
[31m }[m | |
[31m $this->arguments[$name] = $value;[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Input/Input.php b/vendor/Symfony/Component/Console/Input/Input.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 70291be..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Input/Input.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,211 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Input;[m | |
[31m/**[m | |
[31m * Input is the base class for all concrete Input classes.[m | |
[31m *[m | |
[31m * Three concrete classes are provided by default:[m | |
[31m *[m | |
[31m * * `ArgvInput`: The input comes from the CLI arguments (argv)[m | |
[31m * * `StringInput`: The input is provided as a string[m | |
[31m * * `ArrayInput`: The input is provided as an array[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m */[m | |
[31mabstract class Input implements InputInterface[m | |
[31m{[m | |
[31m protected $definition;[m | |
[31m protected $options;[m | |
[31m protected $arguments;[m | |
[31m protected $interactive = true;[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * @param InputDefinition $definition A InputDefinition instance[m | |
[31m */[m | |
[31m public function __construct(InputDefinition $definition = null)[m | |
[31m {[m | |
[31m if (null === $definition) {[m | |
[31m $this->definition = new InputDefinition();[m | |
[31m } else {[m | |
[31m $this->bind($definition);[m | |
[31m $this->validate();[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Binds the current Input instance with the given arguments and options.[m | |
[31m *[m | |
[31m * @param InputDefinition $definition A InputDefinition instance[m | |
[31m */[m | |
[31m public function bind(InputDefinition $definition)[m | |
[31m {[m | |
[31m $this->arguments = array();[m | |
[31m $this->options = array();[m | |
[31m $this->definition = $definition;[m | |
[31m $this->parse();[m | |
[31m }[m | |
[31m /**[m | |
[31m * Processes command line arguments.[m | |
[31m */[m | |
[31m abstract protected function parse();[m | |
[31m /**[m | |
[31m * Validates the input.[m | |
[31m *[m | |
[31m * @throws \RuntimeException When not enough arguments are given[m | |
[31m */[m | |
[31m public function validate()[m | |
[31m {[m | |
[31m if (count($this->arguments) < $this->definition->getArgumentRequiredCount()) {[m | |
[31m throw new \RuntimeException('Not enough arguments.');[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Checks if the input is interactive.[m | |
[31m *[m | |
[31m * @return Boolean Returns true if the input is interactive[m | |
[31m */[m | |
[31m public function isInteractive()[m | |
[31m {[m | |
[31m return $this->interactive;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the input interactivity.[m | |
[31m *[m | |
[31m * @param Boolean $interactive If the input should be interactive[m | |
[31m */[m | |
[31m public function setInteractive($interactive)[m | |
[31m {[m | |
[31m $this->interactive = (Boolean) $interactive;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the argument values.[m | |
[31m *[m | |
[31m * @return array An array of argument values[m | |
[31m */[m | |
[31m public function getArguments()[m | |
[31m {[m | |
[31m return array_merge($this->definition->getArgumentDefaults(), $this->arguments);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the argument value for a given argument name.[m | |
[31m *[m | |
[31m * @param string $name The argument name[m | |
[31m *[m | |
[31m * @return mixed The argument value[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When argument given doesn't exist[m | |
[31m */[m | |
[31m public function getArgument($name)[m | |
[31m {[m | |
[31m if (!$this->definition->hasArgument($name)) {[m | |
[31m throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));[m | |
[31m }[m | |
[31m return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault();[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets an argument value by name.[m | |
[31m *[m | |
[31m * @param string $name The argument name[m | |
[31m * @param string $value The argument value[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When argument given doesn't exist[m | |
[31m */[m | |
[31m public function setArgument($name, $value)[m | |
[31m {[m | |
[31m if (!$this->definition->hasArgument($name)) {[m | |
[31m throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));[m | |
[31m }[m | |
[31m $this->arguments[$name] = $value;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if an InputArgument object exists by name or position.[m | |
[31m *[m | |
[31m * @param string|integer $name The InputArgument name or position[m | |
[31m *[m | |
[31m * @return Boolean true if the InputArgument object exists, false otherwise[m | |
[31m */[m | |
[31m public function hasArgument($name)[m | |
[31m {[m | |
[31m return $this->definition->hasArgument($name);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the options values.[m | |
[31m *[m | |
[31m * @return array An array of option values[m | |
[31m */[m | |
[31m public function getOptions()[m | |
[31m {[m | |
[31m return array_merge($this->definition->getOptionDefaults(), $this->options);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the option value for a given option name.[m | |
[31m *[m | |
[31m * @param string $name The option name[m | |
[31m *[m | |
[31m * @return mixed The option value[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When option given doesn't exist[m | |
[31m */[m | |
[31m public function getOption($name)[m | |
[31m {[m | |
[31m if (!$this->definition->hasOption($name)) {[m | |
[31m throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));[m | |
[31m }[m | |
[31m return isset($this->options[$name]) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets an option value by name.[m | |
[31m *[m | |
[31m * @param string $name The option name[m | |
[31m * @param string $value The option value[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When option given doesn't exist[m | |
[31m */[m | |
[31m public function setOption($name, $value)[m | |
[31m {[m | |
[31m if (!$this->definition->hasOption($name)) {[m | |
[31m throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));[m | |
[31m }[m | |
[31m $this->options[$name] = $value;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if an InputOption object exists by name.[m | |
[31m *[m | |
[31m * @param string $name The InputOption name[m | |
[31m *[m | |
[31m * @return Boolean true if the InputOption object exists, false otherwise[m | |
[31m */[m | |
[31m public function hasOption($name)[m | |
[31m {[m | |
[31m return $this->definition->hasOption($name);[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Input/InputArgument.php b/vendor/Symfony/Component/Console/Input/InputArgument.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex e7cc935..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Input/InputArgument.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,132 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Input;[m | |
[31m/**[m | |
[31m * Represents a command line argument.[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31mclass InputArgument[m | |
[31m{[m | |
[31m const REQUIRED = 1;[m | |
[31m const OPTIONAL = 2;[m | |
[31m const IS_ARRAY = 4;[m | |
[31m private $name;[m | |
[31m private $mode;[m | |
[31m private $default;[m | |
[31m private $description;[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * @param string $name The argument name[m | |
[31m * @param integer $mode The argument mode: self::REQUIRED or self::OPTIONAL[m | |
[31m * @param string $description A description text[m | |
[31m * @param mixed $default The default value (for self::OPTIONAL mode only)[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When argument mode is not valid[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function __construct($name, $mode = null, $description = '', $default = null)[m | |
[31m {[m | |
[31m if (null === $mode) {[m | |
[31m $mode = self::OPTIONAL;[m | |
[31m } elseif (!is_int($mode) || $mode > 7 || $mode < 1) {[m | |
[31m throw new \InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));[m | |
[31m }[m | |
[31m $this->name = $name;[m | |
[31m $this->mode = $mode;[m | |
[31m $this->description = $description;[m | |
[31m $this->setDefault($default);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the argument name.[m | |
[31m *[m | |
[31m * @return string The argument name[m | |
[31m */[m | |
[31m public function getName()[m | |
[31m {[m | |
[31m return $this->name;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if the argument is required.[m | |
[31m *[m | |
[31m * @return Boolean true if parameter mode is self::REQUIRED, false otherwise[m | |
[31m */[m | |
[31m public function isRequired()[m | |
[31m {[m | |
[31m return self::REQUIRED === (self::REQUIRED & $this->mode);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if the argument can take multiple values.[m | |
[31m *[m | |
[31m * @return Boolean true if mode is self::IS_ARRAY, false otherwise[m | |
[31m */[m | |
[31m public function isArray()[m | |
[31m {[m | |
[31m return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the default value.[m | |
[31m *[m | |
[31m * @param mixed $default The default value[m | |
[31m *[m | |
[31m * @throws \LogicException When incorrect default value is given[m | |
[31m */[m | |
[31m public function setDefault($default = null)[m | |
[31m {[m | |
[31m if (self::REQUIRED === $this->mode && null !== $default) {[m | |
[31m throw new \LogicException('Cannot set a default value except for Parameter::OPTIONAL mode.');[m | |
[31m }[m | |
[31m if ($this->isArray()) {[m | |
[31m if (null === $default) {[m | |
[31m $default = array();[m | |
[31m } elseif (!is_array($default)) {[m | |
[31m throw new \LogicException('A default value for an array argument must be an array.');[m | |
[31m }[m | |
[31m }[m | |
[31m $this->default = $default;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the default value.[m | |
[31m *[m | |
[31m * @return mixed The default value[m | |
[31m */[m | |
[31m public function getDefault()[m | |
[31m {[m | |
[31m return $this->default;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the description text.[m | |
[31m *[m | |
[31m * @return string The description text[m | |
[31m */[m | |
[31m public function getDescription()[m | |
[31m {[m | |
[31m return $this->description;[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Input/InputDefinition.php b/vendor/Symfony/Component/Console/Input/InputDefinition.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex ffae4fe..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Input/InputDefinition.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,533 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Input;[m | |
[31m/**[m | |
[31m * A InputDefinition represents a set of valid command line arguments and options.[m | |
[31m *[m | |
[31m * Usage:[m | |
[31m *[m | |
[31m * $definition = new InputDefinition(array([m | |
[31m * new InputArgument('name', InputArgument::REQUIRED),[m | |
[31m * new InputOption('foo', 'f', InputOption::VALUE_REQUIRED),[m | |
[31m * ));[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31mclass InputDefinition[m | |
[31m{[m | |
[31m private $arguments;[m | |
[31m private $requiredCount;[m | |
[31m private $hasAnArrayArgument = false;[m | |
[31m private $hasOptional;[m | |
[31m private $options;[m | |
[31m private $shortcuts;[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * @param array $definition An array of InputArgument and InputOption instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function __construct(array $definition = array())[m | |
[31m {[m | |
[31m $this->setDefinition($definition);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the definition of the input.[m | |
[31m *[m | |
[31m * @param array $definition The definition array[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setDefinition(array $definition)[m | |
[31m {[m | |
[31m $arguments = array();[m | |
[31m $options = array();[m | |
[31m foreach ($definition as $item) {[m | |
[31m if ($item instanceof InputOption) {[m | |
[31m $options[] = $item;[m | |
[31m } else {[m | |
[31m $arguments[] = $item;[m | |
[31m }[m | |
[31m }[m | |
[31m $this->setArguments($arguments);[m | |
[31m $this->setOptions($options);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the InputArgument objects.[m | |
[31m *[m | |
[31m * @param array $arguments An array of InputArgument objects[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setArguments($arguments = array())[m | |
[31m {[m | |
[31m $this->arguments = array();[m | |
[31m $this->requiredCount = 0;[m | |
[31m $this->hasOptional = false;[m | |
[31m $this->hasAnArrayArgument = false;[m | |
[31m $this->addArguments($arguments);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Adds an array of InputArgument objects.[m | |
[31m *[m | |
[31m * @param InputArgument[] $arguments An array of InputArgument objects[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function addArguments($arguments = array())[m | |
[31m {[m | |
[31m if (null !== $arguments) {[m | |
[31m foreach ($arguments as $argument) {[m | |
[31m $this->addArgument($argument);[m | |
[31m }[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Adds an InputArgument object.[m | |
[31m *[m | |
[31m * @param InputArgument $argument An InputArgument object[m | |
[31m *[m | |
[31m * @throws \LogicException When incorrect argument is given[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function addArgument(InputArgument $argument)[m | |
[31m {[m | |
[31m if (isset($this->arguments[$argument->getName()])) {[m | |
[31m throw new \LogicException(sprintf('An argument with name "%s" already exist.', $argument->getName()));[m | |
[31m }[m | |
[31m if ($this->hasAnArrayArgument) {[m | |
[31m throw new \LogicException('Cannot add an argument after an array argument.');[m | |
[31m }[m | |
[31m if ($argument->isRequired() && $this->hasOptional) {[m | |
[31m throw new \LogicException('Cannot add a required argument after an optional one.');[m | |
[31m }[m | |
[31m if ($argument->isArray()) {[m | |
[31m $this->hasAnArrayArgument = true;[m | |
[31m }[m | |
[31m if ($argument->isRequired()) {[m | |
[31m ++$this->requiredCount;[m | |
[31m } else {[m | |
[31m $this->hasOptional = true;[m | |
[31m }[m | |
[31m $this->arguments[$argument->getName()] = $argument;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns an InputArgument by name or by position.[m | |
[31m *[m | |
[31m * @param string|integer $name The InputArgument name or position[m | |
[31m *[m | |
[31m * @return InputArgument An InputArgument object[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When argument given doesn't exist[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getArgument($name)[m | |
[31m {[m | |
[31m $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments;[m | |
[31m if (!$this->hasArgument($name)) {[m | |
[31m throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));[m | |
[31m }[m | |
[31m return $arguments[$name];[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if an InputArgument object exists by name or position.[m | |
[31m *[m | |
[31m * @param string|integer $name The InputArgument name or position[m | |
[31m *[m | |
[31m * @return Boolean true if the InputArgument object exists, false otherwise[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function hasArgument($name)[m | |
[31m {[m | |
[31m $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments;[m | |
[31m return isset($arguments[$name]);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the array of InputArgument objects.[m | |
[31m *[m | |
[31m * @return array An array of InputArgument objects[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getArguments()[m | |
[31m {[m | |
[31m return $this->arguments;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the number of InputArguments.[m | |
[31m *[m | |
[31m * @return integer The number of InputArguments[m | |
[31m */[m | |
[31m public function getArgumentCount()[m | |
[31m {[m | |
[31m return $this->hasAnArrayArgument ? PHP_INT_MAX : count($this->arguments);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the number of required InputArguments.[m | |
[31m *[m | |
[31m * @return integer The number of required InputArguments[m | |
[31m */[m | |
[31m public function getArgumentRequiredCount()[m | |
[31m {[m | |
[31m return $this->requiredCount;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the default values.[m | |
[31m *[m | |
[31m * @return array An array of default values[m | |
[31m */[m | |
[31m public function getArgumentDefaults()[m | |
[31m {[m | |
[31m $values = array();[m | |
[31m foreach ($this->arguments as $argument) {[m | |
[31m $values[$argument->getName()] = $argument->getDefault();[m | |
[31m }[m | |
[31m return $values;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the InputOption objects.[m | |
[31m *[m | |
[31m * @param array $options An array of InputOption objects[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setOptions($options = array())[m | |
[31m {[m | |
[31m $this->options = array();[m | |
[31m $this->shortcuts = array();[m | |
[31m $this->addOptions($options);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Adds an array of InputOption objects.[m | |
[31m *[m | |
[31m * @param InputOption[] $options An array of InputOption objects[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function addOptions($options = array())[m | |
[31m {[m | |
[31m foreach ($options as $option) {[m | |
[31m $this->addOption($option);[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Adds an InputOption object.[m | |
[31m *[m | |
[31m * @param InputOption $option An InputOption object[m | |
[31m *[m | |
[31m * @throws \LogicException When option given already exist[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function addOption(InputOption $option)[m | |
[31m {[m | |
[31m if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) {[m | |
[31m throw new \LogicException(sprintf('An option named "%s" already exist.', $option->getName()));[m | |
[31m } elseif (isset($this->shortcuts[$option->getShortcut()]) && !$option->equals($this->options[$this->shortcuts[$option->getShortcut()]])) {[m | |
[31m throw new \LogicException(sprintf('An option with shortcut "%s" already exist.', $option->getShortcut()));[m | |
[31m }[m | |
[31m $this->options[$option->getName()] = $option;[m | |
[31m if ($option->getShortcut()) {[m | |
[31m $this->shortcuts[$option->getShortcut()] = $option->getName();[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns an InputOption by name.[m | |
[31m *[m | |
[31m * @param string $name The InputOption name[m | |
[31m *[m | |
[31m * @return InputOption A InputOption object[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getOption($name)[m | |
[31m {[m | |
[31m if (!$this->hasOption($name)) {[m | |
[31m throw new \InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));[m | |
[31m }[m | |
[31m return $this->options[$name];[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if an InputOption object exists by name.[m | |
[31m *[m | |
[31m * @param string $name The InputOption name[m | |
[31m *[m | |
[31m * @return Boolean true if the InputOption object exists, false otherwise[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function hasOption($name)[m | |
[31m {[m | |
[31m return isset($this->options[$name]);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the array of InputOption objects.[m | |
[31m *[m | |
[31m * @return array An array of InputOption objects[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getOptions()[m | |
[31m {[m | |
[31m return $this->options;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if an InputOption object exists by shortcut.[m | |
[31m *[m | |
[31m * @param string $name The InputOption shortcut[m | |
[31m *[m | |
[31m * @return Boolean true if the InputOption object exists, false otherwise[m | |
[31m */[m | |
[31m public function hasShortcut($name)[m | |
[31m {[m | |
[31m return isset($this->shortcuts[$name]);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets an InputOption by shortcut.[m | |
[31m *[m | |
[31m * @param string $shortcut the Shortcut name[m | |
[31m *[m | |
[31m * @return InputOption An InputOption object[m | |
[31m */[m | |
[31m public function getOptionForShortcut($shortcut)[m | |
[31m {[m | |
[31m return $this->getOption($this->shortcutToName($shortcut));[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets an array of default values.[m | |
[31m *[m | |
[31m * @return array An array of all default values[m | |
[31m */[m | |
[31m public function getOptionDefaults()[m | |
[31m {[m | |
[31m $values = array();[m | |
[31m foreach ($this->options as $option) {[m | |
[31m $values[$option->getName()] = $option->getDefault();[m | |
[31m }[m | |
[31m return $values;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the InputOption name given a shortcut.[m | |
[31m *[m | |
[31m * @param string $shortcut The shortcut[m | |
[31m *[m | |
[31m * @return string The InputOption name[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When option given does not exist[m | |
[31m */[m | |
[31m private function shortcutToName($shortcut)[m | |
[31m {[m | |
[31m if (!isset($this->shortcuts[$shortcut])) {[m | |
[31m throw new \InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));[m | |
[31m }[m | |
[31m return $this->shortcuts[$shortcut];[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the synopsis.[m | |
[31m *[m | |
[31m * @return string The synopsis[m | |
[31m */[m | |
[31m public function getSynopsis()[m | |
[31m {[m | |
[31m $elements = array();[m | |
[31m foreach ($this->getOptions() as $option) {[m | |
[31m $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';[m | |
[31m $elements[] = sprintf('['.($option->isValueRequired() ? '%s--%s="..."' : ($option->isValueOptional() ? '%s--%s[="..."]' : '%s--%s')).']', $shortcut, $option->getName());[m | |
[31m }[m | |
[31m foreach ($this->getArguments() as $argument) {[m | |
[31m $elements[] = sprintf($argument->isRequired() ? '%s' : '[%s]', $argument->getName().($argument->isArray() ? '1' : ''));[m | |
[31m if ($argument->isArray()) {[m | |
[31m $elements[] = sprintf('... [%sN]', $argument->getName());[m | |
[31m }[m | |
[31m }[m | |
[31m return implode(' ', $elements);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns a textual representation of the InputDefinition.[m | |
[31m *[m | |
[31m * @return string A string representing the InputDefinition[m | |
[31m */[m | |
[31m public function asText()[m | |
[31m {[m | |
[31m // find the largest option or argument name[m | |
[31m $max = 0;[m | |
[31m foreach ($this->getOptions() as $option) {[m | |
[31m $nameLength = strlen($option->getName()) + 2;[m | |
[31m if ($option->getShortcut()) {[m | |
[31m $nameLength += strlen($option->getShortcut()) + 3;[m | |
[31m }[m | |
[31m $max = max($max, $nameLength);[m | |
[31m }[m | |
[31m foreach ($this->getArguments() as $argument) {[m | |
[31m $max = max($max, strlen($argument->getName()));[m | |
[31m }[m | |
[31m ++$max;[m | |
[31m $text = array();[m | |
[31m if ($this->getArguments()) {[m | |
[31m $text[] = '<comment>Arguments:</comment>';[m | |
[31m foreach ($this->getArguments() as $argument) {[m | |
[31m if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) {[m | |
[31m $default = sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($argument->getDefault()));[m | |
[31m } else {[m | |
[31m $default = '';[m | |
[31m }[m | |
[31m $description = str_replace("\n", "\n".str_pad('', $max + 2, ' '), $argument->getDescription());[m | |
[31m $text[] = sprintf(" <info>%-${max}s</info> %s%s", $argument->getName(), $description, $default);[m | |
[31m }[m | |
[31m $text[] = '';[m | |
[31m }[m | |
[31m if ($this->getOptions()) {[m | |
[31m $text[] = '<comment>Options:</comment>';[m | |
[31m foreach ($this->getOptions() as $option) {[m | |
[31m if ($option->acceptValue() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault()))) {[m | |
[31m $default = sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($option->getDefault()));[m | |
[31m } else {[m | |
[31m $default = '';[m | |
[31m }[m | |
[31m $multiple = $option->isArray() ? '<comment> (multiple values allowed)</comment>' : '';[m | |
[31m $description = str_replace("\n", "\n".str_pad('', $max + 2, ' '), $option->getDescription());[m | |
[31m $optionMax = $max - strlen($option->getName()) - 2;[m | |
[31m $text[] = sprintf(" <info>%s</info> %-${optionMax}s%s%s%s",[m | |
[31m '--'.$option->getName(),[m | |
[31m $option->getShortcut() ? sprintf('(-%s) ', $option->getShortcut()) : '',[m | |
[31m $description,[m | |
[31m $default,[m | |
[31m $multiple[m | |
[31m );[m | |
[31m }[m | |
[31m $text[] = '';[m | |
[31m }[m | |
[31m return implode("\n", $text);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns an XML representation of the InputDefinition.[m | |
[31m *[m | |
[31m * @param Boolean $asDom Whether to return a DOM or an XML string[m | |
[31m *[m | |
[31m * @return string|DOMDocument An XML string representing the InputDefinition[m | |
[31m */[m | |
[31m public function asXml($asDom = false)[m | |
[31m {[m | |
[31m $dom = new \DOMDocument('1.0', 'UTF-8');[m | |
[31m $dom->formatOutput = true;[m | |
[31m $dom->appendChild($definitionXML = $dom->createElement('definition'));[m | |
[31m $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));[m | |
[31m foreach ($this->getArguments() as $argument) {[m | |
[31m $argumentsXML->appendChild($argumentXML = $dom->createElement('argument'));[m | |
[31m $argumentXML->setAttribute('name', $argument->getName());[m | |
[31m $argumentXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0);[m | |
[31m $argumentXML->setAttribute('is_array', $argument->isArray() ? 1 : 0);[m | |
[31m $argumentXML->appendChild($descriptionXML = $dom->createElement('description'));[m | |
[31m $descriptionXML->appendChild($dom->createTextNode($argument->getDescription()));[m | |
[31m $argumentXML->appendChild($defaultsXML = $dom->createElement('defaults'));[m | |
[31m $defaults = is_array($argument->getDefault()) ? $argument->getDefault() : (is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array()));[m | |
[31m foreach ($defaults as $default) {[m | |
[31m $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));[m | |
[31m $defaultXML->appendChild($dom->createTextNode($default));[m | |
[31m }[m | |
[31m }[m | |
[31m $definitionXML->appendChild($optionsXML = $dom->createElement('options'));[m | |
[31m foreach ($this->getOptions() as $option) {[m | |
[31m $optionsXML->appendChild($optionXML = $dom->createElement('option'));[m | |
[31m $optionXML->setAttribute('name', '--'.$option->getName());[m | |
[31m $optionXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');[m | |
[31m $optionXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0);[m | |
[31m $optionXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0);[m | |
[31m $optionXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0);[m | |
[31m $optionXML->appendChild($descriptionXML = $dom->createElement('description'));[m | |
[31m $descriptionXML->appendChild($dom->createTextNode($option->getDescription()));[m | |
[31m if ($option->acceptValue()) {[m | |
[31m $optionXML->appendChild($defaultsXML = $dom->createElement('defaults'));[m | |
[31m $defaults = is_array($option->getDefault()) ? $option->getDefault() : (is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array()));[m | |
[31m foreach ($defaults as $default) {[m | |
[31m $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));[m | |
[31m $defaultXML->appendChild($dom->createTextNode($default));[m | |
[31m }[m | |
[31m }[m | |
[31m }[m | |
[31m return $asDom ? $dom : $dom->saveXml();[m | |
[31m }[m | |
[31m private function formatDefaultValue($default)[m | |
[31m {[m | |
[31m if (is_array($default) && $default === array_values($default)) {[m | |
[31m return sprintf("array('%s')", implode("', '", $default));[m | |
[31m }[m | |
[31m return str_replace("\n", '', var_export($default, true));[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Input/InputInterface.php b/vendor/Symfony/Component/Console/Input/InputInterface.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex a4a6223..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Input/InputInterface.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,152 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Input;[m | |
[31m/**[m | |
[31m * InputInterface is the interface implemented by all input classes.[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m */[m | |
[31minterface InputInterface[m | |
[31m{[m | |
[31m /**[m | |
[31m * Returns the first argument from the raw parameters (not parsed).[m | |
[31m *[m | |
[31m * @return string The value of the first argument or null otherwise[m | |
[31m */[m | |
[31m function getFirstArgument();[m | |
[31m /**[m | |
[31m * Returns true if the raw parameters (not parsed) contain a value.[m | |
[31m *[m | |
[31m * This method is to be used to introspect the input parameters[m | |
[31m * before they have been validated. It must be used carefully.[m | |
[31m *[m | |
[31m * @param string|array $values The values to look for in the raw parameters (can be an array)[m | |
[31m *[m | |
[31m * @return Boolean true if the value is contained in the raw parameters[m | |
[31m */[m | |
[31m function hasParameterOption($values);[m | |
[31m /**[m | |
[31m * Returns the value of a raw option (not parsed).[m | |
[31m *[m | |
[31m * This method is to be used to introspect the input parameters[m | |
[31m * before they have been validated. It must be used carefully.[m | |
[31m *[m | |
[31m * @param string|array $values The value(s) to look for in the raw parameters (can be an array)[m | |
[31m * @param mixed $default The default value to return if no result is found[m | |
[31m *[m | |
[31m * @return mixed The option value[m | |
[31m */[m | |
[31m function getParameterOption($values, $default = false);[m | |
[31m /**[m | |
[31m * Binds the current Input instance with the given arguments and options.[m | |
[31m *[m | |
[31m * @param InputDefinition $definition A InputDefinition instance[m | |
[31m */[m | |
[31m function bind(InputDefinition $definition);[m | |
[31m /**[m | |
[31m * Validates if arguments given are correct.[m | |
[31m *[m | |
[31m * Throws an exception when not enough arguments are given.[m | |
[31m *[m | |
[31m * @throws \RuntimeException[m | |
[31m */[m | |
[31m function validate();[m | |
[31m /**[m | |
[31m * Returns all the given arguments merged with the default values.[m | |
[31m *[m | |
[31m * @return array[m | |
[31m */[m | |
[31m function getArguments();[m | |
[31m /**[m | |
[31m * Gets argument by name.[m | |
[31m *[m | |
[31m * @param string $name The name of the argument[m | |
[31m *[m | |
[31m * @return mixed[m | |
[31m */[m | |
[31m function getArgument($name);[m | |
[31m /**[m | |
[31m * Sets an argument value by name.[m | |
[31m *[m | |
[31m * @param string $name The argument name[m | |
[31m * @param string $value The argument value[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When argument given doesn't exist[m | |
[31m */[m | |
[31m function setArgument($name, $value);[m | |
[31m /**[m | |
[31m * Returns true if an InputArgument object exists by name or position.[m | |
[31m *[m | |
[31m * @param string|integer $name The InputArgument name or position[m | |
[31m *[m | |
[31m * @return Boolean true if the InputArgument object exists, false otherwise[m | |
[31m */[m | |
[31m function hasArgument($name);[m | |
[31m /**[m | |
[31m * Returns all the given options merged with the default values.[m | |
[31m *[m | |
[31m * @return array[m | |
[31m */[m | |
[31m function getOptions();[m | |
[31m /**[m | |
[31m * Gets an option by name.[m | |
[31m *[m | |
[31m * @param string $name The name of the option[m | |
[31m *[m | |
[31m * @return mixed[m | |
[31m */[m | |
[31m function getOption($name);[m | |
[31m /**[m | |
[31m * Sets an option value by name.[m | |
[31m *[m | |
[31m * @param string $name The option name[m | |
[31m * @param string $value The option value[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When option given doesn't exist[m | |
[31m */[m | |
[31m function setOption($name, $value);[m | |
[31m /**[m | |
[31m * Returns true if an InputOption object exists by name.[m | |
[31m *[m | |
[31m * @param string $name The InputOption name[m | |
[31m *[m | |
[31m * @return Boolean true if the InputOption object exists, false otherwise[m | |
[31m */[m | |
[31m function hasOption($name);[m | |
[31m /**[m | |
[31m * Is this input means interactive?[m | |
[31m *[m | |
[31m * @return Boolean[m | |
[31m */[m | |
[31m function isInteractive();[m | |
[31m /**[m | |
[31m * Sets the input interactivity.[m | |
[31m *[m | |
[31m * @param Boolean $interactive If the input should be interactive[m | |
[31m */[m | |
[31m function setInteractive($interactive);[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Input/InputOption.php b/vendor/Symfony/Component/Console/Input/InputOption.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 0f26045..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Input/InputOption.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,201 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Input;[m | |
[31m/**[m | |
[31m * Represents a command line option.[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31mclass InputOption[m | |
[31m{[m | |
[31m const VALUE_NONE = 1;[m | |
[31m const VALUE_REQUIRED = 2;[m | |
[31m const VALUE_OPTIONAL = 4;[m | |
[31m const VALUE_IS_ARRAY = 8;[m | |
[31m private $name;[m | |
[31m private $shortcut;[m | |
[31m private $mode;[m | |
[31m private $default;[m | |
[31m private $description;[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * @param string $name The option name[m | |
[31m * @param string $shortcut The shortcut (can be null)[m | |
[31m * @param integer $mode The option mode: One of the VALUE_* constants[m | |
[31m * @param string $description A description text[m | |
[31m * @param mixed $default The default value (must be null for self::VALUE_REQUIRED or self::VALUE_NONE)[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException If option mode is invalid or incompatible[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null)[m | |
[31m {[m | |
[31m if (0 === strpos($name, '--')) {[m | |
[31m $name = substr($name, 2);[m | |
[31m }[m | |
[31m if (empty($shortcut)) {[m | |
[31m $shortcut = null;[m | |
[31m }[m | |
[31m if (null !== $shortcut) {[m | |
[31m if ('-' === $shortcut[0]) {[m | |
[31m $shortcut = substr($shortcut, 1);[m | |
[31m }[m | |
[31m }[m | |
[31m if (null === $mode) {[m | |
[31m $mode = self::VALUE_NONE;[m | |
[31m } elseif (!is_int($mode) || $mode > 15 || $mode < 1) {[m | |
[31m throw new \InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));[m | |
[31m }[m | |
[31m $this->name = $name;[m | |
[31m $this->shortcut = $shortcut;[m | |
[31m $this->mode = $mode;[m | |
[31m $this->description = $description;[m | |
[31m if ($this->isArray() && !$this->acceptValue()) {[m | |
[31m throw new \InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');[m | |
[31m }[m | |
[31m $this->setDefault($default);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the option shortcut.[m | |
[31m *[m | |
[31m * @return string The shortcut[m | |
[31m */[m | |
[31m public function getShortcut()[m | |
[31m {[m | |
[31m return $this->shortcut;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the option name.[m | |
[31m *[m | |
[31m * @return string The name[m | |
[31m */[m | |
[31m public function getName()[m | |
[31m {[m | |
[31m return $this->name;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if the option accepts a value.[m | |
[31m *[m | |
[31m * @return Boolean true if value mode is not self::VALUE_NONE, false otherwise[m | |
[31m */[m | |
[31m public function acceptValue()[m | |
[31m {[m | |
[31m return $this->isValueRequired() || $this->isValueOptional();[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if the option requires a value.[m | |
[31m *[m | |
[31m * @return Boolean true if value mode is self::VALUE_REQUIRED, false otherwise[m | |
[31m */[m | |
[31m public function isValueRequired()[m | |
[31m {[m | |
[31m return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if the option takes an optional value.[m | |
[31m *[m | |
[31m * @return Boolean true if value mode is self::VALUE_OPTIONAL, false otherwise[m | |
[31m */[m | |
[31m public function isValueOptional()[m | |
[31m {[m | |
[31m return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if the option can take multiple values.[m | |
[31m *[m | |
[31m * @return Boolean true if mode is self::VALUE_IS_ARRAY, false otherwise[m | |
[31m */[m | |
[31m public function isArray()[m | |
[31m {[m | |
[31m return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the default value.[m | |
[31m *[m | |
[31m * @param mixed $default The default value[m | |
[31m *[m | |
[31m * @throws \LogicException When incorrect default value is given[m | |
[31m */[m | |
[31m public function setDefault($default = null)[m | |
[31m {[m | |
[31m if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {[m | |
[31m throw new \LogicException('Cannot set a default value when using Option::VALUE_NONE mode.');[m | |
[31m }[m | |
[31m if ($this->isArray()) {[m | |
[31m if (null === $default) {[m | |
[31m $default = array();[m | |
[31m } elseif (!is_array($default)) {[m | |
[31m throw new \LogicException('A default value for an array option must be an array.');[m | |
[31m }[m | |
[31m }[m | |
[31m $this->default = $this->acceptValue() ? $default : false;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the default value.[m | |
[31m *[m | |
[31m * @return mixed The default value[m | |
[31m */[m | |
[31m public function getDefault()[m | |
[31m {[m | |
[31m return $this->default;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the description text.[m | |
[31m *[m | |
[31m * @return string The description text[m | |
[31m */[m | |
[31m public function getDescription()[m | |
[31m {[m | |
[31m return $this->description;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Checks whether the given option equals this one[m | |
[31m *[m | |
[31m * @param InputOption $option option to compare[m | |
[31m * @return Boolean[m | |
[31m */[m | |
[31m public function equals(InputOption $option)[m | |
[31m {[m | |
[31m return $option->getName() === $this->getName()[m | |
[31m && $option->getShortcut() === $this->getShortcut()[m | |
[31m && $option->getDefault() === $this->getDefault()[m | |
[31m && $option->isArray() === $this->isArray()[m | |
[31m && $option->isValueRequired() === $this->isValueRequired()[m | |
[31m && $option->isValueOptional() === $this->isValueOptional()[m | |
[31m ;[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Input/StringInput.php b/vendor/Symfony/Component/Console/Input/StringInput.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 72b725b..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Input/StringInput.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,79 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Input;[m | |
[31m/**[m | |
[31m * StringInput represents an input provided as a string.[m | |
[31m *[m | |
[31m * Usage:[m | |
[31m *[m | |
[31m * $input = new StringInput('foo --bar="foobar"');[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31mclass StringInput extends ArgvInput[m | |
[31m{[m | |
[31m const REGEX_STRING = '([^ ]+?)(?: |(?<!\\\\)"|(?<!\\\\)\'|$)';[m | |
[31m const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * @param string $input An array of parameters from the CLI (in the argv format)[m | |
[31m * @param InputDefinition $definition A InputDefinition instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function __construct($input, InputDefinition $definition = null)[m | |
[31m {[m | |
[31m parent::__construct(array(), $definition);[m | |
[31m $this->setTokens($this->tokenize($input));[m | |
[31m }[m | |
[31m /**[m | |
[31m * Tokenizes a string.[m | |
[31m *[m | |
[31m * @param string $input The input to tokenize[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When unable to parse input (should never happen)[m | |
[31m */[m | |
[31m private function tokenize($input)[m | |
[31m {[m | |
[31m $input = preg_replace('/(\r\n|\r|\n|\t)/', ' ', $input);[m | |
[31m $tokens = array();[m | |
[31m $length = strlen($input);[m | |
[31m $cursor = 0;[m | |
[31m while ($cursor < $length) {[m | |
[31m if (preg_match('/\s+/A', $input, $match, null, $cursor)) {[m | |
[31m } elseif (preg_match('/([^="\' ]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) {[m | |
[31m $tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, strlen($match[3]) - 2)));[m | |
[31m } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) {[m | |
[31m $tokens[] = stripcslashes(substr($match[0], 1, strlen($match[0]) - 2));[m | |
[31m } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) {[m | |
[31m $tokens[] = stripcslashes($match[1]);[m | |
[31m } else {[m | |
[31m // should never happen[m | |
[31m // @codeCoverageIgnoreStart[m | |
[31m throw new \InvalidArgumentException(sprintf('Unable to parse input near "... %s ..."', substr($input, $cursor, 10)));[m | |
[31m // @codeCoverageIgnoreEnd[m | |
[31m }[m | |
[31m $cursor += strlen($match[0]);[m | |
[31m }[m | |
[31m return $tokens;[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/LICENSE b/vendor/Symfony/Component/Console/LICENSE[m | |
[1mdeleted file mode 100755[m | |
[1mindex cdffe7a..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/LICENSE[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,19 +0,0 @@[m | |
[31mCopyright (c) 2004-2012 Fabien Potencier[m | |
[31mPermission is hereby granted, free of charge, to any person obtaining a copy[m | |
[31mof this software and associated documentation files (the "Software"), to deal[m | |
[31min the Software without restriction, including without limitation the rights[m | |
[31mto use, copy, modify, merge, publish, distribute, sublicense, and/or sell[m | |
[31mcopies of the Software, and to permit persons to whom the Software is furnished[m | |
[31mto do so, subject to the following conditions:[m | |
[31mThe above copyright notice and this permission notice shall be included in all[m | |
[31mcopies or substantial portions of the Software.[m | |
[31mTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR[m | |
[31mIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,[m | |
[31mFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE[m | |
[31mAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER[m | |
[31mLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,[m | |
[31mOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN[m | |
[31mTHE SOFTWARE.[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Output/ConsoleOutput.php b/vendor/Symfony/Component/Console/Output/ConsoleOutput.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 1cce332..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Output/ConsoleOutput.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,83 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Output;[m | |
[31muse Symfony\Component\Console\Formatter\OutputFormatter;[m | |
[31muse Symfony\Component\Console\Formatter\OutputFormatterInterface;[m | |
[31muse Symfony\Component\Console\Output\ConsoleOutputInterface;[m | |
[31m/**[m | |
[31m * ConsoleOutput is the default class for all CLI output. It uses STDOUT.[m | |
[31m *[m | |
[31m * This class is a convenient wrapper around `StreamOutput`.[m | |
[31m *[m | |
[31m * $output = new ConsoleOutput();[m | |
[31m *[m | |
[31m * This is equivalent to:[m | |
[31m *[m | |
[31m * $output = new StreamOutput(fopen('php://stdout', 'w'));[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31mclass ConsoleOutput extends StreamOutput implements ConsoleOutputInterface[m | |
[31m{[m | |
[31m private $stderr;[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * @param integer $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL,[m | |
[31m * self::VERBOSITY_VERBOSE)[m | |
[31m * @param Boolean $decorated Whether to decorate messages or not (null for auto-guessing)[m | |
[31m * @param OutputFormatter $formatter Output formatter instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)[m | |
[31m {[m | |
[31m parent::__construct(fopen('php://stdout', 'w'), $verbosity, $decorated, $formatter);[m | |
[31m $this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $formatter);[m | |
[31m }[m | |
[31m public function setDecorated($decorated)[m | |
[31m {[m | |
[31m parent::setDecorated($decorated);[m | |
[31m $this->stderr->setDecorated($decorated);[m | |
[31m }[m | |
[31m public function setFormatter(OutputFormatterInterface $formatter)[m | |
[31m {[m | |
[31m parent::setFormatter($formatter);[m | |
[31m $this->stderr->setFormatter($formatter);[m | |
[31m }[m | |
[31m public function setVerbosity($level)[m | |
[31m {[m | |
[31m parent::setVerbosity($level);[m | |
[31m $this->stderr->setVerbosity($level);[m | |
[31m }[m | |
[31m /**[m | |
[31m * @return OutputInterface[m | |
[31m */[m | |
[31m public function getErrorOutput()[m | |
[31m {[m | |
[31m return $this->stderr;[m | |
[31m }[m | |
[31m public function setErrorOutput(OutputInterface $error)[m | |
[31m {[m | |
[31m $this->stderr = $error;[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Output/ConsoleOutputInterface.php b/vendor/Symfony/Component/Console/Output/ConsoleOutputInterface.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 5006b80..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Output/ConsoleOutputInterface.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,30 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Output;[m | |
[31muse Symfony\Component\Console\Output\OutputInterface;[m | |
[31m/**[m | |
[31m * ConsoleOutputInterface is the interface implemented by ConsoleOutput class.[m | |
[31m * This adds information about stderr output stream.[m | |
[31m *[m | |
[31m * @author Dariusz Górecki <[email protected]>[m | |
[31m */[m | |
[31minterface ConsoleOutputInterface extends OutputInterface[m | |
[31m{[m | |
[31m /**[m | |
[31m * @return OutputInterface[m | |
[31m */[m | |
[31m public function getErrorOutput();[m | |
[31m public function setErrorOutput(OutputInterface $error);[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Output/NullOutput.php b/vendor/Symfony/Component/Console/Output/NullOutput.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex f6c99ab..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Output/NullOutput.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,34 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Output;[m | |
[31m/**[m | |
[31m * NullOutput suppresses all output.[m | |
[31m *[m | |
[31m * $output = new NullOutput();[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31mclass NullOutput extends Output[m | |
[31m{[m | |
[31m /**[m | |
[31m * Writes a message to the output.[m | |
[31m *[m | |
[31m * @param string $message A message to write to the output[m | |
[31m * @param Boolean $newline Whether to add a newline or not[m | |
[31m */[m | |
[31m public function doWrite($message, $newline)[m | |
[31m {[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Output/Output.php b/vendor/Symfony/Component/Console/Output/Output.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 2227880..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Output/Output.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,180 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Output;[m | |
[31muse Symfony\Component\Console\Formatter\OutputFormatterInterface;[m | |
[31muse Symfony\Component\Console\Formatter\OutputFormatter;[m | |
[31m/**[m | |
[31m * Base class for output classes.[m | |
[31m *[m | |
[31m * There are three levels of verbosity:[m | |
[31m *[m | |
[31m * * normal: no option passed (normal output - information)[m | |
[31m * * verbose: -v (more output - debug)[m | |
[31m * * quiet: -q (no output)[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31mabstract class Output implements OutputInterface[m | |
[31m{[m | |
[31m private $verbosity;[m | |
[31m private $formatter;[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * @param integer $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL, self::VERBOSITY_VERBOSE)[m | |
[31m * @param Boolean $decorated Whether to decorate messages or not (null for auto-guessing)[m | |
[31m * @param OutputFormatterInterface $formatter Output formatter instance[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)[m | |
[31m {[m | |
[31m $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity;[m | |
[31m $this->formatter = null === $formatter ? new OutputFormatter() : $formatter;[m | |
[31m $this->formatter->setDecorated((Boolean) $decorated);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets output formatter.[m | |
[31m *[m | |
[31m * @param OutputFormatterInterface $formatter[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setFormatter(OutputFormatterInterface $formatter)[m | |
[31m {[m | |
[31m $this->formatter = $formatter;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns current output formatter instance.[m | |
[31m *[m | |
[31m * @return OutputFormatterInterface[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getFormatter()[m | |
[31m {[m | |
[31m return $this->formatter;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the decorated flag.[m | |
[31m *[m | |
[31m * @param Boolean $decorated Whether to decorate the messages or not[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setDecorated($decorated)[m | |
[31m {[m | |
[31m $this->formatter->setDecorated((Boolean) $decorated);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the decorated flag.[m | |
[31m *[m | |
[31m * @return Boolean true if the output will decorate messages, false otherwise[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function isDecorated()[m | |
[31m {[m | |
[31m return $this->formatter->isDecorated();[m | |
[31m }[m | |
[31m /**[m | |
[31m * Sets the verbosity of the output.[m | |
[31m *[m | |
[31m * @param integer $level The level of verbosity[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function setVerbosity($level)[m | |
[31m {[m | |
[31m $this->verbosity = (int) $level;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the current verbosity of the output.[m | |
[31m *[m | |
[31m * @return integer The current level of verbosity[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function getVerbosity()[m | |
[31m {[m | |
[31m return $this->verbosity;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Writes a message to the output and adds a newline at the end.[m | |
[31m *[m | |
[31m * @param string|array $messages The message as an array of lines of a single string[m | |
[31m * @param integer $type The type of output[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function writeln($messages, $type = 0)[m | |
[31m {[m | |
[31m $this->write($messages, true, $type);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Writes a message to the output.[m | |
[31m *[m | |
[31m * @param string|array $messages The message as an array of lines of a single string[m | |
[31m * @param Boolean $newline Whether to add a newline or not[m | |
[31m * @param integer $type The type of output[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When unknown output type is given[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function write($messages, $newline = false, $type = 0)[m | |
[31m {[m | |
[31m if (self::VERBOSITY_QUIET === $this->verbosity) {[m | |
[31m return;[m | |
[31m }[m | |
[31m $messages = (array) $messages;[m | |
[31m foreach ($messages as $message) {[m | |
[31m switch ($type) {[m | |
[31m case OutputInterface::OUTPUT_NORMAL:[m | |
[31m $message = $this->formatter->format($message);[m | |
[31m break;[m | |
[31m case OutputInterface::OUTPUT_RAW:[m | |
[31m break;[m | |
[31m case OutputInterface::OUTPUT_PLAIN:[m | |
[31m $message = strip_tags($this->formatter->format($message));[m | |
[31m break;[m | |
[31m default:[m | |
[31m throw new \InvalidArgumentException(sprintf('Unknown output type given (%s)', $type));[m | |
[31m }[m | |
[31m $this->doWrite($message, $newline);[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Writes a message to the output.[m | |
[31m *[m | |
[31m * @param string $message A message to write to the output[m | |
[31m * @param Boolean $newline Whether to add a newline or not[m | |
[31m */[m | |
[31m abstract public function doWrite($message, $newline);[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Output/OutputInterface.php b/vendor/Symfony/Component/Console/Output/OutputInterface.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 8423d48..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Output/OutputInterface.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,109 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Output;[m | |
[31muse Symfony\Component\Console\Formatter\OutputFormatterInterface;[m | |
[31m/**[m | |
[31m * OutputInterface is the interface implemented by all Output classes.[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31minterface OutputInterface[m | |
[31m{[m | |
[31m const VERBOSITY_QUIET = 0;[m | |
[31m const VERBOSITY_NORMAL = 1;[m | |
[31m const VERBOSITY_VERBOSE = 2;[m | |
[31m const OUTPUT_NORMAL = 0;[m | |
[31m const OUTPUT_RAW = 1;[m | |
[31m const OUTPUT_PLAIN = 2;[m | |
[31m /**[m | |
[31m * Writes a message to the output.[m | |
[31m *[m | |
[31m * @param string|array $messages The message as an array of lines of a single string[m | |
[31m * @param Boolean $newline Whether to add a newline or not[m | |
[31m * @param integer $type The type of output[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When unknown output type is given[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function write($messages, $newline = false, $type = 0);[m | |
[31m /**[m | |
[31m * Writes a message to the output and adds a newline at the end.[m | |
[31m *[m | |
[31m * @param string|array $messages The message as an array of lines of a single string[m | |
[31m * @param integer $type The type of output[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function writeln($messages, $type = 0);[m | |
[31m /**[m | |
[31m * Sets the verbosity of the output.[m | |
[31m *[m | |
[31m * @param integer $level The level of verbosity[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function setVerbosity($level);[m | |
[31m /**[m | |
[31m * Gets the current verbosity of the output.[m | |
[31m *[m | |
[31m * @return integer The current level of verbosity[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function getVerbosity();[m | |
[31m /**[m | |
[31m * Sets the decorated flag.[m | |
[31m *[m | |
[31m * @param Boolean $decorated Whether to decorate the messages or not[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function setDecorated($decorated);[m | |
[31m /**[m | |
[31m * Gets the decorated flag.[m | |
[31m *[m | |
[31m * @return Boolean true if the output will decorate messages, false otherwise[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function isDecorated();[m | |
[31m /**[m | |
[31m * Sets output formatter.[m | |
[31m *[m | |
[31m * @param OutputFormatterInterface $formatter[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function setFormatter(OutputFormatterInterface $formatter);[m | |
[31m /**[m | |
[31m * Returns current output formatter instance.[m | |
[31m *[m | |
[31m * @return OutputFormatterInterface[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m function getFormatter();[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Output/StreamOutput.php b/vendor/Symfony/Component/Console/Output/StreamOutput.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex de1720f..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Output/StreamOutput.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,113 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Output;[m | |
[31muse Symfony\Component\Console\Formatter\OutputFormatterInterface;[m | |
[31m/**[m | |
[31m * StreamOutput writes the output to a given stream.[m | |
[31m *[m | |
[31m * Usage:[m | |
[31m *[m | |
[31m * $output = new StreamOutput(fopen('php://stdout', 'w'));[m | |
[31m *[m | |
[31m * As `StreamOutput` can use any stream, you can also use a file:[m | |
[31m *[m | |
[31m * $output = new StreamOutput(fopen('/path/to/output.log', 'a', false));[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31mclass StreamOutput extends Output[m | |
[31m{[m | |
[31m private $stream;[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * @param mixed $stream A stream resource[m | |
[31m * @param integer $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL,[m | |
[31m * self::VERBOSITY_VERBOSE)[m | |
[31m * @param Boolean $decorated Whether to decorate messages or not (null for auto-guessing)[m | |
[31m * @param OutputFormatter $formatter Output formatter instance[m | |
[31m *[m | |
[31m * @throws \InvalidArgumentException When first argument is not a real stream[m | |
[31m *[m | |
[31m * @api[m | |
[31m */[m | |
[31m public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)[m | |
[31m {[m | |
[31m if (!is_resource($stream) || 'stream' !== get_resource_type($stream)) {[m | |
[31m throw new \InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');[m | |
[31m }[m | |
[31m $this->stream = $stream;[m | |
[31m if (null === $decorated) {[m | |
[31m $decorated = $this->hasColorSupport($decorated);[m | |
[31m }[m | |
[31m parent::__construct($verbosity, $decorated, $formatter);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the stream attached to this StreamOutput instance.[m | |
[31m *[m | |
[31m * @return resource A stream resource[m | |
[31m */[m | |
[31m public function getStream()[m | |
[31m {[m | |
[31m return $this->stream;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Writes a message to the output.[m | |
[31m *[m | |
[31m * @param string $message A message to write to the output[m | |
[31m * @param Boolean $newline Whether to add a newline or not[m | |
[31m *[m | |
[31m * @throws \RuntimeException When unable to write output (should never happen)[m | |
[31m */[m | |
[31m public function doWrite($message, $newline)[m | |
[31m {[m | |
[31m if (false === @fwrite($this->stream, $message.($newline ? PHP_EOL : ''))) {[m | |
[31m // @codeCoverageIgnoreStart[m | |
[31m // should never happen[m | |
[31m throw new \RuntimeException('Unable to write output.');[m | |
[31m // @codeCoverageIgnoreEnd[m | |
[31m }[m | |
[31m fflush($this->stream);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns true if the stream supports colorization.[m | |
[31m *[m | |
[31m * Colorization is disabled if not supported by the stream:[m | |
[31m *[m | |
[31m * - windows without ansicon[m | |
[31m * - non tty consoles[m | |
[31m *[m | |
[31m * @return Boolean true if the stream supports colorization, false otherwise[m | |
[31m */[m | |
[31m protected function hasColorSupport()[m | |
[31m {[m | |
[31m // @codeCoverageIgnoreStart[m | |
[31m if (DIRECTORY_SEPARATOR == '\\') {[m | |
[31m return false !== getenv('ANSICON');[m | |
[31m }[m | |
[31m return function_exists('posix_isatty') && @posix_isatty($this->stream);[m | |
[31m // @codeCoverageIgnoreEnd[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/README.md b/vendor/Symfony/Component/Console/README.md[m | |
[1mdeleted file mode 100755[m | |
[1mindex d903776..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/README.md[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,48 +0,0 @@[m | |
[31mConsole Component[m | |
[31m=================[m | |
[31mConsole eases the creation of beautiful and testable command line interfaces.[m | |
[31mThe Application object manages the CLI application:[m | |
[31m use Symfony\Component\Console\Application;[m | |
[31m $console = new Application();[m | |
[31m $console->run();[m | |
[31mThe ``run()`` method parses the arguments and options passed on the command[m | |
[31mline and executes the right command.[m | |
[31mRegistering a new command can easily be done via the ``register()`` method,[m | |
[31mwhich returns a ``Command`` instance:[m | |
[31m use Symfony\Component\Console\Input\InputInterface;[m | |
[31m use Symfony\Component\Console\Input\InputArgument;[m | |
[31m use Symfony\Component\Console\Input\InputOption;[m | |
[31m use Symfony\Component\Console\Output\OutputInterface;[m | |
[31m $console[m | |
[31m ->register('ls')[m | |
[31m ->setDefinition(array([m | |
[31m new InputArgument('dir', InputArgument::REQUIRED, 'Directory name'),[m | |
[31m ))[m | |
[31m ->setDescription('Displays the files in the given directory')[m | |
[31m ->setCode(function (InputInterface $input, OutputInterface $output) {[m | |
[31m $dir = $input->getArgument('dir');[m | |
[31m $output->writeln(sprintf('Dir listing for <info>%s</info>', $dir));[m | |
[31m })[m | |
[31m ;[m | |
[31mYou can also register new commands via classes.[m | |
[31mThe component provides a lot of features like output coloring, input and[m | |
[31moutput abstractions (so that you can easily unit-test your commands),[m | |
[31mvalidation, automatic help messages, ...[m | |
[31mResources[m | |
[31m---------[m | |
[31mUnit tests:[m | |
[31mhttps://github.com/symfony/symfony/tree/master/tests/Symfony/Tests/Component/Console[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Shell.php b/vendor/Symfony/Component/Console/Shell.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 6b89b04..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Shell.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,206 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console;[m | |
[31muse Symfony\Component\Console\Application;[m | |
[31muse Symfony\Component\Console\Input\StringInput;[m | |
[31muse Symfony\Component\Console\Output\ConsoleOutput;[m | |
[31muse Symfony\Component\Process\ProcessBuilder;[m | |
[31muse Symfony\Component\Process\PhpExecutableFinder;[m | |
[31m/**[m | |
[31m * A Shell wraps an Application to add shell capabilities to it.[m | |
[31m *[m | |
[31m * Support for history and completion only works with a PHP compiled[m | |
[31m * with readline support (either --with-readline or --with-libedit)[m | |
[31m *[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m * @author Martin Hasoň <[email protected]>[m | |
[31m */[m | |
[31mclass Shell[m | |
[31m{[m | |
[31m private $application;[m | |
[31m private $history;[m | |
[31m private $output;[m | |
[31m private $hasReadline;[m | |
[31m private $prompt;[m | |
[31m private $processIsolation;[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * If there is no readline support for the current PHP executable[m | |
[31m * a \RuntimeException exception is thrown.[m | |
[31m *[m | |
[31m * @param Application $application An application instance[m | |
[31m */[m | |
[31m public function __construct(Application $application)[m | |
[31m {[m | |
[31m $this->hasReadline = function_exists('readline');[m | |
[31m $this->application = $application;[m | |
[31m $this->history = getenv('HOME').'/.history_'.$application->getName();[m | |
[31m $this->output = new ConsoleOutput();[m | |
[31m $this->prompt = $application->getName().' > ';[m | |
[31m $this->processIsolation = false;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Runs the shell.[m | |
[31m */[m | |
[31m public function run()[m | |
[31m {[m | |
[31m $this->application->setAutoExit(false);[m | |
[31m $this->application->setCatchExceptions(true);[m | |
[31m if ($this->hasReadline) {[m | |
[31m readline_read_history($this->history);[m | |
[31m readline_completion_function(array($this, 'autocompleter'));[m | |
[31m }[m | |
[31m $this->output->writeln($this->getHeader());[m | |
[31m $php = null;[m | |
[31m if ($this->processIsolation) {[m | |
[31m $finder = new PhpExecutableFinder();[m | |
[31m $php = $finder->find();[m | |
[31m $this->output->writeln(<<<EOF[m | |
[31m<info>Running with process isolation, you should consider this:</info>[m | |
[31m * each command is executed as separate process,[m | |
[31m * commands don't support interactivity, all params must be passed explicitly,[m | |
[31m * commands output is not colorized.[m | |
[31mEOF[m | |
[31m );[m | |
[31m }[m | |
[31m while (true) {[m | |
[31m $command = $this->readline();[m | |
[31m if (false === $command) {[m | |
[31m $this->output->writeln("\n");[m | |
[31m break;[m | |
[31m }[m | |
[31m if ($this->hasReadline) {[m | |
[31m readline_add_history($command);[m | |
[31m readline_write_history($this->history);[m | |
[31m }[m | |
[31m if ($this->processIsolation) {[m | |
[31m $pb = new ProcessBuilder();[m | |
[31m $process = $pb[m | |
[31m ->add($php)[m | |
[31m ->add($_SERVER['argv'][0])[m | |
[31m ->add($command)[m | |
[31m ->inheritEnvironmentVariables(true)[m | |
[31m ->getProcess()[m | |
[31m ;[m | |
[31m $output = $this->output;[m | |
[31m $process->run(function($type, $data) use ($output) {[m | |
[31m $output->writeln($data);[m | |
[31m });[m | |
[31m $ret = $process->getExitCode();[m | |
[31m } else {[m | |
[31m $ret = $this->application->run(new StringInput($command), $this->output);[m | |
[31m }[m | |
[31m if (0 !== $ret) {[m | |
[31m $this->output->writeln(sprintf('<error>The command terminated with an error status (%s)</error>', $ret));[m | |
[31m }[m | |
[31m }[m | |
[31m }[m | |
[31m /**[m | |
[31m * Returns the shell header.[m | |
[31m *[m | |
[31m * @return string The header string[m | |
[31m */[m | |
[31m protected function getHeader()[m | |
[31m {[m | |
[31m return <<<EOF[m | |
[31mWelcome to the <info>{$this->application->getName()}</info> shell (<comment>{$this->application->getVersion()}</comment>).[m | |
[31mAt the prompt, type <comment>help</comment> for some help,[m | |
[31mor <comment>list</comment> to get a list of available commands.[m | |
[31mTo exit the shell, type <comment>^D</comment>.[m | |
[31mEOF;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Tries to return autocompletion for the current entered text.[m | |
[31m *[m | |
[31m * @param string $text The last segment of the entered text[m | |
[31m * @return Boolean|array A list of guessed strings or true[m | |
[31m */[m | |
[31m private function autocompleter($text)[m | |
[31m {[m | |
[31m $info = readline_info();[m | |
[31m $text = substr($info['line_buffer'], 0, $info['end']);[m | |
[31m if ($info['point'] !== $info['end']) {[m | |
[31m return true;[m | |
[31m }[m | |
[31m // task name?[m | |
[31m if (false === strpos($text, ' ') || !$text) {[m | |
[31m return array_keys($this->application->all());[m | |
[31m }[m | |
[31m // options and arguments?[m | |
[31m try {[m | |
[31m $command = $this->application->find(substr($text, 0, strpos($text, ' ')));[m | |
[31m } catch (\Exception $e) {[m | |
[31m return true;[m | |
[31m }[m | |
[31m $list = array('--help');[m | |
[31m foreach ($command->getDefinition()->getOptions() as $option) {[m | |
[31m $list[] = '--'.$option->getName();[m | |
[31m }[m | |
[31m return $list;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Reads a single line from standard input.[m | |
[31m *[m | |
[31m * @return string The single line from standard input[m | |
[31m */[m | |
[31m private function readline()[m | |
[31m {[m | |
[31m if ($this->hasReadline) {[m | |
[31m $line = readline($this->prompt);[m | |
[31m } else {[m | |
[31m $this->output->write($this->prompt);[m | |
[31m $line = fgets(STDIN, 1024);[m | |
[31m $line = (!$line && strlen($line) == 0) ? false : rtrim($line);[m | |
[31m }[m | |
[31m return $line;[m | |
[31m }[m | |
[31m public function getProcessIsolation()[m | |
[31m {[m | |
[31m return $this->processIsolation;[m | |
[31m }[m | |
[31m public function setProcessIsolation($processIsolation)[m | |
[31m {[m | |
[31m $this->processIsolation = (Boolean) $processIsolation;[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Tester/ApplicationTester.php b/vendor/Symfony/Component/Console/Tester/ApplicationTester.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 9412fba..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Tester/ApplicationTester.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,102 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Tester;[m | |
[31muse Symfony\Component\Console\Application;[m | |
[31muse Symfony\Component\Console\Input\ArrayInput;[m | |
[31muse Symfony\Component\Console\Input\InputInterface;[m | |
[31muse Symfony\Component\Console\Output\OutputInterface;[m | |
[31muse Symfony\Component\Console\Output\StreamOutput;[m | |
[31m/**[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m */[m | |
[31mclass ApplicationTester[m | |
[31m{[m | |
[31m private $application;[m | |
[31m private $input;[m | |
[31m private $output;[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * @param Application $application An Application instance to test.[m | |
[31m */[m | |
[31m public function __construct(Application $application)[m | |
[31m {[m | |
[31m $this->application = $application;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Executes the application.[m | |
[31m *[m | |
[31m * Available options:[m | |
[31m *[m | |
[31m * * interactive: Sets the input interactive flag[m | |
[31m * * decorated: Sets the output decorated flag[m | |
[31m * * verbosity: Sets the output verbosity flag[m | |
[31m *[m | |
[31m * @param array $input An array of arguments and options[m | |
[31m * @param array $options An array of options[m | |
[31m *[m | |
[31m * @return integer The command exit code[m | |
[31m */[m | |
[31m public function run(array $input, $options = array())[m | |
[31m {[m | |
[31m $this->input = new ArrayInput($input);[m | |
[31m if (isset($options['interactive'])) {[m | |
[31m $this->input->setInteractive($options['interactive']);[m | |
[31m }[m | |
[31m $this->output = new StreamOutput(fopen('php://memory', 'w', false));[m | |
[31m if (isset($options['decorated'])) {[m | |
[31m $this->output->setDecorated($options['decorated']);[m | |
[31m }[m | |
[31m if (isset($options['verbosity'])) {[m | |
[31m $this->output->setVerbosity($options['verbosity']);[m | |
[31m }[m | |
[31m return $this->application->run($this->input, $this->output);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the display returned by the last execution of the application.[m | |
[31m *[m | |
[31m * @return string The display[m | |
[31m */[m | |
[31m public function getDisplay()[m | |
[31m {[m | |
[31m rewind($this->output->getStream());[m | |
[31m return stream_get_contents($this->output->getStream());[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the input instance used by the last execution of the application.[m | |
[31m *[m | |
[31m * @return InputInterface The current input instance[m | |
[31m */[m | |
[31m public function getInput()[m | |
[31m {[m | |
[31m return $this->input;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the output instance used by the last execution of the application.[m | |
[31m *[m | |
[31m * @return OutputInterface The current output instance[m | |
[31m */[m | |
[31m public function getOutput()[m | |
[31m {[m | |
[31m return $this->output;[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/Tester/CommandTester.php b/vendor/Symfony/Component/Console/Tester/CommandTester.php[m | |
[1mdeleted file mode 100755[m | |
[1mindex 52be278..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/Tester/CommandTester.php[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,100 +0,0 @@[m | |
[31m<?php[m | |
[31m/*[m | |
[31m * This file is part of the Symfony package.[m | |
[31m *[m | |
[31m * (c) Fabien Potencier <[email protected]>[m | |
[31m *[m | |
[31m * For the full copyright and license information, please view the LICENSE[m | |
[31m * file that was distributed with this source code.[m | |
[31m */[m | |
[31mnamespace Symfony\Component\Console\Tester;[m | |
[31muse Symfony\Component\Console\Command\Command;[m | |
[31muse Symfony\Component\Console\Input\ArrayInput;[m | |
[31muse Symfony\Component\Console\Output\StreamOutput;[m | |
[31m/**[m | |
[31m * @author Fabien Potencier <[email protected]>[m | |
[31m */[m | |
[31mclass CommandTester[m | |
[31m{[m | |
[31m private $command;[m | |
[31m private $input;[m | |
[31m private $output;[m | |
[31m /**[m | |
[31m * Constructor.[m | |
[31m *[m | |
[31m * @param Command $command A Command instance to test.[m | |
[31m */[m | |
[31m public function __construct(Command $command)[m | |
[31m {[m | |
[31m $this->command = $command;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Executes the command.[m | |
[31m *[m | |
[31m * Available options:[m | |
[31m *[m | |
[31m * * interactive: Sets the input interactive flag[m | |
[31m * * decorated: Sets the output decorated flag[m | |
[31m * * verbosity: Sets the output verbosity flag[m | |
[31m *[m | |
[31m * @param array $input An array of arguments and options[m | |
[31m * @param array $options An array of options[m | |
[31m *[m | |
[31m * @return integer The command exit code[m | |
[31m */[m | |
[31m public function execute(array $input, array $options = array())[m | |
[31m {[m | |
[31m $this->input = new ArrayInput($input);[m | |
[31m if (isset($options['interactive'])) {[m | |
[31m $this->input->setInteractive($options['interactive']);[m | |
[31m }[m | |
[31m $this->output = new StreamOutput(fopen('php://memory', 'w', false));[m | |
[31m if (isset($options['decorated'])) {[m | |
[31m $this->output->setDecorated($options['decorated']);[m | |
[31m }[m | |
[31m if (isset($options['verbosity'])) {[m | |
[31m $this->output->setVerbosity($options['verbosity']);[m | |
[31m }[m | |
[31m return $this->command->run($this->input, $this->output);[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the display returned by the last execution of the command.[m | |
[31m *[m | |
[31m * @return string The display[m | |
[31m */[m | |
[31m public function getDisplay()[m | |
[31m {[m | |
[31m rewind($this->output->getStream());[m | |
[31m return stream_get_contents($this->output->getStream());[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the input instance used by the last execution of the command.[m | |
[31m *[m | |
[31m * @return InputInterface The current input instance[m | |
[31m */[m | |
[31m public function getInput()[m | |
[31m {[m | |
[31m return $this->input;[m | |
[31m }[m | |
[31m /**[m | |
[31m * Gets the output instance used by the last execution of the command.[m | |
[31m *[m | |
[31m * @return OutputInterface The current output instance[m | |
[31m */[m | |
[31m public function getOutput()[m | |
[31m {[m | |
[31m return $this->output;[m | |
[31m }[m | |
[31m}[m | |
[1mdiff --git a/vendor/Symfony/Component/Console/composer.json b/vendor/Symfony/Component/Console/composer.json[m | |
[1mdeleted file mode 100755[m | |
[1mindex 961212e..0000000[m | |
[1m--- a/vendor/Symfony/Component/Console/composer.json[m | |
[1m+++ /dev/null[m | |
[36m@@ -1,30 +0,0 @@[m | |
[31m{[m | |
[31m "name": "symfony/console",[m | |
[31m "type": "library",[m | |
[31m "description": "Symfony Console Component",[m | |
[31m "keywords": [],[m | |
[31m "homepage": "http://symfony.com",[m | |
[31m "license": "MIT",[m | |
[31m "authors": [[m | |
[31m {[m | |
[31m "name": "Fabien Potencier",[m | |
[31m "email": "[email protected]"[m | |
[31m },[m | |
[31m {[m | |
[31m "name": "Symfony Community",[m | |
[31m "homepage": "http://symfony.com/contributors"[m | |
[31m }[m | |
[31m ],[m | |
[31m "require": {[m | |
[31m "php": ">=5.3.2"[m | |
[31m },[m | |
[31m "autoload": {[m | |
[31m "psr-0": { "Symfony\\Component\\Console": "" }[m | |
[31m },[m | |
[31m "target-dir": "Symfony/Component/Console",[m | |
[31m "extra": {[m | |
[31m "branch-alias": {[m | |
[31m "dev-master": "2.1-dev"[m | |
[31m }[m | |
[31m }[m | |
[31m}[m | |
diff --git a/application/bundles.php b/application/bundles.php | |
index 49d126b..e8b8f26 100755 | |
--- a/application/bundles.php | |
+++ b/application/bundles.php | |
@@ -33,4 +33,8 @@ | |
| | |
*/ | |
-return array(); | |
\ No newline at end of file | |
+return array( | |
+ | |
+ 'docs' => array('handles' => 'docs'), | |
+ | |
+); | |
\ No newline at end of file | |
diff --git a/application/config/application.php b/application/config/application.php | |
index c5f5a3b..57b0829 100755 | |
--- a/application/config/application.php | |
+++ b/application/config/application.php | |
@@ -17,6 +17,19 @@ return array( | |
/* | |
|-------------------------------------------------------------------------- | |
+ | Asset URL | |
+ |-------------------------------------------------------------------------- | |
+ | | |
+ | The base URL used for your application's asset files. This is useful if | |
+ | you are serving your assets through a different server or a CDN. If it | |
+ | is not set, we'll default to the application URL above. | |
+ | | |
+ */ | |
+ | |
+ 'asset_url' => '', | |
+ | |
+ /* | |
+ |-------------------------------------------------------------------------- | |
| Application Index | |
|-------------------------------------------------------------------------- | |
| | |
@@ -38,16 +51,26 @@ return array( | |
| remain secret and should not be shared with anyone. Make it about 32 | |
| characters of random gibberish. | |
| | |
- | The "auto_key" option tells Laravel to automatically set this key value | |
- | if one has not already been set. This is generally done on the first | |
- | request to the Laravel splash screen. | |
- | | |
*/ | |
'key' => 'YourSecretKeyGoesHere!', | |
/* | |
|-------------------------------------------------------------------------- | |
+ | Profiler Toolbar | |
+ |-------------------------------------------------------------------------- | |
+ | | |
+ | Laravel includes a beautiful profiler toolbar that gives you a heads | |
+ | up display of the queries and logs performed by your application. | |
+ | This is wonderful for development, but, of course, you should | |
+ | disable the toolbar for production applications.. | |
+ | | |
+ */ | |
+ | |
+ 'profiler' => false, | |
+ | |
+ /* | |
+ |-------------------------------------------------------------------------- | |
| Application Character Encoding | |
|-------------------------------------------------------------------------- | |
| | |
@@ -140,6 +163,7 @@ return array( | |
'Log' => 'Laravel\\Log', | |
'Memcached' => 'Laravel\\Memcached', | |
'Paginator' => 'Laravel\\Paginator', | |
+ 'Profiler' => 'Laravel\\Profiling\\Profiler', | |
'URL' => 'Laravel\\URL', | |
'Redirect' => 'Laravel\\Redirect', | |
'Redis' => 'Laravel\\Redis', | |
@@ -157,4 +181,4 @@ return array( | |
'View' => 'Laravel\\View', | |
), | |
-); | |
\ No newline at end of file | |
+); | |
diff --git a/application/config/auth.php b/application/config/auth.php | |
index d013758..0c07c47 100755 | |
--- a/application/config/auth.php | |
+++ b/application/config/auth.php | |
@@ -4,78 +4,57 @@ return array( | |
/* | |
|-------------------------------------------------------------------------- | |
- | Retrieve The Current User | |
+ | Default Authentication Driver | |
|-------------------------------------------------------------------------- | |
| | |
- | This closure is called by the Auth class' "user" method when trying to | |
- | retrieve a user by the ID that is stored in their session. If you find | |
- | the user, just return the user object, but make sure it has an "id" | |
- | property. If you can't find the user, just return null. | |
+ | Laravel uses a flexible driver-based system to handle authentication. | |
+ | You are free to register your own drivers using the Auth::extend | |
+ | method. Of course, a few great drivers are provided out of | |
+ | box to handle basic authentication simply and easily. | |
| | |
- | Of course, a simple and elegant authentication solution has already | |
- | been provided for you using the query builder and hashing engine. | |
- | We love making your life as easy as possible. | |
+ | Drivers: 'fluent', 'eloquent'. | |
| | |
*/ | |
- 'user' => function($id) | |
- { | |
- if (filter_var($id, FILTER_VALIDATE_INT) !== false) | |
- { | |
- return DB::table('users')->find($id); | |
- } | |
- }, | |
+ 'driver' => 'eloquent', | |
/* | |
|-------------------------------------------------------------------------- | |
- | Authenticate User Credentials | |
+ | Authentication Username | |
|-------------------------------------------------------------------------- | |
| | |
- | This closure is called by the Auth::attempt() method when attempting to | |
- | authenticate a user that is logging into your application. It's like a | |
- | super buff bouncer to your application. | |
- | | |
- | If the provided credentials are correct, simply return an object that | |
- | represents the user being authenticated. As long as it has a property | |
- | for the "id", any object will work. If the credentials are not valid, | |
- | you don't meed to return anything. | |
+ | Here you may specify the database column that should be considered the | |
+ | "username" for your users. Typically, this will either be "username" | |
+ | or "email". Of course, you're free to change the value to anything. | |
| | |
*/ | |
- 'attempt' => function($username, $password) | |
- { | |
- $user = DB::table('users')->where_username($username)->first(); | |
- | |
- if ( ! is_null($user) and Hash::check($password, $user->password)) | |
- { | |
- return $user; | |
- } | |
- }, | |
+ 'username' => 'email', | |
/* | |
|-------------------------------------------------------------------------- | |
- | Logout The Current User | |
+ | Authentication Model | |
|-------------------------------------------------------------------------- | |
| | |
- | Here you may do anything that needs to be done when a user logs out of | |
- | your application, such as call the logout method on a third-party API | |
- | you are using for authentication or anything else you desire. | |
+ | When using the "eloquent" authentication driver, you may specify the | |
+ | model that should be considered the "User" model. This model will | |
+ | be used to authenticate and load the users of your application. | |
| | |
*/ | |
- 'logout' => function($user) {}, | |
+ 'model' => 'User', | |
/* | |
|-------------------------------------------------------------------------- | |
- | "Remember Me" Cookie Name | |
+ | Authentication Table | |
|-------------------------------------------------------------------------- | |
| | |
- | Here you may specify the cookie name that will be used for the cookie | |
- | that serves as the "remember me" token. Of course, a sensible default | |
- | has been set for you, so you probably don't need to change it. | |
+ | When using the "fluent" authentication driver, the database table used | |
+ | to load users may be specified here. This table will be used in by | |
+ | the fluent query builder to authenticate and load your users. | |
| | |
*/ | |
- 'cookie' => 'laravel_remember', | |
+ 'table' => 'users', | |
); | |
\ No newline at end of file | |
diff --git a/application/config/session.php b/application/config/session.php | |
index 6a5af5a..ea686f8 100755 | |
--- a/application/config/session.php | |
+++ b/application/config/session.php | |
@@ -16,7 +16,7 @@ return array( | |
| | |
*/ | |
- 'driver' => '', | |
+ 'driver' => 'cookie', | |
/* | |
|-------------------------------------------------------------------------- | |
diff --git a/application/config/strings.php b/application/config/strings.php | |
index 730f973..5d94f81 100755 | |
--- a/application/config/strings.php | |
+++ b/application/config/strings.php | |
@@ -95,6 +95,7 @@ return array( | |
'series', | |
'sheep', | |
'species', | |
+ 'moose', | |
), | |
/* | |
diff --git a/application/routes.php b/application/routes.php | |
index 91d17aa..2135969 100755 | |
--- a/application/routes.php | |
+++ b/application/routes.php | |
@@ -6,9 +6,8 @@ | |
|-------------------------------------------------------------------------- | |
| | |
| Simply tell Laravel the HTTP verbs and URIs it should respond to. It is a | |
-| breeze to setup your applications using Laravel's RESTful routing, and it | |
-| is perfectly suited for building both large applications and simple APIs. | |
-| Enjoy the fresh air and simplicity of the framework. | |
+| breeze to setup your application using Laravel's RESTful routing and it | |
+| is perfectly suited for building large applications and simple APIs. | |
| | |
| Let's respond to a simple GET request to http://example.com/hello: | |
| | |
@@ -19,7 +18,7 @@ | |
| | |
| You can even respond to more than one URI: | |
| | |
-| Route::post('hello, world', function() | |
+| Route::post(array('hello', 'world'), function() | |
| { | |
| return 'Hello World!'; | |
| }); | |
@@ -69,9 +68,9 @@ Event::listen('500', function() | |
|-------------------------------------------------------------------------- | |
| | |
| Filters provide a convenient method for attaching functionality to your | |
-| routes. The built-in "before" and "after" filters are called before and | |
-| after every request to your application, and you may even create other | |
-| filters that can be attached to individual routes. | |
+| routes. The built-in before and after filters are called before and | |
+| after every request to your application, and you may even create | |
+| other filters that can be attached to individual routes. | |
| | |
| Let's walk through an example... | |
| | |
diff --git a/application/start.php b/application/start.php | |
index 085dd09..6bb648b 100755 | |
--- a/application/start.php | |
+++ b/application/start.php | |
@@ -114,6 +114,22 @@ Event::listen(Lang::loader, function($bundle, $language, $file) | |
/* | |
|-------------------------------------------------------------------------- | |
+| Attach The Laravel Profiler | |
+|-------------------------------------------------------------------------- | |
+| | |
+| If the profiler is enabled, we will attach it to the Laravel events | |
+| for both queries and logs. This allows the profiler to intercept | |
+| any of the queries or logs performed by the application. | |
+| | |
+*/ | |
+ | |
+if (Config::get('application.profiler')) | |
+{ | |
+ Profiler::attach(); | |
+} | |
+ | |
+/* | |
+|-------------------------------------------------------------------------- | |
| Enable The Blade View Engine | |
|-------------------------------------------------------------------------- | |
| | |
diff --git a/application/views/error/404.php b/application/views/error/404.php | |
index 9b9bf55..ade2026 100755 | |
--- a/application/views/error/404.php | |
+++ b/application/views/error/404.php | |
@@ -1,92 +1,113 @@ | |
<!doctype html> | |
-<html> | |
- <head> | |
- <meta charset="utf-8"> | |
- | |
- <title>Error 404 - Not Found</title> | |
- | |
- <style> | |
- @import url(http://fonts.googleapis.com/css?family=Ubuntu); | |
- | |
- body { | |
- background: #eee; | |
- color: #6d6d6d; | |
- font: normal normal normal 14px/1.253 Ubuntu, sans-serif; | |
- margin: 0 0 25px 0; | |
- min-width: 800px; | |
- padding: 0; | |
- } | |
- | |
- #main { | |
- background-clip: padding-box; | |
- background-color: #fff; | |
- border:1px solid #ccc; | |
- border-radius: 5px; | |
- box-shadow: 0 0 10px #cdcdcd; | |
- margin: 25px auto 0; | |
- padding: 30px; | |
- width: 700px; | |
- position: relative; | |
- } | |
- | |
- #main h1 { | |
- font-family: 'Ubuntu'; | |
- font-size: 38px; | |
- letter-spacing: 2px; | |
- margin: 0 0 10px 0; | |
- padding: 0; | |
- } | |
- | |
- #main h2 { | |
- color: #999; | |
- font-size: 18px; | |
- letter-spacing: 3px; | |
- margin: 0 0 25px 0; | |
- padding: 0 0 0 0; | |
- } | |
- | |
- #main h3 { | |
- color: #999; | |
- margin-top: 24px; | |
- padding: 0 0 0 0; | |
- } | |
- | |
- #main h3 { | |
- font-size: 18px; | |
- } | |
- | |
- #main p { | |
- line-height: 25px; | |
- margin: 10px 0; | |
- } | |
- | |
- #main pre { | |
- background-color: #333; | |
- border-left: 1px solid #d8d8d8; | |
- border-top: 1px solid #d8d8d8; | |
- border-radius: 5px; | |
- color: #eee; | |
- padding: 10px; | |
- } | |
- | |
- #main ul { | |
- margin: 10px 0; | |
- padding: 0 30px; | |
- } | |
- | |
- #main li { | |
- margin: 5px 0; | |
- } | |
- </style> | |
- </head> | |
- <body> | |
- <div id="main"> | |
+<html lang="en"> | |
+<head> | |
+ <meta charset="utf-8"> | |
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
+ <title>Error 404 - Not Found</title> | |
+ <meta name="viewport" content="width=device-width"> | |
+ <style type="text/css"> | |
+ @import url(http://fonts.googleapis.com/css?family=Droid+Sans); | |
+ | |
+ article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { display: block; } | |
+ audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; } | |
+ audio:not([controls]) { display: none; } | |
+ [hidden] { display: none; } | |
+ html { font-size: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; } | |
+ html, button, input, select, textarea { font-family: sans-serif; color: #222; } | |
+ body { margin: 0; font-size: 1em; line-height: 1.4; } | |
+ ::-moz-selection { background: #E37B52; color: #fff; text-shadow: none; } | |
+ ::selection { background: #E37B52; color: #fff; text-shadow: none; } | |
+ a { color: #00e; } | |
+ a:visited { color: #551a8b; } | |
+ a:hover { color: #06e; } | |
+ a:focus { outline: thin dotted; } | |
+ a:hover, a:active { outline: 0; } | |
+ abbr[title] { border-bottom: 1px dotted; } | |
+ b, strong { font-weight: bold; } | |
+ blockquote { margin: 1em 40px; } | |
+ dfn { font-style: italic; } | |
+ hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; } | |
+ ins { background: #ff9; color: #000; text-decoration: none; } | |
+ mark { background: #ff0; color: #000; font-style: italic; font-weight: bold; } | |
+ pre, code, kbd, samp { font-family: monospace, serif; _font-family: 'courier new', monospace; font-size: 1em; } | |
+ pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; } | |
+ q { quotes: none; } | |
+ q:before, q:after { content: ""; content: none; } | |
+ small { font-size: 85%; } | |
+ sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } | |
+ sup { top: -0.5em; } | |
+ sub { bottom: -0.25em; } | |
+ ul, ol { margin: 1em 0; padding: 0 0 0 40px; } | |
+ dd { margin: 0 0 0 40px; } | |
+ nav ul, nav ol { list-style: none; list-style-image: none; margin: 0; padding: 0; } | |
+ img { border: 0; -ms-interpolation-mode: bicubic; vertical-align: middle; } | |
+ svg:not(:root) { overflow: hidden; } | |
+ figure { margin: 0; } | |
+ form { margin: 0; } | |
+ fieldset { border: 0; margin: 0; padding: 0; } | |
+ label { cursor: pointer; } | |
+ legend { border: 0; *margin-left: -7px; padding: 0; white-space: normal; } | |
+ button, input, select, textarea { font-size: 100%; margin: 0; vertical-align: baseline; *vertical-align: middle; } | |
+ button, input { line-height: normal; } | |
+ button, input[type="button"], input[type="reset"], input[type="submit"] { cursor: pointer; -webkit-appearance: button; *overflow: visible; } | |
+ button[disabled], input[disabled] { cursor: default; } | |
+ input[type="checkbox"], input[type="radio"] { box-sizing: border-box; padding: 0; *width: 13px; *height: 13px; } | |
+ input[type="search"] { -webkit-appearance: textfield; -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; } | |
+ input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; } | |
+ button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; } | |
+ textarea { overflow: auto; vertical-align: top; resize: vertical; } | |
+ input:valid, textarea:valid { } | |
+ input:invalid, textarea:invalid { background-color: #f0dddd; } | |
+ table { border-collapse: collapse; border-spacing: 0; } | |
+ td { vertical-align: top; } | |
+ | |
+ body | |
+ { | |
+ font-family:'Droid Sans', sans-serif; | |
+ font-size:10pt; | |
+ color:#555; | |
+ line-height: 25px; | |
+ } | |
+ | |
+ .wrapper | |
+ { | |
+ width:760px; | |
+ margin:0 auto 5em auto; | |
+ } | |
+ | |
+ .main | |
+ { | |
+ overflow:hidden; | |
+ } | |
+ | |
+ .error-spacer | |
+ { | |
+ height:4em; | |
+ } | |
+ | |
+ a, a:visited | |
+ { | |
+ color:#2972A3; | |
+ } | |
+ | |
+ a:hover | |
+ { | |
+ color:#72ADD4; | |
+ } | |
+ </style> | |
+</head> | |
+<body> | |
+ <div class="wrapper"> | |
+ <div class="error-spacer"></div> | |
+ <div role="main" class="main"> | |
<?php $messages = array('We need a map.', 'I think we\'re lost.', 'We took a wrong turn.'); ?> | |
<h1><?php echo $messages[mt_rand(0, 2)]; ?></h1> | |
<h2>Server Error: 404 (Not Found)</h2> | |
+ <hr> | |
+ | |
<h3>What does this mean?</h3> | |
<p> | |
@@ -99,5 +120,6 @@ | |
Perhaps you would like to go to our <?php echo HTML::link('/', 'home page'); ?>? | |
</p> | |
</div> | |
- </body> | |
+ </div> | |
+</body> | |
</html> | |
\ No newline at end of file | |
diff --git a/application/views/error/500.php b/application/views/error/500.php | |
index 4dcd92a..4ce7c06 100755 | |
--- a/application/views/error/500.php | |
+++ b/application/views/error/500.php | |
@@ -1,92 +1,113 @@ | |
<!doctype html> | |
-<html> | |
- <head> | |
- <meta charset="utf-8"> | |
- | |
- <title>Error 500 - Internal Server Error</title> | |
- | |
- <style> | |
- @import url(http://fonts.googleapis.com/css?family=Ubuntu); | |
- | |
- body { | |
- background: #eee; | |
- color: #6d6d6d; | |
- font: normal normal normal 14px/1.253 Ubuntu, sans-serif; | |
- margin: 0 0 25px 0; | |
- min-width: 800px; | |
- padding: 0; | |
- } | |
- | |
- #main { | |
- background-clip: padding-box; | |
- background-color: #fff; | |
- border:1px solid #ccc; | |
- border-radius: 5px; | |
- box-shadow: 0 0 10px #cdcdcd; | |
- margin: 25px auto 0; | |
- padding: 30px; | |
- width: 700px; | |
- position: relative; | |
- } | |
- | |
- #main h1 { | |
- font-family: 'Ubuntu'; | |
- font-size: 38px; | |
- letter-spacing: 2px; | |
- margin: 0 0 10px 0; | |
- padding: 0; | |
- } | |
- | |
- #main h2 { | |
- color: #999; | |
- font-size: 18px; | |
- letter-spacing: 3px; | |
- margin: 0 0 25px 0; | |
- padding: 0 0 0 0; | |
- } | |
- | |
- #main h3 { | |
- color: #999; | |
- margin-top: 24px; | |
- padding: 0 0 0 0; | |
- } | |
- | |
- #main h3 { | |
- font-size: 18px; | |
- } | |
- | |
- #main p { | |
- line-height: 25px; | |
- margin: 10px 0; | |
- } | |
- | |
- #main pre { | |
- background-color: #333; | |
- border-left: 1px solid #d8d8d8; | |
- border-top: 1px solid #d8d8d8; | |
- border-radius: 5px; | |
- color: #eee; | |
- padding: 10px; | |
- } | |
- | |
- #main ul { | |
- margin: 10px 0; | |
- padding: 0 30px; | |
- } | |
- | |
- #main li { | |
- margin: 5px 0; | |
- } | |
- </style> | |
- </head> | |
- <body> | |
- <div id="main"> | |
+<html lang="en"> | |
+<head> | |
+ <meta charset="utf-8"> | |
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
+ <title>Error 500 - Internal Server Error</title> | |
+ <meta name="viewport" content="width=device-width"> | |
+ <style type="text/css"> | |
+ @import url(http://fonts.googleapis.com/css?family=Droid+Sans); | |
+ | |
+ article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { display: block; } | |
+ audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; } | |
+ audio:not([controls]) { display: none; } | |
+ [hidden] { display: none; } | |
+ html { font-size: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; } | |
+ html, button, input, select, textarea { font-family: sans-serif; color: #222; } | |
+ body { margin: 0; font-size: 1em; line-height: 1.4; } | |
+ ::-moz-selection { background: #E37B52; color: #fff; text-shadow: none; } | |
+ ::selection { background: #E37B52; color: #fff; text-shadow: none; } | |
+ a { color: #00e; } | |
+ a:visited { color: #551a8b; } | |
+ a:hover { color: #06e; } | |
+ a:focus { outline: thin dotted; } | |
+ a:hover, a:active { outline: 0; } | |
+ abbr[title] { border-bottom: 1px dotted; } | |
+ b, strong { font-weight: bold; } | |
+ blockquote { margin: 1em 40px; } | |
+ dfn { font-style: italic; } | |
+ hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; } | |
+ ins { background: #ff9; color: #000; text-decoration: none; } | |
+ mark { background: #ff0; color: #000; font-style: italic; font-weight: bold; } | |
+ pre, code, kbd, samp { font-family: monospace, serif; _font-family: 'courier new', monospace; font-size: 1em; } | |
+ pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; } | |
+ q { quotes: none; } | |
+ q:before, q:after { content: ""; content: none; } | |
+ small { font-size: 85%; } | |
+ sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } | |
+ sup { top: -0.5em; } | |
+ sub { bottom: -0.25em; } | |
+ ul, ol { margin: 1em 0; padding: 0 0 0 40px; } | |
+ dd { margin: 0 0 0 40px; } | |
+ nav ul, nav ol { list-style: none; list-style-image: none; margin: 0; padding: 0; } | |
+ img { border: 0; -ms-interpolation-mode: bicubic; vertical-align: middle; } | |
+ svg:not(:root) { overflow: hidden; } | |
+ figure { margin: 0; } | |
+ form { margin: 0; } | |
+ fieldset { border: 0; margin: 0; padding: 0; } | |
+ label { cursor: pointer; } | |
+ legend { border: 0; *margin-left: -7px; padding: 0; white-space: normal; } | |
+ button, input, select, textarea { font-size: 100%; margin: 0; vertical-align: baseline; *vertical-align: middle; } | |
+ button, input { line-height: normal; } | |
+ button, input[type="button"], input[type="reset"], input[type="submit"] { cursor: pointer; -webkit-appearance: button; *overflow: visible; } | |
+ button[disabled], input[disabled] { cursor: default; } | |
+ input[type="checkbox"], input[type="radio"] { box-sizing: border-box; padding: 0; *width: 13px; *height: 13px; } | |
+ input[type="search"] { -webkit-appearance: textfield; -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; } | |
+ input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; } | |
+ button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; } | |
+ textarea { overflow: auto; vertical-align: top; resize: vertical; } | |
+ input:valid, textarea:valid { } | |
+ input:invalid, textarea:invalid { background-color: #f0dddd; } | |
+ table { border-collapse: collapse; border-spacing: 0; } | |
+ td { vertical-align: top; } | |
+ | |
+ body | |
+ { | |
+ font-family:'Droid Sans', sans-serif; | |
+ font-size:10pt; | |
+ color:#555; | |
+ line-height: 25px; | |
+ } | |
+ | |
+ .wrapper | |
+ { | |
+ width:760px; | |
+ margin:0 auto 5em auto; | |
+ } | |
+ | |
+ .main | |
+ { | |
+ overflow:hidden; | |
+ } | |
+ | |
+ .error-spacer | |
+ { | |
+ height:4em; | |
+ } | |
+ | |
+ a, a:visited | |
+ { | |
+ color:#2972A3; | |
+ } | |
+ | |
+ a:hover | |
+ { | |
+ color:#72ADD4; | |
+ } | |
+ </style> | |
+</head> | |
+<body> | |
+ <div class="wrapper"> | |
+ <div class="error-spacer"></div> | |
+ <div role="main" class="main"> | |
<?php $messages = array('Ouch.', 'Oh no!', 'Whoops!'); ?> | |
<h1><?php echo $messages[mt_rand(0, 2)]; ?></h1> | |
<h2>Server Error: 500 (Internal Server Error)</h2> | |
+ <hr> | |
+ | |
<h3>What does this mean?</h3> | |
<p> | |
@@ -99,5 +120,6 @@ | |
Perhaps you would like to go to our <?php echo HTML::link('/', 'home page'); ?>? | |
</p> | |
</div> | |
- </body> | |
+ </div> | |
+</body> | |
</html> | |
\ No newline at end of file | |
diff --git a/application/views/home/index.php b/application/views/home/index.php | |
deleted file mode 100755 | |
index 156c36a..0000000 | |
--- a/application/views/home/index.php | |
+++ /dev/null | |
@@ -1,129 +0,0 @@ | |
-<!doctype html> | |
-<html> | |
- <head> | |
- <meta charset="utf-8"> | |
- | |
- <title>Laravel - A Framework For Web Artisans</title> | |
- | |
- <style> | |
- @import url(http://fonts.googleapis.com/css?family=Ubuntu); | |
- | |
- body { | |
- background: #eee; | |
- color: #6d6d6d; | |
- font: normal normal normal 14px/1.253 Ubuntu, sans-serif; | |
- margin: 0 0 25px 0; | |
- min-width: 800px; | |
- padding: 0; | |
- } | |
- | |
- #main { | |
- background-clip: padding-box; | |
- background-color: #fff; | |
- border:1px solid #ccc; | |
- border-radius: 5px; | |
- box-shadow: 0 0 10px #cdcdcd; | |
- margin: 25px auto 0; | |
- padding: 30px; | |
- width: 700px; | |
- position: relative; | |
- } | |
- | |
- #main h1 { | |
- font-family: 'Ubuntu'; | |
- font-size: 38px; | |
- letter-spacing: 2px; | |
- margin: 0 0 10px 0; | |
- padding: 0; | |
- } | |
- | |
- #main h2 { | |
- color: #999; | |
- font-size: 18px; | |
- letter-spacing: 3px; | |
- margin: 0 0 25px 0; | |
- padding: 0 0 0 0; | |
- } | |
- | |
- #main h3 { | |
- color: #999; | |
- margin-top: 24px; | |
- padding: 0 0 0 0; | |
- } | |
- | |
- #main h3 { | |
- font-size: 18px; | |
- } | |
- | |
- #main p { | |
- line-height: 25px; | |
- margin: 10px 0; | |
- } | |
- | |
- #main pre { | |
- background-color: #333; | |
- border-left: 1px solid #d8d8d8; | |
- border-top: 1px solid #d8d8d8; | |
- border-radius: 5px; | |
- color: #eee; | |
- padding: 10px; | |
- } | |
- | |
- #main div.warning { | |
- background-color: #feefb3; | |
- border: 1px solid; | |
- border-radius: 5px; | |
- color: #9f6000; | |
- padding: 10px; | |
- } | |
- | |
- #main ul { | |
- margin: 10px 0; | |
- padding: 0 30px; | |
- } | |
- | |
- #main li { | |
- margin: 5px 0; | |
- } | |
- </style> | |
- </head> | |
- <body> | |
- <div id="main"> | |
- <h1>Welcome To Laravel</h1> | |
- | |
- <h2>A Framework For Web Artisans</h2> | |
- | |
- <p> | |
- You have successfully installed the Laravel framework. Laravel is a simple framework | |
- that helps web artisans create beautiful, creative applications using elegant, expressive | |
- syntax. You'll love using it. | |
- </p> | |
- | |
- <h3>Learn the terrain.</h3> | |
- | |
- <p> | |
- You've landed yourself on our default home page. The route that | |
- is generating this page lives at: | |
- </p> | |
- | |
- <pre><code>APP_PATH/routes.php</code></pre> | |
- | |
- <p>And the view sitting before you can be found at:</p> | |
- | |
- <pre><code>APP_PATH/views/home/index.php</code></pre> | |
- | |
- <h3>Create something beautiful.</h3> | |
- | |
- <p> | |
- Now that you're up and running, it's time to start creating! | |
- Here are some links to help you get started: | |
- </p> | |
- | |
- <ul> | |
- <li><a href="http://laravel.com">Official Website</a></li> | |
- <li><a href="http://forums.laravel.com">Laravel Forums</a></li> | |
- <li><a href="http://github.com/laravel/laravel">GitHub Repository</a></li> | |
- </ul> | |
- </div> | |
- </body> | |
-</html> | |
\ No newline at end of file | |
diff --git a/artisan b/artisan | |
index 4e82030..2bae56a 100755 | |
--- a/artisan | |
+++ b/artisan | |
@@ -3,7 +3,7 @@ | |
* Laravel - A PHP Framework For Web Artisans | |
* | |
* @package Laravel | |
- * @version 3.1.9 | |
+ * @version 3.2.0 | |
* @author Taylor Otwell <[email protected]> | |
* @link http://laravel.com | |
*/ | |
diff --git a/changes.md b/changes.md | |
deleted file mode 100755 | |
index be8d437..0000000 | |
--- a/changes.md | |
+++ /dev/null | |
@@ -1,204 +0,0 @@ | |
-## Laravel Change Log | |
- | |
-## Contents | |
- | |
-- [Laravel 3.1.9](#3.1.9) | |
-- [Upgrading From 3.1.8](#upgrade-3.1.9) | |
-- [Laravel 3.1.8](#3.1.8) | |
-- [Upgrading From 3.1.7](#upgrade-3.1.8) | |
-- [Laravel 3.1.7](#3.1.7) | |
-- [Upgrading From 3.1.6](#upgrade-3.1.7) | |
-- [Laravel 3.1.6](#3.1.6) | |
-- [Upgrading From 3.1.5](#upgrade-3.1.6) | |
-- [Laravel 3.1.5](#3.1.5) | |
-- [Upgrading From 3.1.4](#upgrade-3.1.5) | |
-- [Laravel 3.1.4](#3.1.4) | |
-- [Upgrading From 3.1.3](#upgrade-3.1.4) | |
-- [Laravel 3.1.3](#3.1.3) | |
-- [Upgrading From 3.1.2](#uprade-3.1.3) | |
-- [Laravel 3.1.2](#3.1.2) | |
-- [Upgrading From 3.1.1](#upgrade-3.1.2) | |
-- [Laravel 3.1.1](#3.1.1) | |
-- [Upgrading From 3.1](#upgrade-3.1.1) | |
-- [Laravel 3.1](#3.1) | |
-- [Upgrading From 3.0](#upgrade-3.1) | |
- | |
-<a name="3.1.9"></a> | |
-## Laravel 3.1.9 | |
- | |
-- Fixes cookie session driver bug that caused infinite loop on some occasions. | |
- | |
-<a name="upgrade-3.1.9"></a> | |
-## Upgrading From 3.1.8 | |
- | |
-- Replace the **laravel** folder. | |
- | |
-<a name="3.1.8"></a> | |
-## Laravel 3.1.8 | |
- | |
-- Fixes possible WSOD when using Blade's @include expression. | |
- | |
-<a name="upgrade-3.1.8"></a> | |
-## Upgrading From 3.1.7 | |
- | |
-- Replace the **laravel** folder. | |
- | |
-<a name="3.1.7"></a> | |
-## Laravel 3.1.7 | |
- | |
-- Fixes custom validation language line loading from bundles. | |
-- Fixes double-loading of classes when overriding the core. | |
-- Classify migration names. | |
- | |
-<a name="upgrade-3.1.7"></a> | |
-## Upgrading From 3.1.6 | |
- | |
-- Replace the **laravel** folder. | |
- | |
-<a name="3.1.6"></a> | |
-## Laravel 3.1.6 | |
- | |
-- Fixes many-to-many eager loading in Eloquent. | |
- | |
-<a name="upgrade-3.1.6"></a> | |
-## Upgrading From 3.1.5 | |
- | |
-- Replace the **laravel** folder. | |
- | |
-<a name="3.1.5"></a> | |
-## Laravel 3.1.5 | |
- | |
-- Fixes bug that could allow secure cookies to be sent over HTTP. | |
- | |
-<a name="upgrade-3.1.5"></a> | |
-## Upgrading From 3.1.4 | |
- | |
-- Replace the **laravel** folder. | |
- | |
-<a name="3.1.4"></a> | |
-## Laravel 3.1.4 | |
- | |
-- Fixes Response header casing bug. | |
-- Fixes SQL "where in" (...) short-cut bug. | |
- | |
-<a name="upgrade-3.1.4"></a> | |
-## Upgrading From 3.1.3 | |
- | |
-- Replace the **laravel** folder. | |
- | |
-<a name="3.1.3"></a> | |
-## Laravel 3.1.3 | |
- | |
-- Fixes **delete** method in Eloquent models. | |
- | |
-<a name="upgrade-3.1.3"></a> | |
-## Upgrade From 3.1.2 | |
- | |
-- Replace the **laravel** folder. | |
- | |
-<a name="3.1.2"></a> | |
-## Laravel 3.1.2 | |
- | |
-- Fixes Eloquent query method constructor conflict. | |
- | |
-<a name="upgrade-3.1.2"></a> | |
-## Upgrade From 3.1.1 | |
- | |
-- Replace the **laravel** folder. | |
- | |
-<a name="3.1.1"></a> | |
-## Laravel 3.1.1 | |
- | |
-- Fixes Eloquent model hydration bug involving custom setters. | |
- | |
-<a name="upgrade-3.1.1"></a> | |
-## Upgrading From 3.1 | |
- | |
-- Replace the **laravel** folder. | |
- | |
-<a name="3.1"></a> | |
-## Laravel 3.1 | |
- | |
-- Added events to logger for more flexibility. | |
-- Added **database.fetch** configuration option. | |
-- Added controller factories for injecting any IoC. | |
-- Added **link_to_action** HTML helpers. | |
-- Added ability to set default value on Config::get. | |
-- Added the ability to add pattern based filters. | |
-- Improved session ID assignment. | |
-- Added support for "unsigned" integers in schema builder. | |
-- Added config, view, and lang loaders. | |
-- Added more logic to **application/start.php** for more flexibility. | |
-- Added foreign key support to schema builder. | |
-- Postgres "unique" indexes are now added with ADD CONSTRAINT. | |
-- Added "Event::until" method. | |
-- Added "memory" cache and session drivers. | |
-- Added Controller::detect method. | |
-- Added Cache::forever method. | |
-- Controller layouts now resolved in Laravel\Controller __construct. | |
-- Rewrote Eloquent and included in core. | |
-- Added "match" validation rule. | |
-- Fixed table prefix bug. | |
-- Added Form::macro method. | |
-- Added HTML::macro method. | |
-- Added Route::forward method. | |
-- Prepend table name to default index names in schema. | |
-- Added "forelse" to Blade. | |
-- Added View::render_each. | |
-- Able to specify full path to view (path: ). | |
-- Added support for Blade template inheritance. | |
-- Added "before" and "after" validation checks for dates. | |
- | |
-<a name="upgrade-3.1"></a> | |
-## Upgrading From 3.0 | |
- | |
-### Replace your **application/start.php** file. | |
- | |
-The default **start.php** file has been expanded in order to give you more flexibility over the loading of your language, configuration, and view files. To upgrade your file, copy your current file and paste it at the bottom of a copy of the new Laravel 3.1 start file. Next, scroll up in the **start** file until you see the default Autoloader registrations (line 61 and line 76). Delete both of these sections since you just pasted your previous auto-loader registrations at the bottom of the file. | |
- | |
-### Remove the **display** option from your **errors** configuration file. | |
- | |
-This option is now set at the beginning of your **application/start** file. | |
- | |
-### Call the parent controller's constructor from your controller. | |
- | |
-Simply add a **parent::__construct();** to to any of your controllers that have a constructor. | |
- | |
-### Prefix Laravel migration created indexes with their table name. | |
- | |
-If you have created indexes on tables using the Laravel migration system and you used to the default index naming scheme provided by Laravel, prefix the index names with their table name on your database. So, if the current index name is "id_unique" on the "users" table, make the index name "users_id_unique". | |
- | |
-### Add alias for Eloquent in your application configuration. | |
- | |
-Add the following to the **aliases** array in your **application/config/application.php** file: | |
- | |
- 'Eloquent' => 'Laravel\\Database\\Eloquent\\Model', | |
- 'Blade' => 'Laravel\\Blade', | |
- | |
-### Update Eloquent many-to-many tables. | |
- | |
-Eloquent now maintains **created_at** and **updated_at** column on many-to-many intermediate tables by default. Simply add these columns to your tables. Also, many-to-many tables are now the singular model names concatenated with an underscore. For example, if the relationship is between User and Role, the intermediate table name should be **role_user**. | |
- | |
-### Remove Eloquent bundle. | |
- | |
-If you are using the Eloquent bundle with your installation, you can remove it from your bundles directory and your **application/bundles.php** file. Eloquent version 2 is included in the core in Laravel 3.1. Your models can also now extend simply **Eloquent** instead of **Eloquent\Model**. | |
- | |
-### Update your **config/strings.php** file. | |
- | |
-English pluralization and singularization is now automatic. Just completely replace your **application/config/strings.php** file. | |
- | |
-### Add the **fetch** option to your database configuration file. | |
- | |
-A new **fetch** option allows you to specify in which format you receive your database results. Just copy and paste the option from the new **application/config/database.php** file. | |
- | |
-### Add **database** option to your Redis configuration. | |
- | |
-If you are using Redis, add the "database" option to your Redis connection configurations. The "database" value can be zero by default. | |
- | |
- 'redis' => array( | |
- 'default' => array( | |
- 'host' => '127.0.0.1', | |
- 'port' => 6379, | |
- 'database' => 0 | |
- ), | |
- ), | |
diff --git a/laravel/asset.php b/laravel/asset.php | |
index 8b6f930..6bc3647 100755 | |
--- a/laravel/asset.php | |
+++ b/laravel/asset.php | |
@@ -1,4 +1,4 @@ | |
-<?php namespace Laravel; defined('DS') or die('No direct script access.'); | |
+<?php namespace Laravel; | |
class Asset { | |
diff --git a/laravel/auth.php b/laravel/auth.php | |
index bacd086..ad4869c 100755 | |
--- a/laravel/auth.php | |
+++ b/laravel/auth.php | |
@@ -1,216 +1,93 @@ | |
-<?php namespace Laravel; | |
+<?php namespace Laravel; use Closure; | |
class Auth { | |
/** | |
- * The current user of the application. | |
+ * The currently active authentication drivers. | |
* | |
- * @var object | |
+ * @var array | |
*/ | |
- public static $user; | |
+ public static $drivers = array(); | |
/** | |
- * The key used when storing the user ID in the session. | |
+ * The third-party driver registrar. | |
* | |
- * @var string | |
+ * @var array | |
*/ | |
- const user_key = 'laravel_user_id'; | |
+ public static $registrar = array(); | |
/** | |
- * Determine if the user of the application is not logged in. | |
+ * Get an authentication driver instance. | |
* | |
- * This method is the inverse of the "check" method. | |
- * | |
- * @return bool | |
- */ | |
- public static function guest() | |
- { | |
- return ! static::check(); | |
- } | |
- | |
- /** | |
- * Determine if the user of the application is logged in. | |
- * | |
- * @return bool | |
- */ | |
- public static function check() | |
- { | |
- return ! is_null(static::user()); | |
- } | |
- | |
- /** | |
- * Get the current user of the application. | |
- * | |
- * <code> | |
- * // Get the current user of the application | |
- * $user = Auth::user(); | |
- * | |
- * // Access a property on the current user of the application | |
- * $email = Auth::user()->email; | |
- * </code> | |
- * | |
- * @return object|null | |
+ * @param string $driver | |
+ * @return Driver | |
*/ | |
- public static function user() | |
+ public static function driver($driver = null) | |
{ | |
- if ( ! is_null(static::$user)) return static::$user; | |
- | |
- $id = Session::get(Auth::user_key); | |
- | |
- // To retrieve the user, we'll first attempt to use the "user" Closure | |
- // defined in the auth configuration file, passing in the ID. The user | |
- // Closure gives the developer a ton of freedom surrounding how the | |
- // user is actually retrieved. | |
- $config = Config::get('auth'); | |
+ if (is_null($driver)) $driver = Config::get('auth.driver'); | |
- static::$user = call_user_func($config['user'], $id); | |
- | |
- // If the user wasn't found in the database but a "remember me" cookie | |
- // exists, we'll attempt to recall the user based on the cookie value. | |
- // Since all cookies contain a fingerprint hash verifying that they | |
- // haven't changed, we can trust it. | |
- $recaller = Cookie::get($config['cookie']); | |
- | |
- if (is_null(static::$user) and ! is_null($recaller)) | |
+ if ( ! isset(static::$drivers[$driver])) | |
{ | |
- static::$user = static::recall($recaller); | |
+ static::$drivers[$driver] = static::factory($driver); | |
} | |
- return static::$user; | |
+ return static::$drivers[$driver]; | |
} | |
/** | |
- * Attempt to login a user based on a long-lived "remember me" cookie. | |
+ * Create a new authentication driver instance. | |
* | |
- * @param string $recaller | |
- * @return mixed | |
+ * @param string $driver | |
+ * @return Driver | |
*/ | |
- protected static function recall($recaller) | |
+ protected static function factory($driver) | |
{ | |
- $recaller = explode('|', Crypter::decrypt($recaller)); | |
- | |
- // We'll pass the ID that was stored in the cookie into the same user | |
- // Closure that is used by the "user" method. If the method returns | |
- // a user, we will log them into the application. | |
- $user = call_user_func(Config::get('auth.user'), $recaller[0]); | |
- | |
- if ( ! is_null($user)) | |
+ if (isset(static::$registrar[$driver])) | |
{ | |
- static::login($user); | |
+ $resolver = static::$registrar[$driver]; | |
- return $user; | |
+ return $resolver(); | |
} | |
- } | |
- | |
- /** | |
- * Attempt to log a user into the application. | |
- * | |
- * <code> | |
- * // Attempt to log a user into the application | |
- * $success = Auth::attempt('username', 'password'); | |
- * | |
- * // Attempt to login a user and set the "remember me" cookie | |
- * Auth::attempt('username', 'password', true); | |
- * </code> | |
- * | |
- * @param string $username | |
- * @param string $password | |
- * @param bool $remember | |
- * @return bool | |
- */ | |
- public static function attempt($username, $password = null, $remember = false) | |
- { | |
- $config = Config::get('auth'); | |
- // When attempting to login the user, we will call the "attempt" closure | |
- // from the configuration file. This gives the developer the freedom to | |
- // authenticate based on the needs of their application, even allowing | |
- // the user of third-party providers. | |
- $user = call_user_func($config['attempt'], $username, $password); | |
- | |
- if (is_null($user)) return false; | |
+ switch ($driver) | |
+ { | |
+ case 'fluent': | |
+ return new Auth\Drivers\Fluent(Config::get('auth.table')); | |
- static::login($user, $remember); | |
+ case 'eloquent': | |
+ return new Auth\Drivers\Eloquent(Config::get('auth.model')); | |
- return true; | |
+ default: | |
+ throw new \Exception("Auth driver {$driver} is not supported."); | |
+ } | |
} | |
/** | |
- * Log a user into the application. | |
- * | |
- * <code> | |
- * // Login the user with an ID of 15 | |
- * Auth::login(15); | |
- * | |
- * // Login a user by passing a user object | |
- * Auth::login($user); | |
+ * Register a third-party authentication driver. | |
* | |
- * // Login a user and set a "remember me" cookie | |
- * Auth::login($user, true); | |
- * </code> | |
- * | |
- * @param object|int $user | |
- * @param bool $remember | |
+ * @param string $driver | |
+ * @param Closure $resolver | |
* @return void | |
*/ | |
- public static function login($user, $remember = false) | |
+ public static function extend($driver, Closure $resolver) | |
{ | |
- $id = (is_object($user)) ? $user->id : (int) $user; | |
- | |
- if ($remember) static::remember($id); | |
- | |
- Session::put(Auth::user_key, $id); | |
+ static::$registrar[$driver] = $resolver; | |
} | |
/** | |
- * Set a cookie so that the user is "remembered". | |
+ * Magic Method for calling the methods on the default cache driver. | |
* | |
- * @param string $id | |
- * @return void | |
- */ | |
- protected static function remember($id) | |
- { | |
- $recaller = Crypter::encrypt($id.'|'.Str::random(40)); | |
- | |
- // This method assumes the "remember me" cookie should have the same | |
- // configuration as the session cookie. Since this cookie, like the | |
- // session cookie, should be kept very secure, it's probably safe. | |
- // to assume the cookie settings are the same. | |
- $config = Config::get('session'); | |
- | |
- extract($config, EXTR_SKIP); | |
- | |
- $cookie = Config::get('auth.cookie'); | |
- | |
- Cookie::forever($cookie, $recaller, $path, $domain, $secure); | |
- } | |
- | |
- /** | |
- * Log the current user out of the application. | |
+ * <code> | |
+ * // Call the "user" method on the default auth driver | |
+ * $user = Auth::user(); | |
* | |
- * @return void | |
+ * // Call the "check" method on the default auth driver | |
+ * Auth::check(); | |
+ * </code> | |
*/ | |
- public static function logout() | |
+ public static function __callStatic($method, $parameters) | |
{ | |
- // We will call the "logout" closure first, which gives the developer | |
- // the chance to do any clean-up or before the user is logged out of | |
- // the application. No action is taken by default. | |
- call_user_func(Config::get('auth.logout'), static::user()); | |
- | |
- static::$user = null; | |
- | |
- $config = Config::get('session'); | |
- | |
- extract($config, EXTR_SKIP); | |
- | |
- // When forgetting the cookie, we need to also pass in the path and | |
- // domain that would have been used when the cookie was originally | |
- // set by the framework, otherwise it will not be deleted. | |
- $cookie = Config::get('auth.cookie'); | |
- | |
- Cookie::forget($cookie, $path, $domain, $secure); | |
- | |
- Session::forget(Auth::user_key); | |
+ return call_user_func_array(array(static::driver(), $method), $parameters); | |
} | |
} | |
\ No newline at end of file | |
diff --git a/laravel/autoloader.php b/laravel/autoloader.php | |
index f2d4007..296b9db 100755 | |
--- a/laravel/autoloader.php | |
+++ b/laravel/autoloader.php | |
@@ -1,4 +1,4 @@ | |
-<?php namespace Laravel; defined('DS') or die('No direct script access.'); | |
+<?php namespace Laravel; | |
class Autoloader { | |
@@ -52,7 +52,7 @@ class Autoloader { | |
// called again for the "real" class name to load its file. | |
if (isset(static::$aliases[$class])) | |
{ | |
- class_alias(static::$aliases[$class], $class); | |
+ return class_alias(static::$aliases[$class], $class); | |
} | |
// All classes in Laravel are staticly mapped. There is no crazy search | |
@@ -76,20 +76,6 @@ class Autoloader { | |
} | |
} | |
- // If the class uses PEAR-ish style underscores for indicating its | |
- // directory structure we'll load the class using PSR-0 standards | |
- // standards from that directory, trimming the root. | |
- foreach (static::$underscored as $prefix => $directory) | |
- { | |
- if (starts_with($class, $prefix)) | |
- { | |
- return static::load_namespaced($class, $prefix, $directory); | |
- } | |
- } | |
- | |
- // If all else fails we will just iterator through the mapped | |
- // PSR-0 directories looking for the class. This is the last | |
- // resort and slowest loading option for the class. | |
static::load_psr($class); | |
} | |
@@ -177,29 +163,28 @@ class Autoloader { | |
} | |
/** | |
- * Register underscored "namespaces" to directory mappings. | |
+ * Map namespaces to directories. | |
* | |
- * @param array $mappings | |
+ * @param array $mappings | |
+ * @param string $append | |
* @return void | |
*/ | |
- public static function underscored($mappings) | |
+ public static function namespaces($mappings, $append = '\\') | |
{ | |
- $mappings = static::format_mappings($mappings, '_'); | |
+ $mappings = static::format_mappings($mappings, $append); | |
- static::$underscored = array_merge($mappings, static::$underscored); | |
+ static::$namespaces = array_merge($mappings, static::$namespaces); | |
} | |
/** | |
- * Map namespaces to directories. | |
+ * Register underscored "namespaces" to directory mappings. | |
* | |
* @param array $mappings | |
* @return void | |
*/ | |
- public static function namespaces($mappings) | |
+ public static function underscored($mappings) | |
{ | |
- $mappings = static::format_mappings($mappings, '\\'); | |
- | |
- static::$namespaces = array_merge($mappings, static::$namespaces); | |
+ static::namespaces($mappings, '_'); | |
} | |
/** | |
diff --git a/laravel/blade.php b/laravel/blade.php | |
index e3111d0..5961a53 100755 | |
--- a/laravel/blade.php | |
+++ b/laravel/blade.php | |
@@ -1,4 +1,4 @@ | |
-<?php namespace Laravel; use FilesystemIterator as fIterator; | |
+<?php namespace Laravel; use FilesystemIterator as fIterator; use Closure; | |
class Blade { | |
@@ -8,7 +8,9 @@ class Blade { | |
* @var array | |
*/ | |
protected static $compilers = array( | |
+ 'extensions', | |
'layouts', | |
+ 'comments', | |
'echos', | |
'forelse', | |
'empty', | |
@@ -16,6 +18,8 @@ class Blade { | |
'structure_openings', | |
'structure_closings', | |
'else', | |
+ 'unless', | |
+ 'endunless', | |
'includes', | |
'render_each', | |
'render', | |
@@ -26,6 +30,13 @@ class Blade { | |
); | |
/** | |
+ * An array of user defined compilers. | |
+ * | |
+ * @var array | |
+ */ | |
+ protected static $extensions = array(); | |
+ | |
+ /** | |
* Register the Blade view engine with Laravel. | |
* | |
* @return void | |
@@ -39,7 +50,7 @@ class Blade { | |
// return false so the View can be rendered as normal. | |
if ( ! str_contains($view->path, BLADE_EXT)) | |
{ | |
- return false; | |
+ return; | |
} | |
$compiled = path('storage').'views/'.md5($view->path); | |
@@ -62,6 +73,24 @@ class Blade { | |
} | |
/** | |
+ * Register a custom Blade compiler. | |
+ * | |
+ * <code> | |
+ * Blade::extend(function($view) | |
+ * { | |
+ * return str_replace('foo', 'bar', $view); | |
+ * }); | |
+ * </code> | |
+ * | |
+ * @param Closure $compiler | |
+ * @return void | |
+ */ | |
+ public static function extend(Closure $compiler) | |
+ { | |
+ static::$extensions[] = $compiler; | |
+ } | |
+ | |
+ /** | |
* Determine if a view is "expired" and needs to be re-compiled. | |
* | |
* @param string $view | |
@@ -71,8 +100,6 @@ class Blade { | |
*/ | |
public static function expired($view, $path) | |
{ | |
- $compiled = static::compiled($path); | |
- | |
return filemtime($path) > filemtime(static::compiled($path)); | |
} | |
@@ -115,7 +142,7 @@ class Blade { | |
protected static function compile_layouts($value) | |
{ | |
// If the Blade template is not using "layouts", we'll just return it | |
- // it unchanged since there is nothing to do with layouts and we'll | |
+ // unchanged since there is nothing to do with layouts and we will | |
// just let the other Blade compilers handle the rest. | |
if ( ! starts_with($value, '@layout')) | |
{ | |
@@ -123,8 +150,8 @@ class Blade { | |
} | |
// First we'll split out the lines of the template so we can get the | |
- // the layout from the top of the template. By convention it must | |
- // be located on the first line of the template contents. | |
+ // layout from the top of the template. By convention it must be | |
+ // located on the first line of the template contents. | |
$lines = preg_split("/(\r?\n)/", $value); | |
$pattern = static::matcher('layout'); | |
@@ -132,7 +159,7 @@ class Blade { | |
$lines[] = preg_replace($pattern, '$1@include$2', $lines[0]); | |
// We will add a "render" statement to the end of the templates and | |
- // and then slice off the @layout shortcut from the start so the | |
+ // then slice off the "@layout" shortcut from the start so the | |
// sections register before the parent template renders. | |
return implode(CRLF, array_slice($lines, 1)); | |
} | |
@@ -151,6 +178,19 @@ class Blade { | |
} | |
/** | |
+ * Rewrites Blade comments into PHP comments. | |
+ * | |
+ * @param string $value | |
+ * @return string | |
+ */ | |
+ protected static function compile_comments($value) | |
+ { | |
+ $value = preg_replace('/\{\{--(.+?)(--\}\})?\n/', "<?php // $1 ?>", $value); | |
+ | |
+ return preg_replace('/\{\{--((.|\s)*?)--\}\}/', "<?php /* $1 */ ?>\n", $value); | |
+ } | |
+ | |
+ /** | |
* Rewrites Blade echo statements into PHP echo statements. | |
* | |
* @param string $value | |
@@ -176,7 +216,7 @@ class Blade { | |
preg_match('/\$[^\s]*/', $forelse, $variable); | |
// Once we have extracted the variable being looped against, we can add | |
- // an if statmeent to the start of the loop that checks if the count | |
+ // 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 = "<?php if (count({$variable[0]}) > 0): ?>"; | |
@@ -187,8 +227,8 @@ class Blade { | |
$blade = preg_replace($search, $replace, $forelse); | |
// Finally, once we have the check prepended to the loop we'll replace | |
- // all instances of this "forelse" syntax in the view content of the | |
- // view being compiled to Blade syntax with real syntax. | |
+ // all instances of this forelse syntax in the view content of the | |
+ // view being compiled to Blade syntax with real PHP syntax. | |
$value = str_replace($forelse, $blade, $value); | |
} | |
@@ -255,6 +295,30 @@ class Blade { | |
} | |
/** | |
+ * Rewrites Blade "unless" statements into valid PHP. | |
+ * | |
+ * @param string $value | |
+ * @return string | |
+ */ | |
+ protected static function compile_unless($value) | |
+ { | |
+ $pattern = '/(\s*)@unless(\s*\(.*\))/'; | |
+ | |
+ return preg_replace($pattern, '$1<?php if( ! ($2)): ?>', $value); | |
+ } | |
+ | |
+ /** | |
+ * Rewrites Blade "unless" endings into valid PHP. | |
+ * | |
+ * @param string $value | |
+ * @return string | |
+ */ | |
+ protected static function compile_endunless($value) | |
+ { | |
+ return str_replace('@endunless', '<?php endif; ?>', $value); | |
+ } | |
+ | |
+ /** | |
* Rewrites Blade @include statements into valid PHP. | |
* | |
* @param string $value | |
@@ -349,12 +413,28 @@ class Blade { | |
} | |
/** | |
+ * Execute user defined compilers. | |
+ * | |
+ * @param string $value | |
+ * @return string | |
+ */ | |
+ protected static function compile_extensions($value) | |
+ { | |
+ foreach (static::$extensions as $compiler) | |
+ { | |
+ $value = $compiler($value); | |
+ } | |
+ | |
+ return $value; | |
+ } | |
+ | |
+ /** | |
* Get the regular expression for a generic Blade function. | |
* | |
* @param string $function | |
* @return string | |
*/ | |
- protected static function matcher($function) | |
+ public static function matcher($function) | |
{ | |
return '/(\s*)@'.$function.'(\s*\(.*\))/'; | |
} | |
diff --git a/laravel/bundle.php b/laravel/bundle.php | |
index dd58213..2259228 100755 | |
--- a/laravel/bundle.php | |
+++ b/laravel/bundle.php | |
@@ -64,7 +64,7 @@ class Bundle { | |
static::$bundles[$bundle] = array_merge($defaults, $config); | |
- // It is possible for the develoepr to specify auto-loader mappings | |
+ // It is possible for the developer to specify auto-loader mappings | |
// directly on the bundle registration. This provides a convenient | |
// way to register mappings withuot a bootstrap. | |
if (isset($config['autoloads'])) | |
@@ -92,8 +92,12 @@ class Bundle { | |
// Each bundle may have a start script which is responsible for preparing | |
// the bundle for use by the application. The start script may register | |
- // any classes the bundle uses with the auto-loader, etc. | |
- if (file_exists($path = static::path($bundle).'start'.EXT)) | |
+ // any classes the bundle uses with the auto-loader class, etc. | |
+ if ( ! is_null($starter = static::option($bundle, 'starter'))) | |
+ { | |
+ $starter(); | |
+ } | |
+ elseif (file_exists($path = static::path($bundle).'start'.EXT)) | |
{ | |
require $path; | |
} | |
@@ -271,9 +275,19 @@ class Bundle { | |
{ | |
return path('app'); | |
} | |
- else if ($location = array_get(static::$bundles, $bundle.'.location')) | |
+ elseif ($location = array_get(static::$bundles, $bundle.'.location')) | |
{ | |
- return str_finish(path('bundle').$location, DS); | |
+ // If the bundle location starts with "path: ", we will assume that a raw | |
+ // path has been specified and will simply return it. Otherwise, we'll | |
+ // prepend the bundle directory path onto the location and return. | |
+ if (starts_with($location, 'path: ')) | |
+ { | |
+ return str_finish(substr($location, 6), DS); | |
+ } | |
+ else | |
+ { | |
+ return str_finish(path('bundle').$location, DS); | |
+ } | |
} | |
} | |
@@ -287,7 +301,7 @@ class Bundle { | |
{ | |
if (is_null($bundle)) return static::assets(DEFAULT_BUNDLE); | |
- return ($bundle != DEFAULT_BUNDLE) ? URL::base()."/bundles/{$bundle}/" : URL::base().'/'; | |
+ return ($bundle != DEFAULT_BUNDLE) ? "/bundles/{$bundle}/" : '/'; | |
} | |
/** | |
@@ -374,8 +388,8 @@ class Bundle { | |
public static function parse($identifier) | |
{ | |
// The parsed elements are cached so we don't have to reparse them on each | |
- // subsequent request for the parsed element. So, if we've already parsed | |
- // the given element, we'll just return the cached copy. | |
+ // subsequent request for the parsed element. So if we've already parsed | |
+ // the given element, we'll just return the cached copy as the value. | |
if (isset(static::$elements[$identifier])) | |
{ | |
return static::$elements[$identifier]; | |
@@ -387,7 +401,7 @@ class Bundle { | |
} | |
// If no bundle is in the identifier, we will insert the default bundle | |
// since classes like Config and Lang organize their items by bundle. | |
- // The "application" folder essentially behaves as a bundle. | |
+ // The application folder essentially behaves as a default bundle. | |
else | |
{ | |
$element = array(DEFAULT_BUNDLE, strtolower($identifier)); | |
@@ -412,13 +426,19 @@ class Bundle { | |
* | |
* @param string $bundle | |
* @param string $option | |
+ * @param mixed $default | |
* @return mixed | |
*/ | |
- public static function option($bundle, $option) | |
+ public static function option($bundle, $option, $default = null) | |
{ | |
$bundle = static::get($bundle); | |
- if ( ! is_null($bundle)) return array_get($bundle, $option); | |
+ if (is_null($bundle)) | |
+ { | |
+ return value($default); | |
+ } | |
+ | |
+ return array_get($bundle, $option, $default); | |
} | |
/** | |
diff --git a/laravel/cache.php b/laravel/cache.php | |
index 723aa6e..02b86e4 100755 | |
--- a/laravel/cache.php | |
+++ b/laravel/cache.php | |
@@ -1,4 +1,4 @@ | |
-<?php namespace Laravel; defined('DS') or die('No direct script access.'); | |
+<?php namespace Laravel; use Closure; | |
class Cache { | |
@@ -10,6 +10,13 @@ class Cache { | |
public static $drivers = array(); | |
/** | |
+ * The third-party driver registrar. | |
+ * | |
+ * @var array | |
+ */ | |
+ public static $registrar = array(); | |
+ | |
+ /** | |
* Get a cache driver instance. | |
* | |
* If no driver name is specified, the default will be returned. | |
@@ -45,6 +52,13 @@ class Cache { | |
*/ | |
protected static function factory($driver) | |
{ | |
+ if (isset(static::$registrar[$driver])) | |
+ { | |
+ $resolver = static::$registrar[$driver]; | |
+ | |
+ return $resolver(); | |
+ } | |
+ | |
switch ($driver) | |
{ | |
case 'apc': | |
@@ -71,6 +85,18 @@ class Cache { | |
} | |
/** | |
+ * Register a third-party cache driver. | |
+ * | |
+ * @param string $driver | |
+ * @param Closure $resolver | |
+ * @return void | |
+ */ | |
+ public static function extend($driver, Closure $resolver) | |
+ { | |
+ static::$registrar[$driver] = $resolver; | |
+ } | |
+ | |
+ /** | |
* Magic Method for calling the methods on the default cache driver. | |
* | |
* <code> | |
diff --git a/laravel/cache/drivers/database.php b/laravel/cache/drivers/database.php | |
index 3983e93..44bf478 100755 | |
--- a/laravel/cache/drivers/database.php | |
+++ b/laravel/cache/drivers/database.php | |
@@ -75,7 +75,7 @@ class Database extends Driver { | |
$expiration = $this->expiration($minutes); | |
// To update the value, we'll first attempt an insert against the | |
- // database and if we catch an exception, we'll assume that the | |
+ // database and if we catch an exception we'll assume that the | |
// primary key already exists in the table and update. | |
try | |
{ | |
diff --git a/laravel/cache/drivers/driver.php b/laravel/cache/drivers/driver.php | |
index b74ebe0..c6abcb2 100755 | |
--- a/laravel/cache/drivers/driver.php | |
+++ b/laravel/cache/drivers/driver.php | |
@@ -1,4 +1,4 @@ | |
-<?php namespace Laravel\Cache\Drivers; use Closure; | |
+<?php namespace Laravel\Cache\Drivers; | |
abstract class Driver { | |
@@ -69,16 +69,28 @@ abstract class Driver { | |
* @param int $minutes | |
* @return mixed | |
*/ | |
- public function remember($key, $default, $minutes) | |
+ public function remember($key, $default, $minutes, $function = 'put') | |
{ | |
if ( ! is_null($item = $this->get($key, null))) return $item; | |
- $this->put($key, $default = value($default), $minutes); | |
+ $this->$function($key, $default = value($default), $minutes); | |
return $default; | |
} | |
/** | |
+ * Get an item from the cache, or cache the default value forever. | |
+ * | |
+ * @param string $key | |
+ * @param mixed $default | |
+ * @return mixed | |
+ */ | |
+ public function sear($key, $default) | |
+ { | |
+ return $this->remember($key, $default, null, 'forever'); | |
+ } | |
+ | |
+ /** | |
* Delete an item from the cache. | |
* | |
* @param string $key | |
diff --git a/laravel/cache/drivers/file.php b/laravel/cache/drivers/file.php | |
index ee54aa3..c37520e 100755 | |
--- a/laravel/cache/drivers/file.php | |
+++ b/laravel/cache/drivers/file.php | |
@@ -42,9 +42,8 @@ class File extends Driver { | |
if ( ! file_exists($this->path.$key)) return null; | |
// File based caches store have the expiration timestamp stored in | |
- // UNIX format prepended to their contents. This timestamp is then | |
- // extracted and removed when the cache is read to determine if | |
- // the file is still valid. | |
+ // UNIX format prepended to their contents. We'll compare the | |
+ // timestamp to the current time when we read the file. | |
if (time() >= substr($cache = file_get_contents($this->path.$key), 0, 10)) | |
{ | |
return $this->forget($key); | |
@@ -68,6 +67,8 @@ class File extends Driver { | |
*/ | |
public function put($key, $value, $minutes) | |
{ | |
+ if ($minutes <= 0) return; | |
+ | |
$value = $this->expiration($minutes).serialize($value); | |
file_put_contents($this->path.$key, $value, LOCK_EX); | |
diff --git a/laravel/cache/drivers/memcached.php b/laravel/cache/drivers/memcached.php | |
index 4601e38..3e6a454 100755 | |
--- a/laravel/cache/drivers/memcached.php | |
+++ b/laravel/cache/drivers/memcached.php | |
@@ -1,13 +1,13 @@ | |
-<?php namespace Laravel\Cache\Drivers; use Memcache; | |
+<?php namespace Laravel\Cache\Drivers; | |
-class Memcached extends Driver { | |
+class Memcached extends Sectionable { | |
/** | |
* The Memcache instance. | |
* | |
- * @var Memcache | |
+ * @var Memcached | |
*/ | |
- protected $memcache; | |
+ public $memcache; | |
/** | |
* The cache key from the cache configuration file. | |
@@ -19,10 +19,10 @@ class Memcached extends Driver { | |
/** | |
* Create a new Memcached cache driver instance. | |
* | |
- * @param Memcache $memcache | |
+ * @param Memcached $memcache | |
* @return void | |
*/ | |
- public function __construct(Memcache $memcache, $key) | |
+ public function __construct(\Memcached $memcache, $key) | |
{ | |
$this->key = $key; | |
$this->memcache = $memcache; | |
@@ -47,7 +47,13 @@ class Memcached extends Driver { | |
*/ | |
protected function retrieve($key) | |
{ | |
- if (($cache = $this->memcache->get($this->key.$key)) !== false) | |
+ if ($this->sectionable($key)) | |
+ { | |
+ list($section, $key) = $this->parse($key); | |
+ | |
+ return $this->get_from_section($section, $key); | |
+ } | |
+ elseif (($cache = $this->memcache->get($this->key.$key)) !== false) | |
{ | |
return $cache; | |
} | |
@@ -68,7 +74,16 @@ class Memcached extends Driver { | |
*/ | |
public function put($key, $value, $minutes) | |
{ | |
- $this->memcache->set($this->key.$key, $value, 0, $minutes * 60); | |
+ if ($this->sectionable($key)) | |
+ { | |
+ list($section, $key) = $this->parse($key); | |
+ | |
+ return $this->put_in_section($section, $key, $value, $minutes); | |
+ } | |
+ else | |
+ { | |
+ $this->memcache->set($this->key.$key, $value, $minutes * 60); | |
+ } | |
} | |
/** | |
@@ -80,7 +95,16 @@ class Memcached extends Driver { | |
*/ | |
public function forever($key, $value) | |
{ | |
- return $this->put($key, $value, 0); | |
+ if ($this->sectionable($key)) | |
+ { | |
+ list($section, $key) = $this->parse($key); | |
+ | |
+ return $this->forever_in_section($section, $key, $value); | |
+ } | |
+ else | |
+ { | |
+ return $this->put($key, $value, 0); | |
+ } | |
} | |
/** | |
@@ -91,7 +115,71 @@ class Memcached extends Driver { | |
*/ | |
public function forget($key) | |
{ | |
- $this->memcache->delete($this->key.$key); | |
+ if ($this->sectionable($key)) | |
+ { | |
+ list($section, $key) = $this->parse($key); | |
+ | |
+ if ($key == '*') | |
+ { | |
+ $this->forget_section($section); | |
+ } | |
+ else | |
+ { | |
+ $this->forget_in_section($section, $key); | |
+ } | |
+ } | |
+ else | |
+ { | |
+ $this->memcache->delete($this->key.$key); | |
+ } | |
+ } | |
+ | |
+ /** | |
+ * Delete an entire section from the cache. | |
+ * | |
+ * @param string $section | |
+ * @return int|bool | |
+ */ | |
+ public function forget_section($section) | |
+ { | |
+ return $this->memcache->increment($this->key.$this->section_key($section)); | |
+ } | |
+ | |
+ /** | |
+ * Get the current section ID for a given section. | |
+ * | |
+ * @param string $section | |
+ * @return int | |
+ */ | |
+ protected function section_id($section) | |
+ { | |
+ return $this->sear($this->section_key($section), function() | |
+ { | |
+ return rand(1, 10000); | |
+ }); | |
+ } | |
+ | |
+ /** | |
+ * Get a section key name for a given section. | |
+ * | |
+ * @param string $section | |
+ * @return string | |
+ */ | |
+ protected function section_key($section) | |
+ { | |
+ return $section.'_section_key'; | |
+ } | |
+ | |
+ /** | |
+ * Get a section item key for a given section and key. | |
+ * | |
+ * @param string $section | |
+ * @param string $key | |
+ * @return string | |
+ */ | |
+ protected function section_item_key($section, $key) | |
+ { | |
+ return $section.'#'.$this->section_id($section).'#'.$key; | |
} | |
} | |
\ No newline at end of file | |
diff --git a/laravel/cache/drivers/memory.php b/laravel/cache/drivers/memory.php | |
index 3e23334..9f57592 100755 | |
--- a/laravel/cache/drivers/memory.php | |
+++ b/laravel/cache/drivers/memory.php | |
@@ -1,13 +1,13 @@ | |
<?php namespace Laravel\Cache\Drivers; | |
-class Memory extends Driver { | |
+class Memory extends Sectionable { | |
/** | |
* The in-memory array of cached items. | |
* | |
* @var string | |
*/ | |
- protected $storage = array(); | |
+ public $storage = array(); | |
/** | |
* Determine if an item exists in the cache. | |
@@ -28,9 +28,15 @@ class Memory extends Driver { | |
*/ | |
protected function retrieve($key) | |
{ | |
- if (array_key_exists($key, $this->storage)) | |
+ if ($this->sectionable($key)) | |
{ | |
- return $this->storage[$key]; | |
+ list($section, $key) = $this->parse($key); | |
+ | |
+ return $this->get_from_section($section, $key); | |
+ } | |
+ else | |
+ { | |
+ return array_get($this->storage, $key); | |
} | |
} | |
@@ -49,7 +55,16 @@ class Memory extends Driver { | |
*/ | |
public function put($key, $value, $minutes) | |
{ | |
- $this->storage[$key] = $value; | |
+ if ($this->sectionable($key)) | |
+ { | |
+ list($section, $key) = $this->parse($key); | |
+ | |
+ return $this->put_in_section($section, $key, $value, $minutes); | |
+ } | |
+ else | |
+ { | |
+ array_set($this->storage, $key, $value); | |
+ } | |
} | |
/** | |
@@ -61,7 +76,16 @@ class Memory extends Driver { | |
*/ | |
public function forever($key, $value) | |
{ | |
- $this->put($key, $value, 0); | |
+ if ($this->sectionable($key)) | |
+ { | |
+ list($section, $key) = $this->parse($key); | |
+ | |
+ return $this->forever_in_section($section, $key, $value); | |
+ } | |
+ else | |
+ { | |
+ $this->put($key, $value, 0); | |
+ } | |
} | |
/** | |
@@ -72,7 +96,34 @@ class Memory extends Driver { | |
*/ | |
public function forget($key) | |
{ | |
- unset($this->storage[$key]); | |
+ if ($this->sectionable($key)) | |
+ { | |
+ list($section, $key) = $this->parse($key); | |
+ | |
+ if ($key == '*') | |
+ { | |
+ $this->forget_section($section); | |
+ } | |
+ else | |
+ { | |
+ $this->forget_in_section($section, $key); | |
+ } | |
+ } | |
+ else | |
+ { | |
+ array_forget($this->storage, $key); | |
+ } | |
+ } | |
+ | |
+ /** | |
+ * Delete an entire section from the cache. | |
+ * | |
+ * @param string $section | |
+ * @return int|bool | |
+ */ | |
+ public function forget_section($section) | |
+ { | |
+ array_forget($this->storage, 'section#'.$section); | |
} | |
/** | |
@@ -85,4 +136,16 @@ class Memory extends Driver { | |
$this->storage = array(); | |
} | |
+ /** | |
+ * Get a section item key for a given section and key. | |
+ * | |
+ * @param string $section | |
+ * @param string $key | |
+ * @return string | |
+ */ | |
+ protected function section_item_key($section, $key) | |
+ { | |
+ return "section#{$section}.{$key}"; | |
+ } | |
+ | |
} | |
\ No newline at end of file | |
diff --git a/laravel/cli/artisan.php b/laravel/cli/artisan.php | |
index a838f8e..46886dc 100755 | |
--- a/laravel/cli/artisan.php | |
+++ b/laravel/cli/artisan.php | |
@@ -2,6 +2,7 @@ | |
use Laravel\Bundle; | |
use Laravel\Config; | |
+use Laravel\Request; | |
/** | |
* Fire up the default bundle. This will ensure any dependencies that | |
@@ -15,9 +16,10 @@ Bundle::start(DEFAULT_BUNDLE); | |
* for the "database" CLI option. This allows migrations to be run | |
* conveniently for a test or staging database. | |
*/ | |
-if (isset($_SERVER['CLI']['DB'])) | |
+ | |
+if ( ! is_null($database = get_cli_option('db'))) | |
{ | |
- Config::set('database.default', $_SERVER['CLI']['DB']); | |
+ Config::set('database.default', $database); | |
} | |
/** | |
diff --git a/laravel/cli/tasks/bundle/providers/provider.php b/laravel/cli/tasks/bundle/providers/provider.php | |
index bdf3b8c..bf6401f 100755 | |
--- a/laravel/cli/tasks/bundle/providers/provider.php | |
+++ b/laravel/cli/tasks/bundle/providers/provider.php | |
@@ -54,6 +54,7 @@ abstract class Provider { | |
File::rmdir($work.'zip'); | |
+ $zip->close(); | |
@unlink($target); | |
} | |
diff --git a/laravel/config.php b/laravel/config.php | |
index 9ea6894..50bd7dc 100755 | |
--- a/laravel/config.php | |
+++ b/laravel/config.php | |
@@ -1,7 +1,5 @@ | |
<?php namespace Laravel; defined('DS') or die('No direct script access.'); | |
-use Closure; | |
- | |
class Config { | |
/** | |
@@ -226,9 +224,9 @@ class Config { | |
// Configuration files can be made specific for a given environment. If an | |
// environment has been set, we will merge the environment configuration | |
// in last, so that it overrides all other options. | |
- if (isset($_SERVER['LARAVEL_ENV'])) | |
+ if ( ! is_null(Request::env())) | |
{ | |
- $paths[] = $paths[count($paths) - 1].$_SERVER['LARAVEL_ENV'].'/'; | |
+ $paths[] = $paths[count($paths) - 1].Request::env().'/'; | |
} | |
return $paths; | |
diff --git a/laravel/cookie.php b/laravel/cookie.php | |
index 0f92818..8896740 100755 | |
--- a/laravel/cookie.php | |
+++ b/laravel/cookie.php | |
@@ -1,10 +1,15 @@ | |
-<?php namespace Laravel; defined('DS') or die('No direct script access.'); | |
- | |
-use Closure; | |
+<?php namespace Laravel; | |
class Cookie { | |
/** | |
+ * How long is forever (in minutes). | |
+ * | |
+ * @var int | |
+ */ | |
+ const forever = 525600; | |
+ | |
+ /** | |
* The cookies that have been set. | |
* | |
* @var array | |
@@ -23,67 +28,13 @@ class Cookie { | |
} | |
/** | |
- * Send all of the cookies to the browser. | |
- * | |
- * @return void | |
- */ | |
- public static function send() | |
- { | |
- if (headers_sent()) return false; | |
- | |
- // All cookies are stored in the "jar" when set and not sent directly to | |
- // the browser. This simply makes testing all of the cookie stuff very | |
- // easy since the jar can be inspected by tests. | |
- foreach (static::$jar as $cookie) | |
- { | |
- static::set($cookie); | |
- } | |
- } | |
- | |
- /** | |
- * Send a cookie from the cookie jar back to the browser. | |
- * | |
- * @param array $cookie | |
- * @return void | |
- */ | |
- protected static function set($cookie) | |
- { | |
- extract($cookie); | |
- | |
- $time = ($minutes !== 0) ? time() + ($minutes * 60) : 0; | |
- | |
- $value = static::sign($name, $value); | |
- | |
- // A cookie payload can't exceed 4096 bytes, so if the cookie payload | |
- // is greater than that, we'll raise an error to warn the developer | |
- // since it could cause cookie session problems. | |
- if (strlen($value) > 4000) | |
- { | |
- throw new \Exception("Payload too large for cookie."); | |
- } | |
- else | |
- { | |
- // We don't want to send secure cookies over HTTP unless the developer has | |
- // turned off the "SSL" application configuration option, which is used | |
- // while developing the application but should be true in production. | |
- if ($secure and ! Request::secure() and Config::get('application.ssl')) | |
- { | |
- return; | |
- } | |
- | |
- setcookie($name, $value, $time, $path, $domain, $secure); | |
- } | |
- } | |
- | |
- | |
- /** | |
* Get the value of a cookie. | |
* | |
* <code> | |
* // Get the value of the "favorite" cookie | |
* $favorite = Cookie::get('favorite'); | |
* | |
- * // Get the value of a cookie or return a default value | |
+ * // Get the value of a cookie or return a default value | |
* $favorite = Cookie::get('framework', 'Laravel'); | |
* </code> | |
* | |
@@ -93,27 +44,9 @@ class Cookie { | |
*/ | |
public static function get($name, $default = null) | |
{ | |
- if (isset(static::$jar[$name])) return static::$jar[$name]['value']; | |
- | |
- $value = array_get($_COOKIE, $name); | |
- | |
- if ( ! is_null($value) and isset($value[40]) and $value[40] == '~') | |
- { | |
- // The hash signature and the cookie value are separated by a tilde | |
- // character for convenience. To separate the hash and the payload | |
- // we can simply expode on that character. | |
- list($hash, $value) = explode('~', $value, 2); | |
+ if (isset(static::$jar[$name])) return static::$jar[$name]; | |
- // By re-feeding the cookie value into the "hash" method we should | |
- // be able to generate a hash that matches the one taken from the | |
- // cookie. If they don't, we return null. | |
- if (static::hash($name, $value) === $hash) | |
- { | |
- return $value; | |
- } | |
- } | |
- | |
- return value($default); | |
+ return array_get(Request::foundation()->cookies->all(), $name, $default); | |
} | |
/** | |
@@ -129,15 +62,28 @@ class Cookie { | |
* | |
* @param string $name | |
* @param string $value | |
- * @param int $minutes | |
+ * @param int $expiration | |
* @param string $path | |
* @param string $domain | |
* @param bool $secure | |
* @return void | |
*/ | |
- public static function put($name, $value, $minutes = 0, $path = '/', $domain = null, $secure = false) | |
+ public static function put($name, $value, $expiration = 0, $path = '/', $domain = null, $secure = false) | |
{ | |
- static::$jar[$name] = compact('name', 'value', 'minutes', 'path', 'domain', 'secure'); | |
+ if ($expiration !== 0) | |
+ { | |
+ $expiration = time() + ($expiration * 60); | |
+ } | |
+ | |
+ // If the secure option is set to true, yet the request is not over HTTPS | |
+ // we'll throw an exception to let the developer know that they are | |
+ // attempting to send a secure cookie over the unsecure HTTP. | |
+ if ($secure and ! Request::secure()) | |
+ { | |
+ throw new \Exception("Attempting to set secure cookie over HTTP."); | |
+ } | |
+ | |
+ static::$jar[$name] = compact('name', 'value', 'expiration', 'path', 'domain', 'secure'); | |
} | |
/** | |
@@ -157,31 +103,7 @@ class Cookie { | |
*/ | |
public static function forever($name, $value, $path = '/', $domain = null, $secure = false) | |
{ | |
- return static::put($name, $value, 525600, $path, $domain, $secure); | |
- } | |
- | |
- /** | |
- * Generate a cookie signature based on the contents. | |
- * | |
- * @param string $name | |
- * @param string $value | |
- * @return string | |
- */ | |
- public static function sign($name, $value) | |
- { | |
- return static::hash($name, $value).'~'.$value; | |
- } | |
- | |
- /** | |
- * Generate a cookie hash based on the contents. | |
- * | |
- * @param string $name | |
- * @param string $value | |
- * @return string | |
- */ | |
- protected static function hash($name, $value) | |
- { | |
- return sha1($name.$value.Config::get('application.key')); | |
+ return static::put($name, $value, static::forever, $path, $domain, $secure); | |
} | |
/** | |
diff --git a/laravel/core.php b/laravel/core.php | |
index aeec701..0dcaaca 100755 | |
--- a/laravel/core.php | |
+++ b/laravel/core.php | |
@@ -92,53 +92,116 @@ Autoloader::map(array( | |
| Register The Symfony Components | |
|-------------------------------------------------------------------------- | |
| | |
-| Laravel's "Artisan" CLI makes use of the Symfony Console component to | |
-| build a wonderful CLI environment that is both robust and testable. | |
-| We'll register the component's namespace here. | |
+| Laravel makes use of the Symfony components where the situation is | |
+| applicable and it is possible to do so. This allows us to focus | |
+| on the parts of the framework that are unique and not re-do | |
+| plumbing code that others have written. | |
| | |
*/ | |
Autoloader::namespaces(array( | |
- 'Symfony\Component\Console' => path('base').'vendor/Symfony/Component/Console', | |
+ 'Symfony\Component\Console' | |
+ => path('sys').'vendor/Symfony/Component/Console', | |
+ 'Symfony\Component\HttpFoundation' | |
+ => path('sys').'vendor/Symfony/Component/HttpFoundation', | |
)); | |
/* | |
|-------------------------------------------------------------------------- | |
-| Set The CLI Options Array | |
+| Magic Quotes Strip Slashes | |
|-------------------------------------------------------------------------- | |
| | |
-| If the current request is from the Artisan command-line interface, we | |
-| will parse the command line arguments and options and set them the | |
-| array of options in the $_SERVER global array for convenience. | |
+| Even though "Magic Quotes" are deprecated in PHP 5.3.x, they may still | |
+| be enabled on the server. To account for this, we will strip slashes | |
+| on all input arrays if magic quotes are enabled for the server. | |
| | |
*/ | |
-if (defined('STDIN')) | |
+if (magic_quotes()) | |
{ | |
- $console = CLI\Command::options($_SERVER['argv']); | |
+ $magics = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); | |
- list($arguments, $options) = $console; | |
+ foreach ($magics as &$magic) | |
+ { | |
+ $magic = array_strip_slashes($magic); | |
+ } | |
+} | |
- $options = array_change_key_case($options, CASE_UPPER); | |
+/* | |
+|-------------------------------------------------------------------------- | |
+| Create The HttpFoundation Request | |
+|-------------------------------------------------------------------------- | |
+| | |
+| Laravel uses the HttpFoundation Symfony component to handle the request | |
+| and response functionality for the framework. This allows us to not | |
+| worry about that boilerplate code and focus on what matters. | |
+| | |
+*/ | |
- $_SERVER['CLI'] = $options; | |
+use Symfony\Component\HttpFoundation\LaravelRequest as RequestFoundation; | |
+ | |
+Request::$foundation = RequestFoundation::createFromGlobals(); | |
+ | |
+/* | |
+|-------------------------------------------------------------------------- | |
+| Determine The Application Environment | |
+|-------------------------------------------------------------------------- | |
+| | |
+| Next we're ready to determine the application environment. This may be | |
+| set either via the command line options, or, if the request is from | |
+| the web, via the mapping of URIs to environments that lives in | |
+| the "paths.php" file for the application and is parsed. | |
+| | |
+*/ | |
+ | |
+if (Request::cli()) | |
+{ | |
+ $environment = get_cli_option('env'); | |
+} | |
+else | |
+{ | |
+ $root = Request::foundation()->getRootUrl(); | |
+ | |
+ $environment = Request::detect_env($environments, $root); | |
} | |
/* | |
|-------------------------------------------------------------------------- | |
-| Set The CLI Laravel Environment | |
+| Set The Application Environment | |
|-------------------------------------------------------------------------- | |
| | |
-| Next we'll set the LARAVEL_ENV variable if the current request is from | |
-| the Artisan command-line interface. Since the environment is often | |
-| specified within an Apache .htaccess file, we need to set it here | |
-| when the request is not coming through Apache. | |
+| Once we have determined the application environment, we will set it on | |
+| the global server array of the HttpFoundation request. This makes it | |
+| available throughout the application, thought it is mainly only | |
+| used to determine which configuration files to merge in. | |
| | |
*/ | |
-if (isset($_SERVER['CLI']['ENV'])) | |
+if (isset($environment)) | |
{ | |
- $_SERVER['LARAVEL_ENV'] = $_SERVER['CLI']['ENV']; | |
+ Request::set_env($environment); | |
+} | |
+ | |
+/* | |
+|-------------------------------------------------------------------------- | |
+| Set The CLI Options Array | |
+|-------------------------------------------------------------------------- | |
+| | |
+| If the current request is from the Artisan command-line interface, we | |
+| will parse the command line arguments and options and set them the | |
+| array of options in the $_SERVER global array for convenience. | |
+| | |
+*/ | |
+ | |
+if (defined('STDIN')) | |
+{ | |
+ $console = CLI\Command::options($_SERVER['argv']); | |
+ | |
+ list($arguments, $options) = $console; | |
+ | |
+ $options = array_change_key_case($options, CASE_UPPER); | |
+ | |
+ $_SERVER['CLI'] = $options; | |
} | |
/* | |
@@ -147,7 +210,7 @@ if (isset($_SERVER['CLI']['ENV'])) | |
|-------------------------------------------------------------------------- | |
| | |
| Finally we will register all of the bundles that have been defined for | |
-| the application. None of them will be started, yet but will be setup | |
+| the application. None of them will be started yet, but will be setup | |
| so that they may be started by the developer at any time. | |
| | |
*/ | |
diff --git a/laravel/crypter.php b/laravel/crypter.php | |
index f5113f3..18bac81 100755 | |
--- a/laravel/crypter.php | |
+++ b/laravel/crypter.php | |
@@ -74,7 +74,7 @@ class Crypter { | |
* | |
* @return int | |
*/ | |
- protected static function randomizer() | |
+ public static function randomizer() | |
{ | |
// There are various sources from which we can get random numbers | |
// but some are more random than others. We'll choose the most | |
diff --git a/laravel/database.php b/laravel/database.php | |
index 447fa76..e403616 100755 | |
--- a/laravel/database.php | |
+++ b/laravel/database.php | |
@@ -13,6 +13,13 @@ class Database { | |
public static $connections = array(); | |
/** | |
+ * The third-party driver registrar. | |
+ * | |
+ * @var array | |
+ */ | |
+ public static $registrar = array(); | |
+ | |
+ /** | |
* Get a database connection. | |
* | |
* If no database name is specified, the default connection will be returned. | |
@@ -66,6 +73,13 @@ class Database { | |
*/ | |
protected static function connector($driver) | |
{ | |
+ if (isset(static::$registrar[$driver])) | |
+ { | |
+ $resolver = static::$registrar[$driver]['connector']; | |
+ | |
+ return $resolver(); | |
+ } | |
+ | |
switch ($driver) | |
{ | |
case 'sqlite': | |
@@ -121,6 +135,22 @@ class Database { | |
} | |
/** | |
+ * Register a database connector and grammars. | |
+ * | |
+ * @param string $name | |
+ * @param Closure $connector | |
+ * @param Closure $query | |
+ * @param Closure $schema | |
+ * @return void | |
+ */ | |
+ public static function extend($name, Closure $connector, $query = null, $schema = null) | |
+ { | |
+ if (is_null($query)) $query = '\Laravel\Database\Query\Grammars\Grammar'; | |
+ | |
+ static::$registrar[$name] = compact('connector', 'query', 'schema'); | |
+ } | |
+ | |
+ /** | |
* Magic Method for calling methods on the default database connection. | |
* | |
* <code> | |
diff --git a/laravel/database/connection.php b/laravel/database/connection.php | |
index 5b2ec0e..dd1d8de 100755 | |
--- a/laravel/database/connection.php | |
+++ b/laravel/database/connection.php | |
@@ -1,4 +1,6 @@ | |
-<?php namespace Laravel\Database; use PDO, PDOStatement, Laravel\Config, Laravel\Event; | |
+<?php namespace Laravel\Database; | |
+ | |
+use PDO, PDOStatement, Laravel\Config, Laravel\Event; | |
class Connection { | |
@@ -71,11 +73,19 @@ class Connection { | |
{ | |
if (isset($this->grammar)) return $this->grammar; | |
- switch (isset($this->config['grammar']) ? $this->config['grammar'] : $this->driver()) | |
+ if (isset(\Laravel\Database::$registrar[$this->driver()])) | |
+ { | |
+ \Laravel\Database::$registrar[$this->driver()]['query'](); | |
+ } | |
+ | |
+ switch ($this->driver()) | |
{ | |
case 'mysql': | |
return $this->grammar = new Query\Grammars\MySQL($this); | |
+ case 'sqlite': | |
+ return $this->grammar = new Query\Grammars\SQLite($this); | |
+ | |
case 'sqlsrv': | |
return $this->grammar = new Query\Grammars\SQLServer($this); | |
@@ -87,14 +97,14 @@ class Connection { | |
/** | |
* Execute a callback wrapped in a database transaction. | |
* | |
- * @param Closure $callback | |
+ * @param callback $callback | |
* @return void | |
*/ | |
public function transaction($callback) | |
{ | |
$this->pdo->beginTransaction(); | |
- // After beginning the database transaction, we will call the Closure | |
+ // After beginning the database transaction, we will call the callback | |
// so that it can do its database work. If an exception occurs we'll | |
// rollback the transaction and re-throw back to the developer. | |
try | |
@@ -165,6 +175,8 @@ class Connection { | |
*/ | |
public function query($sql, $bindings = array()) | |
{ | |
+ $sql = trim($sql); | |
+ | |
list($statement, $result) = $this->execute($sql, $bindings); | |
// The result we return depends on the type of query executed against the | |
@@ -209,6 +221,19 @@ class Connection { | |
$sql = $this->grammar()->shortcut($sql, $bindings); | |
+ // Next we need to translate all DateTime bindings to their date-time | |
+ // strings that are compatible with the database. Each grammar may | |
+ // define it's own date-time format according to its needs. | |
+ $datetime = $this->grammar()->datetime; | |
+ | |
+ for ($i = 0; $i < count($bindings); $i++) | |
+ { | |
+ if ($bindings[$i] instanceof \DateTime) | |
+ { | |
+ $bindings[$i] = $bindings[$i]->format($datetime); | |
+ } | |
+ } | |
+ | |
// Each database operation is wrapped in a try / catch so we can wrap | |
// any database exceptions in our custom exception class, which will | |
// set the message to include the SQL and query bindings. | |
@@ -287,7 +312,7 @@ class Connection { | |
*/ | |
public function driver() | |
{ | |
- return $this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME); | |
+ return $this->config['driver']; | |
} | |
/** | |
@@ -298,4 +323,4 @@ class Connection { | |
return $this->table($method); | |
} | |
-} | |
\ No newline at end of file | |
+} | |
diff --git a/laravel/database/eloquent/model.php b/laravel/database/eloquent/model.php | |
index 966a00c..3af4905 100755 | |
--- a/laravel/database/eloquent/model.php | |
+++ b/laravel/database/eloquent/model.php | |
@@ -1,6 +1,7 @@ | |
<?php namespace Laravel\Database\Eloquent; | |
use Laravel\Str; | |
+use Laravel\Event; | |
use Laravel\Database; | |
use Laravel\Database\Eloquent\Relationships\Has_Many_And_Belongs_To; | |
@@ -56,6 +57,13 @@ abstract class Model { | |
public static $accessible; | |
/** | |
+ * The attributes that should be excluded from to_array. | |
+ * | |
+ * @var array | |
+ */ | |
+ public static $hidden = array(); | |
+ | |
+ /** | |
* Indicates if the model has update and creation timestamps. | |
* | |
* @var bool | |
@@ -108,14 +116,23 @@ abstract class Model { | |
* Hydrate the model with an array of attributes. | |
* | |
* @param array $attributes | |
+ * @param bool $raw | |
* @return Model | |
*/ | |
- public function fill($attributes) | |
+ public function fill(array $attributes, $raw = false) | |
{ | |
- $attributes = (array) $attributes; | |
- | |
foreach ($attributes as $key => $value) | |
{ | |
+ // If the "raw" flag is set, it means that we'll just load every value from | |
+ // the array directly into the attributes, without any accessibility or | |
+ // mutators being accounted for. What you pass in is what you get. | |
+ if ($raw) | |
+ { | |
+ $this->set_attribute($key, $value); | |
+ | |
+ continue; | |
+ } | |
+ | |
// If the "accessible" property is an array, the developer is limiting the | |
// attributes that may be mass assigned, and we need to verify that the | |
// current attribute is included in that list of allowed attributes. | |
@@ -148,13 +165,28 @@ abstract class Model { | |
} | |
/** | |
+ * Fill the model with the contents of the array. | |
+ * | |
+ * No mutators or accessibility checks will be accounted for. | |
+ * | |
+ * @param array $attributes | |
+ * @return Model | |
+ */ | |
+ public function fill_raw(array $attributes) | |
+ { | |
+ return $this->fill($attributes, true); | |
+ } | |
+ | |
+ /** | |
* Set the accessible attributes for the given model. | |
* | |
* @param array $attributes | |
* @return void | |
*/ | |
- public static function accessible($attributes) | |
+ public static function accessible($attributes = null) | |
{ | |
+ if (is_null($attributes)) return static::$accessible; | |
+ | |
static::$accessible = $attributes; | |
} | |
@@ -186,7 +218,7 @@ abstract class Model { | |
{ | |
$model = new static(array(), true); | |
- if (static::$timestamps) $attributes['updated_at'] = $model->get_timestamp(); | |
+ if (static::$timestamps) $attributes['updated_at'] = new \DateTime; | |
return $model->query()->where($model->key(), '=', $id)->update($attributes); | |
} | |
@@ -348,6 +380,8 @@ abstract class Model { | |
$this->timestamp(); | |
} | |
+ $this->fire_event('saving'); | |
+ | |
// If the model exists, we only need to update it in the database, and the update | |
// will be considered successful if there is one affected row returned from the | |
// fluent query instance. We'll set the where condition automatically. | |
@@ -356,6 +390,8 @@ abstract class Model { | |
$query = $this->query()->where(static::$key, '=', $this->get_key()); | |
$result = $query->update($this->get_dirty()) === 1; | |
+ | |
+ if ($result) $this->fire_event('updated'); | |
} | |
// If the model does not exist, we will insert the record and retrieve the last | |
@@ -368,6 +404,8 @@ abstract class Model { | |
$this->set_key($id); | |
$this->exists = $result = is_numeric($this->get_key()); | |
+ | |
+ if ($result) $this->fire_event('created'); | |
} | |
// After the model has been "saved", we will set the original attributes to | |
@@ -375,6 +413,11 @@ abstract class Model { | |
// dirty and subsequent calls won't hit the database. | |
$this->original = $this->attributes; | |
+ if ($result) | |
+ { | |
+ $this->fire_event('saved'); | |
+ } | |
+ | |
return $result; | |
} | |
@@ -387,7 +430,13 @@ abstract class Model { | |
{ | |
if ($this->exists) | |
{ | |
- return $this->query()->where(static::$key, '=', $this->get_key())->delete(); | |
+ $this->fire_event('deleting'); | |
+ | |
+ $result = $this->query()->where(static::$key, '=', $this->get_key())->delete(); | |
+ | |
+ $this->fire_event('deleted'); | |
+ | |
+ return $result; | |
} | |
} | |
@@ -398,22 +447,12 @@ abstract class Model { | |
*/ | |
protected function timestamp() | |
{ | |
- $this->updated_at = $this->get_timestamp(); | |
+ $this->updated_at = new \DateTime; | |
if ( ! $this->exists) $this->created_at = $this->updated_at; | |
} | |
/** | |
- * Get the current timestamp in its storable form. | |
- * | |
- * @return mixed | |
- */ | |
- public function get_timestamp() | |
- { | |
- return date('Y-m-d H:i:s'); | |
- } | |
- | |
- /** | |
* Get a new fluent query builder instance for the model. | |
* | |
* @return Query | |
@@ -475,7 +514,17 @@ abstract class Model { | |
*/ | |
public function get_dirty() | |
{ | |
- return array_diff_assoc($this->attributes, $this->original); | |
+ $dirty = array(); | |
+ | |
+ foreach ($this->attributes as $key => $value) | |
+ { | |
+ if ( ! isset($this->original[$key]) or $value !== $this->original[$key]) | |
+ { | |
+ $dirty[$key] = $value; | |
+ } | |
+ } | |
+ | |
+ return $dirty; | |
} | |
/** | |
@@ -534,6 +583,68 @@ abstract class Model { | |
} | |
/** | |
+ * Get the model attributes and relationships in array form. | |
+ * | |
+ * @return array | |
+ */ | |
+ public function to_array() | |
+ { | |
+ $attributes = array(); | |
+ | |
+ // First we need to gather all of the regular attributes. If the attribute | |
+ // exists in the array of "hidden" attributes, it will not be added to | |
+ // the array so we can easily exclude things like passwords, etc. | |
+ foreach (array_keys($this->attributes) as $attribute) | |
+ { | |
+ if ( ! in_array($attribute, static::$hidden)) | |
+ { | |
+ $attributes[$attribute] = $this->$attribute; | |
+ } | |
+ } | |
+ | |
+ foreach ($this->relationships as $name => $models) | |
+ { | |
+ // If the relationship is not a "to-many" relationship, we can just | |
+ // to_array the related model and add it as an attribute to the | |
+ // array of existing regular attributes we gathered. | |
+ if ($models instanceof Model) | |
+ { | |
+ $attributes[$name] = $models->to_array(); | |
+ } | |
+ | |
+ // If the relationship is a "to-many" relationship we need to spin | |
+ // through each of the related models and add each one with the | |
+ // to_array method, keying them both by name and ID. | |
+ elseif (is_array($models)) | |
+ { | |
+ foreach ($models as $id => $model) | |
+ { | |
+ $attributes[$name][$id] = $model->to_array(); | |
+ } | |
+ } | |
+ elseif (is_null($models)) | |
+ { | |
+ $attributes[$name] = $models; | |
+ } | |
+ } | |
+ | |
+ return $attributes; | |
+ } | |
+ | |
+ /** | |
+ * Fire a given event for the model. | |
+ * | |
+ * @param string $event | |
+ * @return array | |
+ */ | |
+ protected function fire_event($event) | |
+ { | |
+ $events = array("eloquent.{$event}", "eloquent.{$event}: ".get_class($this)); | |
+ | |
+ Event::fire($events, array($this)); | |
+ } | |
+ | |
+ /** | |
* Handle the dynamic retrieval of attributes and associations. | |
* | |
* @param string $key | |
@@ -598,6 +709,8 @@ abstract class Model { | |
{ | |
if (array_key_exists($key, $this->$source)) return true; | |
} | |
+ | |
+ if (method_exists($this, $key)) return true; | |
} | |
/** | |
@@ -623,10 +736,12 @@ abstract class Model { | |
*/ | |
public function __call($method, $parameters) | |
{ | |
+ $meta = array('key', 'table', 'connection', 'sequence', 'per_page', 'timestamps'); | |
+ | |
// If the method is actually the name of a static property on the model we'll | |
// return the value of the static property. This makes it convenient for | |
// relationships to access these values off of the instances. | |
- if (in_array($method, array('key', 'table', 'connection', 'sequence', 'per_page'))) | |
+ if (in_array($method, $meta)) | |
{ | |
return static::$$method; | |
} | |
@@ -644,11 +759,11 @@ abstract class Model { | |
// to perform the appropriate action based on the method. | |
if (starts_with($method, 'get_')) | |
{ | |
- return $this->attributes[substr($method, 4)]; | |
+ return $this->get_attribute(substr($method, 4)); | |
} | |
elseif (starts_with($method, 'set_')) | |
{ | |
- $this->attributes[substr($method, 4)] = $parameters[0]; | |
+ $this->set_attribute(substr($method, 4), $parameters[0]); | |
} | |
// Finally we will assume that the method is actually the beginning of a | |
diff --git a/laravel/database/eloquent/pivot.php b/laravel/database/eloquent/pivot.php | |
index b98fc22..d2878bb 100755 | |
--- a/laravel/database/eloquent/pivot.php | |
+++ b/laravel/database/eloquent/pivot.php | |
@@ -20,11 +20,13 @@ class Pivot extends Model { | |
* Create a new pivot table instance. | |
* | |
* @param string $table | |
+ * @param string $connection | |
* @return void | |
*/ | |
- public function __construct($table) | |
+ public function __construct($table, $connection = null) | |
{ | |
$this->pivot_table = $table; | |
+ $this->connection = $connection; | |
parent::__construct(array(), true); | |
} | |
@@ -39,4 +41,14 @@ class Pivot extends Model { | |
return $this->pivot_table; | |
} | |
+ /** | |
+ * Get the connection used by the pivot table. | |
+ * | |
+ * @return string | |
+ */ | |
+ public function connection() | |
+ { | |
+ return $this->connection; | |
+ } | |
+ | |
} | |
\ No newline at end of file | |
diff --git a/laravel/database/eloquent/query.php b/laravel/database/eloquent/query.php | |
index e55e6a4..3aee79c 100755 | |
--- a/laravel/database/eloquent/query.php | |
+++ b/laravel/database/eloquent/query.php | |
@@ -1,5 +1,6 @@ | |
<?php namespace Laravel\Database\Eloquent; | |
+use Laravel\Event; | |
use Laravel\Database; | |
use Laravel\Database\Eloquent\Relationships\Has_Many_And_Belongs_To; | |
@@ -33,7 +34,7 @@ class Query { | |
*/ | |
public $passthru = array( | |
'lists', 'only', 'insert', 'insert_get_id', 'update', 'increment', | |
- 'decrement', 'count', 'min', 'max', 'avg', 'sum', | |
+ 'delete', 'decrement', 'count', 'min', 'max', 'avg', 'sum', | |
); | |
/** | |
@@ -66,12 +67,11 @@ class Query { | |
* Get all of the model results for the query. | |
* | |
* @param array $columns | |
- * @param bool $keyed | |
* @return array | |
*/ | |
- public function get($columns = array('*'), $keyed = true) | |
+ public function get($columns = array('*')) | |
{ | |
- return $this->hydrate($this->model, $this->table->get($columns), $keyed); | |
+ return $this->hydrate($this->model, $this->table->get($columns)); | |
} | |
/** | |
@@ -100,10 +100,9 @@ class Query { | |
* | |
* @param Model $model | |
* @param array $results | |
- * @param bool $keyed | |
* @return array | |
*/ | |
- public function hydrate($model, $results, $keyed = true) | |
+ public function hydrate($model, $results) | |
{ | |
$class = get_class($model); | |
@@ -121,33 +120,18 @@ class Query { | |
// We need to set the attributes manually in case the accessible property is | |
// set on the array which will prevent the mass assignemnt of attributes if | |
// we were to pass them in using the constructor or fill methods. | |
- foreach ($result as $key => $value) | |
- { | |
- $new->set_attribute($key, $value); | |
- } | |
- | |
- $new->original = $new->attributes; | |
+ $new->fill_raw($result); | |
- // Typically, the resulting models are keyed by their primary key, but it | |
- // may be useful to not do this in some circumstances such as when we | |
- // are eager loading a *-to-* relationships which has duplicates. | |
- if ($keyed) | |
- { | |
- $models[$result[$this->model->key()]] = $new; | |
- } | |
- else | |
- { | |
- $models[] = $new; | |
- } | |
+ $models[] = $new; | |
} | |
if (count($results) > 0) | |
{ | |
foreach ($this->model_includes() as $relationship => $constraints) | |
{ | |
- // If the relationship is nested, we will skip laoding it here and let | |
+ // If the relationship is nested, we will skip loading it here and let | |
// the load method parse and set the nested eager loads on the right | |
- // relationship when it is getting ready to eager laod. | |
+ // relationship when it is getting ready to eager load. | |
if (str_contains($relationship, '.')) | |
{ | |
continue; | |
@@ -199,17 +183,7 @@ class Query { | |
$query->initialize($results, $relationship); | |
- // If we're eager loading a many-to-many relationship we will disable | |
- // the primary key indexing on the hydration since there could be | |
- // roles shared across users and we don't want to overwrite. | |
- if ( ! $query instanceof Has_Many_And_Belongs_To) | |
- { | |
- $query->match($relationship, $results, $query->get()); | |
- } | |
- else | |
- { | |
- $query->match($relationship, $results, $query->get(array('*'), false)); | |
- } | |
+ $query->match($relationship, $results, $query->get()); | |
} | |
/** | |
@@ -293,8 +267,8 @@ class Query { | |
$result = call_user_func_array(array($this->table, $method), $parameters); | |
// Some methods may get their results straight from the fluent query | |
- // builder, such as the aggregate methods. If the called method is | |
- // one of these, we will return the result straight away. | |
+ // builder such as the aggregate methods. If the called method is | |
+ // one of these, we will just return the result straight away. | |
if (in_array($method, $this->passthru)) | |
{ | |
return $result; | |
diff --git a/laravel/database/eloquent/relationships/belongs_to.php b/laravel/database/eloquent/relationships/belongs_to.php | |
index b73c57b..6ec8acd 100755 | |
--- a/laravel/database/eloquent/relationships/belongs_to.php | |
+++ b/laravel/database/eloquent/relationships/belongs_to.php | |
@@ -32,7 +32,7 @@ class Belongs_To extends Relationship { | |
*/ | |
protected function constrain() | |
{ | |
- $this->table->where($this->base->key(), '=', $this->foreign_value()); | |
+ $this->table->where($this->model->key(), '=', $this->foreign_value()); | |
} | |
/** | |
@@ -65,9 +65,14 @@ class Belongs_To extends Relationship { | |
// are looking for the parent of a child model in this relationship. | |
foreach ($results as $result) | |
{ | |
- $keys[] = $result->{$this->foreign_key()}; | |
+ if ( ! is_null($key = $result->{$this->foreign_key()})) | |
+ { | |
+ $keys[] = $key; | |
+ } | |
} | |
+ if (count($keys) == 0) $keys = array(0); | |
+ | |
$this->table->where_in($this->model->key(), array_unique($keys)); | |
} | |
@@ -84,9 +89,14 @@ class Belongs_To extends Relationship { | |
foreach ($children as &$child) | |
{ | |
- if (array_key_exists($child->$foreign, $parents)) | |
+ $parent = array_first($parents, function($k, $v) use ($child, $foreign) | |
+ { | |
+ return $v->get_key() == $child->$foreign; | |
+ }); | |
+ | |
+ if ( ! is_null($parent)) | |
{ | |
- $child->relationships[$relationship] = $parents[$child->$foreign]; | |
+ $child->relationships[$relationship] = $parent; | |
} | |
} | |
} | |
diff --git a/laravel/database/eloquent/relationships/has_many.php b/laravel/database/eloquent/relationships/has_many.php | |
index b80d384..92a9e49 100755 | |
--- a/laravel/database/eloquent/relationships/has_many.php | |
+++ b/laravel/database/eloquent/relationships/has_many.php | |
@@ -13,6 +13,59 @@ class Has_Many extends Has_One_Or_Many { | |
} | |
/** | |
+ * Sync the association table with an array of models. | |
+ * | |
+ * @param mixed $models | |
+ * @return bool | |
+ */ | |
+ public function save($models) | |
+ { | |
+ // If the given "models" are not an array, we'll force them into an array so | |
+ // we can conveniently loop through them and insert all of them into the | |
+ // related database table assigned to the associated model instance. | |
+ if ( ! is_array($models)) $models = array($models); | |
+ | |
+ $current = $this->table->lists($this->model->key()); | |
+ | |
+ foreach ($models as $attributes) | |
+ { | |
+ $class = get_class($this->model); | |
+ | |
+ // If the "attributes" are actually an array of the related model we'll | |
+ // just use the existing instance instead of creating a fresh model | |
+ // instance for the attributes. This allows for validation. | |
+ if ($attributes instanceof $class) | |
+ { | |
+ $model = $attributes; | |
+ } | |
+ else | |
+ { | |
+ $model = $this->fresh_model($attributes); | |
+ } | |
+ | |
+ // We'll need to associate the model with its parent, so we'll set the | |
+ // foreign key on the model to the key of the parent model, making | |
+ // sure that the two models are associated in the database. | |
+ $foreign = $this->foreign_key(); | |
+ | |
+ $model->$foreign = $this->base->get_key(); | |
+ | |
+ $id = $model->get_key(); | |
+ | |
+ $model->exists = ( ! is_null($id) and in_array($id, $current)); | |
+ | |
+ // Before saving we'll force the entire model to be "dirty" so all of | |
+ // the attributes are saved. It shouldn't affect the updates as | |
+ // saving all the attributes shouldn't hurt anything. | |
+ $model->original = array(); | |
+ | |
+ $model->save(); | |
+ } | |
+ | |
+ return true; | |
+ } | |
+ | |
+ /** | |
* Initialize a relationship on an array of parent models. | |
* | |
* @param array $parents | |
@@ -38,9 +91,14 @@ class Has_Many extends Has_One_Or_Many { | |
{ | |
$foreign = $this->foreign_key(); | |
- foreach ($children as $key => $child) | |
+ foreach ($parents as &$parent) | |
{ | |
- $parents[$child->$foreign]->relationships[$relationship][$child->get_key()] = $child; | |
+ $matching = array_filter($children, function($v) use ($parent, $foreign) | |
+ { | |
+ return $v->$foreign == $parent->get_key(); | |
+ }); | |
+ | |
+ $parent->relationships[$relationship] = array_values($matching); | |
} | |
} | |
diff --git a/laravel/database/eloquent/relationships/has_many_and_belongs_to.php b/laravel/database/eloquent/relationships/has_many_and_belongs_to.php | |
index 9fecb66..587e504 100755 | |
--- a/laravel/database/eloquent/relationships/has_many_and_belongs_to.php | |
+++ b/laravel/database/eloquent/relationships/has_many_and_belongs_to.php | |
@@ -25,7 +25,7 @@ class Has_Many_And_Belongs_To extends Relationship { | |
* | |
* @var array | |
*/ | |
- protected $with = array('id', 'created_at', 'updated_at'); | |
+ protected $with = array('id'); | |
/** | |
* Create a new many to many relationship instance. | |
@@ -43,6 +43,16 @@ class Has_Many_And_Belongs_To extends Relationship { | |
$this->joining = $table ?: $this->joining($model, $associated); | |
+ // If the Pivot table is timestamped, we'll set the timestamp columns to be | |
+ // fetched when the pivot table models are fetched by the developer else | |
+ // the ID will be the only "extra" column fetched in by default. | |
+ if (Pivot::$timestamps) | |
+ { | |
+ $this->with[] = 'created_at'; | |
+ | |
+ $this->with[] = 'updated_at'; | |
+ } | |
+ | |
parent::__construct($model, $associated, $foreign); | |
} | |
@@ -87,6 +97,51 @@ class Has_Many_And_Belongs_To extends Relationship { | |
} | |
/** | |
+ * Detach a record from the joining table of the association. | |
+ * | |
+ * @param int $ids | |
+ * @return bool | |
+ */ | |
+ public function detach($ids) | |
+ { | |
+ if ( ! is_array($ids)) $ids = array($ids); | |
+ | |
+ return $this->pivot()->where_in($this->other_key(), $ids)->delete(); | |
+ } | |
+ | |
+ /** | |
+ * Sync the joining table with the array of given IDs. | |
+ * | |
+ * @param array $ids | |
+ * @return bool | |
+ */ | |
+ public function sync($ids) | |
+ { | |
+ $current = $this->pivot()->lists($this->other_key()); | |
+ | |
+ // First we need to attach any of the associated models that are not currently | |
+ // in the joining table. We'll spin through the given IDs, checking to see | |
+ // if they exist in the array of current ones, and if not we insert. | |
+ foreach ($ids as $id) | |
+ { | |
+ if ( ! in_array($id, $current)) | |
+ { | |
+ $this->attach($id); | |
+ } | |
+ } | |
+ | |
+ // Next we will take the difference of the current and given IDs and detach | |
+ // all of the entities that exists in the current array but are not in | |
+ // the array of IDs given to the method, finishing the sync. | |
+ $detach = array_diff($current, $ids); | |
+ | |
+ if (count($detach) > 0) | |
+ { | |
+ $this->detach(array_diff($current, $ids)); | |
+ } | |
+ } | |
+ | |
+ /** | |
* Insert a new record for the association. | |
* | |
* @param Model|array $attributes | |
@@ -147,9 +202,12 @@ class Has_Many_And_Belongs_To extends Relationship { | |
*/ | |
protected function insert_joining($attributes) | |
{ | |
- $attributes['created_at'] = $this->model->get_timestamp(); | |
+ if (Pivot::$timestamps) | |
+ { | |
+ $attributes['created_at'] = new \DateTime; | |
- $attributes['updated_at'] = $attributes['created_at']; | |
+ $attributes['updated_at'] = $attributes['created_at']; | |
+ } | |
return $this->joining_table()->insert($attributes); | |
} | |
@@ -192,7 +250,7 @@ class Has_Many_And_Belongs_To extends Relationship { | |
$this->with = array_merge($this->with, array($foreign, $other)); | |
// Since pivot tables may have extra information on them that the developer | |
- // needs, we allow an extra array of columns to be specified that will be | |
+ // needs we allow an extra array of columns to be specified that will be | |
// fetched from the pivot table and hydrate into the pivot model. | |
foreach ($this->with as $column) | |
{ | |
@@ -253,7 +311,7 @@ class Has_Many_And_Belongs_To extends Relationship { | |
*/ | |
public function eagerly_constrain($results) | |
{ | |
- $this->table->where_in($this->joining.'.'.$this->foreign_key(), array_keys($results)); | |
+ $this->table->where_in($this->joining.'.'.$this->foreign_key(), $this->keys($results)); | |
} | |
/** | |
@@ -267,9 +325,14 @@ class Has_Many_And_Belongs_To extends Relationship { | |
{ | |
$foreign = $this->foreign_key(); | |
- foreach ($children as $key => $child) | |
+ foreach ($parents as &$parent) | |
{ | |
- $parents[$child->pivot->$foreign]->relationships[$relationship][$child->{$child->key()}] = $child; | |
+ $matching = array_filter($children, function($v) use ($parent, $foreign) | |
+ { | |
+ return $v->pivot->$foreign == $parent->get_key(); | |
+ }); | |
+ | |
+ $parent->relationships[$relationship] = array_values($matching); | |
} | |
} | |
@@ -286,11 +349,11 @@ class Has_Many_And_Belongs_To extends Relationship { | |
// Every model result for a many-to-many relationship needs a Pivot instance | |
// to represent the pivot table's columns. Sometimes extra columns are on | |
// the pivot table that may need to be accessed by the developer. | |
- $pivot = new Pivot($this->joining); | |
+ $pivot = new Pivot($this->joining, $this->model->connection()); | |
// If the attribute key starts with "pivot_", we know this is a column on | |
// the pivot table, so we will move it to the Pivot model and purge it | |
- // from the model since it actually belongs to the pivot. | |
+ // from the model since it actually belongs to the pivot model. | |
foreach ($result->attributes as $key => $value) | |
{ | |
if (starts_with($key, 'pivot_')) | |
@@ -320,9 +383,9 @@ class Has_Many_And_Belongs_To extends Relationship { | |
{ | |
$columns = (is_array($columns)) ? $columns : func_get_args(); | |
- // The "with" array contains a couple of columns by default, so we will | |
- // just merge in the developer specified columns here, and we'll make | |
- // sure the values of the array are unique. | |
+ // The "with" array contains a couple of columns by default, so we will just | |
+ // merge in the developer specified columns here, and we will make sure | |
+ // the values of the array are unique to avoid duplicates. | |
$this->with = array_unique(array_merge($this->with, $columns)); | |
$this->set_select($this->foreign_key(), $this->other_key()); | |
@@ -331,17 +394,15 @@ class Has_Many_And_Belongs_To extends Relationship { | |
} | |
/** | |
- * Get a model instance of the pivot table for the relationship. | |
+ * Get a relationship instance of the pivot table. | |
* | |
- * @return Pivot | |
+ * @return Has_Many | |
*/ | |
public function pivot() | |
{ | |
- $key = $this->base->get_key(); | |
- | |
- $foreign = $this->foreign_key(); | |
+ $pivot = new Pivot($this->joining, $this->model->connection()); | |
- return with(new Pivot($this->joining))->where($foreign, '=', $key); | |
+ return new Has_Many($this->base, $pivot, $this->foreign_key()); | |
} | |
/** | |
diff --git a/laravel/database/eloquent/relationships/has_one.php b/laravel/database/eloquent/relationships/has_one.php | |
index 077c3ad..7addabb 100755 | |
--- a/laravel/database/eloquent/relationships/has_one.php | |
+++ b/laravel/database/eloquent/relationships/has_one.php | |
@@ -38,9 +38,14 @@ class Has_One extends Has_One_Or_Many { | |
{ | |
$foreign = $this->foreign_key(); | |
- foreach ($children as $key => $child) | |
+ foreach ($parents as &$parent) | |
{ | |
- $parents[$child->$foreign]->relationships[$relationship] = $child; | |
+ $matching = array_first($children, function($k, $v) use ($parent, $foreign) | |
+ { | |
+ return $v->$foreign == $parent->get_key(); | |
+ }); | |
+ | |
+ $parent->relationships[$relationship] = $matching; | |
} | |
} | |
diff --git a/laravel/database/eloquent/relationships/has_one_or_many.php b/laravel/database/eloquent/relationships/has_one_or_many.php | |
index 2cdac83..a8268de 100755 | |
--- a/laravel/database/eloquent/relationships/has_one_or_many.php | |
+++ b/laravel/database/eloquent/relationships/has_one_or_many.php | |
@@ -20,6 +20,22 @@ class Has_One_Or_Many extends Relationship { | |
} | |
/** | |
+ * Update a record for the association. | |
+ * | |
+ * @param array $attributes | |
+ * @return bool | |
+ */ | |
+ public function update(array $attributes) | |
+ { | |
+ if ($this->model->timestamps()) | |
+ { | |
+ $attributes['updated_at'] = new \DateTime; | |
+ } | |
+ | |
+ return $this->table->update($attributes); | |
+ } | |
+ | |
+ /** | |
* Set the proper constraints on the relationship table. | |
* | |
* @return void | |
@@ -37,7 +53,7 @@ class Has_One_Or_Many extends Relationship { | |
*/ | |
public function eagerly_constrain($results) | |
{ | |
- $this->table->where_in($this->foreign_key(), array_keys($results)); | |
+ $this->table->where_in($this->foreign_key(), $this->keys($results)); | |
} | |
} | |
\ No newline at end of file | |
diff --git a/laravel/database/eloquent/relationships/relationship.php b/laravel/database/eloquent/relationships/relationship.php | |
index 2ec10aa..34c03f6 100755 | |
--- a/laravel/database/eloquent/relationships/relationship.php | |
+++ b/laravel/database/eloquent/relationships/relationship.php | |
@@ -101,4 +101,22 @@ abstract class Relationship extends Query { | |
return static::foreign($this->base, $this->foreign); | |
} | |
+ /** | |
+ * Gather all the primary keys from a result set. | |
+ * | |
+ * @param array $results | |
+ * @return array | |
+ */ | |
+ public function keys($results) | |
+ { | |
+ $keys = array(); | |
+ | |
+ foreach ($results as $result) | |
+ { | |
+ $keys[] = $result->get_key(); | |
+ } | |
+ | |
+ return array_unique($keys); | |
+ } | |
+ | |
} | |
\ No newline at end of file | |
diff --git a/laravel/database/query.php b/laravel/database/query.php | |
index 9d22117..607a862 100755 | |
--- a/laravel/database/query.php | |
+++ b/laravel/database/query.php | |
@@ -71,6 +71,13 @@ class Query { | |
public $groupings; | |
/** | |
+ * The HAVING clauses. | |
+ * | |
+ * @var array | |
+ */ | |
+ public $havings; | |
+ | |
+ /** | |
* The ORDER BY clauses. | |
* | |
* @var array | |
@@ -407,7 +414,10 @@ class Query { | |
// Once the callback has been run on the query, we will store the nested | |
// query instance on the where clause array so that it's passed to the | |
// query's query grammar instance when building. | |
- $this->wheres[] = compact('type', 'query', 'connector'); | |
+ if ($query->wheres !== null) | |
+ { | |
+ $this->wheres[] = compact('type', 'query', 'connector'); | |
+ } | |
$this->bindings = array_merge($this->bindings, $query->bindings); | |
@@ -476,6 +486,22 @@ class Query { | |
} | |
/** | |
+ * Add a having to the query. | |
+ * | |
+ * @param string $column | |
+ * @param string $operator | |
+ * @param mixed $value | |
+ */ | |
+ public function having($column, $operator, $value) | |
+ { | |
+ $this->havings[] = compact('column', 'operator', 'value'); | |
+ | |
+ $this->bindings[] = $value; | |
+ | |
+ return $this; | |
+ } | |
+ | |
+ /** | |
* Add an ordering to the query. | |
* | |
* @param string $column | |
diff --git a/laravel/database/query/grammars/grammar.php b/laravel/database/query/grammars/grammar.php | |
index 50d2b20..e7d9e28 100755 | |
--- a/laravel/database/query/grammars/grammar.php | |
+++ b/laravel/database/query/grammars/grammar.php | |
@@ -6,13 +6,20 @@ use Laravel\Database\Expression; | |
class Grammar extends \Laravel\Database\Grammar { | |
/** | |
+ * The format for properly saving a DateTime. | |
+ * | |
+ * @var string | |
+ */ | |
+ public $datetime = 'Y-m-d H:i:s'; | |
+ | |
+ /** | |
* All of the query componenets in the order they should be built. | |
* | |
* @var array | |
*/ | |
protected $components = array( | |
'aggregate', 'selects', 'from', 'joins', 'wheres', | |
- 'groupings', 'orderings', 'limit', 'offset', | |
+ 'groupings', 'havings', 'orderings', 'limit', 'offset', | |
); | |
/** | |
@@ -280,6 +287,24 @@ class Grammar extends \Laravel\Database\Grammar { | |
} | |
/** | |
+ * Compile the HAVING clause for a query. | |
+ * | |
+ * @param Query $query | |
+ * @return string | |
+ */ | |
+ protected function havings(Query $query) | |
+ { | |
+ if (is_null($query->havings)) return ''; | |
+ | |
+ foreach ($query->havings as $having) | |
+ { | |
+ $sql[] = 'AND '.$this->wrap($having['column']).' '.$having['operator'].' '.$this->parameter($having['value']); | |
+ } | |
+ | |
+ return 'HAVING '.preg_replace('/AND /', '', implode(' ', $sql), 1); | |
+ } | |
+ | |
+ /** | |
* Compile the ORDER BY clause for a query. | |
* | |
* @param Query $query | |
diff --git a/laravel/database/query/grammars/sqlserver.php b/laravel/database/query/grammars/sqlserver.php | |
index 8edb30c..def519a 100755 | |
--- a/laravel/database/query/grammars/sqlserver.php | |
+++ b/laravel/database/query/grammars/sqlserver.php | |
@@ -12,6 +12,13 @@ class SQLServer extends Grammar { | |
protected $wrapper = '[%s]'; | |
/** | |
+ * The format for properly saving a DateTime. | |
+ * | |
+ * @var string | |
+ */ | |
+ public $datetime = 'Y-m-d H:i:s.000'; | |
+ | |
+ /** | |
* Compile a SQL SELECT statement from a Query instance. | |
* | |
* @param Query $query | |
diff --git a/laravel/database/schema.php b/laravel/database/schema.php | |
index 3787e33..c7e5630 100755 | |
--- a/laravel/database/schema.php | |
+++ b/laravel/database/schema.php | |
@@ -44,12 +44,15 @@ class Schema { | |
* Drop a database table from the schema. | |
* | |
* @param string $table | |
+ * @param string $connection | |
* @return void | |
*/ | |
- public static function drop($table) | |
+ public static function drop($table, $connection = null) | |
{ | |
$table = new Schema\Table($table); | |
+ $table->on($connection); | |
+ | |
// To indicate that the table needs to be dropped, we will run the | |
// "drop" command on the table instance and pass the instance to | |
// the execute method as calling a Closure isn't needed. | |
@@ -145,6 +148,11 @@ class Schema { | |
{ | |
$driver = $connection->driver(); | |
+ if (isset(\Laravel\Database::$registrar[$driver])) | |
+ { | |
+ return \Laravel\Database::$registrar[$driver]['schema'](); | |
+ } | |
+ | |
switch ($driver) | |
{ | |
case 'mysql': | |
diff --git a/laravel/database/schema/grammars/postgres.php b/laravel/database/schema/grammars/postgres.php | |
index 760af1a..e0492ba 100755 | |
--- a/laravel/database/schema/grammars/postgres.php | |
+++ b/laravel/database/schema/grammars/postgres.php | |
@@ -368,7 +368,7 @@ class Postgres extends Grammar { | |
*/ | |
protected function type_date(Fluent $column) | |
{ | |
- return 'TIMESTAMP'; | |
+ return 'TIMESTAMP(0) WITHOUT TIME ZONE'; | |
} | |
/** | |
diff --git a/laravel/error.php b/laravel/error.php | |
index bf668d8..bfb2fcd 100755 | |
--- a/laravel/error.php | |
+++ b/laravel/error.php | |
@@ -6,13 +6,14 @@ class Error { | |
* Handle an exception and display the exception report. | |
* | |
* @param Exception $exception | |
+ * @param bool $trace | |
* @return void | |
*/ | |
- public static function exception($exception) | |
+ public static function exception($exception, $trace = true) | |
{ | |
static::log($exception); | |
- ob_get_level() and ob_end_clean(); | |
+ //ob_get_level() and ob_end_clean(); | |
// If detailed errors are enabled, we'll just format the exception into | |
// a simple error message and display it on the screen. We don't use a | |
@@ -23,9 +24,14 @@ class Error { | |
<h3>Message:</h3> | |
<pre>".$exception->getMessage()."</pre> | |
<h3>Location:</h3> | |
- <pre>".$exception->getFile()." on line ".$exception->getLine()."</pre> | |
+ <pre>".$exception->getFile()." on line ".$exception->getLine()."</pre>"; | |
+ | |
+ if ($trace) | |
+ { | |
+ echo " | |
<h3>Stack Trace:</h3> | |
<pre>".$exception->getTraceAsString()."</pre></html>"; | |
+ } | |
} | |
// If we're not using detailed error messages, we'll use the event | |
@@ -62,8 +68,6 @@ class Error { | |
if (in_array($code, Config::get('error.ignore'))) | |
{ | |
return static::log($exception); | |
- | |
- return true; | |
} | |
static::exception($exception); | |
@@ -85,7 +89,7 @@ class Error { | |
{ | |
extract($error, EXTR_SKIP); | |
- static::exception(new \ErrorException($message, $type, 0, $file, $line)); | |
+ static::exception(new \ErrorException($message, $type, 0, $file, $line), false); | |
} | |
} | |
diff --git a/laravel/event.php b/laravel/event.php | |
index 7fdc136..1f88d99 100755 | |
--- a/laravel/event.php | |
+++ b/laravel/event.php | |
@@ -10,6 +10,20 @@ class Event { | |
public static $events = array(); | |
/** | |
+ * The queued events waiting for flushing. | |
+ * | |
+ * @var array | |
+ */ | |
+ public static $queued = array(); | |
+ | |
+ /** | |
+ * All of the registered queue flusher callbacks. | |
+ * | |
+ * @var array | |
+ */ | |
+ public static $flushers = array(); | |
+ | |
+ /** | |
* Determine if an event has any registered listeners. | |
* | |
* @param string $event | |
@@ -55,6 +69,31 @@ class Event { | |
} | |
/** | |
+ * Add an item to an event queue for processing. | |
+ * | |
+ * @param string $queue | |
+ * @param string $key | |
+ * @param mixed $data | |
+ * @return void | |
+ */ | |
+ public static function queue($queue, $key, $data = array()) | |
+ { | |
+ static::$queued[$queue][$key] = $data; | |
+ } | |
+ | |
+ /** | |
+ * Register a queue flusher callback. | |
+ * | |
+ * @param string $queue | |
+ * @param mixed $callback | |
+ * @return void | |
+ */ | |
+ public static function flusher($queue, $callback) | |
+ { | |
+ static::$flushers[$queue][] = $callback; | |
+ } | |
+ | |
+ /** | |
* Clear all event listeners for a given event. | |
* | |
* @param string $event | |
@@ -100,6 +139,30 @@ class Event { | |
} | |
/** | |
+ * Flush an event queue, firing the flusher for each payload. | |
+ * | |
+ * @param string $queue | |
+ * @return void | |
+ */ | |
+ public static function flush($queue) | |
+ { | |
+ foreach (static::$flushers[$queue] as $flusher) | |
+ { | |
+ // We will simply spin through each payload registered for the event and | |
+ // fire the flusher, passing each payloads as we go. This allows all | |
+ // the events on the queue to be processed by the flusher easily. | |
+ if ( ! isset(static::$queued[$queue])) continue; | |
+ | |
+ foreach (static::$queued[$queue] as $key => $payload) | |
+ { | |
+ array_unshift($payload, $key); | |
+ | |
+ call_user_func_array($flusher, $payload); | |
+ } | |
+ } | |
+ } | |
+ | |
+ /** | |
* Fire an event so that all listeners are called. | |
* | |
* <code> | |
@@ -108,14 +171,17 @@ class Event { | |
* | |
* // Fire the "start" event passing an array of parameters | |
* $responses = Event::fire('start', array('Laravel', 'Framework')); | |
+ * | |
+ * // Fire multiple events with the same parameters | |
+ * $responses = Event::fire(array('start', 'loading'), $parameters); | |
* </code> | |
* | |
- * @param string $event | |
- * @param array $parameters | |
- * @param bool $halt | |
+ * @param string|array $event | |
+ * @param array $parameters | |
+ * @param bool $halt | |
* @return array | |
*/ | |
- public static function fire($event, $parameters = array(), $halt = false) | |
+ public static function fire($events, $parameters = array(), $halt = false) | |
{ | |
$responses = array(); | |
@@ -124,28 +190,31 @@ class Event { | |
// If the event has listeners, we will simply iterate through them and call | |
// each listener, passing in the parameters. We will add the responses to | |
// an array of event responses and return the array. | |
- if (static::listeners($event)) | |
+ foreach ((array) $events as $event) | |
{ | |
- foreach (static::$events[$event] as $callback) | |
+ if (static::listeners($event)) | |
{ | |
- $response = call_user_func_array($callback, $parameters); | |
- | |
- // If the event is set to halt, we will return the first response | |
- // that is not null. This allows the developer to easily stack | |
- // events but still get the first valid response. | |
- if ($halt and ! is_null($response)) | |
+ foreach (static::$events[$event] as $callback) | |
{ | |
- return $response; | |
+ $response = call_user_func_array($callback, $parameters); | |
+ | |
+ // If the event is set to halt, we will return the first response | |
+ // that is not null. This allows the developer to easily stack | |
+ // events but still get the first valid response. | |
+ if ($halt and ! is_null($response)) | |
+ { | |
+ return $response; | |
+ } | |
+ | |
+ // After the handler has been called, we'll add the response to | |
+ // an array of responses and return the array to the caller so | |
+ // all of the responses can be easily examined. | |
+ $responses[] = $response; | |
} | |
- | |
- // After the handler has been called, we'll add the response to | |
- // an array of responses and return the array to the caller so | |
- // all of the responses can be easily examined. | |
- $responses[] = $response; | |
} | |
} | |
- return $responses; | |
+ return $halt ? null : $responses; | |
} | |
} | |
\ No newline at end of file | |
diff --git a/laravel/file.php b/laravel/file.php | |
index 0346c83..efb46de 100755 | |
--- a/laravel/file.php | |
+++ b/laravel/file.php | |
@@ -1,4 +1,4 @@ | |
-<?php namespace Laravel; use Closure, FilesystemIterator as fIterator; | |
+<?php namespace Laravel; use FilesystemIterator as fIterator; | |
class File { | |
@@ -61,11 +61,11 @@ class File { | |
* Delete a file. | |
* | |
* @param string $path | |
- * @return void | |
+ * @return bool | |
*/ | |
public static function delete($path) | |
{ | |
- if (static::exists($path)) @unlink($path); | |
+ if (static::exists($path)) return @unlink($path); | |
} | |
/** | |
@@ -94,7 +94,7 @@ class File { | |
/** | |
* Extract the file extension from a file path. | |
- * | |
+ * | |
* @param string $path | |
* @return string | |
*/ | |
@@ -273,8 +273,9 @@ class File { | |
} | |
} | |
- if ($delete) rmdir($source); | |
- | |
+ unset($items); | |
+ if ($delete) @rmdir($source); | |
+ | |
return true; | |
} | |
@@ -306,6 +307,7 @@ class File { | |
} | |
} | |
+ unset($items); | |
if ( ! $preserve) @rmdir($directory); | |
} | |
diff --git a/laravel/form.php b/laravel/form.php | |
index a768f50..619043e 100755 | |
--- a/laravel/form.php | |
+++ b/laravel/form.php | |
@@ -397,13 +397,40 @@ class Form { | |
foreach ($options as $value => $display) | |
{ | |
- $html[] = static::option($value, $display, $selected); | |
+ if (is_array($display)) | |
+ { | |
+ $html[] = static::optgroup($display, $value, $selected); | |
+ } | |
+ else | |
+ { | |
+ $html[] = static::option($value, $display, $selected); | |
+ } | |
} | |
return '<select'.HTML::attributes($attributes).'>'.implode('', $html).'</select>'; | |
} | |
/** | |
+ * Create a HTML select element optgroup. | |
+ * | |
+ * @param array $options | |
+ * @param string $label | |
+ * @param string $selected | |
+ * @return string | |
+ */ | |
+ protected static function optgroup($options, $label, $selected) | |
+ { | |
+ $html = array(); | |
+ | |
+ foreach ($options as $value => $display) | |
+ { | |
+ $html[] = static::option($value, $display, $selected); | |
+ } | |
+ | |
+ return '<optgroup label="'.HTML::entities($label).'">'.implode('', $html).'</option>'; | |
+ } | |
+ | |
+ /** | |
* Create a HTML select element option. | |
* | |
* @param string $value | |
diff --git a/laravel/helpers.php b/laravel/helpers.php | |
index b04a8c4..db5ff43 100755 | |
--- a/laravel/helpers.php | |
+++ b/laravel/helpers.php | |
@@ -27,6 +27,17 @@ function __($key, $replacements = array(), $language = null) | |
} | |
/** | |
+ * Dump the given value and kill the script. | |
+ * | |
+ * @param mixed $value | |
+ * @return void | |
+ */ | |
+function dd($value) | |
+{ | |
+ die(var_dump($value)); | |
+} | |
+ | |
+/** | |
* Get an item from an array using "dot" notation. | |
* | |
* <code> | |
@@ -219,6 +230,62 @@ function array_divide($array) | |
} | |
/** | |
+ * Pluck an array of values from an array. | |
+ * | |
+ * @param array $array | |
+ * @param string $key | |
+ * @return array | |
+ */ | |
+function array_pluck($array, $key) | |
+{ | |
+ return array_map(function($v) use ($key) | |
+ { | |
+ return is_object($v) ? $v->$key : $v[$key]; | |
+ | |
+ }, $array); | |
+} | |
+ | |
+/** | |
+ * Get a subset of the items from the given array. | |
+ * | |
+ * @param array $array | |
+ * @param array $keys | |
+ * @return array | |
+ */ | |
+function array_only($array, $keys) | |
+{ | |
+ return array_intersect_key( $array, array_flip((array) $keys) ); | |
+} | |
+ | |
+/** | |
+ * Get all of the given array except for a specified array of items. | |
+ * | |
+ * @param array $array | |
+ * @param array $keys | |
+ * @return array | |
+ */ | |
+function array_except($array, $keys) | |
+{ | |
+ return array_diff_key( $array, array_flip((array) $keys) ); | |
+} | |
+ | |
+/** | |
+ * Transform Eloquent models to a JSON object. | |
+ * | |
+ * @param Eloquent|array $models | |
+ * @return object | |
+ */ | |
+function eloquent_to_json($models) | |
+{ | |
+ if ($models instanceof Laravel\Database\Eloquent\Model) | |
+ { | |
+ return json_encode($models->to_array()); | |
+ } | |
+ | |
+ return json_encode(array_map(function($m) { return $m->to_array(); }, $models)); | |
+} | |
+ | |
+/** | |
* Determine if "Magic Quotes" are enabled on the server. | |
* | |
* @return bool | |
@@ -340,13 +407,18 @@ function ends_with($haystack, $needle) | |
/** | |
* Determine if a given string contains a given sub-string. | |
* | |
- * @param string $haystack | |
- * @param string $needle | |
+ * @param string $haystack | |
+ * @param string|array $needle | |
* @return bool | |
*/ | |
function str_contains($haystack, $needle) | |
{ | |
- return strpos($haystack, $needle) !== false; | |
+ foreach ((array) $needle as $n) | |
+ { | |
+ if (strpos($haystack, $n) !== false) return true; | |
+ } | |
+ | |
+ return false; | |
} | |
/** | |
@@ -362,6 +434,17 @@ function str_finish($value, $cap) | |
} | |
/** | |
+ * Determine if the given object has a toString method. | |
+ * | |
+ * @param object $value | |
+ * @return bool | |
+ */ | |
+function str_object($value) | |
+{ | |
+ return is_object($value) and method_exists($value, '__toString'); | |
+} | |
+ | |
+/** | |
* Get the root namespace of a given class. | |
* | |
* @param string $class | |
@@ -401,7 +484,7 @@ function class_basename($class) | |
*/ | |
function value($value) | |
{ | |
- return ($value instanceof Closure) ? call_user_func($value) : $value; | |
+ return (is_callable($value) and ! is_string($value)) ? call_user_func($value) : $value; | |
} | |
/** | |
@@ -477,4 +560,24 @@ function render_each($partial, array $data, $iterator, $empty = 'raw|') | |
function yield($section) | |
{ | |
return Laravel\Section::yield($section); | |
+} | |
+ | |
+/** | |
+ * Get a CLI option from the argv $_SERVER variable. | |
+ * | |
+ * @param string $option | |
+ * @param mixed $default | |
+ * @return string | |
+ */ | |
+function get_cli_option($option, $default = null) | |
+{ | |
+ foreach (Laravel\Request::foundation()->server->get('argv') as $argument) | |
+ { | |
+ if (starts_with($argument, "--{$option}=")) | |
+ { | |
+ return substr($argument, strlen($option) + 3); | |
+ } | |
+ } | |
+ | |
+ return value($default); | |
} | |
\ No newline at end of file | |
diff --git a/laravel/html.php b/laravel/html.php | |
index bcb6962..b6cd3ee 100755 | |
--- a/laravel/html.php | |
+++ b/laravel/html.php | |
@@ -62,7 +62,7 @@ class HTML { | |
*/ | |
public static function script($url, $attributes = array()) | |
{ | |
- $url = static::entities(URL::to_asset($url)); | |
+ $url = URL::to_asset($url); | |
return '<script src="'.$url.'"'.static::attributes($attributes).'></script>'.PHP_EOL; | |
} | |
@@ -90,7 +90,7 @@ class HTML { | |
$attributes = $attributes + $defaults; | |
- $url = static::entities(URL::to_asset($url)); | |
+ $url = URL::to_asset($url); | |
return '<link href="'.$url.'"'.static::attributes($attributes).'>'.PHP_EOL; | |
} | |
@@ -126,7 +126,7 @@ class HTML { | |
*/ | |
public static function link($url, $title, $attributes = array(), $https = false) | |
{ | |
- $url = static::entities(URL::to($url, $https)); | |
+ $url = URL::to($url, $https); | |
return '<a href="'.$url.'"'.static::attributes($attributes).'>'.static::entities($title).'</a>'; | |
} | |
@@ -157,7 +157,7 @@ class HTML { | |
*/ | |
public static function link_to_asset($url, $title, $attributes = array(), $https = null) | |
{ | |
- $url = static::entities(URL::to_asset($url, $https)); | |
+ $url = URL::to_asset($url, $https); | |
return '<a href="'.$url.'"'.static::attributes($attributes).'>'.static::entities($title).'</a>'; | |
} | |
@@ -267,7 +267,7 @@ class HTML { | |
{ | |
$attributes['alt'] = $alt; | |
- return '<img src="'.static::entities(URL::to_asset($url)).'"'.static::attributes($attributes).'>'; | |
+ return '<img src="'.URL::to_asset($url).'"'.static::attributes($attributes).'>'; | |
} | |
/** | |
@@ -306,6 +306,8 @@ class HTML { | |
{ | |
$html = ''; | |
+ if (count($list) == 0) return $html; | |
+ | |
foreach ($list as $key => $value) | |
{ | |
// If the value is an array, we will recurse the function so that we can | |
diff --git a/laravel/input.php b/laravel/input.php | |
index 8524957..6a28b17 100755 | |
--- a/laravel/input.php | |
+++ b/laravel/input.php | |
@@ -3,11 +3,11 @@ | |
class Input { | |
/** | |
- * The applicable input for the request. | |
+ * The JSON payload for applications using Backbone.js or similar. | |
* | |
- * @var array | |
+ * @var object | |
*/ | |
- public static $input; | |
+ public static $json; | |
/** | |
* The key used to store old input in the session. | |
@@ -23,7 +23,11 @@ class Input { | |
*/ | |
public static function all() | |
{ | |
- return array_merge(static::get(), static::file()); | |
+ $input = array_merge(static::get(), static::query(), static::file()); | |
+ | |
+ unset($input[Request::spoofer]); | |
+ | |
+ return $input; | |
} | |
/** | |
@@ -58,7 +62,53 @@ class Input { | |
*/ | |
public static function get($key = null, $default = null) | |
{ | |
- return array_get(static::$input, $key, $default); | |
+ $input = Request::foundation()->request->all(); | |
+ | |
+ if (is_null($key)) | |
+ { | |
+ return array_merge($input, static::query()); | |
+ } | |
+ | |
+ $value = array_get($input, $key); | |
+ | |
+ if (is_null($value)) | |
+ { | |
+ return array_get(static::query(), $key, $default); | |
+ } | |
+ | |
+ return $value; | |
+ } | |
+ | |
+ /** | |
+ * Get an item from the query string. | |
+ * | |
+ * <code> | |
+ * // Get the "email" item from the query string | |
+ * $email = Input::query('email'); | |
+ * | |
+ * // Return a default value if the specified item doesn't exist | |
+ * $email = Input::query('name', 'Taylor'); | |
+ * </code> | |
+ * | |
+ * @param string $key | |
+ * @param mixed $default | |
+ * @return mixed | |
+ */ | |
+ public static function query($key = null, $default = null) | |
+ { | |
+ return array_get(Request::foundation()->query->all(), $key, $default); | |
+ } | |
+ | |
+ /** | |
+ * Get the JSON payload for the request. | |
+ * | |
+ * @return object | |
+ */ | |
+ public static function json() | |
+ { | |
+ if ( ! is_null(static::$json)) return static::$json; | |
+ | |
+ return static::$json = json_decode(Request::foundation()->getContent()); | |
} | |
/** | |
@@ -77,7 +127,7 @@ class Input { | |
*/ | |
public static function only($keys) | |
{ | |
- return array_intersect_key(static::get(), array_flip((array) $keys)); | |
+ return array_only(static::get(), $keys); | |
} | |
/** | |
@@ -96,7 +146,7 @@ class Input { | |
*/ | |
public static function except($keys) | |
{ | |
- return array_diff_key(static::get(), array_flip($keys)); | |
+ return array_except(static::get(), $keys); | |
} | |
/** | |
@@ -136,14 +186,11 @@ class Input { | |
* <code> | |
* // Get the array of information for the "picture" upload | |
* $picture = Input::file('picture'); | |
- * | |
- * // Get a specific element from within the file's data array | |
- * $size = Input::file('picture.size'); | |
* </code> | |
* | |
- * @param string $key | |
- * @param mixed $default | |
- * @return array | |
+ * @param string $key | |
+ * @param mixed $default | |
+ * @return UploadedFile | |
*/ | |
public static function file($key = null, $default = null) | |
{ | |
@@ -151,24 +198,36 @@ class Input { | |
} | |
/** | |
+ * Determine if the uploaded data contains a file. | |
+ * | |
+ * @param string $key | |
+ * @return bool | |
+ */ | |
+ public static function has_file($key) | |
+ { | |
+ return ! is_null(static::file("{$key}.tmp_name")); | |
+ } | |
+ | |
+ /** | |
* Move an uploaded file to permanent storage. | |
* | |
* This method is simply a convenient wrapper around move_uploaded_file. | |
* | |
* <code> | |
- * // Move the "picture" file to a permanent location on disk | |
- * Input::upload('picture', 'path/to/photos/picture.jpg'); | |
+ * // Move the "picture" file to a new permanent location on disk | |
+ * Input::upload('picture', 'path/to/photos', 'picture.jpg'); | |
* </code> | |
* | |
* @param string $key | |
- * @param string $path | |
+ * @param string $directory | |
+ * @param string $name | |
* @return bool | |
*/ | |
- public static function upload($key, $path) | |
+ public static function upload($key, $directory, $name = null) | |
{ | |
if (is_null(static::file($key))) return false; | |
- return move_uploaded_file(static::file("{$key}.tmp_name"), $path); | |
+ return Request::foundation()->files->get($key)->move($directory, $name); | |
} | |
/** | |
@@ -206,4 +265,26 @@ class Input { | |
Session::flash(Input::old_input, array()); | |
} | |
+ /** | |
+ * Merge new input into the current request's input array. | |
+ * | |
+ * @param array $input | |
+ * @return void | |
+ */ | |
+ public static function merge(array $input) | |
+ { | |
+ Request::foundation()->request->add($input); | |
+ } | |
+ | |
+ /** | |
+ * Replace the input for the current request. | |
+ * | |
+ * @param array $input | |
+ * @return void | |
+ */ | |
+ public static function replace(array $input) | |
+ { | |
+ Request::foundation()->request->replace($input); | |
+ } | |
+ | |
} | |
\ No newline at end of file | |
diff --git a/laravel/ioc.php b/laravel/ioc.php | |
index b02280f..e752635 100755 | |
--- a/laravel/ioc.php | |
+++ b/laravel/ioc.php | |
@@ -20,12 +20,14 @@ class IoC { | |
* Register an object and its resolver. | |
* | |
* @param string $name | |
- * @param Closure $resolver | |
+ * @param mixed $resolver | |
* @param bool $singleton | |
* @return void | |
*/ | |
- public static function register($name, Closure $resolver, $singleton = false) | |
+ public static function register($name, $resolver = null, $singleton = false) | |
{ | |
+ if (is_null($resolver)) $resolver = $name; | |
+ | |
static::$registry[$name] = compact('resolver', 'singleton'); | |
} | |
@@ -49,7 +51,7 @@ class IoC { | |
* @param Closure $resolver | |
* @return void | |
*/ | |
- public static function singleton($name, $resolver) | |
+ public static function singleton($name, $resolver = null) | |
{ | |
static::register($name, $resolver, true); | |
} | |
@@ -72,70 +74,132 @@ class IoC { | |
} | |
/** | |
- * Register a controller with the IoC container. | |
- * | |
- * @param string $name | |
- * @param Closure $resolver | |
- * @return void | |
- */ | |
- public static function controller($name, $resolver) | |
- { | |
- static::register("controller: {$name}", $resolver); | |
- } | |
- | |
- /** | |
- * Resolve a core Laravel class from the container. | |
+ * Resolve a given type to an instance. | |
* | |
* <code> | |
- * // Resolve the "laravel.router" class from the container | |
- * $input = IoC::core('router'); | |
+ * // Get an instance of the "mailer" object registered in the container | |
+ * $mailer = IoC::resolve('mailer'); | |
* | |
- * // Equivalent resolution of the router using the "resolve" method | |
- * $input = IoC::resolve('laravel.router'); | |
+ * // Get an instance of the "mailer" object and pass parameters to the resolver | |
+ * $mailer = IoC::resolve('mailer', array('test')); | |
* </code> | |
* | |
- * @param string $name | |
- * @param array $parameters | |
+ * @param string $type | |
* @return mixed | |
*/ | |
- public static function core($name, $parameters = array()) | |
+ public static function resolve($type, $parameters = array()) | |
{ | |
- return static::resolve("laravel.{$name}", $parameters); | |
+ // If an instance of the type is currently being managed as a singleton, we will | |
+ // just return the existing instance instead of instantiating a fresh instance | |
+ // so the developer can keep re-using the exact same object instance from us. | |
+ if (isset(static::$singletons[$type])) | |
+ { | |
+ return static::$singletons[$type]; | |
+ } | |
+ | |
+ // If we don't have a registered resolver or concrete for the type, we'll just | |
+ // assume the type is the concrete name and will attempt to resolve it as is | |
+ // since the container should be able to resolve concretes automatically. | |
+ if ( ! isset(static::$registry[$type])) | |
+ { | |
+ $concrete = $type; | |
+ } | |
+ else | |
+ { | |
+ $concrete = array_get(static::$registry[$type], 'resolver', $type); | |
+ } | |
+ | |
+ // We're ready to instantiate an instance of the concrete type registered for | |
+ // the binding. This will instantiate the type, as well as resolve any of | |
+ // its nested dependencies recursively until they are each resolved. | |
+ if ($concrete == $type or $concrete instanceof Closure) | |
+ { | |
+ $object = static::build($concrete); | |
+ } | |
+ else | |
+ { | |
+ $object = static::resolve($concrete); | |
+ } | |
+ | |
+ // If the requested type is registered as a singleton, we want to cache off | |
+ // the instance in memory so we can return it later without creating an | |
+ // entirely new instances of the object on each subsequent request. | |
+ if (isset(static::$registry[$type]['singleton'])) | |
+ { | |
+ static::$singletons[$type] = $object; | |
+ } | |
+ | |
+ return $object; | |
} | |
/** | |
- * Resolve an object instance from the container. | |
- * | |
- * <code> | |
- * // Get an instance of the "mailer" object registered in the container | |
- * $mailer = IoC::resolve('mailer'); | |
+ * Instantiate an instance of the given type. | |
* | |
- * // Get an instance of the "mailer" object and pass parameters to the resolver | |
- * $mailer = IoC::resolve('mailer', array('test')); | |
- * </code> | |
- * | |
- * @param string $name | |
+ * @param string $type | |
* @param array $parameters | |
* @return mixed | |
*/ | |
- public static function resolve($name, $parameters = array()) | |
+ protected static function build($type, $parameters = array()) | |
{ | |
- if (array_key_exists($name, static::$singletons)) | |
+ // If the concrete type is actually a Closure, we will just execute it and | |
+ // hand back the results of the function, which allows functions to be | |
+ // used as resolvers for more fine-tuned resolution of the objects. | |
+ if ($type instanceof Closure) | |
{ | |
- return static::$singletons[$name]; | |
+ return call_user_func_array($type, $parameters); | |
} | |
- $object = call_user_func(static::$registry[$name]['resolver'], $parameters); | |
+ $reflector = new \ReflectionClass($type); | |
- // If the resolver is registering as a singleton resolver, we will cache | |
- // the instance of the object in the container so we can resolve it next | |
- // time without having to instantiate a brand new instance. | |
- if (static::$registry[$name]['singleton']) | |
+ // If the type is not instantiable, the developer is attempting to resolve | |
+ // an abstract type such as an Interface of Abstract Class and there is | |
+ // no binding registered for the abstraction so we need to bail out. | |
+ if ( ! $reflector->isInstantiable()) | |
{ | |
- return static::$singletons[$name] = $object; | |
+ throw new Exception("Resolution target [$type] is not instantiable."); | |
} | |
- return $object; | |
+ $constructor = $reflector->getConstructor(); | |
+ | |
+ // If there is no constructor, that means there are no dependencies and | |
+ // we can just resolve an instance of the object right away without | |
+ // resolving any other types or dependencies from the container. | |
+ if (is_null($constructor)) | |
+ { | |
+ return new $type; | |
+ } | |
+ | |
+ $dependencies = static::dependencies($constructor->getParameters()); | |
+ | |
+ return $reflector->newInstanceArgs($dependencies); | |
+ } | |
+ | |
+ /** | |
+ * Resolve all of the dependencies from the ReflectionParameters. | |
+ * | |
+ * @param array $parameterrs | |
+ * @return array | |
+ */ | |
+ protected static function dependencies($parameters) | |
+ { | |
+ $dependencies = array(); | |
+ | |
+ foreach ($parameters as $parameter) | |
+ { | |
+ $dependency = $parameter->getClass(); | |
+ | |
+ // If the class is null, it means the dependency is a string or some other | |
+ // primitive type, which we can not esolve since it is not a class and | |
+ // we'll just bomb out with an error since we have nowhere to go. | |
+ if (is_null($dependency)) | |
+ { | |
+ throw new Exception("Unresolvable dependency resolving [$parameter]."); | |
+ } | |
+ | |
+ $dependencies[] = static::resolve($dependency->name); | |
+ } | |
+ | |
+ return (array) $dependencies; | |
} | |
} | |
\ No newline at end of file | |
diff --git a/laravel/lang.php b/laravel/lang.php | |
index 87be5f3..8fd5f7b 100755 | |
--- a/laravel/lang.php | |
+++ b/laravel/lang.php | |
@@ -1,4 +1,4 @@ | |
-<?php namespace Laravel; use Closure; | |
+<?php namespace Laravel; | |
class Lang { | |
@@ -51,7 +51,7 @@ class Lang { | |
{ | |
$this->key = $key; | |
$this->language = $language; | |
- $this->replacements = $replacements; | |
+ $this->replacements = (array) $replacements; | |
} | |
/** | |
@@ -89,7 +89,7 @@ class Lang { | |
*/ | |
public static function has($key, $language = null) | |
{ | |
- return ! is_null(static::line($key, array(), $language)->get()); | |
+ return static::line($key, array(), $language)->get() !== $key; | |
} | |
/** | |
@@ -103,7 +103,7 @@ class Lang { | |
* $line = Lang::line('validation.required')->get('sp'); | |
* | |
* // Return a default value if the line doesn't exist | |
- * $line = Lang::line('validation.required', null, 'Default'); | |
+ * $line = Lang::line('validation.required')->get(null, 'Default'); | |
* </code> | |
* | |
* @param string $language | |
@@ -112,13 +112,18 @@ class Lang { | |
*/ | |
public function get($language = null, $default = null) | |
{ | |
+ // If no default value is specified by the developer, we'll just return the | |
+ // key of the language line. This should indicate which language line we | |
+ // were attempting to render and is better than giving nothing back. | |
+ if (is_null($default)) $default = $this->key; | |
+ | |
if (is_null($language)) $language = $this->language; | |
list($bundle, $file, $line) = $this->parse($this->key); | |
- // If the file doesn't exist, we'll just return the default value that was | |
+ // If the file does not exist, we'll just return the default value that was | |
// given to the method. The default value is also returned even when the | |
- // file exists and the file does not actually contain any lines. | |
+ // file exists and that file does not actually contain any lines. | |
if ( ! static::load($bundle, $language, $file)) | |
{ | |
return value($default); | |
@@ -244,4 +249,4 @@ class Lang { | |
return (string) $this->get(); | |
} | |
-} | |
\ No newline at end of file | |
+} | |
diff --git a/laravel/laravel.php b/laravel/laravel.php | |
index b54ca57..a1ca206 100755 | |
--- a/laravel/laravel.php | |
+++ b/laravel/laravel.php | |
@@ -27,18 +27,24 @@ require 'core.php'; | |
set_exception_handler(function($e) | |
{ | |
+ require_once path('sys').'error'.EXT; | |
+ | |
Error::exception($e); | |
}); | |
set_error_handler(function($code, $error, $file, $line) | |
{ | |
+ require_once path('sys').'error'.EXT; | |
+ | |
Error::native($code, $error, $file, $line); | |
}); | |
register_shutdown_function(function() | |
{ | |
+ require_once path('sys').'error'.EXT; | |
+ | |
Error::shutdown(); | |
}); | |
@@ -57,80 +63,6 @@ error_reporting(-1); | |
/* | |
|-------------------------------------------------------------------------- | |
-| Magic Quotes Strip Slashes | |
-|-------------------------------------------------------------------------- | |
-| | |
-| Even though "Magic Quotes" are deprecated in PHP 5.3.x, they may still | |
-| be enabled on the server. To account for this, we will strip slashes | |
-| on all input arrays if magic quotes are enabled for the server. | |
-| | |
-*/ | |
- | |
-if (magic_quotes()) | |
-{ | |
- $magics = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); | |
- | |
- foreach ($magics as &$magic) | |
- { | |
- $magic = array_strip_slashes($magic); | |
- } | |
-} | |
- | |
-/* | |
-|-------------------------------------------------------------------------- | |
-| Sniff The Input For The Request | |
-|-------------------------------------------------------------------------- | |
-| | |
-| Next we'll gather the input to the application based on the global input | |
-| variables for the current request. The input will be gathered based on | |
-| the current request method and will be set on the Input manager class | |
-| as a simple static $input property which can be easily accessed. | |
-| | |
-*/ | |
- | |
-$input = array(); | |
- | |
-switch (Request::method()) | |
-{ | |
- case 'GET': | |
- $input = $_GET; | |
- break; | |
- | |
- case 'POST': | |
- $input = $_POST; | |
- break; | |
- | |
- default: | |
- if (Request::spoofed()) | |
- { | |
- $input = $_POST; | |
- } | |
- else | |
- { | |
- parse_str(file_get_contents('php://input'), $input); | |
- | |
- if (magic_quotes()) $input = array_strip_slashes($input); | |
- } | |
-} | |
- | |
-/* | |
-|-------------------------------------------------------------------------- | |
-| Remove The Spoofer Input | |
-|-------------------------------------------------------------------------- | |
-| | |
-| The spoofed request method is removed from the input so it is not in | |
-| the Input::all() or Input::get() results. Leaving it in the array | |
-| could cause unexpected results since the developer won't be | |
-| expecting it to be present. | |
-| | |
-*/ | |
- | |
-unset($input[Request::spoofer]); | |
- | |
-Input::$input = $input; | |
- | |
-/* | |
-|-------------------------------------------------------------------------- | |
| Start The Application Bundle | |
|-------------------------------------------------------------------------- | |
| | |
@@ -194,32 +126,32 @@ $response = Request::$route->call(); | |
/* | |
|-------------------------------------------------------------------------- | |
-| Persist The Session To Storage | |
+| "Render" The Response | |
|-------------------------------------------------------------------------- | |
| | |
-| If a session driver has been configured, we will save the session to | |
-| storage so it is avaiable for the next request. This will also set | |
-| the session cookie in the cookie jar to be sent to the user. | |
+| The render method evaluates the content of the response and converts it | |
+| to a string. This evaluates any views and sub-responses within the | |
+| content and sets the raw string result as the new response. | |
| | |
*/ | |
-if (Config::get('session.driver') !== '') | |
-{ | |
- Session::save(); | |
-} | |
+$response->render(); | |
/* | |
|-------------------------------------------------------------------------- | |
-| Let's Eat Cookies | |
+| Persist The Session To Storage | |
|-------------------------------------------------------------------------- | |
| | |
-| All cookies set during the request are actually stored in a cookie jar | |
-| until the end of the request so they can be expected by unit tests or | |
-| the developer. Here, we'll push them out to the browser. | |
+| If a session driver has been configured, we will save the session to | |
+| storage so it is avaiable for the next request. This will also set | |
+| the session cookie in the cookie jar to be sent to the user. | |
| | |
*/ | |
-Cookie::send(); | |
+if (Config::get('session.driver') !== '') | |
+{ | |
+ Session::save(); | |
+} | |
/* | |
|-------------------------------------------------------------------------- | |
diff --git a/laravel/memcached.php b/laravel/memcached.php | |
index 548e298..91e7270 100755 | |
--- a/laravel/memcached.php | |
+++ b/laravel/memcached.php | |
@@ -35,16 +35,16 @@ class Memcached { | |
/** | |
* Create a new Memcached connection instance. | |
* | |
- * @param array $servers | |
+ * @param array $servers | |
* @return Memcached | |
*/ | |
protected static function connect($servers) | |
{ | |
- $memcache = new \Memcache; | |
+ $memcache = new \Memcached; | |
foreach ($servers as $server) | |
{ | |
- $memcache->addServer($server['host'], $server['port'], true, $server['weight']); | |
+ $memcache->addServer($server['host'], $server['port'], $server['weight']); | |
} | |
if ($memcache->getVersion() === false) | |
diff --git a/laravel/request.php b/laravel/request.php | |
index 59d0ec7..510f64e 100755 | |
--- a/laravel/request.php | |
+++ b/laravel/request.php | |
@@ -1,4 +1,4 @@ | |
-<?php namespace Laravel; use Closure; | |
+<?php namespace Laravel; | |
class Request { | |
@@ -10,11 +10,18 @@ class Request { | |
public static $route; | |
/** | |
+ * The Symfony HttpFoundation Request instance. | |
+ * | |
+ * @var HttpFoundation\Request | |
+ */ | |
+ public static $foundation; | |
+ | |
+ /** | |
* The request data key that is used to indicate a spoofed request method. | |
* | |
* @var string | |
*/ | |
- const spoofer = '__spoofer'; | |
+ const spoofer = '_method'; | |
/** | |
* Get the URI for the current request. | |
@@ -33,12 +40,36 @@ class Request { | |
*/ | |
public static function method() | |
{ | |
- if ($_SERVER['REQUEST_METHOD'] == 'HEAD') | |
- { | |
- return 'GET'; | |
- } | |
+ $method = static::foundation()->getMethod(); | |
+ | |
+ return ($method == 'HEAD') ? 'GET' : $method; | |
+ } | |
- return (static::spoofed()) ? $_POST[Request::spoofer] : $_SERVER['REQUEST_METHOD']; | |
+ /** | |
+ * Get a header from the request. | |
+ * | |
+ * <code> | |
+ * // Get a header from the request | |
+ * $referer = Request::header('referer'); | |
+ * </code> | |
+ * | |
+ * @param string $key | |
+ * @param mixed $default | |
+ * @return mixed | |
+ */ | |
+ public static function header($key, $default = null) | |
+ { | |
+ return array_get(static::foundation()->headers->all(), $key, $default); | |
+ } | |
+ | |
+ /** | |
+ * Get all of the HTTP request headers. | |
+ * | |
+ * @return array | |
+ */ | |
+ public static function headers() | |
+ { | |
+ return static::foundation()->headers->all(); | |
} | |
/** | |
@@ -50,7 +81,7 @@ class Request { | |
*/ | |
public static function server($key = null, $default = null) | |
{ | |
- return array_get($_SERVER, strtoupper($key), $default); | |
+ return array_get(static::foundation()->server->all(), strtoupper($key), $default); | |
} | |
/** | |
@@ -60,7 +91,7 @@ class Request { | |
*/ | |
public static function spoofed() | |
{ | |
- return is_array($_POST) and array_key_exists(Request::spoofer, $_POST); | |
+ return ! is_null(static::foundation()->get(Request::spoofer)); | |
} | |
/** | |
@@ -71,30 +102,37 @@ class Request { | |
*/ | |
public static function ip($default = '0.0.0.0') | |
{ | |
- if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) | |
- { | |
- return $_SERVER['HTTP_X_FORWARDED_FOR']; | |
- } | |
- elseif (isset($_SERVER['HTTP_CLIENT_IP'])) | |
- { | |
- return $_SERVER['HTTP_CLIENT_IP']; | |
- } | |
- elseif (isset($_SERVER['REMOTE_ADDR'])) | |
- { | |
- return $_SERVER['REMOTE_ADDR']; | |
- } | |
+ return value(static::foundation()->getClientIp(), $default); | |
+ } | |
- return value($default); | |
+ /** | |
+ * Get the list of acceptable content types for the request. | |
+ * | |
+ * @return array | |
+ */ | |
+ public static function accept() | |
+ { | |
+ return static::foundation()->getAcceptableContentTypes(); | |
} | |
/** | |
- * Get the HTTP protocol for the request. | |
+ * Determine if the request accepts a given content type. | |
* | |
- * @return string | |
+ * @return bool | |
*/ | |
- public static function protocol() | |
+ public static function accepts($type) | |
{ | |
- return array_get($_SERVER, 'SERVER_PROTOCOL', 'HTTP/1.1'); | |
+ return in_array($type, static::accept()); | |
+ } | |
+ | |
+ /** | |
+ * Get the languages accepted by the client's browser. | |
+ * | |
+ * @return array | |
+ */ | |
+ public static function languages() | |
+ { | |
+ return static::foundation()->getLanguages(); | |
} | |
/** | |
@@ -104,7 +142,7 @@ class Request { | |
*/ | |
public static function secure() | |
{ | |
- return isset($_SERVER['HTTPS']) and strtolower($_SERVER['HTTPS']) !== 'off'; | |
+ return static::foundation()->isSecure() and Config::get('application.ssl'); | |
} | |
/** | |
@@ -126,9 +164,7 @@ class Request { | |
*/ | |
public static function ajax() | |
{ | |
- if ( ! isset($_SERVER['HTTP_X_REQUESTED_WITH'])) return false; | |
- | |
- return strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'; | |
+ return static::foundation()->isXmlHttpRequest(); | |
} | |
/** | |
@@ -138,7 +174,7 @@ class Request { | |
*/ | |
public static function referrer() | |
{ | |
- return array_get($_SERVER, 'HTTP_REFERER'); | |
+ return static::foundation()->headers->get('referer'); | |
} | |
/** | |
@@ -158,7 +194,18 @@ class Request { | |
*/ | |
public static function env() | |
{ | |
- if (isset($_SERVER['LARAVEL_ENV'])) return $_SERVER['LARAVEL_ENV']; | |
+ return static::foundation()->server->get('LARAVEL_ENV'); | |
+ } | |
+ | |
+ /** | |
+ * Set the Laravel environment for the current request. | |
+ * | |
+ * @param string $env | |
+ * @return void | |
+ */ | |
+ public static function set_env($env) | |
+ { | |
+ static::foundation()->server->set('LARAVEL_ENV', $env); | |
} | |
/** | |
@@ -173,6 +220,30 @@ class Request { | |
} | |
/** | |
+ * Detect the current environment from an environment configuration. | |
+ * | |
+ * @param array $environments | |
+ * @param string $uri | |
+ * @return string|null | |
+ */ | |
+ public static function detect_env(array $environments, $uri) | |
+ { | |
+ foreach ($environments as $environment => $patterns) | |
+ { | |
+ // Essentially we just want to loop through each environment pattern | |
+ // and determine if the current URI matches the pattern and if so | |
+ // we will simply return the environment for that URI pattern. | |
+ foreach ($patterns as $pattern) | |
+ { | |
+ if (Str::is($pattern, $uri)) | |
+ { | |
+ return $environment; | |
+ } | |
+ } | |
+ } | |
+ } | |
+ | |
+ /** | |
* Get the main route handling the request. | |
* | |
* @return Route | |
@@ -182,4 +253,26 @@ class Request { | |
return static::$route; | |
} | |
+ /** | |
+ * Get the Symfony HttpFoundation Request instance. | |
+ * | |
+ * @return HttpFoundation\Request | |
+ */ | |
+ public static function foundation() | |
+ { | |
+ return static::$foundation; | |
+ } | |
+ | |
+ /** | |
+ * Pass any other methods to the Symfony request. | |
+ * | |
+ * @param string $method | |
+ * @param array $parameters | |
+ * @return mixed | |
+ */ | |
+ public static function __callStatic($method, $parameters) | |
+ { | |
+ return call_user_func_array(array(static::foundation(), $method), $parameters); | |
+ } | |
+ | |
} | |
\ No newline at end of file | |
diff --git a/laravel/response.php b/laravel/response.php | |
index c984140..e547243 100755 | |
--- a/laravel/response.php | |
+++ b/laravel/response.php | |
@@ -1,5 +1,8 @@ | |
<?php namespace Laravel; | |
+use Symfony\Component\HttpFoundation\ResponseHeaderBag; | |
+use Symfony\Component\HttpFoundation\Response as FoundationResponse; | |
+ | |
class Response { | |
/** | |
@@ -10,72 +13,11 @@ class Response { | |
public $content; | |
/** | |
- * The HTTP status code of the response. | |
- * | |
- * @var int | |
- */ | |
- public $status = 200; | |
- | |
- /** | |
- * The response headers. | |
- * | |
- * @var array | |
- */ | |
- public $headers = array(); | |
- | |
- /** | |
- * HTTP status codes. | |
+ * The Symfony HttpFoundation Response instance. | |
* | |
- * @var array | |
+ * @var HttpFoundation\Response | |
*/ | |
- public static $statuses = array( | |
- 100 => 'Continue', | |
- 101 => 'Switching Protocols', | |
- 200 => 'OK', | |
- 201 => 'Created', | |
- 202 => 'Accepted', | |
- 203 => 'Non-Authoritative Information', | |
- 204 => 'No Content', | |
- 205 => 'Reset Content', | |
- 206 => 'Partial Content', | |
- 207 => 'Multi-Status', | |
- 300 => 'Multiple Choices', | |
- 301 => 'Moved Permanently', | |
- 302 => 'Found', | |
- 303 => 'See Other', | |
- 304 => 'Not Modified', | |
- 305 => 'Use Proxy', | |
- 307 => 'Temporary Redirect', | |
- 400 => 'Bad Request', | |
- 401 => 'Unauthorized', | |
- 402 => 'Payment Required', | |
- 403 => 'Forbidden', | |
- 404 => 'Not Found', | |
- 405 => 'Method Not Allowed', | |
- 406 => 'Not Acceptable', | |
- 407 => 'Proxy Authentication Required', | |
- 408 => 'Request Timeout', | |
- 409 => 'Conflict', | |
- 410 => 'Gone', | |
- 411 => 'Length Required', | |
- 412 => 'Precondition Failed', | |
- 413 => 'Request Entity Too Large', | |
- 414 => 'Request-URI Too Long', | |
- 415 => 'Unsupported Media Type', | |
- 416 => 'Requested Range Not Satisfiable', | |
- 417 => 'Expectation Failed', | |
- 422 => 'Unprocessable Entity', | |
- 423 => 'Locked', | |
- 424 => 'Failed Dependency', | |
- 500 => 'Internal Server Error', | |
- 501 => 'Not Implemented', | |
- 502 => 'Bad Gateway', | |
- 503 => 'Service Unavailable', | |
- 504 => 'Gateway Timeout', | |
- 505 => 'HTTP Version Not Supported', | |
- 507 => 'Insufficient Storage', | |
- 509 => 'Bandwidth Limit Exceeded' | |
- ); | |
+ public $foundation; | |
/** | |
* Create a new response instance. | |
@@ -87,9 +29,9 @@ class Response { | |
*/ | |
public function __construct($content, $status = 200, $headers = array()) | |
{ | |
- $this->status = $status; | |
$this->content = $content; | |
- $this->headers = array_change_key_case($headers); | |
+ | |
+ $this->foundation = new FoundationResponse('', $status, $headers); | |
} | |
/** | |
@@ -137,6 +79,46 @@ class Response { | |
} | |
/** | |
+ * Create a new JSON response. | |
+ * | |
+ * <code> | |
+ * // Create a response instance with JSON | |
+ * return Response::json($data, 200, array('header' => 'value')); | |
+ * </code> | |
+ * | |
+ * @param mixed $data | |
+ * @param int $status | |
+ * @param array $headers | |
+ * @return Response | |
+ */ | |
+ public static function json($data, $status = 200, $headers = array()) | |
+ { | |
+ $headers['Content-Type'] = 'application/json'; | |
+ | |
+ return new static(json_encode($data), $status, $headers); | |
+ } | |
+ | |
+ /** | |
+ * Create a new response of JSON'd Eloquent models. | |
+ * | |
+ * <code> | |
+ * // Create a new response instance with Eloquent models | |
+ * return Response::eloquent($data, 200, array('header' => 'value')); | |
+ * </code> | |
+ * | |
+ * @param Eloquenet|array $data | |
+ * @param int $status | |
+ * @param array $headers | |
+ * @return Response | |
+ */ | |
+ public static function eloquent($data, $status = 200, $headers = array()) | |
+ { | |
+ $headers['Content-Type'] = 'application/json'; | |
+ | |
+ return new static(eloquent_to_json($data), $status, $headers); | |
+ } | |
+ | |
+ /** | |
* Create a new error response instance. | |
* | |
* The response status code will be set using the specified code. | |
@@ -180,56 +162,86 @@ class Response { | |
{ | |
if (is_null($name)) $name = basename($path); | |
+ // We'll set some sensible default headers, but merge the array given to | |
+ // us so that the developer has the chance to override any of these | |
+ // default headers with header values of their own liking. | |
$headers = array_merge(array( | |
- 'content-description' => 'File Transfer', | |
- 'content-type' => File::mime(File::extension($path)), | |
- 'content-disposition' => 'attachment; filename="'.$name.'"', | |
- 'content-transfer-encoding' => 'binary', | |
- 'expires' => 0, | |
- 'cache-control' => 'must-revalidate, post-check=0, pre-check=0', | |
- 'pragma' => 'public', | |
- 'content-length' => File::size($path), | |
+ 'Content-Description' => 'File Transfer', | |
+ 'Content-Type' => File::mime(File::extension($path)), | |
+ 'Content-Transfer-Encoding' => 'binary', | |
+ 'Expires' => 0, | |
+ 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', | |
+ 'Pragma' => 'public', | |
+ 'Content-Length' => File::size($path), | |
), $headers); | |
- return new static(File::get($path), 200, $headers); | |
+ // Once we create the response, we need to set the content disposition | |
+ // header on the response based on the file's name. We'll pass this | |
+ // off to the HttpFoundation and let it create the header text. | |
+ $response = new static(File::get($path), 200, $headers); | |
+ | |
+ $d = $response->disposition($name); | |
+ | |
+ return $response->header('Content-Disposition', $d); | |
} | |
/** | |
- * Prepare a response from the given value. | |
+ * Create the proper Content-Disposition header. | |
* | |
- * If the value is not a response, it will be converted into a response | |
- * instance and the content will be cast to a string. | |
+ * @param string $file | |
+ * @return string | |
+ */ | |
+ public function disposition($file) | |
+ { | |
+ $type = ResponseHeaderBag::DISPOSITION_ATTACHMENT; | |
+ | |
+ return $this->foundation->headers->makeDisposition($type, $file); | |
+ } | |
+ | |
+ /** | |
+ * Prepare a response from the given value. | |
* | |
* @param mixed $response | |
* @return Response | |
*/ | |
public static function prepare($response) | |
{ | |
+ // We will need to force the response to be a string before closing | |
+ // the session since the developer may be utilizing the session | |
+ // within the view, and we can't age it until rendering. | |
if ( ! $response instanceof Response) | |
{ | |
$response = new static($response); | |
} | |
- // We'll need to force the response to be a string before closing the session, | |
- // since the developer may be using the session within a view, and we can't | |
- // age the flash data until the view is rendered. | |
- // | |
- // Since this method is used by both the Route and Controller classes, it is | |
- // a convenient spot to cast the application response to a string before it | |
- // is returned to the main request handler. | |
- $response->render(); | |
- | |
return $response; | |
} | |
/** | |
+ * Send the headers and content of the response to the browser. | |
+ * | |
+ * @return void | |
+ */ | |
+ public function send() | |
+ { | |
+ $this->cookies(); | |
+ | |
+ $this->foundation->prepare(Request::foundation()); | |
+ | |
+ $this->foundation->send(); | |
+ } | |
+ | |
+ /** | |
* Convert the content of the Response to a string and return it. | |
* | |
* @return string | |
*/ | |
public function render() | |
{ | |
- if (is_object($this->content) and method_exists($this->content, '__toString')) | |
+ // If the content is a stringable object, we'll go ahead and call | |
+ // to toString method so that we can get the string content of | |
+ // the content object. Otherwise we'll just cast to string. | |
+ if (str_object($this->content)) | |
{ | |
$this->content = $this->content->__toString(); | |
} | |
@@ -238,74 +250,47 @@ class Response { | |
$this->content = (string) $this->content; | |
} | |
+ // Once we obtain the string content, we can set the content on | |
+ // the HttpFoundation's Response instance in preparation for | |
+ // sending it back to client browser when all is finished. | |
+ $this->foundation->setContent($this->content); | |
+ | |
return $this->content; | |
} | |
/** | |
- * Send the headers and content of the response to the browser. | |
+ * Send all of the response headers to the browser. | |
* | |
* @return void | |
*/ | |
- public function send() | |
+ public function send_headers() | |
{ | |
- if ( ! headers_sent()) $this->send_headers(); | |
+ $this->foundation->prepare(Request::foundation()); | |
- echo (string) $this->content; | |
+ $this->foundation->sendHeaders(); | |
} | |
/** | |
- * Send all of the response headers to the browser. | |
+ * Set the cookies on the HttpFoundation Response. | |
* | |
* @return void | |
*/ | |
- public function send_headers() | |
+ protected function cookies() | |
{ | |
- // If the server is using FastCGI, we need to send a slightly different | |
- // protocol and status header than we normally would. Otherwise it will | |
- // not call any custom scripts setup to handle 404 responses. | |
- // | |
- // The status header will contain both the code and the status message, | |
- // such as "OK" or "Not Found". For typical servers, the HTTP protocol | |
- // will also be included with the status. | |
- if (isset($_SERVER['FCGI_SERVER_VERSION'])) | |
- { | |
- header('Status: '.$this->status.' '.$this->message()); | |
- } | |
- else | |
- { | |
- header(Request::protocol().' '.$this->status.' '.$this->message()); | |
- } | |
+ $ref = new \ReflectionClass('Symfony\Component\HttpFoundation\Cookie'); | |
- // If the content type was not set by the developer, we will set the | |
- // header to a default value that indicates to the browser that the | |
- // response is HTML and that it uses the default encoding. | |
- if ( ! isset($this->headers['content-type'])) | |
+ // All of the cookies for the response are actually stored on the | |
+ // Cookie class until we're ready to send the response back to | |
+ // the browser. This allows our cookies to be set easily. | |
+ foreach (Cookie::$jar as $name => $cookie) | |
{ | |
- $encoding = Config::get('application.encoding'); | |
+ $config = array_values($cookie); | |
- $this->header('content-type', 'text/html; charset='.$encoding); | |
- } | |
- | |
- // Once the framework controlled headers have been sentm, we can | |
- // simply iterate over the developer's headers and send each one | |
- // back to the browser for the response. | |
- foreach ($this->headers as $name => $value) | |
- { | |
- header("{$name}: {$value}", true); | |
+ $this->headers()->setCookie($ref->newInstanceArgs($config)); | |
} | |
} | |
/** | |
- * Get the status code message for the response. | |
- * | |
- * @return string | |
- */ | |
- public function message() | |
- { | |
- return static::$statuses[$this->status]; | |
- } | |
- | |
- /** | |
* Add a header to the array of response headers. | |
* | |
* @param string $name | |
@@ -314,20 +299,39 @@ class Response { | |
*/ | |
public function header($name, $value) | |
{ | |
- $this->headers[strtolower($name)] = $value; | |
+ $this->foundation->headers->set($name, $value); | |
+ | |
return $this; | |
} | |
/** | |
- * Set the response status code. | |
+ * Get the HttpFoundation Response headers. | |
* | |
- * @param int $status | |
- * @return Response | |
+ * @return ResponseParameterBag | |
*/ | |
- public function status($status) | |
+ public function headers() | |
{ | |
- $this->status = $status; | |
- return $this; | |
+ return $this->foundation->headers; | |
+ } | |
+ | |
+ /** | |
+ * Get / set the response status code. | |
+ * | |
+ * @param int $status | |
+ * @return mixed | |
+ */ | |
+ public function status($status = null) | |
+ { | |
+ if (is_null($status)) | |
+ { | |
+ return $this->foundation->getStatusCode(); | |
+ } | |
+ else | |
+ { | |
+ $this->foundation->setStatusCode($status); | |
+ | |
+ return $this; | |
+ } | |
} | |
} | |
\ No newline at end of file | |
diff --git a/laravel/routing/controller.php b/laravel/routing/controller.php | |
index f75ef4b..0a780bb 100755 | |
--- a/laravel/routing/controller.php | |
+++ b/laravel/routing/controller.php | |
@@ -140,9 +140,19 @@ abstract class Controller { | |
// improve speed since the bundle is not loaded on every request. | |
Bundle::start($bundle); | |
- list($controller, $method) = explode('@', $destination); | |
+ list($name, $method) = explode('@', $destination); | |
- $controller = static::resolve($bundle, $controller); | |
+ $controller = static::resolve($bundle, $name); | |
+ | |
+ // For convenience we will set the current controller and action on the | |
+ // Request's route instance so they can be easily accessed from the | |
+ // application. This is sometimes useful for dynamic situations. | |
+ if ( ! is_null($route = Request::route())) | |
+ { | |
+ $route->controller = $name; | |
+ | |
+ $route->controller_action = $method; | |
+ } | |
// If the controller could not be resolved, we're out of options and | |
// will return the 404 error response. If we found the controller, | |
diff --git a/laravel/routing/route.php b/laravel/routing/route.php | |
index 6349a0e..73b7952 100755 | |
--- a/laravel/routing/route.php | |
+++ b/laravel/routing/route.php | |
@@ -1,6 +1,7 @@ | |
<?php namespace Laravel\Routing; | |
use Closure; | |
+use Laravel\Str; | |
use Laravel\URI; | |
use Laravel\Bundle; | |
use Laravel\Request; | |
@@ -30,6 +31,20 @@ class Route { | |
public $bundle; | |
/** | |
+ * The name of the controller used by the route. | |
+ * | |
+ * @var string | |
+ */ | |
+ public $controller; | |
+ | |
+ /** | |
+ * The name of the controller action used by the route. | |
+ * | |
+ * @var string | |
+ */ | |
+ public $controller_action; | |
+ | |
+ /** | |
* The action that is assigned to the route. | |
* | |
* @var mixed | |
@@ -46,11 +61,10 @@ class Route { | |
/** | |
* Create a new Route instance. | |
* | |
- * @param string $method | |
- * @param string $uri | |
- * @param array $action | |
- * @param array $parameters | |
- * @return void | |
+ * @param string $method | |
+ * @param string $uri | |
+ * @param array $action | |
+ * @param array $parameters | |
*/ | |
public function __construct($method, $uri, $action, $parameters = array()) | |
{ | |
@@ -66,18 +80,17 @@ class Route { | |
// We'll set the parameters based on the number of parameters passed | |
// compared to the parameters that were needed. If more parameters | |
// are needed, we'll merge in defaults. | |
- $this->parameters($uri, $action, $parameters); | |
+ $this->parameters($action, $parameters); | |
} | |
/** | |
* Set the parameters array to the correct value. | |
* | |
- * @param string $uri | |
* @param array $action | |
* @param array $parameters | |
* @return void | |
*/ | |
- protected function parameters($uri, $action, $parameters) | |
+ protected function parameters($action, $parameters) | |
{ | |
$defaults = (array) array_get($action, 'defaults'); | |
@@ -113,7 +126,7 @@ class Route { | |
// We always return a Response instance from the route calls, so | |
// we'll use the prepare method on the Response class to make | |
- // sure we have a valid Response isntance. | |
+ // sure we have a valid Response instance. | |
$response = Response::prepare($response); | |
Filter::run($this->filters('after'), array($response)); | |
@@ -198,7 +211,7 @@ class Route { | |
// if they match we'll attach the filter. | |
foreach (Filter::$patterns as $pattern => $filter) | |
{ | |
- if (URI::is($pattern, $this->uri)) | |
+ if (Str::is($pattern, $this->uri)) | |
{ | |
$filters[] = $filter; | |
} | |
@@ -251,7 +264,7 @@ class Route { | |
/** | |
* Register a controller with the router. | |
* | |
- * @param string|array $controller | |
+ * @param string|array $controllers | |
* @param string|array $defaults | |
* @return void | |
*/ | |
@@ -393,4 +406,4 @@ class Route { | |
return Router::route(strtoupper($method), $uri)->call(); | |
} | |
-} | |
\ No newline at end of file | |
+} | |
diff --git a/laravel/routing/router.php b/laravel/routing/router.php | |
index a6577b3..9fc946b 100755 | |
--- a/laravel/routing/router.php | |
+++ b/laravel/routing/router.php | |
@@ -119,7 +119,7 @@ class Router { | |
* | |
* <code> | |
* // Register a group of URIs for an action | |
- * Router::share(array('GET', '/'), array('POST', '/'), 'home@index'); | |
+ * Router::share(array(array('GET', '/'), array('POST', '/')), 'home@index'); | |
* </code> | |
* | |
* @param array $routes | |
@@ -174,6 +174,8 @@ class Router { | |
*/ | |
public static function register($method, $route, $action) | |
{ | |
+ if (ctype_digit($route)) $route = "({$route})"; | |
+ | |
if (is_string($route)) $route = explode(', ', $route); | |
// If the developer is registering multiple request methods to handle | |
diff --git a/laravel/section.php b/laravel/section.php | |
index ff12889..9638880 100755 | |
--- a/laravel/section.php | |
+++ b/laravel/section.php | |
@@ -39,7 +39,7 @@ class Section { | |
} | |
else | |
{ | |
- static::append($section, $content); | |
+ static::extend($section, $content); | |
} | |
} | |
@@ -79,19 +79,19 @@ class Section { | |
*/ | |
public static function stop() | |
{ | |
- static::append($last = array_pop(static::$last), ob_get_clean()); | |
+ static::extend($last = array_pop(static::$last), ob_get_clean()); | |
return $last; | |
} | |
/** | |
- * Append content to a given section. | |
+ * Extend the content in a given section. | |
* | |
* @param string $section | |
* @param string $content | |
* @return void | |
*/ | |
- protected static function append($section, $content) | |
+ protected static function extend($section, $content) | |
{ | |
if (isset(static::$sections[$section])) | |
{ | |
@@ -104,6 +104,25 @@ class Section { | |
} | |
/** | |
+ * Append content to a given section. | |
+ * | |
+ * @param string $section | |
+ * @param string $content | |
+ * @return void | |
+ */ | |
+ public static function append($section, $content) | |
+ { | |
+ if (isset(static::$sections[$section])) | |
+ { | |
+ static::$sections[$section] .= $content; | |
+ } | |
+ else | |
+ { | |
+ static::$sections[$section] = $content; | |
+ } | |
+ } | |
+ | |
+ /** | |
* Get the string contents of a section. | |
* | |
* @param string $section | |
diff --git a/laravel/session.php b/laravel/session.php | |
index bdc549a..b5b833f 100755 | |
--- a/laravel/session.php | |
+++ b/laravel/session.php | |
@@ -10,6 +10,13 @@ class Session { | |
public static $instance; | |
/** | |
+ * The third-party driver registrar. | |
+ * | |
+ * @var array | |
+ */ | |
+ public static $registrar = array(); | |
+ | |
+ /** | |
* The string name of the CSRF token stored in the session. | |
* | |
* @var string | |
@@ -47,6 +54,13 @@ class Session { | |
*/ | |
public static function factory($driver) | |
{ | |
+ if (isset(static::$registrar[$driver])) | |
+ { | |
+ $resolver = static::$registrar[$driver]; | |
+ | |
+ return $resolver(); | |
+ } | |
+ | |
switch ($driver) | |
{ | |
case 'apc': | |
@@ -106,6 +120,18 @@ class Session { | |
} | |
/** | |
+ * Register a third-party cache driver. | |
+ * | |
+ * @param string $driver | |
+ * @param Closure $resolver | |
+ * @return void | |
+ */ | |
+ public static function extend($driver, Closure $resolver) | |
+ { | |
+ static::$registrar[$driver] = $resolver; | |
+ } | |
+ | |
+ /** | |
* Magic Method for calling the methods on the session singleton instance. | |
* | |
* <code> | |
diff --git a/laravel/session/drivers/cookie.php b/laravel/session/drivers/cookie.php | |
index d15d706..63a60ee 100755 | |
--- a/laravel/session/drivers/cookie.php | |
+++ b/laravel/session/drivers/cookie.php | |
@@ -1,6 +1,4 @@ | |
-<?php namespace Laravel\Session\Drivers; | |
- | |
-use Laravel\Crypter; | |
+<?php namespace Laravel\Session\Drivers; use Laravel\Crypter, Laravel\Cookie as C; | |
class Cookie extends Driver { | |
@@ -21,9 +19,9 @@ class Cookie extends Driver { | |
*/ | |
public function load($id) | |
{ | |
- if (\Laravel\Cookie::has(Cookie::payload)) | |
+ if (C::has(Cookie::payload)) | |
{ | |
- return unserialize(Crypter::decrypt(\Laravel\Cookie::get(Cookie::payload))); | |
+ return unserialize(Crypter::decrypt(C::get(Cookie::payload))); | |
} | |
} | |
@@ -41,7 +39,7 @@ class Cookie extends Driver { | |
$payload = Crypter::encrypt(serialize($session)); | |
- \Laravel\Cookie::put(Cookie::payload, $payload, $lifetime, $path, $domain); | |
+ C::put(Cookie::payload, $payload, $lifetime, $path, $domain); | |
} | |
/** | |
@@ -52,7 +50,7 @@ class Cookie extends Driver { | |
*/ | |
public function delete($id) | |
{ | |
- \Laravel\Cookie::forget(Cookie::payload); | |
+ C::forget(Cookie::payload); | |
} | |
} | |
\ No newline at end of file | |
diff --git a/laravel/session/drivers/driver.php b/laravel/session/drivers/driver.php | |
index a8b9d4d..8a54ac9 100755 | |
--- a/laravel/session/drivers/driver.php | |
+++ b/laravel/session/drivers/driver.php | |
@@ -31,7 +31,7 @@ abstract class Driver { | |
abstract public function delete($id); | |
/** | |
- * Insert a fresh session and return the payload array. | |
+ * Create a fresh session array with a unique ID. | |
* | |
* @return array | |
*/ | |
diff --git a/laravel/session/payload.php b/laravel/session/payload.php | |
index bf23b94..5b45a53 100755 | |
--- a/laravel/session/payload.php | |
+++ b/laravel/session/payload.php | |
@@ -1,6 +1,5 @@ | |
<?php namespace Laravel\Session; | |
-use Closure; | |
use Laravel\Str; | |
use Laravel\Config; | |
use Laravel\Cookie; | |
@@ -298,10 +297,9 @@ class Payload { | |
// session on the user's subsequent requests to the application. | |
$this->cookie($config); | |
- // Some session drivers implement the Sweeper interface, meaning that | |
+ // Some session drivers implement the Sweeper interface meaning that | |
// they must clean up expired sessions manually. If the driver is a | |
- // sweeper, we need to determine if garbage collection should be | |
- // run for the request. | |
+ // sweeper, we'll calculate if we need to run garbage collection. | |
$sweepage = $config['sweepage']; | |
if ($this->driver instanceof Sweeper and (mt_rand(1, $sweepage[1]) <= $sweepage[0])) | |
diff --git a/laravel/str.php b/laravel/str.php | |
index 78a554e..964b5d5 100755 | |
--- a/laravel/str.php | |
+++ b/laravel/str.php | |
@@ -148,7 +148,9 @@ class Str { | |
*/ | |
public static function words($value, $words = 100, $end = '...') | |
{ | |
- preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/', $value, $matches); | |
+ if (trim($value) == '') return ''; | |
+ | |
+ preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches); | |
if (static::length($value) == static::length($matches[0])) | |
{ | |
@@ -301,6 +303,30 @@ class Str { | |
} | |
/** | |
+ * Determine if a given string matches a given pattern. | |
+ * | |
+ * @param string $pattern | |
+ * @param string $value | |
+ * @return bool | |
+ */ | |
+ public static function is($pattern, $value) | |
+ { | |
+ // Asterisks are translated into zero-or-more regular expression wildcards | |
+ // to make it convenient to check if the URI starts with a given pattern | |
+ // such as "library/*". This is only done when not root. | |
+ if ($pattern !== '/') | |
+ { | |
+ $pattern = str_replace('*', '(.*)', $pattern).'\z'; | |
+ } | |
+ else | |
+ { | |
+ $pattern = '^/$'; | |
+ } | |
+ | |
+ return preg_match('#'.$pattern.'#', $value); | |
+ } | |
+ | |
+ /** | |
* Get the character pool for a given type of random string. | |
* | |
* @param string $type | |
diff --git a/laravel/uri.php b/laravel/uri.php | |
index d342f56..2477fe6 100755 | |
--- a/laravel/uri.php | |
+++ b/laravel/uri.php | |
@@ -17,23 +17,13 @@ class URI { | |
public static $segments = array(); | |
/** | |
- * The server variables to check for the URI. | |
- * | |
- * @var array | |
- */ | |
- protected static $attempt = array( | |
- 'PATH_INFO', 'REQUEST_URI', | |
- 'PHP_SELF', 'REDIRECT_URL' | |
- ); | |
- | |
- /** | |
* Get the full URI including the query string. | |
* | |
* @return string | |
*/ | |
public static function full() | |
{ | |
- return static::current().static::query(); | |
+ return Request::getUri(); | |
} | |
/** | |
@@ -45,45 +35,14 @@ class URI { | |
{ | |
if ( ! is_null(static::$uri)) return static::$uri; | |
- // To get the URI, we'll first call the detect method which will spin | |
- // through each of the server variables that we check for the URI in | |
- // and use the first one we encounter for the URI. | |
- static::$uri = static::detect(); | |
- | |
- // If you ever encounter this error, please inform the nerdy Laravel | |
- // dev team with information about your server. We want to support | |
- // Laravel an as many servers as we possibly can! | |
- if (is_null(static::$uri)) | |
- { | |
- throw new \Exception("Could not detect request URI."); | |
- } | |
- | |
- static::segments(static::$uri); | |
- | |
- return static::$uri; | |
- } | |
- | |
- /** | |
- * Detect the URI from the server variables. | |
- * | |
- * @return string|null | |
- */ | |
- protected static function detect() | |
- { | |
- foreach (static::$attempt as $variable) | |
- { | |
- // Each variable we search for the URI has its own parser function | |
- // which is responsible for doing any formatting before the value | |
- // is fed into the main formatting function. | |
- $method = "parse_{$variable}"; | |
+ // We'll simply get the path info from the Symfony Request instance and then | |
+ // format to meet our needs in the router. If the URI is root, we'll give | |
+ // back a single slash, otherwise we'll strip all of the slashes off. | |
+ $uri = static::format(Request::getPathInfo()); | |
- if (isset($_SERVER[$variable])) | |
- { | |
- $uri = static::$method($_SERVER[$variable]); | |
+ static::segments($uri); | |
- return static::format($uri); | |
- } | |
- } | |
+ return static::$uri = $uri; | |
} | |
/** | |
@@ -94,21 +53,6 @@ class URI { | |
*/ | |
protected static function format($uri) | |
{ | |
- // First we want to remove the application's base URL from the URI if it is | |
- // in the string. It is possible for some of the parsed server variables to | |
- // include the entire document root in the string. | |
- $uri = static::remove_base($uri); | |
- | |
- $index = '/'.Config::get('application.index'); | |
- | |
- // Next we'll remove the index file from the URI if it is there and then | |
- // finally trim down the URI. If the URI is left with spaces, we'll use | |
- // a single slash for the root URI. | |
- if ($index !== '/') | |
- { | |
- $uri = static::remove($uri, $index); | |
- } | |
- | |
return trim($uri, '/') ?: '/'; | |
} | |
@@ -116,81 +60,11 @@ class URI { | |
* Determine if the current URI matches a given pattern. | |
* | |
* @param string $pattern | |
- * @param string $uri | |
* @return bool | |
*/ | |
- public static function is($pattern, $uri = null) | |
+ public static function is($pattern) | |
{ | |
- $uri = $uri ?: static::current(); | |
- | |
- // Asterisks are translated into zero-or-more regular expression wildcards | |
- // to make it convenient to check if the URI starts with a given pattern | |
- // such as "library/*". This is only done when not root. | |
- if ($pattern !== '/') | |
- { | |
- $pattern = str_replace('*', '(.*)', $pattern).'\z'; | |
- } | |
- else | |
- { | |
- $pattern = '^/$'; | |
- } | |
- | |
- return preg_match('#'.$pattern.'#', $uri); | |
- } | |
- | |
- /** | |
- * Parse the PATH_INFO server variable. | |
- * | |
- * @param string $value | |
- * @return string | |
- */ | |
- protected static function parse_path_info($value) | |
- { | |
- return $value; | |
- } | |
- | |
- /** | |
- * Parse the REQUEST_URI server variable. | |
- * | |
- * @param string $value | |
- * @return string | |
- */ | |
- protected static function parse_request_uri($value) | |
- { | |
- return parse_url($value, PHP_URL_PATH); | |
- } | |
- | |
- /** | |
- * Parse the PHP_SELF server variable. | |
- * | |
- * @param string $value | |
- * @return string | |
- */ | |
- protected static function parse_php_self($value) | |
- { | |
- return $value; | |
- } | |
- | |
- /** | |
- * Parse the REDIRECT_URL server variable. | |
- * | |
- * @param string $value | |
- * @return string | |
- */ | |
- protected static function parse_redirect_url($value) | |
- { | |
- return $value; | |
- } | |
- | |
- /** | |
- * Remove the base URL off of the request URI. | |
- * | |
- * @param string $uri | |
- * @return string | |
- */ | |
- protected static function remove_base($uri) | |
- { | |
- return static::remove($uri, parse_url(URL::base(), PHP_URL_PATH)); | |
+ return Str::is($pattern, static::current()); | |
} | |
/** | |
@@ -228,26 +102,4 @@ class URI { | |
static::$segments = array_diff($segments, array('')); | |
} | |
- /** | |
- * Remove a given value from the URI. | |
- * | |
- * @param string $uri | |
- * @param string $value | |
- * @return string | |
- */ | |
- protected static function remove($uri, $value) | |
- { | |
- return (strpos($uri, $value) === 0) ? substr($uri, strlen($value)) : $uri; | |
- } | |
- | |
- /** | |
- * Get the query string for the current request. | |
- * | |
- * @return string | |
- */ | |
- protected static function query() | |
- { | |
- return (count((array) $_GET) > 0) ? '?'.http_build_query($_GET) : ''; | |
- } | |
- | |
} | |
\ No newline at end of file | |
diff --git a/laravel/url.php b/laravel/url.php | |
index d523abb..59c4f9c 100755 | |
--- a/laravel/url.php | |
+++ b/laravel/url.php | |
@@ -61,46 +61,22 @@ class URL { | |
$base = 'http://localhost'; | |
- // If the application URL configuration is set, we will just use that | |
+ // If the application's URL configuration is set, we will just use that | |
// instead of trying to guess the URL from the $_SERVER array's host | |
- // and script variables as this is more reliable. | |
+ // and script variables as this is a more reliable method. | |
if (($url = Config::get('application.url')) !== '') | |
{ | |
$base = $url; | |
} | |
- elseif (isset($_SERVER['HTTP_HOST'])) | |
+ else | |
{ | |
- $base = static::guess(); | |
+ $base = Request::foundation()->getRootUrl(); | |
} | |
return static::$base = $base; | |
} | |
/** | |
- * Guess the application URL based on the $_SERVER variables. | |
- * | |
- * @return string | |
- */ | |
- protected static function guess() | |
- { | |
- $protocol = (Request::secure()) ? 'https://' : 'http://'; | |
- | |
- // Basically, by removing the basename, we are removing everything after | |
- // the and including the front controller from the URI. Leaving us with | |
- // the installation path for the application. | |
- $script = $_SERVER['SCRIPT_NAME']; | |
- | |
- $path = str_replace(basename($script), '', $script); | |
- | |
- // Now that we have the URL, all we need to do is attach the protocol | |
- // protocol and HTTP_HOST to build the URL for the application, and | |
- // we also trim off trailing slashes for cleanliness. | |
- $uri = $protocol.$_SERVER['HTTP_HOST'].$path; | |
- | |
- return rtrim($uri, '/'); | |
- } | |
- | |
- /** | |
* Generate an application URL. | |
* | |
* <code> | |
@@ -117,7 +93,13 @@ class URL { | |
*/ | |
public static function to($url = '', $https = false) | |
{ | |
- if (filter_var($url, FILTER_VALIDATE_URL) !== false) return $url; | |
+ // If the given URL is already valid or begins with a hash, we'll just return | |
+ // the URL unchanged since it is already well formed. Otherwise we will add | |
+ // the base URL of the application and return the full URL. | |
+ if (static::valid($url) or starts_with($url, '#')) | |
+ { | |
+ return $url; | |
+ } | |
$root = static::base().'/'.Config::get('application.index'); | |
@@ -128,6 +110,10 @@ class URL { | |
{ | |
$root = preg_replace('~http://~', 'https://', $root, 1); | |
} | |
+ else | |
+ { | |
+ $root = preg_replace('~https://~', 'http://', $root, 1); | |
+ } | |
return rtrim($root, '/').'/'.ltrim($url, '/'); | |
} | |
@@ -171,7 +157,7 @@ class URL { | |
} | |
// If no route was found that handled the given action, we'll just | |
// generate the URL using the typical controller routing setup | |
- // for URIs and turn SSL to false. | |
+ // for URIs and turn SSL to false by default. | |
else | |
{ | |
return static::convention($action, $parameters); | |
@@ -234,6 +220,16 @@ class URL { | |
*/ | |
public static function to_asset($url, $https = null) | |
{ | |
+ if (static::valid($url)) return $url; | |
+ | |
+ // If a base asset URL is defined in the configuration, use that and don't | |
+ // try and change the HTTP protocol. This allows the delivery of assets | |
+ // through a different server or third-party content delivery network. | |
+ if ($root = Config::get('application.asset_url', false)) | |
+ { | |
+ return rtrim($root, '/').'/'.ltrim($url, '/'); | |
+ } | |
+ | |
if (is_null($https)) $https = Request::secure(); | |
$url = static::to($url, $https); | |
@@ -304,10 +300,21 @@ class URL { | |
// If there are any remaining optional place-holders, we'll just replace | |
// them with empty strings since not every optional parameter has to be | |
- // in the array of parameters that were passed. | |
- $uri = str_replace(array_keys(Router::$optional), '', $uri); | |
+ // in the array of parameters that were passed to us. | |
+ $uri = preg_replace('/\(.+?\)/', '', $uri); | |
return trim($uri, '/'); | |
} | |
+ /** | |
+ * Determine if the given URL is valid. | |
+ * | |
+ * @param string $url | |
+ * @return bool | |
+ */ | |
+ public static function valid($url) | |
+ { | |
+ return filter_var($url, FILTER_VALIDATE_URL) !== false; | |
+ } | |
+ | |
} | |
\ No newline at end of file | |
diff --git a/laravel/validator.php b/laravel/validator.php | |
index b18bf51..dd3a15f 100755 | |
--- a/laravel/validator.php | |
+++ b/laravel/validator.php | |
@@ -946,17 +946,18 @@ class Validator { | |
// of the attribute name in the message. | |
$line = "{$bundle}validation.attributes.{$attribute}"; | |
- $display = Lang::line($line)->get($this->language); | |
+ if (Lang::has($line, $this->language)) | |
+ { | |
+ return Lang::line($line)->get($this->language); | |
+ } | |
// If no language line has been specified for the attribute, all of | |
// the underscores are removed from the attribute name and that | |
// will be used as the attribtue name. | |
- if (is_null($display)) | |
+ else | |
{ | |
return str_replace('_', ' ', $attribute); | |
} | |
- | |
- return $display; | |
} | |
/** | |
diff --git a/laravel/view.php b/laravel/view.php | |
index 76d8d40..f97b3de 100755 | |
--- a/laravel/view.php | |
+++ b/laravel/view.php | |
@@ -38,6 +38,13 @@ class View implements ArrayAccess { | |
public static $names = array(); | |
/** | |
+ * The cache content of loaded view files. | |
+ * | |
+ * @var array | |
+ */ | |
+ public static $cache = array(); | |
+ | |
+ /** | |
* The Laravel view loader event name. | |
* | |
* @var string | |
@@ -103,12 +110,13 @@ class View implements ArrayAccess { | |
} | |
/** | |
- * Get the path to a given view on disk. | |
+ * Determine if the given view exists. | |
* | |
- * @param string $view | |
- * @return string | |
+ * @param string $view | |
+ * @param boolean $return_path | |
+ * @return string|bool | |
*/ | |
- protected function path($view) | |
+ public static function exists($view, $return_path = false) | |
{ | |
list($bundle, $view) = Bundle::parse($view); | |
@@ -117,10 +125,26 @@ class View implements ArrayAccess { | |
// We delegate the determination of view paths to the view loader event | |
// so that the developer is free to override and manage the loading | |
// of views in any way they see fit for their application. | |
- $path = Event::first(static::loader, array($bundle, $view)); | |
+ $path = Event::until(static::loader, array($bundle, $view)); | |
if ( ! is_null($path)) | |
{ | |
+ return $return_path ? $path : true; | |
+ } | |
+ | |
+ return false; | |
+ } | |
+ | |
+ /** | |
+ * Get the path to a given view on disk. | |
+ * | |
+ * @param string $view | |
+ * @return string | |
+ */ | |
+ protected function path($view) | |
+ { | |
+ if ($path = $this->exists($view,true)) | |
+ { | |
return $path; | |
} | |
@@ -226,13 +250,18 @@ class View implements ArrayAccess { | |
* }); | |
* </code> | |
* | |
- * @param string $view | |
- * @param Closure $composer | |
+ * @param string|array $view | |
+ * @param Closure $composer | |
* @return void | |
*/ | |
- public static function composer($view, $composer) | |
+ public static function composer($views, $composer) | |
{ | |
- Event::listen("laravel.composing: {$view}", $composer); | |
+ $views = (array) $views; | |
+ | |
+ foreach ($views as $view) | |
+ { | |
+ Event::listen("laravel.composing: {$view}", $composer); | |
+ } | |
} | |
/** | |
@@ -286,21 +315,16 @@ class View implements ArrayAccess { | |
*/ | |
public function render() | |
{ | |
- // To allow bundles or other pieces of the application to modify the | |
- // view before it is rendered, we'll fire an event, passing in the | |
- // view instance so it can modified. | |
- $composer = "laravel.composing: {$this->view}"; | |
- | |
- Event::fire($composer, array($this)); | |
+ Event::fire("laravel.composing: {$this->view}", array($this)); | |
// If there are listeners to the view engine event, we'll pass them | |
// the view so they can render it according to their needs, which | |
// allows easy attachment of other view parsers. | |
if (Event::listeners(static::engine)) | |
{ | |
- $result = Event::first(static::engine, array($this)); | |
+ $result = Event::until(static::engine, array($this)); | |
- if ($result !== false) return $result; | |
+ if ( ! is_null($result)) return $result; | |
} | |
return $this->get(); | |
@@ -315,6 +339,11 @@ class View implements ArrayAccess { | |
{ | |
$__data = $this->data(); | |
+ // The contents of each view file is cached in an array for the | |
+ // request since partial views may be rendered inside of for | |
+ // loops which could incur performance penalties. | |
+ $__contents = $this->load(); | |
+ | |
ob_start() and extract($__data, EXTR_SKIP); | |
// We'll include the view contents for parsing within a catcher | |
@@ -322,12 +351,12 @@ class View implements ArrayAccess { | |
// will throw it out to the exception handler. | |
try | |
{ | |
- include $this->path; | |
+ eval('?>'.$__contents); | |
} | |
// If we caught an exception, we'll silently flush the output | |
// buffer so that no partially rendered views get thrown out | |
- // to the client and confuse the user. | |
+ // to the client and confuse the user with junk. | |
catch (\Exception $e) | |
{ | |
ob_get_clean(); throw $e; | |
@@ -337,6 +366,23 @@ class View implements ArrayAccess { | |
} | |
/** | |
+ * Get the contents of the view file from disk. | |
+ * | |
+ * @return string | |
+ */ | |
+ protected function load() | |
+ { | |
+ if (isset(static::$cache[$this->path])) | |
+ { | |
+ return static::$cache[$this->path]; | |
+ } | |
+ else | |
+ { | |
+ return static::$cache[$this->path] = file_get_contents($this->path); | |
+ } | |
+ } | |
+ | |
+ /** | |
* Get the array of view data for the view instance. | |
* | |
* The shared view data will be combined with the view data. | |
diff --git a/paths.php b/paths.php | |
index 7d0a3b5..909d3b4 100755 | |
--- a/paths.php | |
+++ b/paths.php | |
@@ -3,28 +3,29 @@ | |
* Laravel - A PHP Framework For Web Artisans | |
* | |
* @package Laravel | |
- * @version 3.1.9 | |
+ * @version 3.2.0 | |
* @author Taylor Otwell <[email protected]> | |
* @link http://laravel.com | |
*/ | |
-// -------------------------------------------------------------- | |
-// Initialize the web variable if it doesn't exist. | |
-// -------------------------------------------------------------- | |
-if ( ! isset($web)) $web = false; | |
+/* | |
+|---------------------------------------------------------------- | |
+| Application Environemtns | |
+|---------------------------------------------------------------- | |
+| | |
+| Laravel takes a dead simple approach to environments, and we | |
+| think you'll love it. Just specify which URLs belongs to a | |
+| given environment, and when you access your application | |
+| from a URL matching that pattern, we'll be sure to | |
+| merge in that environment's configuration files. | |
+| | |
+*/ | |
-// -------------------------------------------------------------- | |
-// Define the directory separator for the environment. | |
-// -------------------------------------------------------------- | |
-if ( ! defined('DS')) | |
-{ | |
- define('DS', DIRECTORY_SEPARATOR); | |
-} | |
+$environments = array( | |
-// -------------------------------------------------------------- | |
-// Define the path to the base directory. | |
-// -------------------------------------------------------------- | |
-$GLOBALS['laravel_paths']['base'] = __DIR__.DS; | |
+ 'local' => array('http://localhost*', '*.dev'), | |
+ | |
+); | |
// -------------------------------------------------------------- | |
// The path to the application directory. | |
@@ -49,22 +50,35 @@ $paths['storage'] = 'storage'; | |
// -------------------------------------------------------------- | |
// The path to the public directory. | |
// -------------------------------------------------------------- | |
-if ($web) | |
-{ | |
- $GLOBALS['laravel_paths']['public'] = realpath('').DS; | |
-} | |
-else | |
+$paths['public'] = 'public'; | |
+ | |
+// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- | |
+// END OF USER CONFIGURATION. HERE BE DRAGONS! | |
+// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- | |
+ | |
+// -------------------------------------------------------------- | |
+// Change to the current working directory. | |
+// -------------------------------------------------------------- | |
+chdir(__DIR__); | |
+ | |
+// -------------------------------------------------------------- | |
+// Define the directory separator for the environment. | |
+// -------------------------------------------------------------- | |
+if ( ! defined('DS')) | |
{ | |
- $paths['public'] = 'public'; | |
+ define('DS', DIRECTORY_SEPARATOR); | |
} | |
// -------------------------------------------------------------- | |
+// Define the path to the base directory. | |
+// -------------------------------------------------------------- | |
+$GLOBALS['laravel_paths']['base'] = __DIR__.DS; | |
+ | |
+// -------------------------------------------------------------- | |
// Define each constant if it hasn't been defined. | |
// -------------------------------------------------------------- | |
foreach ($paths as $name => $path) | |
{ | |
- if ($web) $path = "../{$path}"; | |
- | |
if ( ! isset($GLOBALS['laravel_paths'][$name])) | |
{ | |
$GLOBALS['laravel_paths'][$name] = realpath($path).DS; | |
diff --git a/public/index.php b/public/index.php | |
index 3437557..463d227 100755 | |
--- a/public/index.php | |
+++ b/public/index.php | |
@@ -3,7 +3,7 @@ | |
* Laravel - A PHP Framework For Web Artisans | |
* | |
* @package Laravel | |
- * @version 3.1.9 | |
+ * @version 3.2.0 | |
* @author Taylor Otwell <[email protected]> | |
* @link http://laravel.com | |
*/ | |
diff --git a/readme.md b/readme.md | |
index e05ef39..37ac603 100755 | |
--- a/readme.md | |
+++ b/readme.md | |
@@ -19,29 +19,43 @@ Laravel is a clean and classy framework for PHP web development. Freeing you fro | |
**Hello World:** | |
- Route::get('/', function() | |
- { | |
- return "Hello World!": | |
- }); | |
+```php | |
+<?php | |
+ | |
+Route::get('/', function() | |
+{ | |
+ return "Hello World!": | |
+}); | |
+``` | |
**Passing Data To Views:** | |
- Route::get('user/(:num)', function($id) | |
- { | |
- $user = DB::table('users')->find($id); | |
+```php | |
+<?php | |
+ | |
+Route::get('user/(:num)', function($id) | |
+{ | |
+ $user = DB::table('users')->find($id); | |
- return View::make('profile')->with('user', $user); | |
- }); | |
+ return View::make('profile')->with('user', $user); | |
+}); | |
+``` | |
**Redirecting & Flashing Data To The Session:** | |
- return Redirect::to('profile')->with('message', 'Welcome Back!'); | |
+```php | |
+<?php | |
+ | |
+return Redirect::to('profile')->with('message', 'Welcome Back!'); | |
+``` | |
### Contributing to Laravel | |
Contributions are encouraged and welcome; however, please review the Developer Certificate of Origin in the "license.txt" file included in the repository. All commits must be signed off using the "-s" switch. | |
- git commit -s -m "this commit will be signed off automatically!" | |
+```bash | |
+git commit -s -m "this commit will be signed off automatically!" | |
+``` | |
### License | |
diff --git a/vendor/Symfony/Component/Console/Application.php b/vendor/Symfony/Component/Console/Application.php | |
deleted file mode 100755 | |
index e04940a..0000000 | |
--- a/vendor/Symfony/Component/Console/Application.php | |
+++ /dev/null | |
@@ -1,1007 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console; | |
- | |
-use Symfony\Component\Console\Input\InputInterface; | |
-use Symfony\Component\Console\Input\ArgvInput; | |
-use Symfony\Component\Console\Input\ArrayInput; | |
-use Symfony\Component\Console\Input\InputDefinition; | |
-use Symfony\Component\Console\Input\InputOption; | |
-use Symfony\Component\Console\Input\InputArgument; | |
-use Symfony\Component\Console\Output\OutputInterface; | |
-use Symfony\Component\Console\Output\Output; | |
-use Symfony\Component\Console\Output\ConsoleOutput; | |
-use Symfony\Component\Console\Output\ConsoleOutputInterface; | |
-use Symfony\Component\Console\Command\Command; | |
-use Symfony\Component\Console\Command\HelpCommand; | |
-use Symfony\Component\Console\Command\ListCommand; | |
-use Symfony\Component\Console\Helper\HelperSet; | |
-use Symfony\Component\Console\Helper\FormatterHelper; | |
-use Symfony\Component\Console\Helper\DialogHelper; | |
- | |
-/** | |
- * An Application is the container for a collection of commands. | |
- * | |
- * It is the main entry point of a Console application. | |
- * | |
- * This class is optimized for a standard CLI environment. | |
- * | |
- * Usage: | |
- * | |
- * $app = new Application('myapp', '1.0 (stable)'); | |
- * $app->add(new SimpleCommand()); | |
- * $app->run(); | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- * | |
- * @api | |
- */ | |
-class Application | |
-{ | |
- private $commands; | |
- private $wantHelps = false; | |
- private $runningCommand; | |
- private $name; | |
- private $version; | |
- private $catchExceptions; | |
- private $autoExit; | |
- private $definition; | |
- private $helperSet; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * @param string $name The name of the application | |
- * @param string $version The version of the application | |
- * | |
- * @api | |
- */ | |
- public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') | |
- { | |
- $this->name = $name; | |
- $this->version = $version; | |
- $this->catchExceptions = true; | |
- $this->autoExit = true; | |
- $this->commands = array(); | |
- $this->helperSet = $this->getDefaultHelperSet(); | |
- $this->definition = $this->getDefaultInputDefinition(); | |
- | |
- foreach ($this->getDefaultCommands() as $command) { | |
- $this->add($command); | |
- } | |
- } | |
- | |
- /** | |
- * Runs the current application. | |
- * | |
- * @param InputInterface $input An Input instance | |
- * @param OutputInterface $output An Output instance | |
- * | |
- * @return integer 0 if everything went fine, or an error code | |
- * | |
- * @throws \Exception When doRun returns Exception | |
- * | |
- * @api | |
- */ | |
- public function run(InputInterface $input = null, OutputInterface $output = null) | |
- { | |
- if (null === $input) { | |
- $input = new ArgvInput(); | |
- } | |
- | |
- if (null === $output) { | |
- $output = new ConsoleOutput(); | |
- } | |
- | |
- try { | |
- $statusCode = $this->doRun($input, $output); | |
- } catch (\Exception $e) { | |
- if (!$this->catchExceptions) { | |
- throw $e; | |
- } | |
- | |
- if ($output instanceof ConsoleOutputInterface) { | |
- $this->renderException($e, $output->getErrorOutput()); | |
- } else { | |
- $this->renderException($e, $output); | |
- } | |
- $statusCode = $e->getCode(); | |
- | |
- $statusCode = is_numeric($statusCode) && $statusCode ? $statusCode : 1; | |
- } | |
- | |
- if ($this->autoExit) { | |
- if ($statusCode > 255) { | |
- $statusCode = 255; | |
- } | |
- // @codeCoverageIgnoreStart | |
- exit($statusCode); | |
- // @codeCoverageIgnoreEnd | |
- } | |
- | |
- return $statusCode; | |
- } | |
- | |
- /** | |
- * Runs the current application. | |
- * | |
- * @param InputInterface $input An Input instance | |
- * @param OutputInterface $output An Output instance | |
- * | |
- * @return integer 0 if everything went fine, or an error code | |
- */ | |
- public function doRun(InputInterface $input, OutputInterface $output) | |
- { | |
- $name = $this->getCommandName($input); | |
- | |
- if (true === $input->hasParameterOption(array('--ansi'))) { | |
- $output->setDecorated(true); | |
- } elseif (true === $input->hasParameterOption(array('--no-ansi'))) { | |
- $output->setDecorated(false); | |
- } | |
- | |
- if (true === $input->hasParameterOption(array('--help', '-h'))) { | |
- if (!$name) { | |
- $name = 'help'; | |
- $input = new ArrayInput(array('command' => 'help')); | |
- } else { | |
- $this->wantHelps = true; | |
- } | |
- } | |
- | |
- if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) { | |
- $input->setInteractive(false); | |
- } | |
- | |
- if (function_exists('posix_isatty') && $this->getHelperSet()->has('dialog')) { | |
- $inputStream = $this->getHelperSet()->get('dialog')->getInputStream(); | |
- if (!posix_isatty($inputStream)) { | |
- $input->setInteractive(false); | |
- } | |
- } | |
- | |
- if (true === $input->hasParameterOption(array('--quiet', '-q'))) { | |
- $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); | |
- } elseif (true === $input->hasParameterOption(array('--verbose', '-v'))) { | |
- $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); | |
- } | |
- | |
- if (true === $input->hasParameterOption(array('--version', '-V'))) { | |
- $output->writeln($this->getLongVersion()); | |
- | |
- return 0; | |
- } | |
- | |
- if (!$name) { | |
- $name = 'list'; | |
- $input = new ArrayInput(array('command' => 'list')); | |
- } | |
- | |
- // the command name MUST be the first element of the input | |
- $command = $this->find($name); | |
- | |
- $this->runningCommand = $command; | |
- $statusCode = $command->run($input, $output); | |
- $this->runningCommand = null; | |
- | |
- return is_numeric($statusCode) ? $statusCode : 0; | |
- } | |
- | |
- /** | |
- * Set a helper set to be used with the command. | |
- * | |
- * @param HelperSet $helperSet The helper set | |
- * | |
- * @api | |
- */ | |
- public function setHelperSet(HelperSet $helperSet) | |
- { | |
- $this->helperSet = $helperSet; | |
- } | |
- | |
- /** | |
- * Get the helper set associated with the command. | |
- * | |
- * @return HelperSet The HelperSet instance associated with this command | |
- * | |
- * @api | |
- */ | |
- public function getHelperSet() | |
- { | |
- return $this->helperSet; | |
- } | |
- | |
- /** | |
- * Gets the InputDefinition related to this Application. | |
- * | |
- * @return InputDefinition The InputDefinition instance | |
- */ | |
- public function getDefinition() | |
- { | |
- return $this->definition; | |
- } | |
- | |
- /** | |
- * Gets the help message. | |
- * | |
- * @return string A help message. | |
- */ | |
- public function getHelp() | |
- { | |
- $messages = array( | |
- $this->getLongVersion(), | |
- '', | |
- '<comment>Usage:</comment>', | |
- sprintf(" [options] command [arguments]\n"), | |
- '<comment>Options:</comment>', | |
- ); | |
- | |
- foreach ($this->getDefinition()->getOptions() as $option) { | |
- $messages[] = sprintf(' %-29s %s %s', | |
- '<info>--'.$option->getName().'</info>', | |
- $option->getShortcut() ? '<info>-'.$option->getShortcut().'</info>' : ' ', | |
- $option->getDescription() | |
- ); | |
- } | |
- | |
- return implode(PHP_EOL, $messages); | |
- } | |
- | |
- /** | |
- * Sets whether to catch exceptions or not during commands execution. | |
- * | |
- * @param Boolean $boolean Whether to catch exceptions or not during commands execution | |
- * | |
- * @api | |
- */ | |
- public function setCatchExceptions($boolean) | |
- { | |
- $this->catchExceptions = (Boolean) $boolean; | |
- } | |
- | |
- /** | |
- * Sets whether to automatically exit after a command execution or not. | |
- * | |
- * @param Boolean $boolean Whether to automatically exit after a command execution or not | |
- * | |
- * @api | |
- */ | |
- public function setAutoExit($boolean) | |
- { | |
- $this->autoExit = (Boolean) $boolean; | |
- } | |
- | |
- /** | |
- * Gets the name of the application. | |
- * | |
- * @return string The application name | |
- * | |
- * @api | |
- */ | |
- public function getName() | |
- { | |
- return $this->name; | |
- } | |
- | |
- /** | |
- * Sets the application name. | |
- * | |
- * @param string $name The application name | |
- * | |
- * @api | |
- */ | |
- public function setName($name) | |
- { | |
- $this->name = $name; | |
- } | |
- | |
- /** | |
- * Gets the application version. | |
- * | |
- * @return string The application version | |
- * | |
- * @api | |
- */ | |
- public function getVersion() | |
- { | |
- return $this->version; | |
- } | |
- | |
- /** | |
- * Sets the application version. | |
- * | |
- * @param string $version The application version | |
- * | |
- * @api | |
- */ | |
- public function setVersion($version) | |
- { | |
- $this->version = $version; | |
- } | |
- | |
- /** | |
- * Returns the long version of the application. | |
- * | |
- * @return string The long application version | |
- * | |
- * @api | |
- */ | |
- public function getLongVersion() | |
- { | |
- if ('UNKNOWN' !== $this->getName() && 'UNKNOWN' !== $this->getVersion()) { | |
- return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion()); | |
- } | |
- | |
- return '<info>Console Tool</info>'; | |
- } | |
- | |
- /** | |
- * Registers a new command. | |
- * | |
- * @param string $name The command name | |
- * | |
- * @return Command The newly created command | |
- * | |
- * @api | |
- */ | |
- public function register($name) | |
- { | |
- return $this->add(new Command($name)); | |
- } | |
- | |
- /** | |
- * Adds an array of command objects. | |
- * | |
- * @param Command[] $commands An array of commands | |
- * | |
- * @api | |
- */ | |
- public function addCommands(array $commands) | |
- { | |
- foreach ($commands as $command) { | |
- $this->add($command); | |
- } | |
- } | |
- | |
- /** | |
- * Adds a command object. | |
- * | |
- * If a command with the same name already exists, it will be overridden. | |
- * | |
- * @param Command $command A Command object | |
- * | |
- * @return Command The registered command | |
- * | |
- * @api | |
- */ | |
- public function add(Command $command) | |
- { | |
- $command->setApplication($this); | |
- | |
- if (!$command->isEnabled()) { | |
- $command->setApplication(null); | |
- | |
- return; | |
- } | |
- | |
- $this->commands[$command->getName()] = $command; | |
- | |
- foreach ($command->getAliases() as $alias) { | |
- $this->commands[$alias] = $command; | |
- } | |
- | |
- return $command; | |
- } | |
- | |
- /** | |
- * Returns a registered command by name or alias. | |
- * | |
- * @param string $name The command name or alias | |
- * | |
- * @return Command A Command object | |
- * | |
- * @throws \InvalidArgumentException When command name given does not exist | |
- * | |
- * @api | |
- */ | |
- public function get($name) | |
- { | |
- if (!isset($this->commands[$name])) { | |
- throw new \InvalidArgumentException(sprintf('The command "%s" does not exist.', $name)); | |
- } | |
- | |
- $command = $this->commands[$name]; | |
- | |
- if ($this->wantHelps) { | |
- $this->wantHelps = false; | |
- | |
- $helpCommand = $this->get('help'); | |
- $helpCommand->setCommand($command); | |
- | |
- return $helpCommand; | |
- } | |
- | |
- return $command; | |
- } | |
- | |
- /** | |
- * Returns true if the command exists, false otherwise. | |
- * | |
- * @param string $name The command name or alias | |
- * | |
- * @return Boolean true if the command exists, false otherwise | |
- * | |
- * @api | |
- */ | |
- public function has($name) | |
- { | |
- return isset($this->commands[$name]); | |
- } | |
- | |
- /** | |
- * Returns an array of all unique namespaces used by currently registered commands. | |
- * | |
- * It does not returns the global namespace which always exists. | |
- * | |
- * @return array An array of namespaces | |
- */ | |
- public function getNamespaces() | |
- { | |
- $namespaces = array(); | |
- foreach ($this->commands as $command) { | |
- $namespaces[] = $this->extractNamespace($command->getName()); | |
- | |
- foreach ($command->getAliases() as $alias) { | |
- $namespaces[] = $this->extractNamespace($alias); | |
- } | |
- } | |
- | |
- return array_values(array_unique(array_filter($namespaces))); | |
- } | |
- | |
- /** | |
- * Finds a registered namespace by a name or an abbreviation. | |
- * | |
- * @param string $namespace A namespace or abbreviation to search for | |
- * | |
- * @return string A registered namespace | |
- * | |
- * @throws \InvalidArgumentException When namespace is incorrect or ambiguous | |
- */ | |
- public function findNamespace($namespace) | |
- { | |
- $allNamespaces = array(); | |
- foreach ($this->getNamespaces() as $n) { | |
- $allNamespaces[$n] = explode(':', $n); | |
- } | |
- | |
- $found = array(); | |
- foreach (explode(':', $namespace) as $i => $part) { | |
- $abbrevs = static::getAbbreviations(array_unique(array_values(array_filter(array_map(function ($p) use ($i) { return isset($p[$i]) ? $p[$i] : ''; }, $allNamespaces))))); | |
- | |
- if (!isset($abbrevs[$part])) { | |
- $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace); | |
- | |
- if (1 <= $i) { | |
- $part = implode(':', $found).':'.$part; | |
- } | |
- | |
- if ($alternatives = $this->findAlternativeNamespace($part, $abbrevs)) { | |
- $message .= "\n\nDid you mean one of these?\n "; | |
- $message .= implode("\n ", $alternatives); | |
- } | |
- | |
- throw new \InvalidArgumentException($message); | |
- } | |
- | |
- if (count($abbrevs[$part]) > 1) { | |
- throw new \InvalidArgumentException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions($abbrevs[$part]))); | |
- } | |
- | |
- $found[] = $abbrevs[$part][0]; | |
- } | |
- | |
- return implode(':', $found); | |
- } | |
- | |
- /** | |
- * Finds a command by name or alias. | |
- * | |
- * Contrary to get, this command tries to find the best | |
- * match if you give it an abbreviation of a name or alias. | |
- * | |
- * @param string $name A command name or a command alias | |
- * | |
- * @return Command A Command instance | |
- * | |
- * @throws \InvalidArgumentException When command name is incorrect or ambiguous | |
- * | |
- * @api | |
- */ | |
- public function find($name) | |
- { | |
- // namespace | |
- $namespace = ''; | |
- $searchName = $name; | |
- if (false !== $pos = strrpos($name, ':')) { | |
- $namespace = $this->findNamespace(substr($name, 0, $pos)); | |
- $searchName = $namespace.substr($name, $pos); | |
- } | |
- | |
- // name | |
- $commands = array(); | |
- foreach ($this->commands as $command) { | |
- if ($this->extractNamespace($command->getName()) == $namespace) { | |
- $commands[] = $command->getName(); | |
- } | |
- } | |
- | |
- $abbrevs = static::getAbbreviations(array_unique($commands)); | |
- if (isset($abbrevs[$searchName]) && 1 == count($abbrevs[$searchName])) { | |
- return $this->get($abbrevs[$searchName][0]); | |
- } | |
- | |
- if (isset($abbrevs[$searchName]) && count($abbrevs[$searchName]) > 1) { | |
- $suggestions = $this->getAbbreviationSuggestions($abbrevs[$searchName]); | |
- | |
- throw new \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions)); | |
- } | |
- | |
- // aliases | |
- $aliases = array(); | |
- foreach ($this->commands as $command) { | |
- foreach ($command->getAliases() as $alias) { | |
- if ($this->extractNamespace($alias) == $namespace) { | |
- $aliases[] = $alias; | |
- } | |
- } | |
- } | |
- | |
- $aliases = static::getAbbreviations(array_unique($aliases)); | |
- if (!isset($aliases[$searchName])) { | |
- $message = sprintf('Command "%s" is not defined.', $name); | |
- | |
- if ($alternatives = $this->findAlternativeCommands($searchName, $abbrevs)) { | |
- $message .= "\n\nDid you mean one of these?\n "; | |
- $message .= implode("\n ", $alternatives); | |
- } | |
- | |
- throw new \InvalidArgumentException($message); | |
- } | |
- | |
- if (count($aliases[$searchName]) > 1) { | |
- throw new \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $name, $this->getAbbreviationSuggestions($aliases[$searchName]))); | |
- } | |
- | |
- return $this->get($aliases[$searchName][0]); | |
- } | |
- | |
- /** | |
- * Gets the commands (registered in the given namespace if provided). | |
- * | |
- * The array keys are the full names and the values the command instances. | |
- * | |
- * @param string $namespace A namespace name | |
- * | |
- * @return array An array of Command instances | |
- * | |
- * @api | |
- */ | |
- public function all($namespace = null) | |
- { | |
- if (null === $namespace) { | |
- return $this->commands; | |
- } | |
- | |
- $commands = array(); | |
- foreach ($this->commands as $name => $command) { | |
- if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) { | |
- $commands[$name] = $command; | |
- } | |
- } | |
- | |
- return $commands; | |
- } | |
- | |
- /** | |
- * Returns an array of possible abbreviations given a set of names. | |
- * | |
- * @param array $names An array of names | |
- * | |
- * @return array An array of abbreviations | |
- */ | |
- static public function getAbbreviations($names) | |
- { | |
- $abbrevs = array(); | |
- foreach ($names as $name) { | |
- for ($len = strlen($name) - 1; $len > 0; --$len) { | |
- $abbrev = substr($name, 0, $len); | |
- if (!isset($abbrevs[$abbrev])) { | |
- $abbrevs[$abbrev] = array($name); | |
- } else { | |
- $abbrevs[$abbrev][] = $name; | |
- } | |
- } | |
- } | |
- | |
- // Non-abbreviations always get entered, even if they aren't unique | |
- foreach ($names as $name) { | |
- $abbrevs[$name] = array($name); | |
- } | |
- | |
- return $abbrevs; | |
- } | |
- | |
- /** | |
- * Returns a text representation of the Application. | |
- * | |
- * @param string $namespace An optional namespace name | |
- * @param boolean $raw Whether to return raw command list | |
- * | |
- * @return string A string representing the Application | |
- */ | |
- public function asText($namespace = null, $raw = false) | |
- { | |
- $commands = $namespace ? $this->all($this->findNamespace($namespace)) : $this->commands; | |
- | |
- $width = 0; | |
- foreach ($commands as $command) { | |
- $width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width; | |
- } | |
- $width += 2; | |
- | |
- if ($raw) { | |
- $messages = array(); | |
- foreach ($this->sortCommands($commands) as $space => $commands) { | |
- foreach ($commands as $name => $command) { | |
- $messages[] = sprintf("%-${width}s %s", $name, $command->getDescription()); | |
- } | |
- } | |
- | |
- return implode(PHP_EOL, $messages); | |
- } | |
- | |
- $messages = array($this->getHelp(), ''); | |
- if ($namespace) { | |
- $messages[] = sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $namespace); | |
- } else { | |
- $messages[] = '<comment>Available commands:</comment>'; | |
- } | |
- | |
- // add commands by namespace | |
- foreach ($this->sortCommands($commands) as $space => $commands) { | |
- if (!$namespace && '_global' !== $space) { | |
- $messages[] = '<comment>'.$space.'</comment>'; | |
- } | |
- | |
- foreach ($commands as $name => $command) { | |
- $messages[] = sprintf(" <info>%-${width}s</info> %s", $name, $command->getDescription()); | |
- } | |
- } | |
- | |
- return implode(PHP_EOL, $messages); | |
- } | |
- | |
- /** | |
- * Returns an XML representation of the Application. | |
- * | |
- * @param string $namespace An optional namespace name | |
- * @param Boolean $asDom Whether to return a DOM or an XML string | |
- * | |
- * @return string|DOMDocument An XML string representing the Application | |
- */ | |
- public function asXml($namespace = null, $asDom = false) | |
- { | |
- $commands = $namespace ? $this->all($this->findNamespace($namespace)) : $this->commands; | |
- | |
- $dom = new \DOMDocument('1.0', 'UTF-8'); | |
- $dom->formatOutput = true; | |
- $dom->appendChild($xml = $dom->createElement('symfony')); | |
- | |
- $xml->appendChild($commandsXML = $dom->createElement('commands')); | |
- | |
- if ($namespace) { | |
- $commandsXML->setAttribute('namespace', $namespace); | |
- } else { | |
- $namespacesXML = $dom->createElement('namespaces'); | |
- $xml->appendChild($namespacesXML); | |
- } | |
- | |
- // add commands by namespace | |
- foreach ($this->sortCommands($commands) as $space => $commands) { | |
- if (!$namespace) { | |
- $namespaceArrayXML = $dom->createElement('namespace'); | |
- $namespacesXML->appendChild($namespaceArrayXML); | |
- $namespaceArrayXML->setAttribute('id', $space); | |
- } | |
- | |
- foreach ($commands as $name => $command) { | |
- if ($name !== $command->getName()) { | |
- continue; | |
- } | |
- | |
- if (!$namespace) { | |
- $commandXML = $dom->createElement('command'); | |
- $namespaceArrayXML->appendChild($commandXML); | |
- $commandXML->appendChild($dom->createTextNode($name)); | |
- } | |
- | |
- $node = $command->asXml(true)->getElementsByTagName('command')->item(0); | |
- $node = $dom->importNode($node, true); | |
- | |
- $commandsXML->appendChild($node); | |
- } | |
- } | |
- | |
- return $asDom ? $dom : $dom->saveXml(); | |
- } | |
- | |
- /** | |
- * Renders a catched exception. | |
- * | |
- * @param Exception $e An exception instance | |
- * @param OutputInterface $output An OutputInterface instance | |
- */ | |
- public function renderException($e, $output) | |
- { | |
- $strlen = function ($string) { | |
- if (!function_exists('mb_strlen')) { | |
- return strlen($string); | |
- } | |
- | |
- if (false === $encoding = mb_detect_encoding($string)) { | |
- return strlen($string); | |
- } | |
- | |
- return mb_strlen($string, $encoding); | |
- }; | |
- | |
- do { | |
- $title = sprintf(' [%s] ', get_class($e)); | |
- $len = $strlen($title); | |
- $lines = array(); | |
- foreach (explode("\n", $e->getMessage()) as $line) { | |
- $lines[] = sprintf(' %s ', $line); | |
- $len = max($strlen($line) + 4, $len); | |
- } | |
- | |
- $messages = array(str_repeat(' ', $len), $title.str_repeat(' ', $len - $strlen($title))); | |
- | |
- foreach ($lines as $line) { | |
- $messages[] = $line.str_repeat(' ', $len - $strlen($line)); | |
- } | |
- | |
- $messages[] = str_repeat(' ', $len); | |
- | |
- $output->writeln(""); | |
- $output->writeln(""); | |
- foreach ($messages as $message) { | |
- $output->writeln('<error>'.$message.'</error>'); | |
- } | |
- $output->writeln(""); | |
- $output->writeln(""); | |
- | |
- if (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity()) { | |
- $output->writeln('<comment>Exception trace:</comment>'); | |
- | |
- // exception related properties | |
- $trace = $e->getTrace(); | |
- array_unshift($trace, array( | |
- 'function' => '', | |
- 'file' => $e->getFile() != null ? $e->getFile() : 'n/a', | |
- 'line' => $e->getLine() != null ? $e->getLine() : 'n/a', | |
- 'args' => array(), | |
- )); | |
- | |
- for ($i = 0, $count = count($trace); $i < $count; $i++) { | |
- $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : ''; | |
- $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : ''; | |
- $function = $trace[$i]['function']; | |
- $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a'; | |
- $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a'; | |
- | |
- $output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line)); | |
- } | |
- | |
- $output->writeln(""); | |
- $output->writeln(""); | |
- } | |
- } while ($e = $e->getPrevious()); | |
- | |
- if (null !== $this->runningCommand) { | |
- $output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName()))); | |
- $output->writeln(""); | |
- $output->writeln(""); | |
- } | |
- } | |
- | |
- /** | |
- * Gets the name of the command based on input. | |
- * | |
- * @param InputInterface $input The input interface | |
- * | |
- * @return string The command name | |
- */ | |
- protected function getCommandName(InputInterface $input) | |
- { | |
- return $input->getFirstArgument('command'); | |
- } | |
- | |
- /** | |
- * Gets the default input definition. | |
- * | |
- * @return InputDefinition An InputDefinition instance | |
- */ | |
- protected function getDefaultInputDefinition() | |
- { | |
- return new InputDefinition(array( | |
- new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'), | |
- | |
- new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message.'), | |
- new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message.'), | |
- new InputOption('--verbose', '-v', InputOption::VALUE_NONE, 'Increase verbosity of messages.'), | |
- new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version.'), | |
- new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output.'), | |
- new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output.'), | |
- new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question.'), | |
- )); | |
- } | |
- | |
- /** | |
- * Gets the default commands that should always be available. | |
- * | |
- * @return array An array of default Command instances | |
- */ | |
- protected function getDefaultCommands() | |
- { | |
- return array(new HelpCommand(), new ListCommand()); | |
- } | |
- | |
- /** | |
- * Gets the default helper set with the helpers that should always be available. | |
- * | |
- * @return HelperSet A HelperSet instance | |
- */ | |
- protected function getDefaultHelperSet() | |
- { | |
- return new HelperSet(array( | |
- new FormatterHelper(), | |
- new DialogHelper(), | |
- )); | |
- } | |
- | |
- /** | |
- * Sorts commands in alphabetical order. | |
- * | |
- * @param array $commands An associative array of commands to sort | |
- * | |
- * @return array A sorted array of commands | |
- */ | |
- private function sortCommands($commands) | |
- { | |
- $namespacedCommands = array(); | |
- foreach ($commands as $name => $command) { | |
- $key = $this->extractNamespace($name, 1); | |
- if (!$key) { | |
- $key = '_global'; | |
- } | |
- | |
- $namespacedCommands[$key][$name] = $command; | |
- } | |
- ksort($namespacedCommands); | |
- | |
- foreach ($namespacedCommands as &$commands) { | |
- ksort($commands); | |
- } | |
- | |
- return $namespacedCommands; | |
- } | |
- | |
- /** | |
- * Returns abbreviated suggestions in string format. | |
- * | |
- * @param array $abbrevs Abbreviated suggestions to convert | |
- * | |
- * @return string A formatted string of abbreviated suggestions | |
- */ | |
- private function getAbbreviationSuggestions($abbrevs) | |
- { | |
- return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], count($abbrevs) > 2 ? sprintf(' and %d more', count($abbrevs) - 2) : ''); | |
- } | |
- | |
- /** | |
- * Returns the namespace part of the command name. | |
- * | |
- * @param string $name The full name of the command | |
- * @param string $limit The maximum number of parts of the namespace | |
- * | |
- * @return string The namespace of the command | |
- */ | |
- private function extractNamespace($name, $limit = null) | |
- { | |
- $parts = explode(':', $name); | |
- array_pop($parts); | |
- | |
- return implode(':', null === $limit ? $parts : array_slice($parts, 0, $limit)); | |
- } | |
- | |
- /** | |
- * Finds alternative commands of $name | |
- * | |
- * @param string $name The full name of the command | |
- * @param array $abbrevs The abbreviations | |
- * | |
- * @return array A sorted array of similar commands | |
- */ | |
- private function findAlternativeCommands($name, $abbrevs) | |
- { | |
- $callback = function($item) { | |
- return $item->getName(); | |
- }; | |
- | |
- return $this->findAlternatives($name, $this->commands, $abbrevs, $callback); | |
- } | |
- | |
- /** | |
- * Finds alternative namespace of $name | |
- * | |
- * @param string $name The full name of the namespace | |
- * @param array $abbrevs The abbreviations | |
- * | |
- * @return array A sorted array of similar namespace | |
- */ | |
- private function findAlternativeNamespace($name, $abbrevs) | |
- { | |
- return $this->findAlternatives($name, $this->getNamespaces(), $abbrevs); | |
- } | |
- | |
- /** | |
- * Finds alternative of $name among $collection, | |
- * if nothing is found in $collection, try in $abbrevs | |
- * | |
- * @param string $name The string | |
- * @param array|Traversable $collection The collecion | |
- * @param array $abbrevs The abbreviations | |
- * @param Closure|string|array $callback The callable to transform collection item before comparison | |
- * | |
- * @return array A sorted array of similar string | |
- */ | |
- private function findAlternatives($name, $collection, $abbrevs, $callback = null) { | |
- $alternatives = array(); | |
- | |
- foreach ($collection as $item) { | |
- if (null !== $callback) { | |
- $item = call_user_func($callback, $item); | |
- } | |
- | |
- $lev = levenshtein($name, $item); | |
- if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) { | |
- $alternatives[$item] = $lev; | |
- } | |
- } | |
- | |
- if (!$alternatives) { | |
- foreach ($abbrevs as $key => $values) { | |
- $lev = levenshtein($name, $key); | |
- if ($lev <= strlen($name) / 3 || false !== strpos($key, $name)) { | |
- foreach ($values as $value) { | |
- $alternatives[$value] = $lev; | |
- } | |
- } | |
- } | |
- } | |
- | |
- asort($alternatives); | |
- | |
- return array_keys($alternatives); | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Command/Command.php b/vendor/Symfony/Component/Console/Command/Command.php | |
deleted file mode 100755 | |
index 033a95c..0000000 | |
--- a/vendor/Symfony/Component/Console/Command/Command.php | |
+++ /dev/null | |
@@ -1,612 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Command; | |
- | |
-use Symfony\Component\Console\Input\InputDefinition; | |
-use Symfony\Component\Console\Input\InputOption; | |
-use Symfony\Component\Console\Input\InputArgument; | |
-use Symfony\Component\Console\Input\InputInterface; | |
-use Symfony\Component\Console\Output\OutputInterface; | |
-use Symfony\Component\Console\Application; | |
-use Symfony\Component\Console\Helper\HelperSet; | |
- | |
-/** | |
- * Base class for all commands. | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- * | |
- * @api | |
- */ | |
-class Command | |
-{ | |
- private $application; | |
- private $name; | |
- private $aliases; | |
- private $definition; | |
- private $help; | |
- private $description; | |
- private $ignoreValidationErrors; | |
- private $applicationDefinitionMerged; | |
- private $code; | |
- private $synopsis; | |
- private $helperSet; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * @param string $name The name of the command | |
- * | |
- * @throws \LogicException When the command name is empty | |
- * | |
- * @api | |
- */ | |
- public function __construct($name = null) | |
- { | |
- $this->definition = new InputDefinition(); | |
- $this->ignoreValidationErrors = false; | |
- $this->applicationDefinitionMerged = false; | |
- $this->aliases = array(); | |
- | |
- if (null !== $name) { | |
- $this->setName($name); | |
- } | |
- | |
- $this->configure(); | |
- | |
- if (!$this->name) { | |
- throw new \LogicException('The command name cannot be empty.'); | |
- } | |
- } | |
- | |
- /** | |
- * Ignores validation errors. | |
- * | |
- * This is mainly useful for the help command. | |
- */ | |
- public function ignoreValidationErrors() | |
- { | |
- $this->ignoreValidationErrors = true; | |
- } | |
- | |
- /** | |
- * Sets the application instance for this command. | |
- * | |
- * @param Application $application An Application instance | |
- * | |
- * @api | |
- */ | |
- public function setApplication(Application $application = null) | |
- { | |
- $this->application = $application; | |
- if ($application) { | |
- $this->setHelperSet($application->getHelperSet()); | |
- } else { | |
- $this->helperSet = null; | |
- } | |
- } | |
- | |
- /** | |
- * Sets the helper set. | |
- * | |
- * @param HelperSet $helperSet A HelperSet instance | |
- */ | |
- public function setHelperSet(HelperSet $helperSet) | |
- { | |
- $this->helperSet = $helperSet; | |
- } | |
- | |
- /** | |
- * Gets the helper set. | |
- * | |
- * @return HelperSet A HelperSet instance | |
- */ | |
- public function getHelperSet() | |
- { | |
- return $this->helperSet; | |
- } | |
- | |
- /** | |
- * Gets the application instance for this command. | |
- * | |
- * @return Application An Application instance | |
- * | |
- * @api | |
- */ | |
- public function getApplication() | |
- { | |
- return $this->application; | |
- } | |
- | |
- /** | |
- * Checks whether the command is enabled or not in the current environment | |
- * | |
- * Override this to check for x or y and return false if the command can not | |
- * run properly under the current conditions. | |
- * | |
- * @return Boolean | |
- */ | |
- public function isEnabled() | |
- { | |
- return true; | |
- } | |
- | |
- /** | |
- * Configures the current command. | |
- */ | |
- protected function configure() | |
- { | |
- } | |
- | |
- /** | |
- * Executes the current command. | |
- * | |
- * This method is not abstract because you can use this class | |
- * as a concrete class. In this case, instead of defining the | |
- * execute() method, you set the code to execute by passing | |
- * a Closure to the setCode() method. | |
- * | |
- * @param InputInterface $input An InputInterface instance | |
- * @param OutputInterface $output An OutputInterface instance | |
- * | |
- * @return integer 0 if everything went fine, or an error code | |
- * | |
- * @throws \LogicException When this abstract method is not implemented | |
- * @see setCode() | |
- */ | |
- protected function execute(InputInterface $input, OutputInterface $output) | |
- { | |
- throw new \LogicException('You must override the execute() method in the concrete command class.'); | |
- } | |
- | |
- /** | |
- * Interacts with the user. | |
- * | |
- * @param InputInterface $input An InputInterface instance | |
- * @param OutputInterface $output An OutputInterface instance | |
- */ | |
- protected function interact(InputInterface $input, OutputInterface $output) | |
- { | |
- } | |
- | |
- /** | |
- * Initializes the command just after the input has been validated. | |
- * | |
- * This is mainly useful when a lot of commands extends one main command | |
- * where some things need to be initialized based on the input arguments and options. | |
- * | |
- * @param InputInterface $input An InputInterface instance | |
- * @param OutputInterface $output An OutputInterface instance | |
- */ | |
- protected function initialize(InputInterface $input, OutputInterface $output) | |
- { | |
- } | |
- | |
- /** | |
- * Runs the command. | |
- * | |
- * The code to execute is either defined directly with the | |
- * setCode() method or by overriding the execute() method | |
- * in a sub-class. | |
- * | |
- * @param InputInterface $input An InputInterface instance | |
- * @param OutputInterface $output An OutputInterface instance | |
- * | |
- * @see setCode() | |
- * @see execute() | |
- * | |
- * @api | |
- */ | |
- public function run(InputInterface $input, OutputInterface $output) | |
- { | |
- // force the creation of the synopsis before the merge with the app definition | |
- $this->getSynopsis(); | |
- | |
- // add the application arguments and options | |
- $this->mergeApplicationDefinition(); | |
- | |
- // bind the input against the command specific arguments/options | |
- try { | |
- $input->bind($this->definition); | |
- } catch (\Exception $e) { | |
- if (!$this->ignoreValidationErrors) { | |
- throw $e; | |
- } | |
- } | |
- | |
- $this->initialize($input, $output); | |
- | |
- if ($input->isInteractive()) { | |
- $this->interact($input, $output); | |
- } | |
- | |
- $input->validate(); | |
- | |
- if ($this->code) { | |
- return call_user_func($this->code, $input, $output); | |
- } | |
- | |
- return $this->execute($input, $output); | |
- } | |
- | |
- /** | |
- * Sets the code to execute when running this command. | |
- * | |
- * If this method is used, it overrides the code defined | |
- * in the execute() method. | |
- * | |
- * @param \Closure $code A \Closure | |
- * | |
- * @return Command The current instance | |
- * | |
- * @see execute() | |
- * | |
- * @api | |
- */ | |
- public function setCode(\Closure $code) | |
- { | |
- $this->code = $code; | |
- | |
- return $this; | |
- } | |
- | |
- /** | |
- * Merges the application definition with the command definition. | |
- */ | |
- private function mergeApplicationDefinition() | |
- { | |
- if (null === $this->application || true === $this->applicationDefinitionMerged) { | |
- return; | |
- } | |
- | |
- $currentArguments = $this->definition->getArguments(); | |
- $this->definition->setArguments($this->application->getDefinition()->getArguments()); | |
- $this->definition->addArguments($currentArguments); | |
- | |
- $this->definition->addOptions($this->application->getDefinition()->getOptions()); | |
- | |
- $this->applicationDefinitionMerged = true; | |
- } | |
- | |
- /** | |
- * Sets an array of argument and option instances. | |
- * | |
- * @param array|InputDefinition $definition An array of argument and option instances or a definition instance | |
- * | |
- * @return Command The current instance | |
- * | |
- * @api | |
- */ | |
- public function setDefinition($definition) | |
- { | |
- if ($definition instanceof InputDefinition) { | |
- $this->definition = $definition; | |
- } else { | |
- $this->definition->setDefinition($definition); | |
- } | |
- | |
- $this->applicationDefinitionMerged = false; | |
- | |
- return $this; | |
- } | |
- | |
- /** | |
- * Gets the InputDefinition attached to this Command. | |
- * | |
- * @return InputDefinition An InputDefinition instance | |
- * | |
- * @api | |
- */ | |
- public function getDefinition() | |
- { | |
- return $this->definition; | |
- } | |
- | |
- /** | |
- * Gets the InputDefinition to be used to create XML and Text representations of this Command. | |
- * | |
- * Can be overridden to provide the original command representation when it would otherwise | |
- * be changed by merging with the application InputDefinition. | |
- * | |
- * @return InputDefinition An InputDefinition instance | |
- */ | |
- protected function getNativeDefinition() | |
- { | |
- return $this->getDefinition(); | |
- } | |
- | |
- /** | |
- * Adds an argument. | |
- * | |
- * @param string $name The argument name | |
- * @param integer $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL | |
- * @param string $description A description text | |
- * @param mixed $default The default value (for InputArgument::OPTIONAL mode only) | |
- * | |
- * @return Command The current instance | |
- * | |
- * @api | |
- */ | |
- public function addArgument($name, $mode = null, $description = '', $default = null) | |
- { | |
- $this->definition->addArgument(new InputArgument($name, $mode, $description, $default)); | |
- | |
- return $this; | |
- } | |
- | |
- /** | |
- * Adds an option. | |
- * | |
- * @param string $name The option name | |
- * @param string $shortcut The shortcut (can be null) | |
- * @param integer $mode The option mode: One of the InputOption::VALUE_* constants | |
- * @param string $description A description text | |
- * @param mixed $default The default value (must be null for InputOption::VALUE_REQUIRED or InputOption::VALUE_NONE) | |
- * | |
- * @return Command The current instance | |
- * | |
- * @api | |
- */ | |
- public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null) | |
- { | |
- $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default)); | |
- | |
- return $this; | |
- } | |
- | |
- /** | |
- * Sets the name of the command. | |
- * | |
- * This method can set both the namespace and the name if | |
- * you separate them by a colon (:) | |
- * | |
- * $command->setName('foo:bar'); | |
- * | |
- * @param string $name The command name | |
- * | |
- * @return Command The current instance | |
- * | |
- * @throws \InvalidArgumentException When command name given is empty | |
- * | |
- * @api | |
- */ | |
- public function setName($name) | |
- { | |
- $this->validateName($name); | |
- | |
- $this->name = $name; | |
- | |
- return $this; | |
- } | |
- | |
- /** | |
- * Returns the command name. | |
- * | |
- * @return string The command name | |
- * | |
- * @api | |
- */ | |
- public function getName() | |
- { | |
- return $this->name; | |
- } | |
- | |
- /** | |
- * Sets the description for the command. | |
- * | |
- * @param string $description The description for the command | |
- * | |
- * @return Command The current instance | |
- * | |
- * @api | |
- */ | |
- public function setDescription($description) | |
- { | |
- $this->description = $description; | |
- | |
- return $this; | |
- } | |
- | |
- /** | |
- * Returns the description for the command. | |
- * | |
- * @return string The description for the command | |
- * | |
- * @api | |
- */ | |
- public function getDescription() | |
- { | |
- return $this->description; | |
- } | |
- | |
- /** | |
- * Sets the help for the command. | |
- * | |
- * @param string $help The help for the command | |
- * | |
- * @return Command The current instance | |
- * | |
- * @api | |
- */ | |
- public function setHelp($help) | |
- { | |
- $this->help = $help; | |
- | |
- return $this; | |
- } | |
- | |
- /** | |
- * Returns the help for the command. | |
- * | |
- * @return string The help for the command | |
- * | |
- * @api | |
- */ | |
- public function getHelp() | |
- { | |
- return $this->help; | |
- } | |
- | |
- /** | |
- * Returns the processed help for the command replacing the %command.name% and | |
- * %command.full_name% patterns with the real values dynamically. | |
- * | |
- * @return string The processed help for the command | |
- */ | |
- public function getProcessedHelp() | |
- { | |
- $name = $this->name; | |
- | |
- $placeholders = array( | |
- '%command.name%', | |
- '%command.full_name%' | |
- ); | |
- $replacements = array( | |
- $name, | |
- $_SERVER['PHP_SELF'].' '.$name | |
- ); | |
- | |
- return str_replace($placeholders, $replacements, $this->getHelp()); | |
- } | |
- | |
- /** | |
- * Sets the aliases for the command. | |
- * | |
- * @param array $aliases An array of aliases for the command | |
- * | |
- * @return Command The current instance | |
- * | |
- * @api | |
- */ | |
- public function setAliases($aliases) | |
- { | |
- foreach ($aliases as $alias) { | |
- $this->validateName($alias); | |
- } | |
- | |
- $this->aliases = $aliases; | |
- | |
- return $this; | |
- } | |
- | |
- /** | |
- * Returns the aliases for the command. | |
- * | |
- * @return array An array of aliases for the command | |
- * | |
- * @api | |
- */ | |
- public function getAliases() | |
- { | |
- return $this->aliases; | |
- } | |
- | |
- /** | |
- * Returns the synopsis for the command. | |
- * | |
- * @return string The synopsis | |
- */ | |
- public function getSynopsis() | |
- { | |
- if (null === $this->synopsis) { | |
- $this->synopsis = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis())); | |
- } | |
- | |
- return $this->synopsis; | |
- } | |
- | |
- /** | |
- * Gets a helper instance by name. | |
- * | |
- * @param string $name The helper name | |
- * | |
- * @return mixed The helper value | |
- * | |
- * @throws \InvalidArgumentException if the helper is not defined | |
- * | |
- * @api | |
- */ | |
- public function getHelper($name) | |
- { | |
- return $this->helperSet->get($name); | |
- } | |
- | |
- /** | |
- * Returns a text representation of the command. | |
- * | |
- * @return string A string representing the command | |
- */ | |
- public function asText() | |
- { | |
- $messages = array( | |
- '<comment>Usage:</comment>', | |
- ' '.$this->getSynopsis(), | |
- '', | |
- ); | |
- | |
- if ($this->getAliases()) { | |
- $messages[] = '<comment>Aliases:</comment> <info>'.implode(', ', $this->getAliases()).'</info>'; | |
- } | |
- | |
- $messages[] = $this->getNativeDefinition()->asText(); | |
- | |
- if ($help = $this->getProcessedHelp()) { | |
- $messages[] = '<comment>Help:</comment>'; | |
- $messages[] = ' '.str_replace("\n", "\n ", $help)."\n"; | |
- } | |
- | |
- return implode("\n", $messages); | |
- } | |
- | |
- /** | |
- * Returns an XML representation of the command. | |
- * | |
- * @param Boolean $asDom Whether to return a DOM or an XML string | |
- * | |
- * @return string|DOMDocument An XML string representing the command | |
- */ | |
- public function asXml($asDom = false) | |
- { | |
- $dom = new \DOMDocument('1.0', 'UTF-8'); | |
- $dom->formatOutput = true; | |
- $dom->appendChild($commandXML = $dom->createElement('command')); | |
- $commandXML->setAttribute('id', $this->name); | |
- $commandXML->setAttribute('name', $this->name); | |
- | |
- $commandXML->appendChild($usageXML = $dom->createElement('usage')); | |
- $usageXML->appendChild($dom->createTextNode(sprintf($this->getSynopsis(), ''))); | |
- | |
- $commandXML->appendChild($descriptionXML = $dom->createElement('description')); | |
- $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $this->getDescription()))); | |
- | |
- $commandXML->appendChild($helpXML = $dom->createElement('help')); | |
- $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $this->getProcessedHelp()))); | |
- | |
- $commandXML->appendChild($aliasesXML = $dom->createElement('aliases')); | |
- foreach ($this->getAliases() as $alias) { | |
- $aliasesXML->appendChild($aliasXML = $dom->createElement('alias')); | |
- $aliasXML->appendChild($dom->createTextNode($alias)); | |
- } | |
- | |
- $definition = $this->getNativeDefinition()->asXml(true); | |
- $commandXML->appendChild($dom->importNode($definition->getElementsByTagName('arguments')->item(0), true)); | |
- $commandXML->appendChild($dom->importNode($definition->getElementsByTagName('options')->item(0), true)); | |
- | |
- return $asDom ? $dom : $dom->saveXml(); | |
- } | |
- | |
- private function validateName($name) | |
- { | |
- if (!preg_match('/^[^\:]+(\:[^\:]+)*$/', $name)) { | |
- throw new \InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name)); | |
- } | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Command/HelpCommand.php b/vendor/Symfony/Component/Console/Command/HelpCommand.php | |
deleted file mode 100755 | |
index 93c8104..0000000 | |
--- a/vendor/Symfony/Component/Console/Command/HelpCommand.php | |
+++ /dev/null | |
@@ -1,84 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Command; | |
- | |
-use Symfony\Component\Console\Input\InputArgument; | |
-use Symfony\Component\Console\Input\InputOption; | |
-use Symfony\Component\Console\Input\InputInterface; | |
-use Symfony\Component\Console\Output\OutputInterface; | |
-use Symfony\Component\Console\Output\Output; | |
-use Symfony\Component\Console\Command\Command; | |
- | |
-/** | |
- * HelpCommand displays the help for a given command. | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- */ | |
-class HelpCommand extends Command | |
-{ | |
- private $command; | |
- | |
- /** | |
- * {@inheritdoc} | |
- */ | |
- protected function configure() | |
- { | |
- $this->ignoreValidationErrors(); | |
- | |
- $this | |
- ->setName('help') | |
- ->setDefinition(array( | |
- new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'), | |
- new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'), | |
- )) | |
- ->setDescription('Displays help for a command') | |
- ->setHelp(<<<EOF | |
-The <info>%command.name%</info> command displays help for a given command: | |
- | |
- <info>php %command.full_name% list</info> | |
- | |
-You can also output the help as XML by using the <comment>--xml</comment> option: | |
- | |
- <info>php %command.full_name% --xml list</info> | |
-EOF | |
- ) | |
- ; | |
- } | |
- | |
- /** | |
- * Sets the command | |
- * | |
- * @param Command $command The command to set | |
- */ | |
- public function setCommand(Command $command) | |
- { | |
- $this->command = $command; | |
- } | |
- | |
- /** | |
- * {@inheritdoc} | |
- */ | |
- protected function execute(InputInterface $input, OutputInterface $output) | |
- { | |
- if (null === $this->command) { | |
- $this->command = $this->getApplication()->get($input->getArgument('command_name')); | |
- } | |
- | |
- if ($input->getOption('xml')) { | |
- $output->writeln($this->command->asXml(), OutputInterface::OUTPUT_RAW); | |
- } else { | |
- $output->writeln($this->command->asText()); | |
- } | |
- | |
- $this->command = null; | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Command/ListCommand.php b/vendor/Symfony/Component/Console/Command/ListCommand.php | |
deleted file mode 100755 | |
index 032de16..0000000 | |
--- a/vendor/Symfony/Component/Console/Command/ListCommand.php | |
+++ /dev/null | |
@@ -1,87 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Command; | |
- | |
-use Symfony\Component\Console\Input\InputArgument; | |
-use Symfony\Component\Console\Input\InputOption; | |
-use Symfony\Component\Console\Input\InputInterface; | |
-use Symfony\Component\Console\Output\OutputInterface; | |
-use Symfony\Component\Console\Output\Output; | |
-use Symfony\Component\Console\Command\Command; | |
-use Symfony\Component\Console\Input\InputDefinition; | |
- | |
-/** | |
- * ListCommand displays the list of all available commands for the application. | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- */ | |
-class ListCommand extends Command | |
-{ | |
- /** | |
- * {@inheritdoc} | |
- */ | |
- protected function configure() | |
- { | |
- $this | |
- ->setName('list') | |
- ->setDefinition($this->createDefinition()) | |
- ->setDescription('Lists commands') | |
- ->setHelp(<<<EOF | |
-The <info>%command.name%</info> command lists all commands: | |
- | |
- <info>php %command.full_name%</info> | |
- | |
-You can also display the commands for a specific namespace: | |
- | |
- <info>php %command.full_name% test</info> | |
- | |
-You can also output the information as XML by using the <comment>--xml</comment> option: | |
- | |
- <info>php %command.full_name% --xml</info> | |
- | |
-It's also possible to get raw list of commands (useful for embedding command runner): | |
- | |
- <info>php %command.full_name% --raw</info> | |
-EOF | |
- ) | |
- ; | |
- } | |
- | |
- /** | |
- * {@inheritdoc} | |
- */ | |
- protected function getNativeDefinition() | |
- { | |
- return $this->createDefinition(); | |
- } | |
- | |
- /** | |
- * {@inheritdoc} | |
- */ | |
- protected function execute(InputInterface $input, OutputInterface $output) | |
- { | |
- if ($input->getOption('xml')) { | |
- $output->writeln($this->getApplication()->asXml($input->getArgument('namespace')), OutputInterface::OUTPUT_RAW); | |
- } else { | |
- $output->writeln($this->getApplication()->asText($input->getArgument('namespace'), $input->getOption('raw'))); | |
- } | |
- } | |
- | |
- private function createDefinition() | |
- { | |
- return new InputDefinition(array( | |
- new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'), | |
- new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'), | |
- new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'), | |
- )); | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Formatter/OutputFormatter.php b/vendor/Symfony/Component/Console/Formatter/OutputFormatter.php | |
deleted file mode 100755 | |
index 8d60c74..0000000 | |
--- a/vendor/Symfony/Component/Console/Formatter/OutputFormatter.php | |
+++ /dev/null | |
@@ -1,192 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Formatter; | |
- | |
-/** | |
- * Formatter class for console output. | |
- * | |
- * @author Konstantin Kudryashov <[email protected]> | |
- * | |
- * @api | |
- */ | |
-class OutputFormatter implements OutputFormatterInterface | |
-{ | |
- /** | |
- * The pattern to phrase the format. | |
- */ | |
- const FORMAT_PATTERN = '#<([a-z][a-z0-9_=;-]+)>(.*?)</\\1?>#is'; | |
- | |
- private $decorated; | |
- private $styles = array(); | |
- | |
- /** | |
- * Initializes console output formatter. | |
- * | |
- * @param Boolean $decorated Whether this formatter should actually decorate strings | |
- * @param array $styles Array of "name => FormatterStyle" instances | |
- * | |
- * @api | |
- */ | |
- public function __construct($decorated = null, array $styles = array()) | |
- { | |
- $this->decorated = (Boolean) $decorated; | |
- | |
- $this->setStyle('error', new OutputFormatterStyle('white', 'red')); | |
- $this->setStyle('info', new OutputFormatterStyle('green')); | |
- $this->setStyle('comment', new OutputFormatterStyle('yellow')); | |
- $this->setStyle('question', new OutputFormatterStyle('black', 'cyan')); | |
- | |
- foreach ($styles as $name => $style) { | |
- $this->setStyle($name, $style); | |
- } | |
- } | |
- | |
- /** | |
- * Sets the decorated flag. | |
- * | |
- * @param Boolean $decorated Whether to decorate the messages or not | |
- * | |
- * @api | |
- */ | |
- public function setDecorated($decorated) | |
- { | |
- $this->decorated = (Boolean) $decorated; | |
- } | |
- | |
- /** | |
- * Gets the decorated flag. | |
- * | |
- * @return Boolean true if the output will decorate messages, false otherwise | |
- * | |
- * @api | |
- */ | |
- public function isDecorated() | |
- { | |
- return $this->decorated; | |
- } | |
- | |
- /** | |
- * Sets a new style. | |
- * | |
- * @param string $name The style name | |
- * @param OutputFormatterStyleInterface $style The style instance | |
- * | |
- * @api | |
- */ | |
- public function setStyle($name, OutputFormatterStyleInterface $style) | |
- { | |
- $this->styles[strtolower($name)] = $style; | |
- } | |
- | |
- /** | |
- * Checks if output formatter has style with specified name. | |
- * | |
- * @param string $name | |
- * | |
- * @return Boolean | |
- * | |
- * @api | |
- */ | |
- public function hasStyle($name) | |
- { | |
- return isset($this->styles[strtolower($name)]); | |
- } | |
- | |
- /** | |
- * Gets style options from style with specified name. | |
- * | |
- * @param string $name | |
- * | |
- * @return OutputFormatterStyleInterface | |
- * | |
- * @throws \InvalidArgumentException When style isn't defined | |
- * | |
- * @api | |
- */ | |
- public function getStyle($name) | |
- { | |
- if (!$this->hasStyle($name)) { | |
- throw new \InvalidArgumentException('Undefined style: '.$name); | |
- } | |
- | |
- return $this->styles[strtolower($name)]; | |
- } | |
- | |
- /** | |
- * Formats a message according to the given styles. | |
- * | |
- * @param string $message The message to style | |
- * | |
- * @return string The styled message | |
- * | |
- * @api | |
- */ | |
- public function format($message) | |
- { | |
- return preg_replace_callback(self::FORMAT_PATTERN, array($this, 'replaceStyle'), $message); | |
- } | |
- | |
- /** | |
- * Replaces style of the output. | |
- * | |
- * @param array $match | |
- * | |
- * @return string The replaced style | |
- */ | |
- private function replaceStyle($match) | |
- { | |
- if (!$this->isDecorated()) { | |
- return $match[2]; | |
- } | |
- | |
- if (isset($this->styles[strtolower($match[1])])) { | |
- $style = $this->styles[strtolower($match[1])]; | |
- } else { | |
- $style = $this->createStyleFromString($match[1]); | |
- | |
- if (false === $style) { | |
- return $match[0]; | |
- } | |
- } | |
- | |
- return $style->apply($this->format($match[2])); | |
- } | |
- | |
- /** | |
- * Tries to create new style instance from string. | |
- * | |
- * @param string $string | |
- * | |
- * @return Symfony\Component\Console\Format\FormatterStyle|Boolean false if string is not format string | |
- */ | |
- private function createStyleFromString($string) | |
- { | |
- if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) { | |
- return false; | |
- } | |
- | |
- $style = new OutputFormatterStyle(); | |
- foreach ($matches as $match) { | |
- array_shift($match); | |
- | |
- if ('fg' == $match[0]) { | |
- $style->setForeground($match[1]); | |
- } elseif ('bg' == $match[0]) { | |
- $style->setBackground($match[1]); | |
- } else { | |
- $style->setOption($match[1]); | |
- } | |
- } | |
- | |
- return $style; | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Formatter/OutputFormatterInterface.php b/vendor/Symfony/Component/Console/Formatter/OutputFormatterInterface.php | |
deleted file mode 100755 | |
index f14657c..0000000 | |
--- a/vendor/Symfony/Component/Console/Formatter/OutputFormatterInterface.php | |
+++ /dev/null | |
@@ -1,83 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Formatter; | |
- | |
-/** | |
- * Formatter interface for console output. | |
- * | |
- * @author Konstantin Kudryashov <[email protected]> | |
- * | |
- * @api | |
- */ | |
-interface OutputFormatterInterface | |
-{ | |
- /** | |
- * Sets the decorated flag. | |
- * | |
- * @param Boolean $decorated Whether to decorate the messages or not | |
- * | |
- * @api | |
- */ | |
- function setDecorated($decorated); | |
- | |
- /** | |
- * Gets the decorated flag. | |
- * | |
- * @return Boolean true if the output will decorate messages, false otherwise | |
- * | |
- * @api | |
- */ | |
- function isDecorated(); | |
- | |
- /** | |
- * Sets a new style. | |
- * | |
- * @param string $name The style name | |
- * @param OutputFormatterStyleInterface $style The style instance | |
- * | |
- * @api | |
- */ | |
- function setStyle($name, OutputFormatterStyleInterface $style); | |
- | |
- /** | |
- * Checks if output formatter has style with specified name. | |
- * | |
- * @param string $name | |
- * | |
- * @return Boolean | |
- * | |
- * @api | |
- */ | |
- function hasStyle($name); | |
- | |
- /** | |
- * Gets style options from style with specified name. | |
- * | |
- * @param string $name | |
- * | |
- * @return OutputFormatterStyleInterface | |
- * | |
- * @api | |
- */ | |
- function getStyle($name); | |
- | |
- /** | |
- * Formats a message according to the given styles. | |
- * | |
- * @param string $message The message to style | |
- * | |
- * @return string The styled message | |
- * | |
- * @api | |
- */ | |
- function format($message); | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyle.php b/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyle.php | |
deleted file mode 100755 | |
index dc88f2a..0000000 | |
--- a/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyle.php | |
+++ /dev/null | |
@@ -1,218 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Formatter; | |
- | |
-/** | |
- * Formatter style class for defining styles. | |
- * | |
- * @author Konstantin Kudryashov <[email protected]> | |
- * | |
- * @api | |
- */ | |
-class OutputFormatterStyle implements OutputFormatterStyleInterface | |
-{ | |
- static private $availableForegroundColors = array( | |
- 'black' => 30, | |
- 'red' => 31, | |
- 'green' => 32, | |
- 'yellow' => 33, | |
- 'blue' => 34, | |
- 'magenta' => 35, | |
- 'cyan' => 36, | |
- 'white' => 37 | |
- ); | |
- static private $availableBackgroundColors = array( | |
- 'black' => 40, | |
- 'red' => 41, | |
- 'green' => 42, | |
- 'yellow' => 43, | |
- 'blue' => 44, | |
- 'magenta' => 45, | |
- 'cyan' => 46, | |
- 'white' => 47 | |
- ); | |
- static private $availableOptions = array( | |
- 'bold' => 1, | |
- 'underscore' => 4, | |
- 'blink' => 5, | |
- 'reverse' => 7, | |
- 'conceal' => 8 | |
- ); | |
- | |
- private $foreground; | |
- private $background; | |
- private $options = array(); | |
- | |
- /** | |
- * Initializes output formatter style. | |
- * | |
- * @param string $foreground style foreground color name | |
- * @param string $background style background color name | |
- * @param array $options style options | |
- * | |
- * @api | |
- */ | |
- public function __construct($foreground = null, $background = null, array $options = array()) | |
- { | |
- if (null !== $foreground) { | |
- $this->setForeground($foreground); | |
- } | |
- if (null !== $background) { | |
- $this->setBackground($background); | |
- } | |
- if (count($options)) { | |
- $this->setOptions($options); | |
- } | |
- } | |
- | |
- /** | |
- * Sets style foreground color. | |
- * | |
- * @param string $color color name | |
- * | |
- * @throws \InvalidArgumentException When the color name isn't defined | |
- * | |
- * @api | |
- */ | |
- public function setForeground($color = null) | |
- { | |
- if (null === $color) { | |
- $this->foreground = null; | |
- | |
- return; | |
- } | |
- | |
- if (!isset(static::$availableForegroundColors[$color])) { | |
- throw new \InvalidArgumentException(sprintf( | |
- 'Invalid foreground color specified: "%s". Expected one of (%s)', | |
- $color, | |
- implode(', ', array_keys(static::$availableForegroundColors)) | |
- )); | |
- } | |
- | |
- $this->foreground = static::$availableForegroundColors[$color]; | |
- } | |
- | |
- /** | |
- * Sets style background color. | |
- * | |
- * @param string $color color name | |
- * | |
- * @throws \InvalidArgumentException When the color name isn't defined | |
- * | |
- * @api | |
- */ | |
- public function setBackground($color = null) | |
- { | |
- if (null === $color) { | |
- $this->background = null; | |
- | |
- return; | |
- } | |
- | |
- if (!isset(static::$availableBackgroundColors[$color])) { | |
- throw new \InvalidArgumentException(sprintf( | |
- 'Invalid background color specified: "%s". Expected one of (%s)', | |
- $color, | |
- implode(', ', array_keys(static::$availableBackgroundColors)) | |
- )); | |
- } | |
- | |
- $this->background = static::$availableBackgroundColors[$color]; | |
- } | |
- | |
- /** | |
- * Sets some specific style option. | |
- * | |
- * @param string $option option name | |
- * | |
- * @throws \InvalidArgumentException When the option name isn't defined | |
- * | |
- * @api | |
- */ | |
- public function setOption($option) | |
- { | |
- if (!isset(static::$availableOptions[$option])) { | |
- throw new \InvalidArgumentException(sprintf( | |
- 'Invalid option specified: "%s". Expected one of (%s)', | |
- $option, | |
- implode(', ', array_keys(static::$availableOptions)) | |
- )); | |
- } | |
- | |
- if (false === array_search(static::$availableOptions[$option], $this->options)) { | |
- $this->options[] = static::$availableOptions[$option]; | |
- } | |
- } | |
- | |
- /** | |
- * Unsets some specific style option. | |
- * | |
- * @param string $option option name | |
- * | |
- * @throws \InvalidArgumentException When the option name isn't defined | |
- * | |
- */ | |
- public function unsetOption($option) | |
- { | |
- if (!isset(static::$availableOptions[$option])) { | |
- throw new \InvalidArgumentException(sprintf( | |
- 'Invalid option specified: "%s". Expected one of (%s)', | |
- $option, | |
- implode(', ', array_keys(static::$availableOptions)) | |
- )); | |
- } | |
- | |
- $pos = array_search(static::$availableOptions[$option], $this->options); | |
- if (false !== $pos) { | |
- unset($this->options[$pos]); | |
- } | |
- } | |
- | |
- /** | |
- * Sets multiple style options at once. | |
- * | |
- * @param array $options | |
- */ | |
- public function setOptions(array $options) | |
- { | |
- $this->options = array(); | |
- | |
- foreach ($options as $option) { | |
- $this->setOption($option); | |
- } | |
- } | |
- | |
- /** | |
- * Applies the style to a given text. | |
- * | |
- * @param string $text The text to style | |
- * | |
- * @return string | |
- */ | |
- public function apply($text) | |
- { | |
- $codes = array(); | |
- | |
- if (null !== $this->foreground) { | |
- $codes[] = $this->foreground; | |
- } | |
- if (null !== $this->background) { | |
- $codes[] = $this->background; | |
- } | |
- if (count($this->options)) { | |
- $codes = array_merge($codes, $this->options); | |
- } | |
- | |
- return sprintf("\033[%sm%s\033[0m", implode(';', $codes), $text); | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php b/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php | |
deleted file mode 100755 | |
index 212cb86..0000000 | |
--- a/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php | |
+++ /dev/null | |
@@ -1,72 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Formatter; | |
- | |
-/** | |
- * Formatter style interface for defining styles. | |
- * | |
- * @author Konstantin Kudryashov <[email protected]> | |
- * | |
- * @api | |
- */ | |
-interface OutputFormatterStyleInterface | |
-{ | |
- /** | |
- * Sets style foreground color. | |
- * | |
- * @param string $color color name | |
- * | |
- * @api | |
- */ | |
- function setForeground($color = null); | |
- | |
- /** | |
- * Sets style background color. | |
- * | |
- * @param string $color color name | |
- * | |
- * @api | |
- */ | |
- function setBackground($color = null); | |
- | |
- /** | |
- * Sets some specific style option. | |
- * | |
- * @param string $option option name | |
- * | |
- * @api | |
- */ | |
- function setOption($option); | |
- | |
- /** | |
- * Unsets some specific style option. | |
- * | |
- * @param string $option option name | |
- */ | |
- function unsetOption($option); | |
- | |
- /** | |
- * Sets multiple style options at once. | |
- * | |
- * @param array $options | |
- */ | |
- function setOptions(array $options); | |
- | |
- /** | |
- * Applies the style to a given text. | |
- * | |
- * @param string $text The text to style | |
- * | |
- * @return string | |
- */ | |
- function apply($text); | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Helper/DialogHelper.php b/vendor/Symfony/Component/Console/Helper/DialogHelper.php | |
deleted file mode 100755 | |
index e15fdd1..0000000 | |
--- a/vendor/Symfony/Component/Console/Helper/DialogHelper.php | |
+++ /dev/null | |
@@ -1,139 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Helper; | |
- | |
-use Symfony\Component\Console\Output\OutputInterface; | |
- | |
-/** | |
- * The Dialog class provides helpers to interact with the user. | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- */ | |
-class DialogHelper extends Helper | |
-{ | |
- private $inputStream; | |
- | |
- /** | |
- * Asks a question to the user. | |
- * | |
- * @param OutputInterface $output An Output instance | |
- * @param string|array $question The question to ask | |
- * @param string $default The default answer if none is given by the user | |
- * | |
- * @return string The user answer | |
- * | |
- * @throws \RuntimeException If there is no data to read in the input stream | |
- */ | |
- public function ask(OutputInterface $output, $question, $default = null) | |
- { | |
- $output->write($question); | |
- | |
- $ret = fgets($this->inputStream ?: STDIN, 4096); | |
- if (false === $ret) { | |
- throw new \RuntimeException('Aborted'); | |
- } | |
- $ret = trim($ret); | |
- | |
- return strlen($ret) > 0 ? $ret : $default; | |
- } | |
- | |
- /** | |
- * Asks a confirmation to the user. | |
- * | |
- * The question will be asked until the user answers by nothing, yes, or no. | |
- * | |
- * @param OutputInterface $output An Output instance | |
- * @param string|array $question The question to ask | |
- * @param Boolean $default The default answer if the user enters nothing | |
- * | |
- * @return Boolean true if the user has confirmed, false otherwise | |
- */ | |
- public function askConfirmation(OutputInterface $output, $question, $default = true) | |
- { | |
- $answer = 'z'; | |
- while ($answer && !in_array(strtolower($answer[0]), array('y', 'n'))) { | |
- $answer = $this->ask($output, $question); | |
- } | |
- | |
- if (false === $default) { | |
- return $answer && 'y' == strtolower($answer[0]); | |
- } | |
- | |
- return !$answer || 'y' == strtolower($answer[0]); | |
- } | |
- | |
- /** | |
- * Asks for a value and validates the response. | |
- * | |
- * The validator receives the data to validate. It must return the | |
- * validated data when the data is valid and throw an exception | |
- * otherwise. | |
- * | |
- * @param OutputInterface $output An Output instance | |
- * @param string|array $question The question to ask | |
- * @param callback $validator A PHP callback | |
- * @param integer $attempts Max number of times to ask before giving up (false by default, which means infinite) | |
- * @param string $default The default answer if none is given by the user | |
- * | |
- * @return mixed | |
- * | |
- * @throws \Exception When any of the validators return an error | |
- */ | |
- public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null) | |
- { | |
- $error = null; | |
- while (false === $attempts || $attempts--) { | |
- if (null !== $error) { | |
- $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error')); | |
- } | |
- | |
- $value = $this->ask($output, $question, $default); | |
- | |
- try { | |
- return call_user_func($validator, $value); | |
- } catch (\Exception $error) { | |
- } | |
- } | |
- | |
- throw $error; | |
- } | |
- | |
- /** | |
- * Sets the input stream to read from when interacting with the user. | |
- * | |
- * This is mainly useful for testing purpose. | |
- * | |
- * @param resource $stream The input stream | |
- */ | |
- public function setInputStream($stream) | |
- { | |
- $this->inputStream = $stream; | |
- } | |
- | |
- /** | |
- * Returns the helper's input stream | |
- * | |
- * @return string | |
- */ | |
- public function getInputStream() | |
- { | |
- return $this->inputStream; | |
- } | |
- | |
- /** | |
- * Returns the helper's canonical name. | |
- */ | |
- public function getName() | |
- { | |
- return 'dialog'; | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Helper/FormatterHelper.php b/vendor/Symfony/Component/Console/Helper/FormatterHelper.php | |
deleted file mode 100755 | |
index d3f613b..0000000 | |
--- a/vendor/Symfony/Component/Console/Helper/FormatterHelper.php | |
+++ /dev/null | |
@@ -1,97 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Helper; | |
- | |
-/** | |
- * The Formatter class provides helpers to format messages. | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- */ | |
-class FormatterHelper extends Helper | |
-{ | |
- /** | |
- * Formats a message within a section. | |
- * | |
- * @param string $section The section name | |
- * @param string $message The message | |
- * @param string $style The style to apply to the section | |
- */ | |
- public function formatSection($section, $message, $style = 'info') | |
- { | |
- return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message); | |
- } | |
- | |
- /** | |
- * Formats a message as a block of text. | |
- * | |
- * @param string|array $messages The message to write in the block | |
- * @param string $style The style to apply to the whole block | |
- * @param Boolean $large Whether to return a large block | |
- * | |
- * @return string The formatter message | |
- */ | |
- public function formatBlock($messages, $style, $large = false) | |
- { | |
- $messages = (array) $messages; | |
- | |
- $len = 0; | |
- $lines = array(); | |
- foreach ($messages as $message) { | |
- $lines[] = sprintf($large ? ' %s ' : ' %s ', $message); | |
- $len = max($this->strlen($message) + ($large ? 4 : 2), $len); | |
- } | |
- | |
- $messages = $large ? array(str_repeat(' ', $len)) : array(); | |
- foreach ($lines as $line) { | |
- $messages[] = $line.str_repeat(' ', $len - $this->strlen($line)); | |
- } | |
- if ($large) { | |
- $messages[] = str_repeat(' ', $len); | |
- } | |
- | |
- foreach ($messages as &$message) { | |
- $message = sprintf('<%s>%s</%s>', $style, $message, $style); | |
- } | |
- | |
- return implode("\n", $messages); | |
- } | |
- | |
- /** | |
- * Returns the length of a string, using mb_strlen if it is available. | |
- * | |
- * @param string $string The string to check its length | |
- * | |
- * @return integer The length of the string | |
- */ | |
- private function strlen($string) | |
- { | |
- if (!function_exists('mb_strlen')) { | |
- return strlen($string); | |
- } | |
- | |
- if (false === $encoding = mb_detect_encoding($string)) { | |
- return strlen($string); | |
- } | |
- | |
- return mb_strlen($string, $encoding); | |
- } | |
- | |
- /** | |
- * Returns the helper's canonical name. | |
- * | |
- * @return string The canonical name of the helper | |
- */ | |
- public function getName() | |
- { | |
- return 'formatter'; | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Helper/Helper.php b/vendor/Symfony/Component/Console/Helper/Helper.php | |
deleted file mode 100755 | |
index 28488ca..0000000 | |
--- a/vendor/Symfony/Component/Console/Helper/Helper.php | |
+++ /dev/null | |
@@ -1,42 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Helper; | |
- | |
-/** | |
- * Helper is the base class for all helper classes. | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- */ | |
-abstract class Helper implements HelperInterface | |
-{ | |
- protected $helperSet = null; | |
- | |
- /** | |
- * Sets the helper set associated with this helper. | |
- * | |
- * @param HelperSet $helperSet A HelperSet instance | |
- */ | |
- public function setHelperSet(HelperSet $helperSet = null) | |
- { | |
- $this->helperSet = $helperSet; | |
- } | |
- | |
- /** | |
- * Gets the helper set associated with this helper. | |
- * | |
- * @return HelperSet A HelperSet instance | |
- */ | |
- public function getHelperSet() | |
- { | |
- return $this->helperSet; | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Helper/HelperInterface.php b/vendor/Symfony/Component/Console/Helper/HelperInterface.php | |
deleted file mode 100755 | |
index 25ee513..0000000 | |
--- a/vendor/Symfony/Component/Console/Helper/HelperInterface.php | |
+++ /dev/null | |
@@ -1,49 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Helper; | |
- | |
-/** | |
- * HelperInterface is the interface all helpers must implement. | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- * | |
- * @api | |
- */ | |
-interface HelperInterface | |
-{ | |
- /** | |
- * Sets the helper set associated with this helper. | |
- * | |
- * @param HelperSet $helperSet A HelperSet instance | |
- * | |
- * @api | |
- */ | |
- function setHelperSet(HelperSet $helperSet = null); | |
- | |
- /** | |
- * Gets the helper set associated with this helper. | |
- * | |
- * @return HelperSet A HelperSet instance | |
- * | |
- * @api | |
- */ | |
- function getHelperSet(); | |
- | |
- /** | |
- * Returns the canonical name of this helper. | |
- * | |
- * @return string The canonical name | |
- * | |
- * @api | |
- */ | |
- function getName(); | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Helper/HelperSet.php b/vendor/Symfony/Component/Console/Helper/HelperSet.php | |
deleted file mode 100755 | |
index 0092c4c..0000000 | |
--- a/vendor/Symfony/Component/Console/Helper/HelperSet.php | |
+++ /dev/null | |
@@ -1,104 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Helper; | |
- | |
-use Symfony\Component\Console\Command\Command; | |
- | |
-/** | |
- * HelperSet represents a set of helpers to be used with a command. | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- */ | |
-class HelperSet | |
-{ | |
- private $helpers; | |
- private $command; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * @param Helper[] $helpers An array of helper. | |
- */ | |
- public function __construct(array $helpers = array()) | |
- { | |
- $this->helpers = array(); | |
- foreach ($helpers as $alias => $helper) { | |
- $this->set($helper, is_int($alias) ? null : $alias); | |
- } | |
- } | |
- | |
- /** | |
- * Sets a helper. | |
- * | |
- * @param HelperInterface $helper The helper instance | |
- * @param string $alias An alias | |
- */ | |
- public function set(HelperInterface $helper, $alias = null) | |
- { | |
- $this->helpers[$helper->getName()] = $helper; | |
- if (null !== $alias) { | |
- $this->helpers[$alias] = $helper; | |
- } | |
- | |
- $helper->setHelperSet($this); | |
- } | |
- | |
- /** | |
- * Returns true if the helper if defined. | |
- * | |
- * @param string $name The helper name | |
- * | |
- * @return Boolean true if the helper is defined, false otherwise | |
- */ | |
- public function has($name) | |
- { | |
- return isset($this->helpers[$name]); | |
- } | |
- | |
- /** | |
- * Gets a helper value. | |
- * | |
- * @param string $name The helper name | |
- * | |
- * @return HelperInterface The helper instance | |
- * | |
- * @throws \InvalidArgumentException if the helper is not defined | |
- */ | |
- public function get($name) | |
- { | |
- if (!$this->has($name)) { | |
- throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name)); | |
- } | |
- | |
- return $this->helpers[$name]; | |
- } | |
- | |
- /** | |
- * Sets the command associated with this helper set. | |
- * | |
- * @param Command $command A Command instance | |
- */ | |
- public function setCommand(Command $command = null) | |
- { | |
- $this->command = $command; | |
- } | |
- | |
- /** | |
- * Gets the command associated with this helper set. | |
- * | |
- * @return Command A Command instance | |
- */ | |
- public function getCommand() | |
- { | |
- return $this->command; | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Input/ArgvInput.php b/vendor/Symfony/Component/Console/Input/ArgvInput.php | |
deleted file mode 100755 | |
index f0cfb14..0000000 | |
--- a/vendor/Symfony/Component/Console/Input/ArgvInput.php | |
+++ /dev/null | |
@@ -1,311 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Input; | |
- | |
-/** | |
- * ArgvInput represents an input coming from the CLI arguments. | |
- * | |
- * Usage: | |
- * | |
- * $input = new ArgvInput(); | |
- * | |
- * By default, the `$_SERVER['argv']` array is used for the input values. | |
- * | |
- * This can be overridden by explicitly passing the input values in the constructor: | |
- * | |
- * $input = new ArgvInput($_SERVER['argv']); | |
- * | |
- * If you pass it yourself, don't forget that the first element of the array | |
- * is the name of the running application. | |
- * | |
- * When passing an argument to the constructor, be sure that it respects | |
- * the same rules as the argv one. It's almost always better to use the | |
- * `StringInput` when you want to provide your own input. | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- * | |
- * @see http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html | |
- * @see http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html#tag_12_02 | |
- * | |
- * @api | |
- */ | |
-class ArgvInput extends Input | |
-{ | |
- private $tokens; | |
- private $parsed; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * @param array $argv An array of parameters from the CLI (in the argv format) | |
- * @param InputDefinition $definition A InputDefinition instance | |
- * | |
- * @api | |
- */ | |
- public function __construct(array $argv = null, InputDefinition $definition = null) | |
- { | |
- if (null === $argv) { | |
- $argv = $_SERVER['argv']; | |
- } | |
- | |
- // strip the application name | |
- array_shift($argv); | |
- | |
- $this->tokens = $argv; | |
- | |
- parent::__construct($definition); | |
- } | |
- | |
- protected function setTokens(array $tokens) | |
- { | |
- $this->tokens = $tokens; | |
- } | |
- | |
- /** | |
- * Processes command line arguments. | |
- */ | |
- protected function parse() | |
- { | |
- $parseOptions = true; | |
- $this->parsed = $this->tokens; | |
- while (null !== $token = array_shift($this->parsed)) { | |
- if ($parseOptions && '--' == $token) { | |
- $parseOptions = false; | |
- } elseif ($parseOptions && 0 === strpos($token, '--')) { | |
- $this->parseLongOption($token); | |
- } elseif ($parseOptions && '-' === $token[0]) { | |
- $this->parseShortOption($token); | |
- } else { | |
- $this->parseArgument($token); | |
- } | |
- } | |
- } | |
- | |
- /** | |
- * Parses a short option. | |
- * | |
- * @param string $token The current token. | |
- */ | |
- private function parseShortOption($token) | |
- { | |
- $name = substr($token, 1); | |
- | |
- if (strlen($name) > 1) { | |
- if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) { | |
- // an option with a value (with no space) | |
- $this->addShortOption($name[0], substr($name, 1)); | |
- } else { | |
- $this->parseShortOptionSet($name); | |
- } | |
- } else { | |
- $this->addShortOption($name, null); | |
- } | |
- } | |
- | |
- /** | |
- * Parses a short option set. | |
- * | |
- * @param string $name The current token | |
- * | |
- * @throws \RuntimeException When option given doesn't exist | |
- */ | |
- private function parseShortOptionSet($name) | |
- { | |
- $len = strlen($name); | |
- for ($i = 0; $i < $len; $i++) { | |
- if (!$this->definition->hasShortcut($name[$i])) { | |
- throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $name[$i])); | |
- } | |
- | |
- $option = $this->definition->getOptionForShortcut($name[$i]); | |
- if ($option->acceptValue()) { | |
- $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1)); | |
- | |
- break; | |
- } else { | |
- $this->addLongOption($option->getName(), true); | |
- } | |
- } | |
- } | |
- | |
- /** | |
- * Parses a long option. | |
- * | |
- * @param string $token The current token | |
- */ | |
- private function parseLongOption($token) | |
- { | |
- $name = substr($token, 2); | |
- | |
- if (false !== $pos = strpos($name, '=')) { | |
- $this->addLongOption(substr($name, 0, $pos), substr($name, $pos + 1)); | |
- } else { | |
- $this->addLongOption($name, null); | |
- } | |
- } | |
- | |
- /** | |
- * Parses an argument. | |
- * | |
- * @param string $token The current token | |
- * | |
- * @throws \RuntimeException When too many arguments are given | |
- */ | |
- private function parseArgument($token) | |
- { | |
- $c = count($this->arguments); | |
- | |
- // if input is expecting another argument, add it | |
- if ($this->definition->hasArgument($c)) { | |
- $arg = $this->definition->getArgument($c); | |
- $this->arguments[$arg->getName()] = $arg->isArray()? array($token) : $token; | |
- | |
- // if last argument isArray(), append token to last argument | |
- } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) { | |
- $arg = $this->definition->getArgument($c - 1); | |
- $this->arguments[$arg->getName()][] = $token; | |
- | |
- // unexpected argument | |
- } else { | |
- throw new \RuntimeException('Too many arguments.'); | |
- } | |
- } | |
- | |
- /** | |
- * Adds a short option value. | |
- * | |
- * @param string $shortcut The short option key | |
- * @param mixed $value The value for the option | |
- * | |
- * @throws \RuntimeException When option given doesn't exist | |
- */ | |
- private function addShortOption($shortcut, $value) | |
- { | |
- if (!$this->definition->hasShortcut($shortcut)) { | |
- throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut)); | |
- } | |
- | |
- $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value); | |
- } | |
- | |
- /** | |
- * Adds a long option value. | |
- * | |
- * @param string $name The long option key | |
- * @param mixed $value The value for the option | |
- * | |
- * @throws \RuntimeException When option given doesn't exist | |
- */ | |
- private function addLongOption($name, $value) | |
- { | |
- if (!$this->definition->hasOption($name)) { | |
- throw new \RuntimeException(sprintf('The "--%s" option does not exist.', $name)); | |
- } | |
- | |
- $option = $this->definition->getOption($name); | |
- | |
- if (null === $value && $option->acceptValue()) { | |
- // if option accepts an optional or mandatory argument | |
- // let's see if there is one provided | |
- $next = array_shift($this->parsed); | |
- if ('-' !== $next[0]) { | |
- $value = $next; | |
- } else { | |
- array_unshift($this->parsed, $next); | |
- } | |
- } | |
- | |
- if (null === $value) { | |
- if ($option->isValueRequired()) { | |
- throw new \RuntimeException(sprintf('The "--%s" option requires a value.', $name)); | |
- } | |
- | |
- $value = $option->isValueOptional() ? $option->getDefault() : true; | |
- } | |
- | |
- if ($option->isArray()) { | |
- $this->options[$name][] = $value; | |
- } else { | |
- $this->options[$name] = $value; | |
- } | |
- } | |
- | |
- /** | |
- * Returns the first argument from the raw parameters (not parsed). | |
- * | |
- * @return string The value of the first argument or null otherwise | |
- */ | |
- public function getFirstArgument() | |
- { | |
- foreach ($this->tokens as $token) { | |
- if ($token && '-' === $token[0]) { | |
- continue; | |
- } | |
- | |
- return $token; | |
- } | |
- } | |
- | |
- /** | |
- * Returns true if the raw parameters (not parsed) contain a value. | |
- * | |
- * This method is to be used to introspect the input parameters | |
- * before they have been validated. It must be used carefully. | |
- * | |
- * @param string|array $values The value(s) to look for in the raw parameters (can be an array) | |
- * | |
- * @return Boolean true if the value is contained in the raw parameters | |
- */ | |
- public function hasParameterOption($values) | |
- { | |
- $values = (array) $values; | |
- | |
- foreach ($this->tokens as $v) { | |
- if (in_array($v, $values)) { | |
- return true; | |
- } | |
- } | |
- | |
- return false; | |
- } | |
- | |
- /** | |
- * Returns the value of a raw option (not parsed). | |
- * | |
- * This method is to be used to introspect the input parameters | |
- * before they have been validated. It must be used carefully. | |
- * | |
- * @param string|array $values The value(s) to look for in the raw parameters (can be an array) | |
- * @param mixed $default The default value to return if no result is found | |
- * | |
- * @return mixed The option value | |
- */ | |
- public function getParameterOption($values, $default = false) | |
- { | |
- $values = (array) $values; | |
- | |
- $tokens = $this->tokens; | |
- while ($token = array_shift($tokens)) { | |
- foreach ($values as $value) { | |
- if (0 === strpos($token, $value)) { | |
- if (false !== $pos = strpos($token, '=')) { | |
- return substr($token, $pos + 1); | |
- } | |
- | |
- return array_shift($tokens); | |
- } | |
- } | |
- } | |
- | |
- return $default; | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Input/ArrayInput.php b/vendor/Symfony/Component/Console/Input/ArrayInput.php | |
deleted file mode 100755 | |
index c9d8ee9..0000000 | |
--- a/vendor/Symfony/Component/Console/Input/ArrayInput.php | |
+++ /dev/null | |
@@ -1,190 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Input; | |
- | |
-/** | |
- * ArrayInput represents an input provided as an array. | |
- * | |
- * Usage: | |
- * | |
- * $input = new ArrayInput(array('name' => 'foo', '--bar' => 'foobar')); | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- * | |
- * @api | |
- */ | |
-class ArrayInput extends Input | |
-{ | |
- private $parameters; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * @param array $parameters An array of parameters | |
- * @param InputDefinition $definition A InputDefinition instance | |
- * | |
- * @api | |
- */ | |
- public function __construct(array $parameters, InputDefinition $definition = null) | |
- { | |
- $this->parameters = $parameters; | |
- | |
- parent::__construct($definition); | |
- } | |
- | |
- /** | |
- * Returns the first argument from the raw parameters (not parsed). | |
- * | |
- * @return string The value of the first argument or null otherwise | |
- */ | |
- public function getFirstArgument() | |
- { | |
- foreach ($this->parameters as $key => $value) { | |
- if ($key && '-' === $key[0]) { | |
- continue; | |
- } | |
- | |
- return $value; | |
- } | |
- } | |
- | |
- /** | |
- * Returns true if the raw parameters (not parsed) contain a value. | |
- * | |
- * This method is to be used to introspect the input parameters | |
- * before they have been validated. It must be used carefully. | |
- * | |
- * @param string|array $values The values to look for in the raw parameters (can be an array) | |
- * | |
- * @return Boolean true if the value is contained in the raw parameters | |
- */ | |
- public function hasParameterOption($values) | |
- { | |
- $values = (array) $values; | |
- | |
- foreach ($this->parameters as $k => $v) { | |
- if (!is_int($k)) { | |
- $v = $k; | |
- } | |
- | |
- if (in_array($v, $values)) { | |
- return true; | |
- } | |
- } | |
- | |
- return false; | |
- } | |
- | |
- /** | |
- * Returns the value of a raw option (not parsed). | |
- * | |
- * This method is to be used to introspect the input parameters | |
- * before they have been validated. It must be used carefully. | |
- * | |
- * @param string|array $values The value(s) to look for in the raw parameters (can be an array) | |
- * @param mixed $default The default value to return if no result is found | |
- * | |
- * @return mixed The option value | |
- */ | |
- public function getParameterOption($values, $default = false) | |
- { | |
- $values = (array) $values; | |
- | |
- foreach ($this->parameters as $k => $v) { | |
- if (is_int($k) && in_array($v, $values)) { | |
- return true; | |
- } elseif (in_array($k, $values)) { | |
- return $v; | |
- } | |
- } | |
- | |
- return $default; | |
- } | |
- | |
- /** | |
- * Processes command line arguments. | |
- */ | |
- protected function parse() | |
- { | |
- foreach ($this->parameters as $key => $value) { | |
- if (0 === strpos($key, '--')) { | |
- $this->addLongOption(substr($key, 2), $value); | |
- } elseif ('-' === $key[0]) { | |
- $this->addShortOption(substr($key, 1), $value); | |
- } else { | |
- $this->addArgument($key, $value); | |
- } | |
- } | |
- } | |
- | |
- /** | |
- * Adds a short option value. | |
- * | |
- * @param string $shortcut The short option key | |
- * @param mixed $value The value for the option | |
- * | |
- * @throws \InvalidArgumentException When option given doesn't exist | |
- */ | |
- private function addShortOption($shortcut, $value) | |
- { | |
- if (!$this->definition->hasShortcut($shortcut)) { | |
- throw new \InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut)); | |
- } | |
- | |
- $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value); | |
- } | |
- | |
- /** | |
- * Adds a long option value. | |
- * | |
- * @param string $name The long option key | |
- * @param mixed $value The value for the option | |
- * | |
- * @throws \InvalidArgumentException When option given doesn't exist | |
- * @throws \InvalidArgumentException When a required value is missing | |
- */ | |
- private function addLongOption($name, $value) | |
- { | |
- if (!$this->definition->hasOption($name)) { | |
- throw new \InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name)); | |
- } | |
- | |
- $option = $this->definition->getOption($name); | |
- | |
- if (null === $value) { | |
- if ($option->isValueRequired()) { | |
- throw new \InvalidArgumentException(sprintf('The "--%s" option requires a value.', $name)); | |
- } | |
- | |
- $value = $option->isValueOptional() ? $option->getDefault() : true; | |
- } | |
- | |
- $this->options[$name] = $value; | |
- } | |
- | |
- /** | |
- * Adds an argument value. | |
- * | |
- * @param string $name The argument name | |
- * @param mixed $value The value for the argument | |
- * | |
- * @throws \InvalidArgumentException When argument given doesn't exist | |
- */ | |
- private function addArgument($name, $value) | |
- { | |
- if (!$this->definition->hasArgument($name)) { | |
- throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); | |
- } | |
- | |
- $this->arguments[$name] = $value; | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Input/Input.php b/vendor/Symfony/Component/Console/Input/Input.php | |
deleted file mode 100755 | |
index 70291be..0000000 | |
--- a/vendor/Symfony/Component/Console/Input/Input.php | |
+++ /dev/null | |
@@ -1,211 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Input; | |
- | |
-/** | |
- * Input is the base class for all concrete Input classes. | |
- * | |
- * Three concrete classes are provided by default: | |
- * | |
- * * `ArgvInput`: The input comes from the CLI arguments (argv) | |
- * * `StringInput`: The input is provided as a string | |
- * * `ArrayInput`: The input is provided as an array | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- */ | |
-abstract class Input implements InputInterface | |
-{ | |
- protected $definition; | |
- protected $options; | |
- protected $arguments; | |
- protected $interactive = true; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * @param InputDefinition $definition A InputDefinition instance | |
- */ | |
- public function __construct(InputDefinition $definition = null) | |
- { | |
- if (null === $definition) { | |
- $this->definition = new InputDefinition(); | |
- } else { | |
- $this->bind($definition); | |
- $this->validate(); | |
- } | |
- } | |
- | |
- /** | |
- * Binds the current Input instance with the given arguments and options. | |
- * | |
- * @param InputDefinition $definition A InputDefinition instance | |
- */ | |
- public function bind(InputDefinition $definition) | |
- { | |
- $this->arguments = array(); | |
- $this->options = array(); | |
- $this->definition = $definition; | |
- | |
- $this->parse(); | |
- } | |
- | |
- /** | |
- * Processes command line arguments. | |
- */ | |
- abstract protected function parse(); | |
- | |
- /** | |
- * Validates the input. | |
- * | |
- * @throws \RuntimeException When not enough arguments are given | |
- */ | |
- public function validate() | |
- { | |
- if (count($this->arguments) < $this->definition->getArgumentRequiredCount()) { | |
- throw new \RuntimeException('Not enough arguments.'); | |
- } | |
- } | |
- | |
- /** | |
- * Checks if the input is interactive. | |
- * | |
- * @return Boolean Returns true if the input is interactive | |
- */ | |
- public function isInteractive() | |
- { | |
- return $this->interactive; | |
- } | |
- | |
- /** | |
- * Sets the input interactivity. | |
- * | |
- * @param Boolean $interactive If the input should be interactive | |
- */ | |
- public function setInteractive($interactive) | |
- { | |
- $this->interactive = (Boolean) $interactive; | |
- } | |
- | |
- /** | |
- * Returns the argument values. | |
- * | |
- * @return array An array of argument values | |
- */ | |
- public function getArguments() | |
- { | |
- return array_merge($this->definition->getArgumentDefaults(), $this->arguments); | |
- } | |
- | |
- /** | |
- * Returns the argument value for a given argument name. | |
- * | |
- * @param string $name The argument name | |
- * | |
- * @return mixed The argument value | |
- * | |
- * @throws \InvalidArgumentException When argument given doesn't exist | |
- */ | |
- public function getArgument($name) | |
- { | |
- if (!$this->definition->hasArgument($name)) { | |
- throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); | |
- } | |
- | |
- return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault(); | |
- } | |
- | |
- /** | |
- * Sets an argument value by name. | |
- * | |
- * @param string $name The argument name | |
- * @param string $value The argument value | |
- * | |
- * @throws \InvalidArgumentException When argument given doesn't exist | |
- */ | |
- public function setArgument($name, $value) | |
- { | |
- if (!$this->definition->hasArgument($name)) { | |
- throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); | |
- } | |
- | |
- $this->arguments[$name] = $value; | |
- } | |
- | |
- /** | |
- * Returns true if an InputArgument object exists by name or position. | |
- * | |
- * @param string|integer $name The InputArgument name or position | |
- * | |
- * @return Boolean true if the InputArgument object exists, false otherwise | |
- */ | |
- public function hasArgument($name) | |
- { | |
- return $this->definition->hasArgument($name); | |
- } | |
- | |
- /** | |
- * Returns the options values. | |
- * | |
- * @return array An array of option values | |
- */ | |
- public function getOptions() | |
- { | |
- return array_merge($this->definition->getOptionDefaults(), $this->options); | |
- } | |
- | |
- /** | |
- * Returns the option value for a given option name. | |
- * | |
- * @param string $name The option name | |
- * | |
- * @return mixed The option value | |
- * | |
- * @throws \InvalidArgumentException When option given doesn't exist | |
- */ | |
- public function getOption($name) | |
- { | |
- if (!$this->definition->hasOption($name)) { | |
- throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name)); | |
- } | |
- | |
- return isset($this->options[$name]) ? $this->options[$name] : $this->definition->getOption($name)->getDefault(); | |
- } | |
- | |
- /** | |
- * Sets an option value by name. | |
- * | |
- * @param string $name The option name | |
- * @param string $value The option value | |
- * | |
- * @throws \InvalidArgumentException When option given doesn't exist | |
- */ | |
- public function setOption($name, $value) | |
- { | |
- if (!$this->definition->hasOption($name)) { | |
- throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name)); | |
- } | |
- | |
- $this->options[$name] = $value; | |
- } | |
- | |
- /** | |
- * Returns true if an InputOption object exists by name. | |
- * | |
- * @param string $name The InputOption name | |
- * | |
- * @return Boolean true if the InputOption object exists, false otherwise | |
- */ | |
- public function hasOption($name) | |
- { | |
- return $this->definition->hasOption($name); | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Input/InputArgument.php b/vendor/Symfony/Component/Console/Input/InputArgument.php | |
deleted file mode 100755 | |
index e7cc935..0000000 | |
--- a/vendor/Symfony/Component/Console/Input/InputArgument.php | |
+++ /dev/null | |
@@ -1,132 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Input; | |
- | |
-/** | |
- * Represents a command line argument. | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- * | |
- * @api | |
- */ | |
-class InputArgument | |
-{ | |
- const REQUIRED = 1; | |
- const OPTIONAL = 2; | |
- const IS_ARRAY = 4; | |
- | |
- private $name; | |
- private $mode; | |
- private $default; | |
- private $description; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * @param string $name The argument name | |
- * @param integer $mode The argument mode: self::REQUIRED or self::OPTIONAL | |
- * @param string $description A description text | |
- * @param mixed $default The default value (for self::OPTIONAL mode only) | |
- * | |
- * @throws \InvalidArgumentException When argument mode is not valid | |
- * | |
- * @api | |
- */ | |
- public function __construct($name, $mode = null, $description = '', $default = null) | |
- { | |
- if (null === $mode) { | |
- $mode = self::OPTIONAL; | |
- } elseif (!is_int($mode) || $mode > 7 || $mode < 1) { | |
- throw new \InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode)); | |
- } | |
- | |
- $this->name = $name; | |
- $this->mode = $mode; | |
- $this->description = $description; | |
- | |
- $this->setDefault($default); | |
- } | |
- | |
- /** | |
- * Returns the argument name. | |
- * | |
- * @return string The argument name | |
- */ | |
- public function getName() | |
- { | |
- return $this->name; | |
- } | |
- | |
- /** | |
- * Returns true if the argument is required. | |
- * | |
- * @return Boolean true if parameter mode is self::REQUIRED, false otherwise | |
- */ | |
- public function isRequired() | |
- { | |
- return self::REQUIRED === (self::REQUIRED & $this->mode); | |
- } | |
- | |
- /** | |
- * Returns true if the argument can take multiple values. | |
- * | |
- * @return Boolean true if mode is self::IS_ARRAY, false otherwise | |
- */ | |
- public function isArray() | |
- { | |
- return self::IS_ARRAY === (self::IS_ARRAY & $this->mode); | |
- } | |
- | |
- /** | |
- * Sets the default value. | |
- * | |
- * @param mixed $default The default value | |
- * | |
- * @throws \LogicException When incorrect default value is given | |
- */ | |
- public function setDefault($default = null) | |
- { | |
- if (self::REQUIRED === $this->mode && null !== $default) { | |
- throw new \LogicException('Cannot set a default value except for Parameter::OPTIONAL mode.'); | |
- } | |
- | |
- if ($this->isArray()) { | |
- if (null === $default) { | |
- $default = array(); | |
- } elseif (!is_array($default)) { | |
- throw new \LogicException('A default value for an array argument must be an array.'); | |
- } | |
- } | |
- | |
- $this->default = $default; | |
- } | |
- | |
- /** | |
- * Returns the default value. | |
- * | |
- * @return mixed The default value | |
- */ | |
- public function getDefault() | |
- { | |
- return $this->default; | |
- } | |
- | |
- /** | |
- * Returns the description text. | |
- * | |
- * @return string The description text | |
- */ | |
- public function getDescription() | |
- { | |
- return $this->description; | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Input/InputDefinition.php b/vendor/Symfony/Component/Console/Input/InputDefinition.php | |
deleted file mode 100755 | |
index ffae4fe..0000000 | |
--- a/vendor/Symfony/Component/Console/Input/InputDefinition.php | |
+++ /dev/null | |
@@ -1,533 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Input; | |
- | |
-/** | |
- * A InputDefinition represents a set of valid command line arguments and options. | |
- * | |
- * Usage: | |
- * | |
- * $definition = new InputDefinition(array( | |
- * new InputArgument('name', InputArgument::REQUIRED), | |
- * new InputOption('foo', 'f', InputOption::VALUE_REQUIRED), | |
- * )); | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- * | |
- * @api | |
- */ | |
-class InputDefinition | |
-{ | |
- private $arguments; | |
- private $requiredCount; | |
- private $hasAnArrayArgument = false; | |
- private $hasOptional; | |
- private $options; | |
- private $shortcuts; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * @param array $definition An array of InputArgument and InputOption instance | |
- * | |
- * @api | |
- */ | |
- public function __construct(array $definition = array()) | |
- { | |
- $this->setDefinition($definition); | |
- } | |
- | |
- /** | |
- * Sets the definition of the input. | |
- * | |
- * @param array $definition The definition array | |
- * | |
- * @api | |
- */ | |
- public function setDefinition(array $definition) | |
- { | |
- $arguments = array(); | |
- $options = array(); | |
- foreach ($definition as $item) { | |
- if ($item instanceof InputOption) { | |
- $options[] = $item; | |
- } else { | |
- $arguments[] = $item; | |
- } | |
- } | |
- | |
- $this->setArguments($arguments); | |
- $this->setOptions($options); | |
- } | |
- | |
- /** | |
- * Sets the InputArgument objects. | |
- * | |
- * @param array $arguments An array of InputArgument objects | |
- * | |
- * @api | |
- */ | |
- public function setArguments($arguments = array()) | |
- { | |
- $this->arguments = array(); | |
- $this->requiredCount = 0; | |
- $this->hasOptional = false; | |
- $this->hasAnArrayArgument = false; | |
- $this->addArguments($arguments); | |
- } | |
- | |
- /** | |
- * Adds an array of InputArgument objects. | |
- * | |
- * @param InputArgument[] $arguments An array of InputArgument objects | |
- * | |
- * @api | |
- */ | |
- public function addArguments($arguments = array()) | |
- { | |
- if (null !== $arguments) { | |
- foreach ($arguments as $argument) { | |
- $this->addArgument($argument); | |
- } | |
- } | |
- } | |
- | |
- /** | |
- * Adds an InputArgument object. | |
- * | |
- * @param InputArgument $argument An InputArgument object | |
- * | |
- * @throws \LogicException When incorrect argument is given | |
- * | |
- * @api | |
- */ | |
- public function addArgument(InputArgument $argument) | |
- { | |
- if (isset($this->arguments[$argument->getName()])) { | |
- throw new \LogicException(sprintf('An argument with name "%s" already exist.', $argument->getName())); | |
- } | |
- | |
- if ($this->hasAnArrayArgument) { | |
- throw new \LogicException('Cannot add an argument after an array argument.'); | |
- } | |
- | |
- if ($argument->isRequired() && $this->hasOptional) { | |
- throw new \LogicException('Cannot add a required argument after an optional one.'); | |
- } | |
- | |
- if ($argument->isArray()) { | |
- $this->hasAnArrayArgument = true; | |
- } | |
- | |
- if ($argument->isRequired()) { | |
- ++$this->requiredCount; | |
- } else { | |
- $this->hasOptional = true; | |
- } | |
- | |
- $this->arguments[$argument->getName()] = $argument; | |
- } | |
- | |
- /** | |
- * Returns an InputArgument by name or by position. | |
- * | |
- * @param string|integer $name The InputArgument name or position | |
- * | |
- * @return InputArgument An InputArgument object | |
- * | |
- * @throws \InvalidArgumentException When argument given doesn't exist | |
- * | |
- * @api | |
- */ | |
- public function getArgument($name) | |
- { | |
- $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments; | |
- | |
- if (!$this->hasArgument($name)) { | |
- throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); | |
- } | |
- | |
- return $arguments[$name]; | |
- } | |
- | |
- /** | |
- * Returns true if an InputArgument object exists by name or position. | |
- * | |
- * @param string|integer $name The InputArgument name or position | |
- * | |
- * @return Boolean true if the InputArgument object exists, false otherwise | |
- * | |
- * @api | |
- */ | |
- public function hasArgument($name) | |
- { | |
- $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments; | |
- | |
- return isset($arguments[$name]); | |
- } | |
- | |
- /** | |
- * Gets the array of InputArgument objects. | |
- * | |
- * @return array An array of InputArgument objects | |
- * | |
- * @api | |
- */ | |
- public function getArguments() | |
- { | |
- return $this->arguments; | |
- } | |
- | |
- /** | |
- * Returns the number of InputArguments. | |
- * | |
- * @return integer The number of InputArguments | |
- */ | |
- public function getArgumentCount() | |
- { | |
- return $this->hasAnArrayArgument ? PHP_INT_MAX : count($this->arguments); | |
- } | |
- | |
- /** | |
- * Returns the number of required InputArguments. | |
- * | |
- * @return integer The number of required InputArguments | |
- */ | |
- public function getArgumentRequiredCount() | |
- { | |
- return $this->requiredCount; | |
- } | |
- | |
- /** | |
- * Gets the default values. | |
- * | |
- * @return array An array of default values | |
- */ | |
- public function getArgumentDefaults() | |
- { | |
- $values = array(); | |
- foreach ($this->arguments as $argument) { | |
- $values[$argument->getName()] = $argument->getDefault(); | |
- } | |
- | |
- return $values; | |
- } | |
- | |
- /** | |
- * Sets the InputOption objects. | |
- * | |
- * @param array $options An array of InputOption objects | |
- * | |
- * @api | |
- */ | |
- public function setOptions($options = array()) | |
- { | |
- $this->options = array(); | |
- $this->shortcuts = array(); | |
- $this->addOptions($options); | |
- } | |
- | |
- /** | |
- * Adds an array of InputOption objects. | |
- * | |
- * @param InputOption[] $options An array of InputOption objects | |
- * | |
- * @api | |
- */ | |
- public function addOptions($options = array()) | |
- { | |
- foreach ($options as $option) { | |
- $this->addOption($option); | |
- } | |
- } | |
- | |
- /** | |
- * Adds an InputOption object. | |
- * | |
- * @param InputOption $option An InputOption object | |
- * | |
- * @throws \LogicException When option given already exist | |
- * | |
- * @api | |
- */ | |
- public function addOption(InputOption $option) | |
- { | |
- if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) { | |
- throw new \LogicException(sprintf('An option named "%s" already exist.', $option->getName())); | |
- } elseif (isset($this->shortcuts[$option->getShortcut()]) && !$option->equals($this->options[$this->shortcuts[$option->getShortcut()]])) { | |
- throw new \LogicException(sprintf('An option with shortcut "%s" already exist.', $option->getShortcut())); | |
- } | |
- | |
- $this->options[$option->getName()] = $option; | |
- if ($option->getShortcut()) { | |
- $this->shortcuts[$option->getShortcut()] = $option->getName(); | |
- } | |
- } | |
- | |
- /** | |
- * Returns an InputOption by name. | |
- * | |
- * @param string $name The InputOption name | |
- * | |
- * @return InputOption A InputOption object | |
- * | |
- * @api | |
- */ | |
- public function getOption($name) | |
- { | |
- if (!$this->hasOption($name)) { | |
- throw new \InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name)); | |
- } | |
- | |
- return $this->options[$name]; | |
- } | |
- | |
- /** | |
- * Returns true if an InputOption object exists by name. | |
- * | |
- * @param string $name The InputOption name | |
- * | |
- * @return Boolean true if the InputOption object exists, false otherwise | |
- * | |
- * @api | |
- */ | |
- public function hasOption($name) | |
- { | |
- return isset($this->options[$name]); | |
- } | |
- | |
- /** | |
- * Gets the array of InputOption objects. | |
- * | |
- * @return array An array of InputOption objects | |
- * | |
- * @api | |
- */ | |
- public function getOptions() | |
- { | |
- return $this->options; | |
- } | |
- | |
- /** | |
- * Returns true if an InputOption object exists by shortcut. | |
- * | |
- * @param string $name The InputOption shortcut | |
- * | |
- * @return Boolean true if the InputOption object exists, false otherwise | |
- */ | |
- public function hasShortcut($name) | |
- { | |
- return isset($this->shortcuts[$name]); | |
- } | |
- | |
- /** | |
- * Gets an InputOption by shortcut. | |
- * | |
- * @param string $shortcut the Shortcut name | |
- * | |
- * @return InputOption An InputOption object | |
- */ | |
- public function getOptionForShortcut($shortcut) | |
- { | |
- return $this->getOption($this->shortcutToName($shortcut)); | |
- } | |
- | |
- /** | |
- * Gets an array of default values. | |
- * | |
- * @return array An array of all default values | |
- */ | |
- public function getOptionDefaults() | |
- { | |
- $values = array(); | |
- foreach ($this->options as $option) { | |
- $values[$option->getName()] = $option->getDefault(); | |
- } | |
- | |
- return $values; | |
- } | |
- | |
- /** | |
- * Returns the InputOption name given a shortcut. | |
- * | |
- * @param string $shortcut The shortcut | |
- * | |
- * @return string The InputOption name | |
- * | |
- * @throws \InvalidArgumentException When option given does not exist | |
- */ | |
- private function shortcutToName($shortcut) | |
- { | |
- if (!isset($this->shortcuts[$shortcut])) { | |
- throw new \InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut)); | |
- } | |
- | |
- return $this->shortcuts[$shortcut]; | |
- } | |
- | |
- /** | |
- * Gets the synopsis. | |
- * | |
- * @return string The synopsis | |
- */ | |
- public function getSynopsis() | |
- { | |
- $elements = array(); | |
- foreach ($this->getOptions() as $option) { | |
- $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : ''; | |
- $elements[] = sprintf('['.($option->isValueRequired() ? '%s--%s="..."' : ($option->isValueOptional() ? '%s--%s[="..."]' : '%s--%s')).']', $shortcut, $option->getName()); | |
- } | |
- | |
- foreach ($this->getArguments() as $argument) { | |
- $elements[] = sprintf($argument->isRequired() ? '%s' : '[%s]', $argument->getName().($argument->isArray() ? '1' : '')); | |
- | |
- if ($argument->isArray()) { | |
- $elements[] = sprintf('... [%sN]', $argument->getName()); | |
- } | |
- } | |
- | |
- return implode(' ', $elements); | |
- } | |
- | |
- /** | |
- * Returns a textual representation of the InputDefinition. | |
- * | |
- * @return string A string representing the InputDefinition | |
- */ | |
- public function asText() | |
- { | |
- // find the largest option or argument name | |
- $max = 0; | |
- foreach ($this->getOptions() as $option) { | |
- $nameLength = strlen($option->getName()) + 2; | |
- if ($option->getShortcut()) { | |
- $nameLength += strlen($option->getShortcut()) + 3; | |
- } | |
- | |
- $max = max($max, $nameLength); | |
- } | |
- foreach ($this->getArguments() as $argument) { | |
- $max = max($max, strlen($argument->getName())); | |
- } | |
- ++$max; | |
- | |
- $text = array(); | |
- | |
- if ($this->getArguments()) { | |
- $text[] = '<comment>Arguments:</comment>'; | |
- foreach ($this->getArguments() as $argument) { | |
- if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) { | |
- $default = sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($argument->getDefault())); | |
- } else { | |
- $default = ''; | |
- } | |
- | |
- $description = str_replace("\n", "\n".str_pad('', $max + 2, ' '), $argument->getDescription()); | |
- | |
- $text[] = sprintf(" <info>%-${max}s</info> %s%s", $argument->getName(), $description, $default); | |
- } | |
- | |
- $text[] = ''; | |
- } | |
- | |
- if ($this->getOptions()) { | |
- $text[] = '<comment>Options:</comment>'; | |
- | |
- foreach ($this->getOptions() as $option) { | |
- if ($option->acceptValue() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault()))) { | |
- $default = sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($option->getDefault())); | |
- } else { | |
- $default = ''; | |
- } | |
- | |
- $multiple = $option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''; | |
- $description = str_replace("\n", "\n".str_pad('', $max + 2, ' '), $option->getDescription()); | |
- | |
- $optionMax = $max - strlen($option->getName()) - 2; | |
- $text[] = sprintf(" <info>%s</info> %-${optionMax}s%s%s%s", | |
- '--'.$option->getName(), | |
- $option->getShortcut() ? sprintf('(-%s) ', $option->getShortcut()) : '', | |
- $description, | |
- $default, | |
- $multiple | |
- ); | |
- } | |
- | |
- $text[] = ''; | |
- } | |
- | |
- return implode("\n", $text); | |
- } | |
- | |
- /** | |
- * Returns an XML representation of the InputDefinition. | |
- * | |
- * @param Boolean $asDom Whether to return a DOM or an XML string | |
- * | |
- * @return string|DOMDocument An XML string representing the InputDefinition | |
- */ | |
- public function asXml($asDom = false) | |
- { | |
- $dom = new \DOMDocument('1.0', 'UTF-8'); | |
- $dom->formatOutput = true; | |
- $dom->appendChild($definitionXML = $dom->createElement('definition')); | |
- | |
- $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments')); | |
- foreach ($this->getArguments() as $argument) { | |
- $argumentsXML->appendChild($argumentXML = $dom->createElement('argument')); | |
- $argumentXML->setAttribute('name', $argument->getName()); | |
- $argumentXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0); | |
- $argumentXML->setAttribute('is_array', $argument->isArray() ? 1 : 0); | |
- $argumentXML->appendChild($descriptionXML = $dom->createElement('description')); | |
- $descriptionXML->appendChild($dom->createTextNode($argument->getDescription())); | |
- | |
- $argumentXML->appendChild($defaultsXML = $dom->createElement('defaults')); | |
- $defaults = is_array($argument->getDefault()) ? $argument->getDefault() : (is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array())); | |
- foreach ($defaults as $default) { | |
- $defaultsXML->appendChild($defaultXML = $dom->createElement('default')); | |
- $defaultXML->appendChild($dom->createTextNode($default)); | |
- } | |
- } | |
- | |
- $definitionXML->appendChild($optionsXML = $dom->createElement('options')); | |
- foreach ($this->getOptions() as $option) { | |
- $optionsXML->appendChild($optionXML = $dom->createElement('option')); | |
- $optionXML->setAttribute('name', '--'.$option->getName()); | |
- $optionXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : ''); | |
- $optionXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0); | |
- $optionXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0); | |
- $optionXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0); | |
- $optionXML->appendChild($descriptionXML = $dom->createElement('description')); | |
- $descriptionXML->appendChild($dom->createTextNode($option->getDescription())); | |
- | |
- if ($option->acceptValue()) { | |
- $optionXML->appendChild($defaultsXML = $dom->createElement('defaults')); | |
- $defaults = is_array($option->getDefault()) ? $option->getDefault() : (is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array())); | |
- foreach ($defaults as $default) { | |
- $defaultsXML->appendChild($defaultXML = $dom->createElement('default')); | |
- $defaultXML->appendChild($dom->createTextNode($default)); | |
- } | |
- } | |
- } | |
- | |
- return $asDom ? $dom : $dom->saveXml(); | |
- } | |
- | |
- private function formatDefaultValue($default) | |
- { | |
- if (is_array($default) && $default === array_values($default)) { | |
- return sprintf("array('%s')", implode("', '", $default)); | |
- } | |
- | |
- return str_replace("\n", '', var_export($default, true)); | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Input/InputInterface.php b/vendor/Symfony/Component/Console/Input/InputInterface.php | |
deleted file mode 100755 | |
index a4a6223..0000000 | |
--- a/vendor/Symfony/Component/Console/Input/InputInterface.php | |
+++ /dev/null | |
@@ -1,152 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Input; | |
- | |
-/** | |
- * InputInterface is the interface implemented by all input classes. | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- */ | |
-interface InputInterface | |
-{ | |
- /** | |
- * Returns the first argument from the raw parameters (not parsed). | |
- * | |
- * @return string The value of the first argument or null otherwise | |
- */ | |
- function getFirstArgument(); | |
- | |
- /** | |
- * Returns true if the raw parameters (not parsed) contain a value. | |
- * | |
- * This method is to be used to introspect the input parameters | |
- * before they have been validated. It must be used carefully. | |
- * | |
- * @param string|array $values The values to look for in the raw parameters (can be an array) | |
- * | |
- * @return Boolean true if the value is contained in the raw parameters | |
- */ | |
- function hasParameterOption($values); | |
- | |
- /** | |
- * Returns the value of a raw option (not parsed). | |
- * | |
- * This method is to be used to introspect the input parameters | |
- * before they have been validated. It must be used carefully. | |
- * | |
- * @param string|array $values The value(s) to look for in the raw parameters (can be an array) | |
- * @param mixed $default The default value to return if no result is found | |
- * | |
- * @return mixed The option value | |
- */ | |
- function getParameterOption($values, $default = false); | |
- | |
- /** | |
- * Binds the current Input instance with the given arguments and options. | |
- * | |
- * @param InputDefinition $definition A InputDefinition instance | |
- */ | |
- function bind(InputDefinition $definition); | |
- | |
- /** | |
- * Validates if arguments given are correct. | |
- * | |
- * Throws an exception when not enough arguments are given. | |
- * | |
- * @throws \RuntimeException | |
- */ | |
- function validate(); | |
- | |
- /** | |
- * Returns all the given arguments merged with the default values. | |
- * | |
- * @return array | |
- */ | |
- function getArguments(); | |
- | |
- /** | |
- * Gets argument by name. | |
- * | |
- * @param string $name The name of the argument | |
- * | |
- * @return mixed | |
- */ | |
- function getArgument($name); | |
- | |
- /** | |
- * Sets an argument value by name. | |
- * | |
- * @param string $name The argument name | |
- * @param string $value The argument value | |
- * | |
- * @throws \InvalidArgumentException When argument given doesn't exist | |
- */ | |
- function setArgument($name, $value); | |
- | |
- /** | |
- * Returns true if an InputArgument object exists by name or position. | |
- * | |
- * @param string|integer $name The InputArgument name or position | |
- * | |
- * @return Boolean true if the InputArgument object exists, false otherwise | |
- */ | |
- function hasArgument($name); | |
- | |
- /** | |
- * Returns all the given options merged with the default values. | |
- * | |
- * @return array | |
- */ | |
- function getOptions(); | |
- | |
- /** | |
- * Gets an option by name. | |
- * | |
- * @param string $name The name of the option | |
- * | |
- * @return mixed | |
- */ | |
- function getOption($name); | |
- | |
- /** | |
- * Sets an option value by name. | |
- * | |
- * @param string $name The option name | |
- * @param string $value The option value | |
- * | |
- * @throws \InvalidArgumentException When option given doesn't exist | |
- */ | |
- function setOption($name, $value); | |
- | |
- /** | |
- * Returns true if an InputOption object exists by name. | |
- * | |
- * @param string $name The InputOption name | |
- * | |
- * @return Boolean true if the InputOption object exists, false otherwise | |
- */ | |
- function hasOption($name); | |
- | |
- /** | |
- * Is this input means interactive? | |
- * | |
- * @return Boolean | |
- */ | |
- function isInteractive(); | |
- | |
- /** | |
- * Sets the input interactivity. | |
- * | |
- * @param Boolean $interactive If the input should be interactive | |
- */ | |
- function setInteractive($interactive); | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Input/InputOption.php b/vendor/Symfony/Component/Console/Input/InputOption.php | |
deleted file mode 100755 | |
index 0f26045..0000000 | |
--- a/vendor/Symfony/Component/Console/Input/InputOption.php | |
+++ /dev/null | |
@@ -1,201 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Input; | |
- | |
-/** | |
- * Represents a command line option. | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- * | |
- * @api | |
- */ | |
-class InputOption | |
-{ | |
- const VALUE_NONE = 1; | |
- const VALUE_REQUIRED = 2; | |
- const VALUE_OPTIONAL = 4; | |
- const VALUE_IS_ARRAY = 8; | |
- | |
- private $name; | |
- private $shortcut; | |
- private $mode; | |
- private $default; | |
- private $description; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * @param string $name The option name | |
- * @param string $shortcut The shortcut (can be null) | |
- * @param integer $mode The option mode: One of the VALUE_* constants | |
- * @param string $description A description text | |
- * @param mixed $default The default value (must be null for self::VALUE_REQUIRED or self::VALUE_NONE) | |
- * | |
- * @throws \InvalidArgumentException If option mode is invalid or incompatible | |
- * | |
- * @api | |
- */ | |
- public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null) | |
- { | |
- if (0 === strpos($name, '--')) { | |
- $name = substr($name, 2); | |
- } | |
- | |
- if (empty($shortcut)) { | |
- $shortcut = null; | |
- } | |
- | |
- if (null !== $shortcut) { | |
- if ('-' === $shortcut[0]) { | |
- $shortcut = substr($shortcut, 1); | |
- } | |
- } | |
- | |
- if (null === $mode) { | |
- $mode = self::VALUE_NONE; | |
- } elseif (!is_int($mode) || $mode > 15 || $mode < 1) { | |
- throw new \InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode)); | |
- } | |
- | |
- $this->name = $name; | |
- $this->shortcut = $shortcut; | |
- $this->mode = $mode; | |
- $this->description = $description; | |
- | |
- if ($this->isArray() && !$this->acceptValue()) { | |
- throw new \InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.'); | |
- } | |
- | |
- $this->setDefault($default); | |
- } | |
- | |
- /** | |
- * Returns the option shortcut. | |
- * | |
- * @return string The shortcut | |
- */ | |
- public function getShortcut() | |
- { | |
- return $this->shortcut; | |
- } | |
- | |
- /** | |
- * Returns the option name. | |
- * | |
- * @return string The name | |
- */ | |
- public function getName() | |
- { | |
- return $this->name; | |
- } | |
- | |
- /** | |
- * Returns true if the option accepts a value. | |
- * | |
- * @return Boolean true if value mode is not self::VALUE_NONE, false otherwise | |
- */ | |
- public function acceptValue() | |
- { | |
- return $this->isValueRequired() || $this->isValueOptional(); | |
- } | |
- | |
- /** | |
- * Returns true if the option requires a value. | |
- * | |
- * @return Boolean true if value mode is self::VALUE_REQUIRED, false otherwise | |
- */ | |
- public function isValueRequired() | |
- { | |
- return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode); | |
- } | |
- | |
- /** | |
- * Returns true if the option takes an optional value. | |
- * | |
- * @return Boolean true if value mode is self::VALUE_OPTIONAL, false otherwise | |
- */ | |
- public function isValueOptional() | |
- { | |
- return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode); | |
- } | |
- | |
- /** | |
- * Returns true if the option can take multiple values. | |
- * | |
- * @return Boolean true if mode is self::VALUE_IS_ARRAY, false otherwise | |
- */ | |
- public function isArray() | |
- { | |
- return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode); | |
- } | |
- | |
- /** | |
- * Sets the default value. | |
- * | |
- * @param mixed $default The default value | |
- * | |
- * @throws \LogicException When incorrect default value is given | |
- */ | |
- public function setDefault($default = null) | |
- { | |
- if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) { | |
- throw new \LogicException('Cannot set a default value when using Option::VALUE_NONE mode.'); | |
- } | |
- | |
- if ($this->isArray()) { | |
- if (null === $default) { | |
- $default = array(); | |
- } elseif (!is_array($default)) { | |
- throw new \LogicException('A default value for an array option must be an array.'); | |
- } | |
- } | |
- | |
- $this->default = $this->acceptValue() ? $default : false; | |
- } | |
- | |
- /** | |
- * Returns the default value. | |
- * | |
- * @return mixed The default value | |
- */ | |
- public function getDefault() | |
- { | |
- return $this->default; | |
- } | |
- | |
- /** | |
- * Returns the description text. | |
- * | |
- * @return string The description text | |
- */ | |
- public function getDescription() | |
- { | |
- return $this->description; | |
- } | |
- | |
- /** | |
- * Checks whether the given option equals this one | |
- * | |
- * @param InputOption $option option to compare | |
- * @return Boolean | |
- */ | |
- public function equals(InputOption $option) | |
- { | |
- return $option->getName() === $this->getName() | |
- && $option->getShortcut() === $this->getShortcut() | |
- && $option->getDefault() === $this->getDefault() | |
- && $option->isArray() === $this->isArray() | |
- && $option->isValueRequired() === $this->isValueRequired() | |
- && $option->isValueOptional() === $this->isValueOptional() | |
- ; | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Input/StringInput.php b/vendor/Symfony/Component/Console/Input/StringInput.php | |
deleted file mode 100755 | |
index 72b725b..0000000 | |
--- a/vendor/Symfony/Component/Console/Input/StringInput.php | |
+++ /dev/null | |
@@ -1,79 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Input; | |
- | |
-/** | |
- * StringInput represents an input provided as a string. | |
- * | |
- * Usage: | |
- * | |
- * $input = new StringInput('foo --bar="foobar"'); | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- * | |
- * @api | |
- */ | |
-class StringInput extends ArgvInput | |
-{ | |
- const REGEX_STRING = '([^ ]+?)(?: |(?<!\\\\)"|(?<!\\\\)\'|$)'; | |
- const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')'; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * @param string $input An array of parameters from the CLI (in the argv format) | |
- * @param InputDefinition $definition A InputDefinition instance | |
- * | |
- * @api | |
- */ | |
- public function __construct($input, InputDefinition $definition = null) | |
- { | |
- parent::__construct(array(), $definition); | |
- | |
- $this->setTokens($this->tokenize($input)); | |
- } | |
- | |
- /** | |
- * Tokenizes a string. | |
- * | |
- * @param string $input The input to tokenize | |
- * | |
- * @throws \InvalidArgumentException When unable to parse input (should never happen) | |
- */ | |
- private function tokenize($input) | |
- { | |
- $input = preg_replace('/(\r\n|\r|\n|\t)/', ' ', $input); | |
- | |
- $tokens = array(); | |
- $length = strlen($input); | |
- $cursor = 0; | |
- while ($cursor < $length) { | |
- if (preg_match('/\s+/A', $input, $match, null, $cursor)) { | |
- } elseif (preg_match('/([^="\' ]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) { | |
- $tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, strlen($match[3]) - 2))); | |
- } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) { | |
- $tokens[] = stripcslashes(substr($match[0], 1, strlen($match[0]) - 2)); | |
- } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) { | |
- $tokens[] = stripcslashes($match[1]); | |
- } else { | |
- // should never happen | |
- // @codeCoverageIgnoreStart | |
- throw new \InvalidArgumentException(sprintf('Unable to parse input near "... %s ..."', substr($input, $cursor, 10))); | |
- // @codeCoverageIgnoreEnd | |
- } | |
- | |
- $cursor += strlen($match[0]); | |
- } | |
- | |
- return $tokens; | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/LICENSE b/vendor/Symfony/Component/Console/LICENSE | |
deleted file mode 100755 | |
index cdffe7a..0000000 | |
--- a/vendor/Symfony/Component/Console/LICENSE | |
+++ /dev/null | |
@@ -1,19 +0,0 @@ | |
-Copyright (c) 2004-2012 Fabien Potencier | |
- | |
-Permission is hereby granted, free of charge, to any person obtaining a copy | |
-of this software and associated documentation files (the "Software"), to deal | |
-in the Software without restriction, including without limitation the rights | |
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
-copies of the Software, and to permit persons to whom the Software is furnished | |
-to do so, subject to the following conditions: | |
- | |
-The above copyright notice and this permission notice shall be included in all | |
-copies or substantial portions of the Software. | |
- | |
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
-THE SOFTWARE. | |
diff --git a/vendor/Symfony/Component/Console/Output/ConsoleOutput.php b/vendor/Symfony/Component/Console/Output/ConsoleOutput.php | |
deleted file mode 100755 | |
index 1cce332..0000000 | |
--- a/vendor/Symfony/Component/Console/Output/ConsoleOutput.php | |
+++ /dev/null | |
@@ -1,83 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Output; | |
- | |
-use Symfony\Component\Console\Formatter\OutputFormatter; | |
-use Symfony\Component\Console\Formatter\OutputFormatterInterface; | |
-use Symfony\Component\Console\Output\ConsoleOutputInterface; | |
- | |
-/** | |
- * ConsoleOutput is the default class for all CLI output. It uses STDOUT. | |
- * | |
- * This class is a convenient wrapper around `StreamOutput`. | |
- * | |
- * $output = new ConsoleOutput(); | |
- * | |
- * This is equivalent to: | |
- * | |
- * $output = new StreamOutput(fopen('php://stdout', 'w')); | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- * | |
- * @api | |
- */ | |
-class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface | |
-{ | |
- private $stderr; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * @param integer $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL, | |
- * self::VERBOSITY_VERBOSE) | |
- * @param Boolean $decorated Whether to decorate messages or not (null for auto-guessing) | |
- * @param OutputFormatter $formatter Output formatter instance | |
- * | |
- * @api | |
- */ | |
- public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null) | |
- { | |
- parent::__construct(fopen('php://stdout', 'w'), $verbosity, $decorated, $formatter); | |
- $this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $formatter); | |
- } | |
- | |
- public function setDecorated($decorated) | |
- { | |
- parent::setDecorated($decorated); | |
- $this->stderr->setDecorated($decorated); | |
- } | |
- | |
- public function setFormatter(OutputFormatterInterface $formatter) | |
- { | |
- parent::setFormatter($formatter); | |
- $this->stderr->setFormatter($formatter); | |
- } | |
- | |
- public function setVerbosity($level) | |
- { | |
- parent::setVerbosity($level); | |
- $this->stderr->setVerbosity($level); | |
- } | |
- | |
- /** | |
- * @return OutputInterface | |
- */ | |
- public function getErrorOutput() | |
- { | |
- return $this->stderr; | |
- } | |
- | |
- public function setErrorOutput(OutputInterface $error) | |
- { | |
- $this->stderr = $error; | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Output/ConsoleOutputInterface.php b/vendor/Symfony/Component/Console/Output/ConsoleOutputInterface.php | |
deleted file mode 100755 | |
index 5006b80..0000000 | |
--- a/vendor/Symfony/Component/Console/Output/ConsoleOutputInterface.php | |
+++ /dev/null | |
@@ -1,30 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Output; | |
- | |
-use Symfony\Component\Console\Output\OutputInterface; | |
- | |
-/** | |
- * ConsoleOutputInterface is the interface implemented by ConsoleOutput class. | |
- * This adds information about stderr output stream. | |
- * | |
- * @author Dariusz Górecki <[email protected]> | |
- */ | |
-interface ConsoleOutputInterface extends OutputInterface | |
-{ | |
- /** | |
- * @return OutputInterface | |
- */ | |
- public function getErrorOutput(); | |
- | |
- public function setErrorOutput(OutputInterface $error); | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Output/NullOutput.php b/vendor/Symfony/Component/Console/Output/NullOutput.php | |
deleted file mode 100755 | |
index f6c99ab..0000000 | |
--- a/vendor/Symfony/Component/Console/Output/NullOutput.php | |
+++ /dev/null | |
@@ -1,34 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Output; | |
- | |
-/** | |
- * NullOutput suppresses all output. | |
- * | |
- * $output = new NullOutput(); | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- * | |
- * @api | |
- */ | |
-class NullOutput extends Output | |
-{ | |
- /** | |
- * Writes a message to the output. | |
- * | |
- * @param string $message A message to write to the output | |
- * @param Boolean $newline Whether to add a newline or not | |
- */ | |
- public function doWrite($message, $newline) | |
- { | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Output/Output.php b/vendor/Symfony/Component/Console/Output/Output.php | |
deleted file mode 100755 | |
index 2227880..0000000 | |
--- a/vendor/Symfony/Component/Console/Output/Output.php | |
+++ /dev/null | |
@@ -1,180 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Output; | |
- | |
-use Symfony\Component\Console\Formatter\OutputFormatterInterface; | |
-use Symfony\Component\Console\Formatter\OutputFormatter; | |
- | |
-/** | |
- * Base class for output classes. | |
- * | |
- * There are three levels of verbosity: | |
- * | |
- * * normal: no option passed (normal output - information) | |
- * * verbose: -v (more output - debug) | |
- * * quiet: -q (no output) | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- * | |
- * @api | |
- */ | |
-abstract class Output implements OutputInterface | |
-{ | |
- private $verbosity; | |
- private $formatter; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * @param integer $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL, self::VERBOSITY_VERBOSE) | |
- * @param Boolean $decorated Whether to decorate messages or not (null for auto-guessing) | |
- * @param OutputFormatterInterface $formatter Output formatter instance | |
- * | |
- * @api | |
- */ | |
- public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null) | |
- { | |
- $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity; | |
- $this->formatter = null === $formatter ? new OutputFormatter() : $formatter; | |
- $this->formatter->setDecorated((Boolean) $decorated); | |
- } | |
- | |
- /** | |
- * Sets output formatter. | |
- * | |
- * @param OutputFormatterInterface $formatter | |
- * | |
- * @api | |
- */ | |
- public function setFormatter(OutputFormatterInterface $formatter) | |
- { | |
- $this->formatter = $formatter; | |
- } | |
- | |
- /** | |
- * Returns current output formatter instance. | |
- * | |
- * @return OutputFormatterInterface | |
- * | |
- * @api | |
- */ | |
- public function getFormatter() | |
- { | |
- return $this->formatter; | |
- } | |
- | |
- /** | |
- * Sets the decorated flag. | |
- * | |
- * @param Boolean $decorated Whether to decorate the messages or not | |
- * | |
- * @api | |
- */ | |
- public function setDecorated($decorated) | |
- { | |
- $this->formatter->setDecorated((Boolean) $decorated); | |
- } | |
- | |
- /** | |
- * Gets the decorated flag. | |
- * | |
- * @return Boolean true if the output will decorate messages, false otherwise | |
- * | |
- * @api | |
- */ | |
- public function isDecorated() | |
- { | |
- return $this->formatter->isDecorated(); | |
- } | |
- | |
- /** | |
- * Sets the verbosity of the output. | |
- * | |
- * @param integer $level The level of verbosity | |
- * | |
- * @api | |
- */ | |
- public function setVerbosity($level) | |
- { | |
- $this->verbosity = (int) $level; | |
- } | |
- | |
- /** | |
- * Gets the current verbosity of the output. | |
- * | |
- * @return integer The current level of verbosity | |
- * | |
- * @api | |
- */ | |
- public function getVerbosity() | |
- { | |
- return $this->verbosity; | |
- } | |
- | |
- /** | |
- * Writes a message to the output and adds a newline at the end. | |
- * | |
- * @param string|array $messages The message as an array of lines of a single string | |
- * @param integer $type The type of output | |
- * | |
- * @api | |
- */ | |
- public function writeln($messages, $type = 0) | |
- { | |
- $this->write($messages, true, $type); | |
- } | |
- | |
- /** | |
- * Writes a message to the output. | |
- * | |
- * @param string|array $messages The message as an array of lines of a single string | |
- * @param Boolean $newline Whether to add a newline or not | |
- * @param integer $type The type of output | |
- * | |
- * @throws \InvalidArgumentException When unknown output type is given | |
- * | |
- * @api | |
- */ | |
- public function write($messages, $newline = false, $type = 0) | |
- { | |
- if (self::VERBOSITY_QUIET === $this->verbosity) { | |
- return; | |
- } | |
- | |
- $messages = (array) $messages; | |
- | |
- foreach ($messages as $message) { | |
- switch ($type) { | |
- case OutputInterface::OUTPUT_NORMAL: | |
- $message = $this->formatter->format($message); | |
- break; | |
- case OutputInterface::OUTPUT_RAW: | |
- break; | |
- case OutputInterface::OUTPUT_PLAIN: | |
- $message = strip_tags($this->formatter->format($message)); | |
- break; | |
- default: | |
- throw new \InvalidArgumentException(sprintf('Unknown output type given (%s)', $type)); | |
- } | |
- | |
- $this->doWrite($message, $newline); | |
- } | |
- } | |
- | |
- /** | |
- * Writes a message to the output. | |
- * | |
- * @param string $message A message to write to the output | |
- * @param Boolean $newline Whether to add a newline or not | |
- */ | |
- abstract public function doWrite($message, $newline); | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Output/OutputInterface.php b/vendor/Symfony/Component/Console/Output/OutputInterface.php | |
deleted file mode 100755 | |
index 8423d48..0000000 | |
--- a/vendor/Symfony/Component/Console/Output/OutputInterface.php | |
+++ /dev/null | |
@@ -1,109 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Output; | |
- | |
-use Symfony\Component\Console\Formatter\OutputFormatterInterface; | |
- | |
-/** | |
- * OutputInterface is the interface implemented by all Output classes. | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- * | |
- * @api | |
- */ | |
-interface OutputInterface | |
-{ | |
- const VERBOSITY_QUIET = 0; | |
- const VERBOSITY_NORMAL = 1; | |
- const VERBOSITY_VERBOSE = 2; | |
- | |
- const OUTPUT_NORMAL = 0; | |
- const OUTPUT_RAW = 1; | |
- const OUTPUT_PLAIN = 2; | |
- | |
- /** | |
- * Writes a message to the output. | |
- * | |
- * @param string|array $messages The message as an array of lines of a single string | |
- * @param Boolean $newline Whether to add a newline or not | |
- * @param integer $type The type of output | |
- * | |
- * @throws \InvalidArgumentException When unknown output type is given | |
- * | |
- * @api | |
- */ | |
- function write($messages, $newline = false, $type = 0); | |
- | |
- /** | |
- * Writes a message to the output and adds a newline at the end. | |
- * | |
- * @param string|array $messages The message as an array of lines of a single string | |
- * @param integer $type The type of output | |
- * | |
- * @api | |
- */ | |
- function writeln($messages, $type = 0); | |
- | |
- /** | |
- * Sets the verbosity of the output. | |
- * | |
- * @param integer $level The level of verbosity | |
- * | |
- * @api | |
- */ | |
- function setVerbosity($level); | |
- | |
- /** | |
- * Gets the current verbosity of the output. | |
- * | |
- * @return integer The current level of verbosity | |
- * | |
- * @api | |
- */ | |
- function getVerbosity(); | |
- | |
- /** | |
- * Sets the decorated flag. | |
- * | |
- * @param Boolean $decorated Whether to decorate the messages or not | |
- * | |
- * @api | |
- */ | |
- function setDecorated($decorated); | |
- | |
- /** | |
- * Gets the decorated flag. | |
- * | |
- * @return Boolean true if the output will decorate messages, false otherwise | |
- * | |
- * @api | |
- */ | |
- function isDecorated(); | |
- | |
- /** | |
- * Sets output formatter. | |
- * | |
- * @param OutputFormatterInterface $formatter | |
- * | |
- * @api | |
- */ | |
- function setFormatter(OutputFormatterInterface $formatter); | |
- | |
- /** | |
- * Returns current output formatter instance. | |
- * | |
- * @return OutputFormatterInterface | |
- * | |
- * @api | |
- */ | |
- function getFormatter(); | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Output/StreamOutput.php b/vendor/Symfony/Component/Console/Output/StreamOutput.php | |
deleted file mode 100755 | |
index de1720f..0000000 | |
--- a/vendor/Symfony/Component/Console/Output/StreamOutput.php | |
+++ /dev/null | |
@@ -1,113 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Output; | |
- | |
-use Symfony\Component\Console\Formatter\OutputFormatterInterface; | |
- | |
-/** | |
- * StreamOutput writes the output to a given stream. | |
- * | |
- * Usage: | |
- * | |
- * $output = new StreamOutput(fopen('php://stdout', 'w')); | |
- * | |
- * As `StreamOutput` can use any stream, you can also use a file: | |
- * | |
- * $output = new StreamOutput(fopen('/path/to/output.log', 'a', false)); | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- * | |
- * @api | |
- */ | |
-class StreamOutput extends Output | |
-{ | |
- private $stream; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * @param mixed $stream A stream resource | |
- * @param integer $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL, | |
- * self::VERBOSITY_VERBOSE) | |
- * @param Boolean $decorated Whether to decorate messages or not (null for auto-guessing) | |
- * @param OutputFormatter $formatter Output formatter instance | |
- * | |
- * @throws \InvalidArgumentException When first argument is not a real stream | |
- * | |
- * @api | |
- */ | |
- public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null) | |
- { | |
- if (!is_resource($stream) || 'stream' !== get_resource_type($stream)) { | |
- throw new \InvalidArgumentException('The StreamOutput class needs a stream as its first argument.'); | |
- } | |
- | |
- $this->stream = $stream; | |
- | |
- if (null === $decorated) { | |
- $decorated = $this->hasColorSupport($decorated); | |
- } | |
- | |
- parent::__construct($verbosity, $decorated, $formatter); | |
- } | |
- | |
- /** | |
- * Gets the stream attached to this StreamOutput instance. | |
- * | |
- * @return resource A stream resource | |
- */ | |
- public function getStream() | |
- { | |
- return $this->stream; | |
- } | |
- | |
- /** | |
- * Writes a message to the output. | |
- * | |
- * @param string $message A message to write to the output | |
- * @param Boolean $newline Whether to add a newline or not | |
- * | |
- * @throws \RuntimeException When unable to write output (should never happen) | |
- */ | |
- public function doWrite($message, $newline) | |
- { | |
- if (false === @fwrite($this->stream, $message.($newline ? PHP_EOL : ''))) { | |
- // @codeCoverageIgnoreStart | |
- // should never happen | |
- throw new \RuntimeException('Unable to write output.'); | |
- // @codeCoverageIgnoreEnd | |
- } | |
- | |
- fflush($this->stream); | |
- } | |
- | |
- /** | |
- * Returns true if the stream supports colorization. | |
- * | |
- * Colorization is disabled if not supported by the stream: | |
- * | |
- * - windows without ansicon | |
- * - non tty consoles | |
- * | |
- * @return Boolean true if the stream supports colorization, false otherwise | |
- */ | |
- protected function hasColorSupport() | |
- { | |
- // @codeCoverageIgnoreStart | |
- if (DIRECTORY_SEPARATOR == '\\') { | |
- return false !== getenv('ANSICON'); | |
- } | |
- | |
- return function_exists('posix_isatty') && @posix_isatty($this->stream); | |
- // @codeCoverageIgnoreEnd | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/README.md b/vendor/Symfony/Component/Console/README.md | |
deleted file mode 100755 | |
index d903776..0000000 | |
--- a/vendor/Symfony/Component/Console/README.md | |
+++ /dev/null | |
@@ -1,48 +0,0 @@ | |
-Console Component | |
-================= | |
- | |
-Console eases the creation of beautiful and testable command line interfaces. | |
- | |
-The Application object manages the CLI application: | |
- | |
- use Symfony\Component\Console\Application; | |
- | |
- $console = new Application(); | |
- $console->run(); | |
- | |
-The ``run()`` method parses the arguments and options passed on the command | |
-line and executes the right command. | |
- | |
-Registering a new command can easily be done via the ``register()`` method, | |
-which returns a ``Command`` instance: | |
- | |
- use Symfony\Component\Console\Input\InputInterface; | |
- use Symfony\Component\Console\Input\InputArgument; | |
- use Symfony\Component\Console\Input\InputOption; | |
- use Symfony\Component\Console\Output\OutputInterface; | |
- | |
- $console | |
- ->register('ls') | |
- ->setDefinition(array( | |
- new InputArgument('dir', InputArgument::REQUIRED, 'Directory name'), | |
- )) | |
- ->setDescription('Displays the files in the given directory') | |
- ->setCode(function (InputInterface $input, OutputInterface $output) { | |
- $dir = $input->getArgument('dir'); | |
- | |
- $output->writeln(sprintf('Dir listing for <info>%s</info>', $dir)); | |
- }) | |
- ; | |
- | |
-You can also register new commands via classes. | |
- | |
-The component provides a lot of features like output coloring, input and | |
-output abstractions (so that you can easily unit-test your commands), | |
-validation, automatic help messages, ... | |
- | |
-Resources | |
---------- | |
- | |
-Unit tests: | |
- | |
-https://github.com/symfony/symfony/tree/master/tests/Symfony/Tests/Component/Console | |
diff --git a/vendor/Symfony/Component/Console/Shell.php b/vendor/Symfony/Component/Console/Shell.php | |
deleted file mode 100755 | |
index 6b89b04..0000000 | |
--- a/vendor/Symfony/Component/Console/Shell.php | |
+++ /dev/null | |
@@ -1,206 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console; | |
- | |
-use Symfony\Component\Console\Application; | |
-use Symfony\Component\Console\Input\StringInput; | |
-use Symfony\Component\Console\Output\ConsoleOutput; | |
-use Symfony\Component\Process\ProcessBuilder; | |
-use Symfony\Component\Process\PhpExecutableFinder; | |
- | |
-/** | |
- * A Shell wraps an Application to add shell capabilities to it. | |
- * | |
- * Support for history and completion only works with a PHP compiled | |
- * with readline support (either --with-readline or --with-libedit) | |
- * | |
- * @author Fabien Potencier <[email protected]> | |
- * @author Martin Hasoň <[email protected]> | |
- */ | |
-class Shell | |
-{ | |
- private $application; | |
- private $history; | |
- private $output; | |
- private $hasReadline; | |
- private $prompt; | |
- private $processIsolation; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * If there is no readline support for the current PHP executable | |
- * a \RuntimeException exception is thrown. | |
- * | |
- * @param Application $application An application instance | |
- */ | |
- public function __construct(Application $application) | |
- { | |
- $this->hasReadline = function_exists('readline'); | |
- $this->application = $application; | |
- $this->history = getenv('HOME').'/.history_'.$application->getName(); | |
- $this->output = new ConsoleOutput(); | |
- $this->prompt = $application->getName().' > '; | |
- $this->processIsolation = false; | |
- } | |
- | |
- /** | |
- * Runs the shell. | |
- */ | |
- public function run() | |
- { | |
- $this->application->setAutoExit(false); | |
- $this->application->setCatchExceptions(true); | |
- | |
- if ($this->hasReadline) { | |
- readline_read_history($this->history); | |
- readline_completion_function(array($this, 'autocompleter')); | |
- } | |
- | |
- $this->output->writeln($this->getHeader()); | |
- $php = null; | |
- if ($this->processIsolation) { | |
- $finder = new PhpExecutableFinder(); | |
- $php = $finder->find(); | |
- $this->output->writeln(<<<EOF | |
-<info>Running with process isolation, you should consider this:</info> | |
- * each command is executed as separate process, | |
- * commands don't support interactivity, all params must be passed explicitly, | |
- * commands output is not colorized. | |
- | |
-EOF | |
- ); | |
- } | |
- | |
- while (true) { | |
- $command = $this->readline(); | |
- | |
- if (false === $command) { | |
- $this->output->writeln("\n"); | |
- | |
- break; | |
- } | |
- | |
- if ($this->hasReadline) { | |
- readline_add_history($command); | |
- readline_write_history($this->history); | |
- } | |
- | |
- if ($this->processIsolation) { | |
- $pb = new ProcessBuilder(); | |
- | |
- $process = $pb | |
- ->add($php) | |
- ->add($_SERVER['argv'][0]) | |
- ->add($command) | |
- ->inheritEnvironmentVariables(true) | |
- ->getProcess() | |
- ; | |
- | |
- $output = $this->output; | |
- $process->run(function($type, $data) use ($output) { | |
- $output->writeln($data); | |
- }); | |
- | |
- $ret = $process->getExitCode(); | |
- } else { | |
- $ret = $this->application->run(new StringInput($command), $this->output); | |
- } | |
- | |
- if (0 !== $ret) { | |
- $this->output->writeln(sprintf('<error>The command terminated with an error status (%s)</error>', $ret)); | |
- } | |
- } | |
- } | |
- | |
- /** | |
- * Returns the shell header. | |
- * | |
- * @return string The header string | |
- */ | |
- protected function getHeader() | |
- { | |
- return <<<EOF | |
- | |
-Welcome to the <info>{$this->application->getName()}</info> shell (<comment>{$this->application->getVersion()}</comment>). | |
- | |
-At the prompt, type <comment>help</comment> for some help, | |
-or <comment>list</comment> to get a list of available commands. | |
- | |
-To exit the shell, type <comment>^D</comment>. | |
- | |
-EOF; | |
- } | |
- | |
- /** | |
- * Tries to return autocompletion for the current entered text. | |
- * | |
- * @param string $text The last segment of the entered text | |
- * @return Boolean|array A list of guessed strings or true | |
- */ | |
- private function autocompleter($text) | |
- { | |
- $info = readline_info(); | |
- $text = substr($info['line_buffer'], 0, $info['end']); | |
- | |
- if ($info['point'] !== $info['end']) { | |
- return true; | |
- } | |
- | |
- // task name? | |
- if (false === strpos($text, ' ') || !$text) { | |
- return array_keys($this->application->all()); | |
- } | |
- | |
- // options and arguments? | |
- try { | |
- $command = $this->application->find(substr($text, 0, strpos($text, ' '))); | |
- } catch (\Exception $e) { | |
- return true; | |
- } | |
- | |
- $list = array('--help'); | |
- foreach ($command->getDefinition()->getOptions() as $option) { | |
- $list[] = '--'.$option->getName(); | |
- } | |
- | |
- return $list; | |
- } | |
- | |
- /** | |
- * Reads a single line from standard input. | |
- * | |
- * @return string The single line from standard input | |
- */ | |
- private function readline() | |
- { | |
- if ($this->hasReadline) { | |
- $line = readline($this->prompt); | |
- } else { | |
- $this->output->write($this->prompt); | |
- $line = fgets(STDIN, 1024); | |
- $line = (!$line && strlen($line) == 0) ? false : rtrim($line); | |
- } | |
- | |
- return $line; | |
- } | |
- | |
- public function getProcessIsolation() | |
- { | |
- return $this->processIsolation; | |
- } | |
- | |
- public function setProcessIsolation($processIsolation) | |
- { | |
- $this->processIsolation = (Boolean) $processIsolation; | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Tester/ApplicationTester.php b/vendor/Symfony/Component/Console/Tester/ApplicationTester.php | |
deleted file mode 100755 | |
index 9412fba..0000000 | |
--- a/vendor/Symfony/Component/Console/Tester/ApplicationTester.php | |
+++ /dev/null | |
@@ -1,102 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Tester; | |
- | |
-use Symfony\Component\Console\Application; | |
-use Symfony\Component\Console\Input\ArrayInput; | |
-use Symfony\Component\Console\Input\InputInterface; | |
-use Symfony\Component\Console\Output\OutputInterface; | |
-use Symfony\Component\Console\Output\StreamOutput; | |
- | |
-/** | |
- * @author Fabien Potencier <[email protected]> | |
- */ | |
-class ApplicationTester | |
-{ | |
- private $application; | |
- private $input; | |
- private $output; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * @param Application $application An Application instance to test. | |
- */ | |
- public function __construct(Application $application) | |
- { | |
- $this->application = $application; | |
- } | |
- | |
- /** | |
- * Executes the application. | |
- * | |
- * Available options: | |
- * | |
- * * interactive: Sets the input interactive flag | |
- * * decorated: Sets the output decorated flag | |
- * * verbosity: Sets the output verbosity flag | |
- * | |
- * @param array $input An array of arguments and options | |
- * @param array $options An array of options | |
- * | |
- * @return integer The command exit code | |
- */ | |
- public function run(array $input, $options = array()) | |
- { | |
- $this->input = new ArrayInput($input); | |
- if (isset($options['interactive'])) { | |
- $this->input->setInteractive($options['interactive']); | |
- } | |
- | |
- $this->output = new StreamOutput(fopen('php://memory', 'w', false)); | |
- if (isset($options['decorated'])) { | |
- $this->output->setDecorated($options['decorated']); | |
- } | |
- if (isset($options['verbosity'])) { | |
- $this->output->setVerbosity($options['verbosity']); | |
- } | |
- | |
- return $this->application->run($this->input, $this->output); | |
- } | |
- | |
- /** | |
- * Gets the display returned by the last execution of the application. | |
- * | |
- * @return string The display | |
- */ | |
- public function getDisplay() | |
- { | |
- rewind($this->output->getStream()); | |
- | |
- return stream_get_contents($this->output->getStream()); | |
- } | |
- | |
- /** | |
- * Gets the input instance used by the last execution of the application. | |
- * | |
- * @return InputInterface The current input instance | |
- */ | |
- public function getInput() | |
- { | |
- return $this->input; | |
- } | |
- | |
- /** | |
- * Gets the output instance used by the last execution of the application. | |
- * | |
- * @return OutputInterface The current output instance | |
- */ | |
- public function getOutput() | |
- { | |
- return $this->output; | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/Tester/CommandTester.php b/vendor/Symfony/Component/Console/Tester/CommandTester.php | |
deleted file mode 100755 | |
index 52be278..0000000 | |
--- a/vendor/Symfony/Component/Console/Tester/CommandTester.php | |
+++ /dev/null | |
@@ -1,100 +0,0 @@ | |
-<?php | |
- | |
-/* | |
- * This file is part of the Symfony package. | |
- * | |
- * (c) Fabien Potencier <[email protected]> | |
- * | |
- * For the full copyright and license information, please view the LICENSE | |
- * file that was distributed with this source code. | |
- */ | |
- | |
-namespace Symfony\Component\Console\Tester; | |
- | |
-use Symfony\Component\Console\Command\Command; | |
-use Symfony\Component\Console\Input\ArrayInput; | |
-use Symfony\Component\Console\Output\StreamOutput; | |
- | |
-/** | |
- * @author Fabien Potencier <[email protected]> | |
- */ | |
-class CommandTester | |
-{ | |
- private $command; | |
- private $input; | |
- private $output; | |
- | |
- /** | |
- * Constructor. | |
- * | |
- * @param Command $command A Command instance to test. | |
- */ | |
- public function __construct(Command $command) | |
- { | |
- $this->command = $command; | |
- } | |
- | |
- /** | |
- * Executes the command. | |
- * | |
- * Available options: | |
- * | |
- * * interactive: Sets the input interactive flag | |
- * * decorated: Sets the output decorated flag | |
- * * verbosity: Sets the output verbosity flag | |
- * | |
- * @param array $input An array of arguments and options | |
- * @param array $options An array of options | |
- * | |
- * @return integer The command exit code | |
- */ | |
- public function execute(array $input, array $options = array()) | |
- { | |
- $this->input = new ArrayInput($input); | |
- if (isset($options['interactive'])) { | |
- $this->input->setInteractive($options['interactive']); | |
- } | |
- | |
- $this->output = new StreamOutput(fopen('php://memory', 'w', false)); | |
- if (isset($options['decorated'])) { | |
- $this->output->setDecorated($options['decorated']); | |
- } | |
- if (isset($options['verbosity'])) { | |
- $this->output->setVerbosity($options['verbosity']); | |
- } | |
- | |
- return $this->command->run($this->input, $this->output); | |
- } | |
- | |
- /** | |
- * Gets the display returned by the last execution of the command. | |
- * | |
- * @return string The display | |
- */ | |
- public function getDisplay() | |
- { | |
- rewind($this->output->getStream()); | |
- | |
- return stream_get_contents($this->output->getStream()); | |
- } | |
- | |
- /** | |
- * Gets the input instance used by the last execution of the command. | |
- * | |
- * @return InputInterface The current input instance | |
- */ | |
- public function getInput() | |
- { | |
- return $this->input; | |
- } | |
- | |
- /** | |
- * Gets the output instance used by the last execution of the command. | |
- * | |
- * @return OutputInterface The current output instance | |
- */ | |
- public function getOutput() | |
- { | |
- return $this->output; | |
- } | |
-} | |
diff --git a/vendor/Symfony/Component/Console/composer.json b/vendor/Symfony/Component/Console/composer.json | |
deleted file mode 100755 | |
index 961212e..0000000 | |
--- a/vendor/Symfony/Component/Console/composer.json | |
+++ /dev/null | |
@@ -1,30 +0,0 @@ | |
-{ | |
- "name": "symfony/console", | |
- "type": "library", | |
- "description": "Symfony Console Component", | |
- "keywords": [], | |
- "homepage": "http://symfony.com", | |
- "license": "MIT", | |
- "authors": [ | |
- { | |
- "name": "Fabien Potencier", | |
- "email": "[email protected]" | |
- }, | |
- { | |
- "name": "Symfony Community", | |
- "homepage": "http://symfony.com/contributors" | |
- } | |
- ], | |
- "require": { | |
- "php": ">=5.3.2" | |
- }, | |
- "autoload": { | |
- "psr-0": { "Symfony\\Component\\Console": "" } | |
- }, | |
- "target-dir": "Symfony/Component/Console", | |
- "extra": { | |
- "branch-alias": { | |
- "dev-master": "2.1-dev" | |
- } | |
- } | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment