Skip to content

Commit

Permalink
Code cleanup and improvemnt for overriding standard widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
Denys Kyselov committed Nov 14, 2014
1 parent b0b851f commit 76d48ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/View/Helper/FormHelper.php
Expand Up @@ -202,8 +202,10 @@ public function __construct(View $View, array $config = []) {
unset($config['registry']);
}
if (isset($config['widgets'])) {
if (is_string($config['widgets'])) $config['widgets'] = [$config['widgets']];
$widgets = $widgets + $config['widgets'];
if (is_string($config['widgets'])) {
$config['widgets'] = (array)$config['widgets'];
}
$widgets += $config['widgets'];
unset($config['widgets']);
}

Expand Down
8 changes: 6 additions & 2 deletions src/View/Widget/WidgetRegistry.php
Expand Up @@ -65,6 +65,9 @@ public function __construct(StringTemplate $templates, View $view, $widgets = []
$this->add($widgets);
}
$this->_widgets['_view'] = $view;
debug($this->_widgets);
exit();

}

/**
Expand Down Expand Up @@ -104,7 +107,7 @@ public function load($file) {
* @throws \RuntimeException When class does not implement WidgetInterface.
*/
public function add(array $widgets) {
foreach ($widgets as $object) {
foreach ($widgets as $key=>$object) {
if (gettype($object) === 'object' &&
!($object instanceof WidgetInterface)
) {
Expand All @@ -113,9 +116,10 @@ public function add(array $widgets) {
);
} elseif (is_string($object)){
$this->load($object);
unset($widgets[$key]);
}
}
$this->_widgets = $widgets + $this->_widgets;
$this->_widgets += $widgets;
}

/**
Expand Down

0 comments on commit 76d48ed

Please sign in to comment.