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

<?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;
            }
        }
    }
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.