本文整理汇总了PHP中Zend\View\Renderer\PhpRenderer::resolver方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpRenderer::resolver方法的具体用法?PHP PhpRenderer::resolver怎么用?PHP PhpRenderer::resolver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\View\Renderer\PhpRenderer
的用法示例。
在下文中一共展示了PhpRenderer::resolver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCanSetResolverInstance
public function testCanSetResolverInstance()
{
$resolver = new TemplatePathStack();
$this->renderer->setResolver($resolver);
$this->assertSame($resolver, $this->renderer->resolver());
$this->assertSame($this->phpRenderer->resolver(), $this->renderer->resolver());
}
示例2: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->helper = new SnippetHelper();
$view = new PhpRenderer();
$view->resolver()->addPath(__DIR__ . '/../../../view');
$view->resolver()->addPath(__DIR__ . '/_files/modules');
$this->helper->setView($view);
}
示例3: setUp
/**
* Prepares the environment before running a test
*
*/
protected function setUp()
{
$cwd = __DIR__;
// read navigation config
$this->_files = $cwd . '/_files';
$config = ConfigFactory::fromFile($this->_files . '/navigation.xml', true);
// setup containers from config
$this->_nav1 = new Navigation($config->get('nav_test1'));
$this->_nav2 = new Navigation($config->get('nav_test2'));
// setup view
$view = new PhpRenderer();
$view->resolver()->addPath($cwd . '/_files/mvc/views');
// create helper
$this->_helper = new $this->_helperName();
$this->_helper->setView($view);
// set nav1 in helper as default
$this->_helper->setContainer($this->_nav1);
// setup service manager
$smConfig = array('modules' => array(), 'module_listener_options' => array('config_cache_enabled' => false, 'cache_dir' => 'data/cache', 'module_paths' => array(), 'extra_config' => array('service_manager' => array('factories' => array('Config' => function () use($config) {
return array('navigation' => array('default' => $config->get('nav_test1')));
})))));
$sm = $this->serviceManager = new ServiceManager(new ServiceManagerConfig());
$sm->setService('ApplicationConfig', $smConfig);
$sm->get('ModuleManager')->loadModules();
$sm->get('Application')->bootstrap();
$sm->setFactory('Navigation', 'Zend\\Navigation\\Service\\DefaultNavigationFactory');
$sm->setService('nav1', $this->_nav1);
$sm->setService('nav2', $this->_nav2);
$app = $this->serviceManager->get('Application');
$app->getMvcEvent()->setRouteMatch(new RouteMatch(array('controller' => 'post', 'action' => 'view', 'id' => '1337')));
}
示例4: setUp
public function setUp()
{
$view = new View();
$base = str_replace('/', DIRECTORY_SEPARATOR, '/../_templates');
$view->resolver()->addPath(__DIR__ . $base);
$view->vars()->setStrictVars(true);
$this->view = $view;
}
示例5: getControllerConfig
public function getControllerConfig()
{
return array('factories' => array('Modules\\Controller\\Console\\List' => function (ControllerManager $cm) {
$sl = $cm->getServiceLocator();
$renderer = new PhpRenderer();
$renderer->resolver()->setPaths([__DIR__ . '/view']);
return new Controller\Console\ListController(new ComposerInfo('composer.lock'), $sl->get('ModuleManager'), new ListViewModel(), $renderer);
}, 'Modules\\Controller\\Console\\Init' => function (ControllerManager $cm) {
$sl = $cm->getServiceLocator();
return new Controller\Console\InitController($sl->get('Zend\\Db\\Adapter\\Adapter'), $sl->get('Zend\\Db\\Metadata\\Metadata'));
}));
}
示例6: _before
public function _before(FunctionalTester $I)
{
$application = $I->getApplication();
$this->event = $application->getMvcEvent();
$this->routeMatch = new RouteMatch(array('controller' => 'Modules\\Controller\\Console\\List'));
$this->event->setRouteMatch($this->routeMatch);
$renderer = new PhpRenderer();
$renderer->resolver()->setPaths([dirname(dirname(dirname(__DIR__))) . '/view']);
$this->viewModel = new ListViewModel();
$this->controller = new ListController(new ComposerInfo('composer.lock'), $application->getServiceManager()->get('Zend\\ModuleManager\\ModuleManager'), $this->viewModel, $renderer);
$this->controller->setEvent($this->event);
$this->controller->setEventManager($application->getEventManager());
$this->controller->setServiceLocator($application->getServiceManager());
}
示例7: getRenderer
/**
*
* @return \Zend\View\Renderer\PhpRenderer
*/
public function getRenderer()
{
if ($this->renderer === null) {
$renderer = new PhpRenderer();
// register view helpers
$formHelperConfig = new ZendFormHelperConfig();
$formHelperConfig->configureServiceManager($renderer->getHelperPluginManager());
// register view helpers
$formHelperConfig = new FormHelperConfig();
$formHelperConfig->configureServiceManager($renderer->getHelperPluginManager());
// set base path
$path = $this->templatePath ?: __DIR__ . '/view/scripts';
$renderer->resolver()->addPath($path);
$this->setRenderer($renderer);
}
return $this->renderer;
}
示例8: setUp
/**
* Prepares the environment before running a test
*
*/
protected function setUp()
{
$cwd = __DIR__;
// read navigation config
$this->_files = $cwd . '/_files';
$config = ConfigFactory::fromFile($this->_files . '/navigation.xml', true);
// setup containers from config
$this->_nav1 = new Navigation($config->get('nav_test1'));
$this->_nav2 = new Navigation($config->get('nav_test2'));
// setup view
$view = new PhpRenderer();
$view->resolver()->addPath($cwd . '/_files/mvc/views');
// create helper
$this->_helper = new $this->_helperName();
$this->_helper->setView($view);
// set nav1 in helper as default
$this->_helper->setContainer($this->_nav1);
}
示例9: addPath
/**
* Add path in Zend\View\Resolver\TemplatePathStack
*
* @param string $dir Directory
*
* @return \Gc\View\Renderer
*/
public function addPath($dir)
{
$this->checkRenderer();
$this->renderer->resolver()->addPath($dir);
return $this;
}
示例10: testRendersWithPartial
public function testRendersWithPartial()
{
$view = new View\Renderer\PhpRenderer();
$view->resolver()->addPath(__DIR__ . '/_files/scripts');
Helper\PaginationControl::setDefaultViewPartial('partial.phtml');
$this->paginator->setView($view);
$string = $this->paginator->__toString();
$this->assertEquals('partial rendered successfully', $string);
}
示例11: testShouldNotConvertToArrayRecursivelyIfModelIsTraversable
public function testShouldNotConvertToArrayRecursivelyIfModelIsTraversable()
{
$rIterator = new RecursiveIteratorTest();
for ($i = 0; $i < 5; ++$i) {
$data = array('message' => 'foo' . $i);
$rIterator->addItem(new IteratorTest($data));
}
$view = new View();
$view->resolver()->addPath($this->basePath . '/application/views/scripts');
$this->helper->setView($view);
$this->helper->setObjectKey('obj');
$result = $this->helper->__invoke('partialLoopShouldNotConvertToArrayRecursively.phtml', $rIterator);
foreach ($rIterator as $item) {
foreach ($item as $key => $value) {
$this->assertContains('This is an iteration: ' . $value, $result, var_export($value, 1));
}
}
}
示例12: testCanPassViewModelAsSoleArgument
public function testCanPassViewModelAsSoleArgument()
{
$model = new ViewModel(array('foo' => 'bar', 'bar' => 'baz'));
$model->setTemplate('partialVars.phtml');
$view = new View();
$view->resolver()->addPath($this->basePath . '/application/views/scripts');
$this->helper->setView($view);
$return = $this->helper->__invoke($model);
foreach ($model->getVariables() as $key => $value) {
$string = sprintf('%s: %s', $key, $value);
$this->assertContains($string, $return);
}
}
示例13: testPartialLoopPartialCounterResets
/**
* @group ZF-5174
*/
public function testPartialLoopPartialCounterResets()
{
$data = array(array('message' => 'foo'), array('message' => 'bar'), array('message' => 'baz'), array('message' => 'bat'));
$view = new View();
$view->resolver()->addPath($this->basePath . '/application/views/scripts');
$this->helper->setView($view);
$result = $this->helper->__invoke('partialLoopCouter.phtml', $data);
foreach ($data as $key => $item) {
$string = 'This is an iteration: ' . $item['message'] . ', pointer at ' . ($key + 1);
$this->assertContains($string, $result);
}
$result = $this->helper->__invoke('partialLoopCouter.phtml', $data);
foreach ($data as $key => $item) {
$string = 'This is an iteration: ' . $item['message'] . ', pointer at ' . ($key + 1);
$this->assertContains($string, $result);
}
}
示例14: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
*/
protected function setUp()
{
$this->view = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
$this->view->save();
$this->layout = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
$this->layout->save();
$this->user = UserModel::fromArray(array('lastname' => 'User test', 'firstname' => 'User test', 'email' => 'pierre.rambaud86@gmail.com', 'login' => 'test', 'user_acl_role_id' => 1));
$this->user->setPassword('test');
$this->user->save();
$this->documentType = DocumentTypeModel::fromArray(array('name' => 'Document Type Name', 'description' => 'Document Type description', 'icon_id' => 1, 'defaultview_id' => $this->view->getId(), 'user_id' => $this->user->getId()));
$this->documentType->save();
$this->document = DocumentModel::fromArray(array('name' => 'Document name', 'url_key' => 'url-key', 'status' => DocumentModel::STATUS_ENABLE, 'show_in_nav' => true, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => 0));
$this->document->save();
$this->object = new Documents();
$view = new View();
$view->resolver()->addPath(__DIR__ . '/_files/views');
$view->setHelperPluginManager(Registry::get('Application')->getServiceManager()->get('viewhelpermanager'));
$this->object->setView($view);
}
示例15: testGetDocument
/**
* Test
*
* @return void
*/
public function testGetDocument()
{
$parent = new ViewModel();
$parent->setTemplate('layout');
$view = new View();
$renderer = Registry::get('Application')->getServiceManager()->get('Zend\\View\\Renderer\\PhpRenderer');
$view->setHelperPluginManager($renderer->getHelperPluginManager());
$view->plugin('view_model')->setRoot($parent);
$view->resolver()->addPath(__DIR__ . '/_files/views');
$this->object->setView($view);
$this->assertInstanceOf('Gc\\Document\\Model', $this->object->getDocument());
}