Skip to content

Instantly share code, notes, and snippets.

@vespakoen
Created June 11, 2012 22:00
Show Gist options
  • Save vespakoen/2913014 to your computer and use it in GitHub Desktop.
Save vespakoen/2913014 to your computer and use it in GitHub Desktop.
3.1.9 - 3.2.0
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 <taylorotwell@gmail.com>
* @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 <taylorotwell@gmail.com>
* @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 <taylorotwell@gmail.com>
* @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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- */
-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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- */
-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 <fabien@symfony.com>
- *
- * 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 <ever.zet@gmail.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <ever.zet@gmail.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <ever.zet@gmail.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <ever.zet@gmail.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- */
-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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- */
-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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- */
-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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- */
-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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- */
-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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- */
-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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <darek.krk@gmail.com>
- */
-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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- *
- * @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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- * @author Martin Hasoň <martin.hason@gmail.com>
- */
-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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- */
-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 <fabien@symfony.com>
- *
- * 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 <fabien@symfony.com>
- */
-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": "fabien@symfony.com"
- },
- {
- "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