本文整理汇总了PHP中Magento\Framework\View\Element\Template::assign方法的典型用法代码示例。如果您正苦于以下问题:PHP Template::assign方法的具体用法?PHP Template::assign怎么用?PHP Template::assign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\View\Element\Template
的用法示例。
在下文中一共展示了Template::assign方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFetchView
public function testFetchView()
{
$this->expectOutputString('');
$template = 'themedir/template.phtml';
$this->validator->expects($this->once())->method('isValid')->with($template)->willReturn(true);
$output = '<h1>Template Contents</h1>';
$vars = ['var1' => 'value1', 'var2' => 'value2'];
$this->templateEngine->expects($this->once())->method('render')->willReturn($output);
$this->block->assign($vars);
$this->assertEquals($output, $this->block->fetchView($template));
}
示例2: afterAssignBlockVariables
/**
* @param OriginalBloc $baseImage
* @param Template $block
* @return Template
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterAssignBlockVariables(OriginalBloc $baseImage, Template $block)
{
$block->assign(['videoPlaceholderText' => __('Click here to add videos.'), 'addVideoTitle' => __('New Video')]);
return $block;
}
示例3: assignBlockVariables
/**
* @param \Magento\Framework\View\Element\Template $block
* @return \Magento\Framework\View\Element\Template
*/
public function assignBlockVariables(\Magento\Framework\View\Element\Template $block)
{
$block->assign(['htmlId' => $this->_escaper->escapeHtml($this->getHtmlId()), 'fileMaxSize' => $this->maxFileSize, 'uploadUrl' => $this->_escaper->escapeHtml($this->_getUploadUrl()), 'spacerImage' => $this->assetRepo->getUrl('images/spacer.gif'), 'imagePlaceholderText' => __('Click here or drag and drop to add images.'), 'deleteImageText' => __('Delete image'), 'makeBaseText' => __('Make Base'), 'hiddenText' => __('Hidden'), 'imageManagementText' => __('Images and Videos')]);
return $block;
}