Código PHP:
require_once 'Zend/Controller/Action/Helper/FlashMessenger.php';
class Carlos_Controller_Action_Helper_FlashMessengerModificado extends Zend_Controller_Action_Helper_FlashMessenger {
const ERROR = 'error';
const WARNING = 'warning';
const NOTICE = 'notice';
const SUCCESS = 'success';
protected $_namespace = 'default';
public function addError($message, $class = null, $method = null) {
return $this->_addMessage($message, self::ERROR, $class, $method);
}
public function addSuccess($message, $class = null, $method = null) {
return $this->_addMessage($message, self::SUCCESS, $class, $method);
;
}
public function addWarning($message, $class = null, $method = null) {
return $this->_addMessage($message, self::WARNING, $class, $method);
;
}
public function addNotice($message, $class = null, $method = null) {
return $this->_addMessage($message, self::NOTICE, $class, $method);
;
}
protected function _addMessage($message, $type, $class = null, $method = null) {
if (self::$_messageAdded === false) {
self::$_session->setExpirationHops(1, null, true);
}
if (!is_array(self::$_session->{$this->_namespace})) {
self::$_session->{$this->_namespace}[$type] = array();
}
self::$_session->{$this->_namespace}[$type][] = $this->_factory($message, $type, $class, $method);
return $this;
}
protected function _factory($message, $type, $class = null, $method = null) {
$messg = new stdClass();
$messg->message = $message;
$messg->type = $type;
$messg->class = $class;
$messg->method = $method;
return $messg;
}
public function getMessages($type = null) {
if ($type === null) {
return parent::getMessages();
}
if (isset(self::$_messages[$this->_namespace][$type])) {
return self::$_messages[$this->_namespace][$type];
}
return array();
}
public function getCurrentMessages($type = null) {
if ($type === null) {
return parent::getCurrentMessages();
}
if (isset(self::$_session->{$this->_namespace}[$type])) {
return self::$_session->{$this->_namespace}[$type];
}
return array();
}
}
Código PHP:
class Carlos_View_Helper_FlashMessenger extends Zend_View_Helper_FormElement{
//put your code here
#
private $_types = array(
Carlos_Controller_Action_Helper_FlashMessengerModificado::ERROR,
Carlos_Controller_Action_Helper_FlashMessengerModificado::WARNING,
Carlos_Controller_Action_Helper_FlashMessengerModificado::NOTICE,
Carlos_Controller_Action_Helper_FlashMessengerModificado::SUCCESS
);
public function flashMessenger()
{
$flashMessenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessengerModificado');
$html = '';
foreach ($this->_types as $type) {
$messages = $flashMessenger->getMessages($type);
if (!$messages){
$messages = $flashMessenger->getCurrentMessages($type);
}
if ($messages) {
if ( !$html ) {
$html .= '<ul class="messages">';
}
$html .= '<li class="' . $type . '-msg">';
$html .= '<ul>';
foreach ( $messages as $message ) {
$html.= '<li>';
$html.= $message->message;
$html.= '</li>';
}
$html .= '</ul>';
$html .= '</li>';
}
}
if ( $html) {
$html .= '</ul>';
}
return $html;
}
}
library\carlos\controller\action\helper\FlashMesse ngerModificado.php y el view Helper
library\carlos\view\helper\FlashMesenger.php
mi pregunta es la siguiente donde llamo a mi FlashMessengerModificado.php yo lo instancio o defino en el init() del controller que lo voy a utilizar
Código PHP:
$this->_flashMessenger = $this->_helper->getHelper('FlashMessengerModificado');
Código PHP:
<div id="messages"><?php echo $this->flashMessenger(); ?></div>
[PPHP]atal error: Uncaught exception ‘Zend_Loader_PluginLoader_Exception’ with message ‘Plugin by name ‘FlashMessenger’ was not found in the registry; used paths: Zend_View_Helper_: Zend/View/Helper/;C:\xampp\htdocs\siscavj\application/views\helpers/’ in C:\xampp\htdocs\zframework\library\Zend\Loader\Plu ginLoader.php:406 Stack trace: #0 C:\xampp\htdocs\zframework\library\Zend\View\Abstr act.php(1170): Zend_Loader_PluginLoader->load(’FlashMessenger’) #1 C:\xampp\htdocs\zframework\library\Zend\View\Abstr act.php(610): Zend_View_Abstract->_getPlugin(’helper’, ‘flashMessenger’) #2 C:\xampp\htdocs\zframework\library\Zend\View\Abstr act.php(336): Zend_View_Abstract->getHelper(’flashMessenger’) #3 [internal function]: Zend_View_Abstract->__call(’flashMessenger’, Array) #4 C:\xampp\htdocs\siscavj\application\layouts\script s\layout.phtml(63): Zend_View->flashMessenger() #5 C:\xampp\htdocs\zframework\library\Zend\View.php(1 08): include(’C:\xampp\htdocs…’) #6 C:\xampp\htdocs\zframework\library\Zend\View\Abstr act.php(880): Zend_View->_run( in C:\xampp\htdocs\zframework\library\Zend\Loader\Plu ginLoader.php on line 406[/PHP]
y helper view que me cree no se donde llamar o donde debo llamar
por favor les estare agradecido por la ayuda