Source

zf-form-builder / www / system / modules / blog / controllers / EntryController.php

Full commit
<?php
class Blog_EntryController extends ZendY_Controller_Action
{
    public function listAction()
    {
        $service = new Blog_Service_Entry();
        $this->view->entries = $entries = $service->getPage($this->_getParam('page'));
        $this->view->routeName('blog_entry_list');

        if ($this->_helper->isEmpty($entries)) {
            $this->_forward('empty-list');
            return;
        }

        $this->page(__METHOD__);
    }

    public function showAction()
    {
        $service = new Blog_Service_Entry();
        $this->view->entry = $entry = $service->get($this->_getParam('title_slug'));
        $this->_helper->isEmpty->notFound($entry);

        $this->page(__METHOD__);
    }

    public function newAction()
    {
        $service = new Blog_Service_Entry();
        $this->view->form = $form = $service->getForm();

        $this->processForm($form);

        $this->page(__METHOD__);
    }

    public function editAction()
    {
        $entry = $service->get($this->_getParam('title_slug'));
        $this->_helper->isEmpty->notFound($entry);

        $service = new Blog_Service_Entry();
        $this->view->form = $form = $service->getForm($entry);

        $this->processForm($form);

        $this->page(__METHOD__);
    }

    public function deleteAction()
    {
        $service = new Blog_Service_Entry();
        $service->delete($this->_getParam('title_slug'));

        $this->_helper->redirector->gotoRoute(array(), 'blog_entry_list', true);
    }

    public function emptyListAction()
    {
        $this->page(__METHOD__);
    }

    public function processForm($form)
    {
        if ($this->_request->isPost()) {
            if ($form->isValidAndPopulate($this->_request->getPost())) {
                $form->save();

                $this->_helper->redirector->gotoRoute(array(), 'blog_entry_list',
                        true);
                return;
            }
        }
    }
}