Skip to content

Commit

Permalink
Merge pull request #13087 from sergeyklay/3.2.x
Browse files Browse the repository at this point in the history
Fixed Phalcon\Mvc\View::render
  • Loading branch information
sergeyklay authored Sep 24, 2017
2 parents c43f5ee + 3f70383 commit f03af41
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
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

0 comments on commit f03af41

Please sign in to comment.