當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Template::assign方法代碼示例

本文整理匯總了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));
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:11,代碼來源:TemplateTest.php

示例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;
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:12,代碼來源:BaseImage.php

示例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;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:9,代碼來源:BaseImage.php


注:本文中的Magento\Framework\View\Element\Template::assign方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。