Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6462814

Browse filesBrowse files
committed
[Framework] Fixed command registration magic to work when commands have sub-namespaces.
1 parent 92130c3 commit 6462814
Copy full SHA for 6462814

File tree

Expand file treeCollapse file tree

2 files changed

+6
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-6
lines changed

‎src/Symfony/Framework/Bundle/Bundle.php

Copy file name to clipboardExpand all lines: src/Symfony/Framework/Bundle/Bundle.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,16 @@ public function getReflection()
122122
*/
123123
public function registerCommands(Application $application)
124124
{
125-
if (!is_dir($dir = $this->getPath().'/Command')) {
125+
if (!$dir = realpath($this->getPath().'/Command')) {
126126
return;
127127
}
128128

129129
$finder = new Finder();
130130
$finder->files()->name('*Command.php')->in($dir);
131131

132-
$prefix = $this->namespacePrefix.'\\'.$this->name.'\\Command\\';
132+
$prefix = $this->namespacePrefix.'\\'.$this->name.'\\Command';
133133
foreach ($finder as $file) {
134-
$r = new \ReflectionClass($prefix.basename($file, '.php'));
134+
$r = new \ReflectionClass($prefix.strtr($file->getPath(), array($dir => '', '/' => '\\')).'\\'.basename($file, '.php'));
135135
if ($r->isSubclassOf('Symfony\\Components\\Console\\Command\\Command') && !$r->isAbstract()) {
136136
$application->addCommand($r->newInstance());
137137
}

‎src/Symfony/Framework/bootstrap.php

Copy file name to clipboardExpand all lines: src/Symfony/Framework/bootstrap.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ public function getReflection()
7575

7676
public function registerCommands(Application $application)
7777
{
78-
if (!is_dir($dir = $this->getPath().'/Command')) {
78+
if (!$dir = realpath($this->getPath().'/Command')) {
7979
return;
8080
}
8181

8282
$finder = new Finder();
8383
$finder->files()->name('*Command.php')->in($dir);
8484

85-
$prefix = $this->namespacePrefix.'\\'.$this->name.'\\Command\\';
85+
$prefix = $this->namespacePrefix.'\\'.$this->name.'\\Command';
8686
foreach ($finder as $file) {
87-
$r = new \ReflectionClass($prefix.basename($file, '.php'));
87+
$r = new \ReflectionClass($prefix.strtr($file->getPath(), array($dir => '', '/' => '\\')).'\\'.basename($file, '.php'));
8888
if ($r->isSubclassOf('Symfony\\Components\\Console\\Command\\Command') && !$r->isAbstract()) {
8989
$application->addCommand($r->newInstance());
9090
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.