Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
d4c51147
Commit
d4c51147
authored
Jan 25, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code quality and backreference support in controllers.
parent
ae56f68c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
7 deletions
+35
-7
grammar.php
laravel/database/grammar.php
+5
-1
schema.php
laravel/database/schema.php
+2
-3
controller.php
laravel/routing/controller.php
+28
-3
No files found.
laravel/database/grammar.php
View file @
d4c51147
...
@@ -30,7 +30,11 @@ abstract class Grammar {
...
@@ -30,7 +30,11 @@ abstract class Grammar {
{
{
$segments
=
explode
(
' '
,
$value
);
$segments
=
explode
(
' '
,
$value
);
return
$this
->
wrap
(
$segments
[
0
])
.
' AS '
.
$this
->
wrap
(
$segments
[
2
]);
return
sprintf
(
'%s AS %s'
,
$this
->
wrap
(
$segments
[
0
]),
$this
->
wrap
(
$segments
[
2
])
);
}
}
// Since columns may be prefixed with their corresponding table
// Since columns may be prefixed with their corresponding table
...
...
laravel/database/schema.php
View file @
d4c51147
...
@@ -75,9 +75,8 @@ class Schema {
...
@@ -75,9 +75,8 @@ class Schema {
}
}
// For some extra syntax sugar, we'll check for any implicit
// For some extra syntax sugar, we'll check for any implicit
// indexes on the table. The developer may specify the index
// indexes on the table since the developer may specify the
// type on the fluent column declaration. Here we'll find
// index type on the fluent column declaration.
// any implicit indexes and add the commands.
foreach
(
$table
->
columns
as
$column
)
foreach
(
$table
->
columns
as
$column
)
{
{
foreach
(
array
(
'primary'
,
'unique'
,
'fulltext'
,
'index'
)
as
$key
)
foreach
(
array
(
'primary'
,
'unique'
,
'fulltext'
,
'index'
)
as
$key
)
...
...
laravel/routing/controller.php
View file @
d4c51147
...
@@ -57,16 +57,41 @@ abstract class Controller {
...
@@ -57,16 +57,41 @@ abstract class Controller {
list
(
$controller
,
$method
)
=
explode
(
'@'
,
$destination
);
list
(
$controller
,
$method
)
=
explode
(
'@'
,
$destination
);
list
(
$method
,
$parameters
)
=
static
::
backreference
(
$method
,
$parameters
);
$controller
=
static
::
resolve
(
$bundle
,
$controller
);
$controller
=
static
::
resolve
(
$bundle
,
$controller
);
// If the controller could not be resolved, we're out of options and
will
// If the controller could not be resolved, we're out of options and
//
return the 404 error response. Of course, i
f we found the controller,
//
will return the 404 error response. I
f we found the controller,
// we can
go ahead and
execute the requested method on the instance.
// we can execute the requested method on the instance.
if
(
is_null
(
$controller
))
return
Response
::
error
(
'404'
);
if
(
is_null
(
$controller
))
return
Response
::
error
(
'404'
);
return
$controller
->
execute
(
$method
,
$parameters
);
return
$controller
->
execute
(
$method
,
$parameters
);
}
}
/**
* Replace all back-references on the given method.
*
* @param string $method
* @param array $parameters
* @return array
*/
protected
static
function
backreference
(
$method
,
$parameters
)
{
// Controller delegates may use back-references to the action parameters,
// which allows the developer to setup more flexible rouets to their
// controllers with less code. We will replace the back-references
// with their corresponding parameter value.
foreach
(
$parameters
as
$key
=>
$value
)
{
$method
=
str_replace
(
'(:'
.
(
$key
+
1
)
.
')'
,
$value
,
$method
,
$count
);
if
(
$count
>
0
)
unset
(
$parameters
[
$key
]);
}
return
array
(
str_replace
(
'$1'
,
'index'
,
$method
),
$parameters
);
}
/**
/**
* Resolve a bundle and controller name to a controller instance.
* Resolve a bundle and controller name to a controller instance.
*
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment