黑客攻击phprenderer,助手抛出错误

时间:2016-08-08 16:27:26

标签: zend-framework zend-framework2

我有一条路线用于创建缓存updatePostCaches。我正在将curl调用回我的应用程序,保存输出,压缩它,并将其写入我的缓存目录。问题是它非常慢,因为它必须一遍又一遍地加载我的整个应用程序。我在另一个上下文中使用了phprenderer,但它从未需要'translate'等帮助程序。

    $this->renderer = new \Zend\View\Renderer\PhpRenderer();
    $this->resolver = new \Zend\View\Resolver\TemplateMapResolver();
    $this->renderer->setResolver($this->resolver);

    $this->renderer->getHelperPluginManager()->setServiceLocator($serviceLocator);

    //This one DID resolve an error about getting 'rootLocationJson', but I feel like I shouldn't even have to do this
    $this->renderer->getHelperPluginManager()->setFactory('rootLocationJson', \Location\View\Helper\LocationFactory::class);

    //Even this doesn't work
    $this->renderer->getHelperPluginManager()-> setFactory('translate', 'Zend\I18n\View\Helper\Translate');

    $this->rootLocations = $this->om->getRepository(\Location\Entity\Location::class)->findBy(array('parent' => null));

    //Also wish I didn't have to do this
    $this->resolver->add(
        array(
            'layout' => realpath(__DIR__ . '/../../../../Application/view/layout/layout.phtml'),
            'index' => realpath(__DIR__ . '/../../../../Cache/view/cache/index/index.phtml'),
            'post' => realpath(__DIR__ . '/../../../../Cache/view/cache/index/post.phtml'),
            'location' => realpath(__DIR__ . '/../../../../Cache/view/cache/index/location.phtml'),
        )
    );

    $viewModel = new \Zend\View\Model\ViewModel($vars);
    $viewModel->setTemplate($view);

    $layout = new \Zend\View\Model\ViewModel(array('content' => $this->renderer->render($viewModel)));
    $layout->setTemplate('layout');


    $output = $this->renderer->render($layout);

在最后一行之后,我收到以下错误:Zend\View\HelperPluginManager::get was unable to fetch or create an instance for 'translate'

我觉得我只是做错了。有人建议我使用当前实例化的phprenderer,但这会使它中毒,因为再次,这是一个不同请求的phprenderer,最终仍需要呈现。

0 个答案:

没有答案