Where does this method belong to the zend structure?

I have some of the reusable functions that I want to use in my controller to manage the ajax data in my controller. as the controller has no idea (since it is AJAX). I want to know where this method rightfully belongs to the Zend Framework

function blockUnblock($value, $id) {
    $image = ($value == 0) ? 'tick.png' : 'tock.png';
    $alt = ($value == 0) ? 'Yes' : 'No';
    $src = '<a class="toggle" href="#toggle">';
    $src .= '<img src = "/css/images/'.$image.'" alt = "'.$alt.'" data-id = "'.$id.'" data-block = "'.$value.'"/>';
    $src .= '</a>';
    return $src;
}

I need to reuse this method for different controllers and actions.

what helper method does it belong to?

+3
source share
2 answers

html, , , . , AjaxContext json- ( , viewcript). , , :

$imageLink = $this->view->blockUnblock($value, $id);
$this->view->imageLink = $imageLink;

:

// .../views/helpers/BlockUnblock.php
class Zend_View_Helper_BlockUnblock extends Zend_View_Helper_Abstract
{

    public function blockUnblock($value, $id)
    {
        $image = ($value == 0) ? 'tick.png' : 'tock.png';
        $alt = ($value == 0) ? 'Yes' : 'No';
        $src = '<a class="toggle" href="#toggle">';
        $src .= '<img src = "/css/images/'.$image.'" alt = "'.$alt.'" data-id = "'.$id.'" data-block = "'.$value.'"/>';
        $src .= '</a>';
        return $src;
    }
}
+4

( ) .

-, . , / .

- . ( ) -, .

+2

All Articles