Permalink
Browse files

Added check for Parent* and Child* records and try to use the Decorat…

…or that matches the model name without parent or child
  • Loading branch information...
Joey Trapp
Joey Trapp committed Apr 18, 2012
1 parent c0054f8 commit a006dbdbb14ab2874d23e916b784b967e60db990
Showing with 10 additions and 2 deletions.
  1. +10 −2 View/Decorator/Decorator.php
@@ -102,11 +102,19 @@ protected function _buildAssociations($data) {
is_array($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))) {
- $this->{$key} = DecoratorFactory::build($key, $value, $key);
+ $method = "build";
} else {
- $this->{$key} = DecoratorFactory::create($key, $value, $key);
+ $method = "create";
}
+ $this->{$key} = DecoratorFactory::$method($_key, $value, $key);
unset($data[$key]);
}
}

0 comments on commit a006dbd

Please sign in to comment.