8000 [TwigBridge] Added bundle name suggestion on wrongly overrided templates paths by pmontoya · Pull Request #26919 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[TwigBridge] Added bundle name suggestion on wrongly overrided templates paths #26919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 19, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refs #26898
Check if projectDir is not null before loop
  • Loading branch information
Pascal Montoya committed Jun 18, 2018
commit da42b3e23c3975ac05f17f3244407eb8786e227b
8 changes: 4 additions & 4 deletions src/Symfony/Bridge/Twig/Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,13 @@ private function findWrongBundleOverrides(): array
$alternatives = array();
$bundleNames = array();

if ($this->rootDir) {
if ($this->rootDir && $this->projectDir) {
$folders = glob($this->rootDir.'/Resources/*/views', GLOB_ONLYDIR);
$relativePath = ltrim(substr($this->rootDir.'/Resources/', \strlen($this->projectDir)), DIRECTORY_SEPARATOR);
$bundleNames = array_reduce(
$folders,
function ($carry, $absolutePath) use ($relativePath) {
if (null !== $this->projectDir && 0 === strpos($absolutePath, $this->projectDir)) {
if (0 === strpos($absolutePath, $this->projectDir)) {
$name = basename(\dirname($absolutePath));
$path = $relativePath.$name;
$carry[$name] = $path;
Expand All @@ -292,13 +292,13 @@ function ($carry, $absolutePath) use ($relativePath) {
);
}

if ($this->twigDefaultPath) {
if ($this->twigDefaultPath && $this->projectDir) {
$folders = glob($this->twigDefaultPath.'/bundles/*', GLOB_ONLYDIR);
$relativePath = ltrim(substr($this->twigDefaultPath.'/bundles', \strlen($this->projectDir)), DIRECTORY_SEPARATOR);
$bundleNames = array_reduce(
$folders,
function ($carry, $absolutePath) use ($relativePath) {
if (null !== $this->projectDir && 0 === strpos($absolutePath, $this->projectDir)) {
if (0 === strpos($absolutePath, $this->projectDir)) {
$path = ltrim(substr($absolutePath, \strlen($this->projectDir)), DIRECTORY_SEPARATOR);
$name = ltrim(substr($path, \strlen($relativePath)), DIRECTORY_SEPARATOR);
$carry[$name] = $path;
Expand Down
0