本文整理汇总了PHP中Magento\Framework\Escaper类的典型用法代码示例。如果您正苦于以下问题:PHP Escaper类的具体用法?PHP Escaper怎么用?PHP Escaper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Escaper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
$this->methodMock = $this->getMock('Magento\\OfflinePayments\\Model\\Checkmo', [], [], '', false);
$paymentHelperMock = $this->getMock('Magento\\Payment\\Helper\\Data', [], [], '', false);
$paymentHelperMock->expects($this->once())->method('getMethodInstance')->with(Checkmo::PAYMENT_METHOD_CHECKMO_CODE)->willReturn($this->methodMock);
$this->escaperMock = $this->getMock('Magento\\Framework\\Escaper');
$this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0);
$this->model = new CheckmoConfigProvider($paymentHelperMock, $this->escaperMock);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:9,代码来源:CheckmoConfigProviderTest.php
示例2: setUp
protected function setUp()
{
$this->escaperMock = $this->getMock('Magento\\Framework\\Escaper', [], [], '', false);
$this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0);
$this->contextMock = $this->getMock('Magento\\Backend\\Block\\Context', ['getEscaper'], [], '', false);
$this->contextMock->expects($this->any())->method('getEscaper')->will($this->returnValue($this->escaperMock));
$this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->buttonRenderer = $this->objectManagerHelper->getObject('Magento\\Integration\\Block\\Adminhtml\\Widget\\Grid\\Column\\Renderer\\Button', ['context' => $this->contextMock]);
}
开发者ID:nja78,项目名称:magento2,代码行数:9,代码来源:ButtonTest.php
示例3: setUp
protected function setUp()
{
$this->methodOneMock = $this->getMock('Magento\\Payment\\Model\\Method\\AbstractMethod', ['isAvailable', 'getInstructions'], [], '', false);
$this->methodTwoMock = $this->getMock('Magento\\Payment\\Model\\Method\\AbstractMethod', ['isAvailable', 'getInstructions'], [], '', false);
$paymentHelperMock = $this->getMock('Magento\\Payment\\Helper\\Data', [], [], '', false);
$paymentHelperMock->expects($this->exactly(2))->method('getMethodInstance')->willReturnMap([[Banktransfer::PAYMENT_METHOD_BANKTRANSFER_CODE, $this->methodOneMock], [Cashondelivery::PAYMENT_METHOD_CASHONDELIVERY_CODE, $this->methodTwoMock]]);
$this->escaperMock = $this->getMock('Magento\\Framework\\Escaper');
$this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0);
$this->model = new InstructionsConfigProvider($paymentHelperMock, $this->escaperMock);
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:InstructionsConfigProviderTest.php
示例4: setUp
protected function setUp()
{
$this->pageConfigMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->getMock();
$this->assetMergeServiceMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\MergeService')->disableOriginalConstructor()->getMock();
$this->urlBuilderMock = $this->getMockForAbstractClass('Magento\\Framework\\UrlInterface');
$this->escaperMock = $this->getMockBuilder('Magento\\Framework\\Escaper')->disableOriginalConstructor()->getMock();
$this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnArgument(0);
$this->stringMock = $this->getMockBuilder('Magento\\Framework\\Stdlib\\StringUtils')->disableOriginalConstructor()->getMock();
$this->loggerMock = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
$this->assetsCollection = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\GroupedCollection')->setMethods(['getGroups'])->disableOriginalConstructor()->getMock();
$this->assetInterfaceMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Asset\\AssetInterface');
$this->titleMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->setMethods(['set', 'get'])->disableOriginalConstructor()->getMock();
$this->objectManagerHelper = new ObjectManager($this);
$this->renderer = $this->objectManagerHelper->getObject('Magento\\Framework\\View\\Page\\Config\\Renderer', ['pageConfig' => $this->pageConfigMock, 'assetMergeService' => $this->assetMergeServiceMock, 'urlBuilder' => $this->urlBuilderMock, 'escaper' => $this->escaperMock, 'string' => $this->stringMock, 'logger' => $this->loggerMock]);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:RendererTest.php
示例5: testEmulateWelcomeBlock
/**
* @magentoConfigFixture current_store persistent/options/enabled 1
* @magentoConfigFixture current_store persistent/options/remember_enabled 1
* @magentoConfigFixture current_store persistent/options/remember_default 1
* @magentoAppArea frontend
* @magentoAppIsolation enabled
*/
public function testEmulateWelcomeBlock()
{
$this->_customerSession->loginById(1);
$httpContext = new \Magento\Framework\App\Http\Context();
$httpContext->setValue(Context::CONTEXT_AUTH, 1, 1);
$block = $this->_objectManager->create('Magento\\Sales\\Block\\Reorder\\Sidebar', ['httpContext' => $httpContext]);
$this->_observer->emulateWelcomeBlock($block);
$customerName = $this->_escaper->escapeHtml($this->_customerViewHelper->getCustomerName($this->customerRepository->getById($this->_persistentSessionHelper->getSession()->getCustomerId())));
$translation = __('Welcome, %1!', $customerName);
$this->assertStringMatchesFormat('%A' . $translation . '%A', $block->getWelcome());
$this->_customerSession->logout();
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:19,代码来源:ObserverTest.php
示例6: execute
/**
* Register form key in session from cookie value
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
if ($this->cookieFormKey->get()) {
$this->updateCookieFormKey($this->cookieFormKey->get());
$this->sessionFormKey->set($this->escaper->escapeHtml($this->cookieFormKey->get()));
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:RegisterFormKeyFromCookie.php
示例7: testGetLinkData
public function testGetLinkData()
{
$expectingFileData = ['file' => ['file' => 'file/link.gif', 'name' => '<a href="final_url">link.gif</a>', 'size' => '1.1', 'status' => 'old'], 'sample_file' => ['file' => 'file/sample.gif', 'name' => '<a href="final_url">sample.gif</a>', 'size' => '1.1', 'status' => 'old']];
$this->productModel->expects($this->any())->method('getTypeId')->will($this->returnValue('downloadable'));
$this->productModel->expects($this->any())->method('getTypeInstance')->will($this->returnValue($this->downloadableProductModel));
$this->productModel->expects($this->any())->method('getStoreId')->will($this->returnValue(0));
$this->downloadableProductModel->expects($this->any())->method('getLinks')->will($this->returnValue([$this->downloadableLinkModel]));
$this->coreRegistry->expects($this->any())->method('registry')->will($this->returnValue($this->productModel));
$this->downloadableLinkModel->expects($this->any())->method('getId')->will($this->returnValue(1));
$this->downloadableLinkModel->expects($this->any())->method('getTitle')->will($this->returnValue('Link Title'));
$this->downloadableLinkModel->expects($this->any())->method('getPrice')->will($this->returnValue('10'));
$this->downloadableLinkModel->expects($this->any())->method('getNumberOfDownloads')->will($this->returnValue('6'));
$this->downloadableLinkModel->expects($this->any())->method('getLinkUrl')->will($this->returnValue(null));
$this->downloadableLinkModel->expects($this->any())->method('getLinkType')->will($this->returnValue('file'));
$this->downloadableLinkModel->expects($this->any())->method('getSampleFile')->will($this->returnValue('file/sample.gif'));
$this->downloadableLinkModel->expects($this->any())->method('getSampleType')->will($this->returnValue('file'));
$this->downloadableLinkModel->expects($this->any())->method('getSortOrder')->will($this->returnValue(0));
$this->downloadableLinkModel->expects($this->any())->method('getLinkFile')->will($this->returnValue('file/link.gif'));
$this->downloadableLinkModel->expects($this->any())->method('getStoreTitle')->will($this->returnValue('Store Title'));
$this->escaper->expects($this->any())->method('escapeHtml')->will($this->returnValue('Link Title'));
$this->fileHelper->expects($this->any())->method('getFilePath')->will($this->returnValue('/file/path/link.gif'));
$this->fileHelper->expects($this->any())->method('ensureFileInFilesystem')->will($this->returnValue(true));
$this->fileHelper->expects($this->any())->method('getFileSize')->will($this->returnValue('1.1'));
$this->urlBuilder->expects($this->any())->method('getUrl')->will($this->returnValue('final_url'));
$linkData = $this->block->getLinkData();
foreach ($linkData as $link) {
$fileSave = $link->getFileSave(0);
$sampleFileSave = $link->getSampleFileSave(0);
$this->assertEquals($expectingFileData['file'], $fileSave);
$this->assertEquals($expectingFileData['sample_file'], $sampleFileSave);
}
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:32,代码来源:LinksTest.php
示例8: getTitle
/**
* get toooltip title
*
* @param bool $escaped
* @return string
*/
public function getTitle($escaped = true)
{
if ($escaped) {
return $this->escaper->escapeHtml($this->title);
}
return $this->title;
}
开发者ID:artmouse,项目名称:Umc_Base,代码行数:13,代码来源:Tooltip.php
示例9: generateCurrentOptions
/**
* Generate current options
*
* @return void
*/
protected function generateCurrentOptions()
{
$websiteCollection = $this->systemStore->getWebsiteCollection();
$groupCollection = $this->systemStore->getGroupCollection();
$storeCollection = $this->systemStore->getStoreCollection();
/** @var \Magento\Store\Model\Website $website */
foreach ($websiteCollection as $website) {
$groups = [];
/** @var \Magento\Store\Model\Group $group */
foreach ($groupCollection as $group) {
if ($group->getWebsiteId() == $website->getId()) {
$stores = [];
/** @var \Magento\Store\Model\Store $store */
foreach ($storeCollection as $store) {
if ($store->getGroupId() == $group->getId()) {
$name = $this->escaper->escapeHtml($store->getName());
$stores[$name]['label'] = str_repeat(' ', 8) . $name;
$stores[$name]['value'] = $store->getId();
}
}
if (!empty($stores)) {
$name = $this->escaper->escapeHtml($group->getName());
$groups[$name]['label'] = str_repeat(' ', 4) . $name;
$groups[$name]['value'] = array_values($stores);
}
}
}
if (!empty($groups)) {
$name = $this->escaper->escapeHtml($website->getName());
$this->currentOptions[$name]['label'] = $name;
$this->currentOptions[$name]['value'] = array_values($groups);
}
}
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:39,代码来源:Options.php
示例10: prepareItem
/**
* Get data
*
* @param array $item
* @return string
*/
protected function prepareItem(array $item)
{
$content = '';
$origStores = $item['store_id'];
if (empty($origStores)) {
return '';
}
if (!is_array($origStores)) {
$origStores = [$origStores];
}
if (in_array(0, $origStores) && count($origStores) == 1) {
return __('All Store Views');
}
$data = $this->systemStore->getStoresStructure(false, $origStores);
foreach ($data as $website) {
$content .= $website['label'] . "<br/>";
foreach ($website['children'] as $group) {
$content .= str_repeat(' ', 3) . $this->escaper->escapeHtml($group['label']) . "<br/>";
foreach ($group['children'] as $store) {
$content .= str_repeat(' ', 6) . $this->escaper->escapeHtml($store['label']) . "<br/>";
}
}
}
return $content;
}
开发者ID:nja78,项目名称:magento2,代码行数:31,代码来源:Store.php
示例11: getFormKey
/**
* Retrieve Session Form Key
*
* @return string A 16 bit unique key for forms
*/
public function getFormKey()
{
if (!$this->isPresent()) {
$this->set($this->mathRandom->getRandomString(16));
}
return $this->escaper->escapeHtmlAttr($this->session->getData(self::FORM_KEY));
}
开发者ID:vv-team,项目名称:foodo,代码行数:12,代码来源:FormKey.php
示例12: execute
/**
* Register form key in session from cookie value
*
* @return void
*/
public function execute()
{
$formKeyFromCookie = $this->_formKey->get();
if ($formKeyFromCookie) {
$this->_session->setData(\Magento\Framework\Data\Form\FormKey::FORM_KEY, $this->_escaper->escapeHtml($formKeyFromCookie));
}
}
开发者ID:zhangjiachao,项目名称:magento2,代码行数:12,代码来源:RegisterFormKeyFromCookie.php
示例13: execute
/**
* Forgot customer password action
*
* @return \Magento\Framework\Controller\Result\Redirect
*/
public function execute()
{
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
$email = (string) $this->getRequest()->getPost('email');
if ($email) {
if (!\Zend_Validate::is($email, 'EmailAddress')) {
$this->_getSession()->setForgottenEmail($email);
$this->messageManager->addError(__('Please correct the email address.'));
$resultRedirect->setPath('*/*/forgotpassword');
return $resultRedirect;
}
try {
$this->customerAccountManagement->initiatePasswordReset($email, AccountManagement::EMAIL_RESET);
} catch (NoSuchEntityException $e) {
// Do nothing, we don't want anyone to use this action to determine which email accounts are registered.
} catch (\Exception $exception) {
$this->messageManager->addException($exception, __('Unable to send password reset email.'));
$resultRedirect->setPath('*/*/forgotpassword');
return $resultRedirect;
}
$email = $this->escaper->escapeHtml($email);
// @codingStandardsIgnoreStart
$this->messageManager->addSuccess(__('If there is an account associated with %1 you will receive an email with a link to reset your password.', $email));
// @codingStandardsIgnoreEnd
$resultRedirect->setPath('*/*/');
return $resultRedirect;
} else {
$this->messageManager->addError(__('Please enter your email.'));
$resultRedirect->setPath('*/*/forgotpassword');
return $resultRedirect;
}
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:38,代码来源:ForgotPasswordPost.php
示例14: execute
/**
* Add shared wishlist item to shopping cart
*
* If Product has required options - redirect
* to product view page with message about needed defined required options
*
* @return \Magento\Framework\Controller\Result\Redirect
*/
public function execute()
{
$itemId = (int) $this->getRequest()->getParam('item');
/* @var $item Item */
$item = $this->itemFactory->create()->load($itemId);
$redirectUrl = $this->_redirect->getRefererUrl();
try {
/** @var OptionCollection $options */
$options = $this->optionFactory->create()->getCollection()->addItemFilter([$itemId]);
$item->setOptions($options->getOptionsByItem($itemId));
$item->addToCart($this->cart);
$this->cart->save();
if (!$this->cart->getQuote()->getHasError()) {
$message = __('You added %1 to your shopping cart.', $this->escaper->escapeHtml($item->getProduct()->getName()));
$this->messageManager->addSuccess($message);
}
if ($this->cartHelper->getShouldRedirectToCart()) {
$redirectUrl = $this->cartHelper->getCartUrl();
}
} catch (ProductException $e) {
$this->messageManager->addError(__('This product(s) is out of stock.'));
} catch (LocalizedException $e) {
$this->messageManager->addNotice($e->getMessage());
$redirectUrl = $item->getProductUrl();
} catch (\Exception $e) {
$this->messageManager->addException($e, __('We can\'t add the item to the cart right now.'));
}
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$resultRedirect->setUrl($redirectUrl);
return $resultRedirect;
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:40,代码来源:Cart.php
示例15: getSectionData
/**
* {@inheritdoc}
*/
public function getSectionData()
{
$customerId = $this->currentCustomer->getCustomerId();
if ($this->paypalData->shouldAskToCreateBillingAgreement($this->config, $customerId)) {
return ['askToCreate' => true, 'confirmUrl' => $this->escaper->escapeUrl($this->urlBuilder->getUrl($this->startAction, [\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1])), 'confirmMessage' => $this->escaper->escapeJsQuote(__('Would you like to sign a billing agreement to streamline further purchases with PayPal?'))];
}
return [];
}
开发者ID:Doability,项目名称:magento2dev,代码行数:11,代码来源:BillingAgreement.php
示例16: emulateWelcomeBlock
/**
* Emulate 'welcome' block with persistent data
*
* @param \Magento\Framework\View\Element\AbstractBlock $block
* @return $this
*/
public function emulateWelcomeBlock($block)
{
$escapedName = $this->_escaper->escapeHtml($this->_customerViewHelper->getCustomerName($this->customerRepository->getById($this->_persistentSession->getSession()->getCustomerId())), null);
$this->_applyAccountLinksPersistentData();
$welcomeMessage = __('Welcome, %1!', $escapedName) . ' ' . $this->_layout->getBlock('header.additional')->toHtml();
$block->setWelcome($welcomeMessage);
return $this;
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:Observer.php
示例17: prepareDataSource
/**
* Prepare Data Source
*
* @param array $dataSource
* @return array
*/
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as &$item) {
$item[$this->getData('name')] = $this->escaper->escapeHtml(str_replace("\n", '<br/>', $item[$this->getData('name')]));
}
}
return $dataSource;
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Address.php
示例18: process
/**
* {@inheritdoc}
*/
public function process($jsLayout)
{
$agreementConfiguration = [];
$agreementsList = $this->checkoutAgreementsRepository->getList();
foreach ($agreementsList as $agreement) {
$agreementConfiguration[] = ['content' => $agreement->getIsHtml() ? $agreement->getContent() : nl2br($this->escaper->escapeHtml($agreement->getContent())), 'height' => $agreement->getContentHeight(), 'checkboxText' => $agreement->getCheckboxText()];
}
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children']['before-place-order']['children']['checkout-agreements-modal']['config']['agreementConfiguration'] = $agreementConfiguration;
return $jsLayout;
}
开发者ID:nja78,项目名称:magento2,代码行数:13,代码来源:LayoutProcessor.php
示例19: testGetHtml
public function testGetHtml()
{
$resultHtml = '<input type="text" name="escapedHtml" ' . 'id="escapedHtml" value="escapedHtml" ' . 'class="input-text admin__control-text no-changes" data-ui-id="filter-escapedhtml" />';
$column = $this->getMockBuilder('Magento\\Backend\\Block\\Widget\\Grid\\Column')->setMethods(['getId', 'getHtmlId'])->disableOriginalConstructor()->getMock();
$this->block->setColumn($column);
$this->escaper->expects($this->any())->method('escapeHtml')->willReturn('escapedHtml');
$column->expects($this->any())->method('getId')->willReturn('id');
$column->expects($this->once())->method('getHtmlId')->willReturn('htmlId');
$this->assertEquals($resultHtml, $this->block->getHtml());
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:TextTest.php
示例20: testPrepareDataSource
/**
* @dataProvider prepareDataSourceDataProvider
*/
public function testPrepareDataSource($dataSource, $expectedResult)
{
$website = 'website';
$group = 'group';
$store = 'store';
$storeStructure = [1 => ['value' => 1, 'label' => $website, 'children' => [1 => ['value' => 1, 'label' => $group, 'children' => [1 => ['value' => 1, 'label' => $store]]]]]];
$this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnMap([[$group, null, $group], [$store, null, $store]]);
$this->systemStoreMock->expects($this->any())->method('getStoresStructure')->willReturn($storeStructure);
$this->assertEquals($this->model->prepareDataSource($dataSource), $expectedResult);
}
开发者ID:koliaGI,项目名称:magento2,代码行数:13,代码来源:StoreTest.php
注:本文中的Magento\Framework\Escaper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论