Skip to content

Commit

Permalink
Adding in the load* handling for preloading complex properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Cornutt committed May 18, 2016
1 parent 0573f3f commit bcc0dbe
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Modler/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public function __construct(array $data = array())
$this->load($data);
}
}

/**
* Checks if a given property is set on the model.
*
*
* @param string $name Property name
*/
public function __isset($name)
public function __isset($name)
{
return array_key_exists($name, $this->properties);
return array_key_exists($name, $this->properties);
}

/**
Expand Down Expand Up @@ -270,6 +270,12 @@ public function load(array $data, $enforceGuard = true)
{
if (array_key_exists($name, $this->properties)) {
$property = $this->properties[$name];

$method = 'load'.ucwords($name);
if (method_exists($this, $method) == true) {
$value = $this->$method($value);
}

if ($enforceGuard === true) {
if (!isset($property['guarded'])
|| (isset($property['guarded']) && $property['guarded'] === false)
Expand Down

0 comments on commit bcc0dbe

Please sign in to comment.