Phalcon\Validation:bind($entity, $data)
actually does NOT assign data to entity - in opposite to what the docs here informs us.
/**
* Assigns the data to an entity
* The entity is used to obtain the validation values
*
* @param object entity
* @param array|object data
* @return \Phalcon\Validation
*/
public function bind(entity, data) -> <Validation>
{
// ...
}
According to the docs I am expecting something like this:
$_GET = [
'lat' => 12.121212,
'lon' => 22.222222,
];
$validation = new PositionValidation();
$position = new Position(); //empty object with "lat", "lon" properties; setters and getters are there
$validation->bind($position, $_GET();
$validation->validate();
var_dump($position); //data are valid so I would like to properties within $position object to be populated by $validation object.
The problem is it does not happen.
The example here is with 2x properties but my case is an API call with about 15 properties. What I was expecting that using Phalcon I can populate the entity object with data from the array so that I don't need to write lot of setting lines.
My questions:
(1) Is this expected behaviour?
(2) Is there a way I can achieve my goal which is easly populate an entity with many properties from $_GET
array after data are being validated?
Thanks in advance!