前回は,
表示項目の検討とアプリケーションへの反映-エントリー一覧画面
エントリー一覧フローが持つ唯一の画面であるエントリー一覧画面は,
/path/
<h4 class="date-header">List</h4>
<table border="1">
<tr flexy:foreach="entries,entry">
<td><a href="{__appRootPath}/edit.php?id={entry.id}">{entry.title}</a></td>
</tr>
</table>
画面を見て頂くとわかるように,
モックオブジェクトの作成-エントリー一覧フロー
このような場合は,
/path/
firstState: DisplayList
viewState:
- name: DisplayList
view: List
activity:
class: Entry_ListAction
method: doActivityOnDisplayList
/path/
<?php
require_once 'Piece/Unity/Service/FlowAction.php';
require_once 'Piece/Unity/Service/FlexyElement.php';
class Entry_ListAction extends Piece_Unity_Service_FlowAction
{
var $_entries = array();
function Entry_ListAction()
{
$entry = &new stdClass();
$entry->id = 1;
$entry->title = 'Foo';
$this->_entries[] = &$entry;
$entry = &new stdClass();
$entry->id = 2;
$entry->title = 'Bar';
$this->_entries[] = &$entry;
$entry = &new stdClass();
$entry->id = 3;
$entry->title = 'Baz';
$this->_entries[] = &$entry;
}
function doActivityOnDisplayList()
{
$viewElement = &$this->_context->getViewElement();
$viewElement->setElementByRef('entries', $this->_entries);
}
}
?>
変更が完了したら,
今度は,