Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
set view names in abstract responder, not in browse responder
  • Loading branch information
Paul M. Jones committed May 12, 2014
1 parent fe0f291 commit e7df9e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
22 changes: 22 additions & 0 deletions example-code/Blog/Responder/AbstractBlogResponder.php
Expand Up @@ -5,6 +5,28 @@

abstract class AbstractBlogResponder extends AbstractResponder
{
protected function init()
{
$view_names = array(
'browse',
'read',
'edit',
'add',
'delete-failure',
'delete-success',
'_form',
'_intro',
);

$view_registry = $this->view->getViewRegistry();
foreach ($view_names as $view_name) {
$view_registry->set(
$view_name,
__DIR__ . "/views/{$view_name}.php"

This comment has been minimized.

Copy link
@harikt

harikt May 12, 2014

Contributor

good idea. By the way can't we set a directory and let the name can be the file name ?

);
}
}

protected function notFound($key)
{
if (! $this->data->$key) {
Expand Down
23 changes: 0 additions & 23 deletions example-code/Blog/Responder/BlogBrowseResponder.php
Expand Up @@ -5,29 +5,6 @@ class BlogBrowseResponder extends AbstractBlogResponder
{
public function __invoke()
{
$view_registry = $this->view->getViewRegistry();
$view_registry->set('browse', __DIR__ . '/views/browse.php');
$view_registry->set('_intro', __DIR__ . '/views/_intro.php');
/*
$this->data->items = array(
array(
'name' => 'Something',
'cost' => 23
),
array(
'name' => 'Many',
'cost' => 23
)
);
$view_registry->set('item_rows', function () {
foreach ($this->items as $item) {
echo $this->render('item_row', array('item' => $item));
}
});
$view_registry->set('item_row', function () {
echo $item['name'] . ' costs ' . $item['price'] . PHP_EOL;
});
*/
return $this->notFound('collection')
|| $this->responseView('browse');
}
Expand Down

0 comments on commit e7df9e5

Please sign in to comment.