Zend FR

Consultez la FAQ sur le ZF avant de poster une question

Vous n'êtes pas identifié.

#1 21-09-2007 17:41:13

zudre
Membre
Date d'inscription: 10-05-2007
Messages: 21

Problème avec redirector

Bonjour,

J'ai un problème avec mes redirection.  J'utilise ZF avec les views autorender.  Depuis ce changement, je ne suis plus capable d'utiliser de $this->_foward().  Dans mes contrôlleurs, j'utilise toujours la structure suivante:

Code:

//load lang file
class IdentifierController extends Zend_Controller_Action
{

    /**
     * Db handler
     *
     * @var object
     */
    protected $db = null;

    /**
     * Redirector - defined for code completion
     *
     * @var Zend_Controller_Action_Helper_Redirector
     */
    protected $_redirector = null;

    /**
     * init
     * @param $action string
     * @param $arguments array
     * @see http://ca.php.net/manual/en/language.oop5.overloading.php
     */
    public function init()
    {
        $this->db = Zend_Registry::get('DB_');
        $this->_redirector = $this->_helper->getHelper('Redirector');
        $this->_redirector->setCode('301')
                          ->setExit(false);
    }


    /**
     * If an action doesn't exist, redirect to indexAction
     * of the current controller.
     *
     * @param string $action
     * @param string $argument
     */
    public function __call($action, $argument)
    {
        $this->_redirector->goto('index');
    }

    /**
     * If the user is log in, show is home page
     * @param null
     * @return null
     * @access public
     */
    public function indexAction($message=null)

Le __call permet d'intercepter des appels à des actions non-existantes et de les rediriger vers l'action index.  Mais comme le $this->_foward ne fonctionne plus (ou mal... si vous avez une piste de solution), je tente d'utiliser le helper de redirection (qui finalement utilise _foward).  Mais voici le message d'erreur que j'ai quand j'appelle une action inexistante (la fameuse «sdfsdfsdf» ;-)):

Code:

