Skip to content

Commit

Permalink
Added check for Parent* and Child* records and try to use the Decorat…
Browse files Browse the repository at this point in the history
…or that matches the model name without parent or child
  • Loading branch information
Joey Trapp committed Apr 18, 2012
1 parent c0054f8 commit a006dbd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions View/Decorator/Decorator.php
Expand Up @@ -102,11 +102,19 @@ protected function _buildAssociations($data) {
is_array($value) && is_array($value) &&
!empty($value) !empty($value)
) { ) {
$_key = $key;
if (preg_match("/^(Parent){1}(.*)/", $key)) {
$_key = str_replace("Parent", "", $key);
}
if (preg_match("/^(Child){1}(.*)/", $key)) {
$_key = str_replace("Child", "", $key);
}
if (preg_match("/[0-9]+/", key($value))) { if (preg_match("/[0-9]+/", key($value))) {
$this->{$key} = DecoratorFactory::build($key, $value, $key); $method = "build";
} else { } else {
$this->{$key} = DecoratorFactory::create($key, $value, $key); $method = "create";
} }
$this->{$key} = DecoratorFactory::$method($_key, $value, $key);
unset($data[$key]); unset($data[$key]);
} }
} }
Expand Down

0 comments on commit a006dbd

Please sign in to comment.