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

Fixed Phalcon\Mvc\View::render #13087

Merged
merged 1 commit into from
Sep 24, 2017
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
2 changes: 1 addition & 1 deletion CHANGELOG-3.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- Fixed `Phalcon\Mvc\Model\Query::_executeSelect` threw RuntimeException, if db:beforeQuery() returned false
- Internal cookies property is now always an array [#12978](https://github.com/phalcon/cphalcon/issues/12978)
- Fixed `Phalcon\Validation\Validator\File::validate` to work properly with parameter 'message' [#12947](https://github.com/phalcon/cphalcon/issues/12947)

- Fixed `Phalcon\Mvc\View::render` to render a view with params [#13046](https://github.com/phalcon/cphalcon/issues/13046)

# [3.2.2](https://github.com/phalcon/cphalcon/releases/tag/v3.2.2) (2017-08-14)
- Fixed `Phalcon\Db\Adapter\Pdo\Postgresql::describeColumns` to work properly with `DOUBLE PRECISION` and `REAL` data types [#12842](https://github.com/phalcon/cphalcon/issues/12842)
Expand Down
11 changes: 8 additions & 3 deletions phalcon/mvc/view.zep
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,10 @@ class View extends Injectable implements ViewInterface

/**
* Gets extra parameters of the action rendered
*
* @deprecated Will be removed in 4.0.0
*/
public function getParams() -> array
deprecated public function getParams() -> array
{
return this->_params;
}
Expand Down Expand Up @@ -785,8 +787,11 @@ class View extends Injectable implements ViewInterface
}

let this->_controllerName = controllerName,
this->_actionName = actionName,
this->_params = params;
this->_actionName = actionName;

if typeof params == "array" {
this->setVars(params);
}

/**
* Check if there is a layouts directory set
Expand Down
4 changes: 3 additions & 1 deletion phalcon/mvc/viewinterface.zep
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ interface ViewInterface extends ViewBaseInterface

/**
* Gets extra parameters of the action rendered
*
* @deprecated Will be removed in 4.0.0
*/
public function getParams() -> array;
deprecated public function getParams() -> array;

/**
* Starts rendering process enabling the output buffering
Expand Down
6 changes: 6 additions & 0 deletions tests/_data/views/test2/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 $age years old";
23 changes: 23 additions & 0 deletions tests/unit/Mvc/ViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,29 @@ function () {
);
}

/**
* Tests View::render with params
*
* @author Serghei Iakovlev <serghei@phalconphp.com>
* @since 2017-09-24
* @issue 13046
*/
public function shouldRenderWithParams()
{
$this->specify(
"The View component doesn't render view with params",
function () {
$view = new View();
$view->setViewsDir(PATH_DATA . 'views' . DIRECTORY_SEPARATOR);

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

expect($view->getContent())->equals("<html>My name is Sam and I am 20 years old</html>\n");
}
);
}

/**
* Tests View::setMainView
Expand Down