Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php cronjob模块中未提供ZF2转换器_Php_Zend Framework_Routing_Translation - Fatal编程技术网

Php cronjob模块中未提供ZF2转换器

Php cronjob模块中未提供ZF2转换器,php,zend-framework,routing,translation,Php,Zend Framework,Routing,Translation,在我的cronjob模块中,我正在运行一些带有模板的电子邮件脚本。现在,我想在电子邮件模板中添加一些URL,例如unsubscribe,但是使用翻译的slug的路由似乎有问题 例如,我有这些路由,我想将它们都包含到我的电子邮件模板中 'newest' => array( 'type' => 'Zend\Mvc\Router\Http\Segment', 'options' => array(

在我的cronjob模块中,我正在运行一些带有模板的电子邮件脚本。现在,我想在电子邮件模板中添加一些URL,例如unsubscribe,但是使用翻译的slug的路由似乎有问题

例如,我有这些路由,我想将它们都包含到我的电子邮件模板中

      'newest' => array(
          'type' => 'Zend\Mvc\Router\Http\Segment',
             'options' => array(
                'route' => '{newest}.html',
                     'defaults'   => array(
                     'controller' => 'Application\Controller\IndexController',
                     'action'     => 'newest',
                ),
            ),
        ),

联系路线没有问题,工作正常!但是,当我试图包含最新的路线时,它出错了,捕获错误检查会返回消息:

string(22) "No translator provided"
嗯,我理解这一点。似乎没有提供翻译,因为它基于我的应用程序模块的Module.php中的语言环境

我会说,我应该能够强迫这个翻译人员使用翻译人员?比如,在从命令行触发路由时在参数中使用参数

下面的代码是我当前的代码,我想我需要把翻译器放在最上面

$request = $this->getRequest();
        if (!$request instanceof ConsoleRequest)
            throw new \RuntimeException('Only access via console!');

        $country                       = $request->getParam('country');
        $sm                            = $this->serviceLocator;
        $http                          = $sm->get('HttpRouter');
        $render                        = $sm->get('ViewRenderer');
        $event                         = $this->getEvent()->setRouter($http);
        $config                        = $sm->get('config');
        $server_url                    = $config['server_url'][$country];
        try {
            var_dump($server_url . $this->url()->fromRoute('home/newest'));
            var_dump($server_url . $this->url()->fromRoute('home/contact'));
        } catch (\Exception $e) {
            var_dump($e->getMessage());
        }
        exit;
$request = $this->getRequest();
        if (!$request instanceof ConsoleRequest)
            throw new \RuntimeException('Only access via console!');

        $country                       = $request->getParam('country');
        $sm                            = $this->serviceLocator;
        $http                          = $sm->get('HttpRouter');
        $render                        = $sm->get('ViewRenderer');
        $event                         = $this->getEvent()->setRouter($http);
        $config                        = $sm->get('config');
        $server_url                    = $config['server_url'][$country];
        try {
            var_dump($server_url . $this->url()->fromRoute('home/newest'));
            var_dump($server_url . $this->url()->fromRoute('home/contact'));
        } catch (\Exception $e) {
            var_dump($e->getMessage());
        }
        exit;