Skip to content
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

Returning Instead Of Breaking - Stop Processing Additional View Directories #14526

Merged
merged 4 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
- Fixed `Phalcon\Mvc\Model\MetaDataInterface::getIdentityField` and `Phalcon\Mvc\Model\MetaData::getIdentityField` to also return `null` if the identity field is not present [#14523](https://github.com/phalcon/cphalcon/issues/14523)
- Fixed `Phalcon\Storage\Serializer\Json` to serialize objects that implement the `JsonSerializable` interface [#14528](https://github.com/phalcon/cphalcon/issues/14528)
- Fixed `Phalcon\Collection` to correctly return one level nested objects that implement `JsonSerializable` [#14528](https://github.com/phalcon/cphalcon/issues/14528)
- Fixed `Phalcon\Mvc\View` to only include first found instance of view when using multiple view directories [#12977](https://github.com/phalcon/cphalcon/issues/12977)

## Removed
- Removed `Phalcon\Logger\Formatter\Syslog` - really did not do much [#14523](https://github.com/phalcon/cphalcon/issues/14523)
Expand Down
37 changes: 14 additions & 23 deletions phalcon/Mvc/View.zep
Original file line number Diff line number Diff line change
Expand Up @@ -929,12 +929,10 @@ class View extends Injectable implements ViewInterface, EventsAwareInterface
bool silence,
bool mustClean = true
) {
bool notExists;
var basePath, engine, eventsManager, extension, viewsDir, viewsDirPath,
viewEnginePath, viewEnginePaths, viewParams;

let notExists = true,
basePath = this->basePath,
let basePath = this->basePath,
viewParams = this->viewParams,
eventsManager = <ManagerInterface> this->eventsManager,
viewEnginePaths = [];
Expand Down Expand Up @@ -967,37 +965,30 @@ class View extends Injectable implements ViewInterface, EventsAwareInterface

engine->render(viewEnginePath, viewParams, mustClean);

/**
* Call afterRenderView if there is an events manager
* available
*/
let notExists = false;

if typeof eventsManager == "object" {
eventsManager->fire("view:afterRenderView", this);
}
break;

return;
}

let viewEnginePaths[] = viewEnginePath;
}
}

if notExists {
/**
* Notify about not found views
*/
if typeof eventsManager == "object" {
let this->activeRenderPaths = viewEnginePaths;
/**
* Notify about not found views
*/
if typeof eventsManager == "object" {
let this->activeRenderPaths = viewEnginePaths;

eventsManager->fire("view:notFoundView", this, viewEnginePath);
}
eventsManager->fire("view:notFoundView", this, viewEnginePath);
}

if !silence {
throw new Exception(
"View '" . viewPath . "' was not found in any of the views directory"
);
}
if !silence {
throw new Exception(
"View '" . viewPath . "' was not found in any of the views directory"
);
}
}

Expand Down
6 changes: 6 additions & 0 deletions tests/_data/fixtures/views-alt/simple/params.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
/**
* @var string $name
* @var int $age
*/
echo "My name is $name and I am not $age years old";
30 changes: 30 additions & 0 deletions tests/integration/Mvc/View/RenderCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,34 @@ public function shouldRenderWithParams(IntegrationTester $I)
$view->getContent()
);
}

public function doesNotRenderMultiple(IntegrationTester $I)
{
$view = new View();

$view->setViewsDir(
[
dataDir('fixtures/views'),
dataDir('fixtures/views-alt')
]
);

$view->start();

$view->render(
'simple',
'params',
[
'name' => 'Sam',
'age' => 20,
]
);

$view->finish();

$I->assertEquals(
'My name is Sam and I am 20 years old',
$view->getContent()
);
}
}