object(Zend_Controller_Action_Exception)#27 (6) {
  ["message:protected"] => string(39) "Invalid redirect HTTP status code (301)"
  ["string:private"] => string(0) ""
  ["code:protected"] => int(0)
  ["file:protected"] => string(97) "/media/sda2/wamp/www/generationflash/cabinec/library/Zend/Controller/Action/Helper/Redirector.php"
  ["line:protected"] => int(88)
  ["trace:private"] => array(6) {
    [0] => array(6) {
      ["file"] => string(97) "/media/sda2/wamp/www/generationflash/cabinec/library/Zend/Controller/Action/Helper/Redirector.php"
      ["line"] => int(102)
      ["function"] => string(10) "_checkCode"
      ["class"] => string(40) "Zend_Controller_Action_Helper_Redirector"
      ["type"] => string(2) "->"
      ["args"] => array(1) {
        [0] => string(3) "301"
      }
    }
    [1] => array(6) {
      ["file"] => string(99) "/media/sda2/wamp/www/generationflash/cabinec/applications/site/controllers/IdentifierController.php"
      ["line"] => int(39)
      ["function"] => string(7) "setCode"
      ["class"] => string(40) "Zend_Controller_Action_Helper_Redirector"
      ["type"] => string(2) "->"
      ["args"] => array(1) {
        [0] => string(3) "301"
      }
    }
    [2] => array(6) {
      ["file"] => string(79) "/media/sda2/wamp/www/generationflash/cabinec/library/Zend/Controller/Action.php"
      ["line"] => int(129)
      ["function"] => string(4) "init"
      ["class"] => string(20) "IdentifierController"
      ["type"] => string(2) "->"
      ["args"] => array(0) {
      }
    }
    [3] => array(6) {
      ["file"] => string(92) "/media/sda2/wamp/www/generationflash/cabinec/library/Zend/Controller/Dispatcher/Standard.php"
      ["line"] => int(213)
      ["function"] => string(11) "__construct"
      ["class"] => string(22) "Zend_Controller_Action"
      ["type"] => string(2) "->"
      ["args"] => array(3) {
        [0] => object(Zend_Controller_Request_Apache404)#10 (13) {
          ["_requestUri:protected"] => string(21) "/identifier/sdfsdfsdf"
          ["_baseUrl:protected"] => string(0) ""
          ["_basePath:protected"] => NULL
          ["_pathInfo:protected"] => string(21) "/identifier/sdfsdfsdf"
          ["_params:protected"] => array(3) {
            ["controller"] => string(10) "identifier"
            ["action"] => string(9) "sdfsdfsdf"
            ["module"] => string(7) "default"
          }
          ["_aliases:protected"] => array(0) {
          }
          ["_dispatched:protected"] => bool(true)
          ["_module:protected"] => string(7) "default"
          ["_moduleKey:protected"] => string(6) "module"
          ["_controller:protected"] => string(10) "identifier"
          ["_controllerKey:protected"] => string(10) "controller"
          ["_action:protected"] => string(9) "sdfsdfsdf"
          ["_actionKey:protected"] => string(6) "action"
        }
        [1] => object(Zend_Controller_Response_Http)#19 (8) {
          ["_body:protected"] => array(0) {
          }
          ["_exceptions:protected"] => array(0) {
          }
          ["_headers:protected"] => array(0) {
          }
          ["_headersRaw:protected"] => array(0) {
          }
          ["_httpResponseCode:protected"] => int(200)
          ["_isRedirect:protected"] => bool(false)
          ["_renderExceptions:protected"] => bool(false)
          ["headersSentThrowsException"] => bool(true)
        }
        [2] => array(0) {
        }
      }
    }
    [4] => array(6) {
      ["file"] => string(78) "/media/sda2/wamp/www/generationflash/cabinec/library/Zend/Controller/Front.php"
      ["line"] => int(911)
      ["function"] => string(8) "dispatch"
      ["class"] => string(35) "Zend_Controller_Dispatcher_Standard"
      ["type"] => string(2) "->"
      ["args"] => array(2) {
        [0] => object(Zend_Controller_Request_Apache404)#10 (13) {
          ["_requestUri:protected"] => string(21) "/identifier/sdfsdfsdf"
          ["_baseUrl:protected"] => string(0) ""
          ["_basePath:protected"] => NULL
          ["_pathInfo:protected"] => string(21) "/identifier/sdfsdfsdf"
          ["_params:protected"] => array(3) {
            ["controller"] => string(10) "identifier"
            ["action"] => string(9) "sdfsdfsdf"
            ["module"] => string(7) "default"
          }
          ["_aliases:protected"] => array(0) {
          }
          ["_dispatched:protected"] => bool(true)
          ["_module:protected"] => string(7) "default"
          ["_moduleKey:protected"] => string(6) "module"
          ["_controller:protected"] => string(10) "identifier"
          ["_controllerKey:protected"] => string(10) "controller"
          ["_action:protected"] => string(9) "sdfsdfsdf"
          ["_actionKey:protected"] => string(6) "action"
        }
        [1] => object(Zend_Controller_Response_Http)#19 (8) {
          ["_body:protected"] => array(0) {
          }
          ["_exceptions:protected"] => array(0) {
          }
          ["_headers:protected"] => array(0) {
          }
          ["_headersRaw:protected"] => array(0) {
          }
          ["_httpResponseCode:protected"] => int(200)
          ["_isRedirect:protected"] => bool(false)
          ["_renderExceptions:protected"] => bool(false)
          ["headersSentThrowsException"] => bool(true)
        }
      }
    }
    [5] => array(6) {
      ["file"] => string(66) "/media/sda2/wamp/www/generationflash/cabinec/public_html/index.php"
      ["line"] => int(62)
      ["function"] => string(8) "dispatch"
      ["class"] => string(21) "Zend_Controller_Front"
      ["type"] => string(2) "->"
      ["args"] => array(1) {
        [0] => object(Zend_Controller_Request_Apache404)#10 (13) {
          ["_requestUri:protected"] => string(21) "/identifier/sdfsdfsdf"
          ["_baseUrl:protected"] => string(0) ""
          ["_basePath:protected"] => NULL
          ["_pathInfo:protected"] => string(21) "/identifier/sdfsdfsdf"
          ["_params:protected"] => array(3) {
            ["controller"] => string(10) "identifier"
            ["action"] => string(9) "sdfsdfsdf"
            ["module"] => string(7) "default"
          }
          ["_aliases:protected"] => array(0) {
          }
          ["_dispatched:protected"] => bool(true)
          ["_module:protected"] => string(7) "default"
          ["_moduleKey:protected"] => string(6) "module"
          ["_controller:protected"] => string(10) "identifier"
          ["_controllerKey:protected"] => string(10) "controller"
          ["_action:protected"] => string(9) "sdfsdfsdf"
          ["_actionKey:protected"] => string(6) "action"
        }
      }
    }
  }
}

Quelqu'un a une idée?

Merci

Hors ligne

 

#2 29-09-2007 16:26:45

Laurent
Membre
Date d'inscription: 23-04-2007
Messages: 15

Re: Problème avec redirector

Bonjour,

Le code doit être de type integer et les guillemets en font une chaine...
Donc:

Code:

$this->_redirector->setCode(301)

Laurent

Hors ligne

 

Pied de page des forums

Propulsé par PunBB
© Copyright 2002–2005 Rickard Andersson
Traduction par punbb.fr

Graphisme réalisé par l'agence Rodolphe Eveilleau
Développement par Kitpages