本文整理匯總了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;
}