本文整理汇总了PHP中Magento\Backend\Model\UrlInterface类的典型用法代码示例。如果您正苦于以下问题:PHP UrlInterface类的具体用法?PHP UrlInterface怎么用?PHP UrlInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UrlInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _validateSecretKey
/**
* Validate Secret Key
*
* @return bool
*/
protected function _validateSecretKey()
{
if (is_array($this->_publicActions) && in_array($this->getRequest()->getActionName(), $this->_publicActions)) {
return true;
}
$secretKey = $this->getRequest()->getParam(\Magento\Backend\Model\UrlInterface::SECRET_KEY_PARAM_NAME, null);
if (!$secretKey || $secretKey != $this->_backendUrl->getSecretKey()) {
return false;
}
return true;
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:AbstractAction.php
示例2: _callbackSecretKey
/**
* Replace Callback Secret Key
*
* @param string[] $match
* @return string
*/
protected function _callbackSecretKey($match)
{
return \Magento\Backend\Model\UrlInterface::SECRET_KEY_PARAM_NAME . '/' . $this->_url->getSecretKey($match[1], $match[2], $match[3]);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:Menu.php
示例3: testUseSecretKey
public function testUseSecretKey()
{
$this->_model->setNoSecret(true);
$this->assertFalse($this->_model->useSecretKey());
$this->_model->setNoSecret(false);
$this->assertTrue($this->_model->useSecretKey());
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:7,代码来源:UrlTest.php
示例4: create
/**
* Declare headers and content file in response for file download
*
* @param string $fileName
* @param string|array $content set to null to avoid starting output, $contentLength should be set explicitly in
* that case
* @param string $baseDir
* @param string $contentType
* @param int $contentLength explicit content length, if strlen($content) isn't applicable
* @return \Magento\Framework\App\ResponseInterface
*/
public function create($fileName, $content, $baseDir = DirectoryList::ROOT, $contentType = 'application/octet-stream', $contentLength = null)
{
if ($this->_auth->getAuthStorage()->isFirstPageAfterLogin()) {
return $this->_redirect($this->_backendUrl->getStartupPageUrl());
}
return parent::create($fileName, $content, $baseDir, $contentType, $contentLength);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:FileFactory.php
示例5: getUrl
/**
* Create url for passed item using passed url model
*
* @param \Magento\Framework\Object $item
* @return string
*/
public function getUrl($item)
{
if (!empty($this->_path)) {
$params = $this->_prepareParameters($item);
return $this->_urlModel->getUrl($this->_path, $params);
}
return '';
}
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:UrlGenerator.php
示例6: getElementHtml
public function getElementHtml()
{
$buttonBlock = $this->getForm()->getParent()->getLayout()->createBlock('Magento\\Backend\\Block\\Widget\\Button');
$params = ['website' => $buttonBlock->getRequest()->getParam('website')];
$url = $this->_backendUrl->getUrl("*/*/exportmatrixrate", $params);
$data = ['label' => __('Export CSV'), 'onclick' => "setLocation('" . $url . "conditionName/' + \$('carriers_matrixrate_condition_name').value + '/matrixrate.csv' )", 'class' => ''];
$html = $buttonBlock->setData($data)->toHtml();
return $html;
}
开发者ID:Doability,项目名称:magento2dev,代码行数:9,代码来源:Exportmatrix.php
示例7: testGetConfig
/**
* @covers \Magento\Cms\Model\Wysiwyg\Config::getConfig
* @param array $data
* @param boolean $isAuthorizationAllowed
* @param array $expectedResults
*
* @dataProvider getConfigDataProvider
*/
public function testGetConfig($data, $isAuthorizationAllowed, $expectedResults)
{
$wysiwygPluginSettings = ['wysiwygPluginSettings' => 'wysiwyg is here'];
$pluginSettings = ['pluginSettings' => 'plugins are here'];
$this->backendUrlMock->expects($this->atLeastOnce())->method('getUrl')->withConsecutive(['cms/wysiwyg/directive'], ['cms/wysiwyg_images/index']);
$this->assetRepoMock->expects($this->atLeastOnce())->method('getUrl')->withConsecutive(['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css'], ['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css']);
$this->authorizationMock->expects($this->atLeastOnce())->method('isAllowed')->with('Magento_Cms::media_gallery')->willReturn($isAuthorizationAllowed);
$this->variableConfigMock->expects($this->any())->method('getWysiwygPluginSettings')->willReturn($wysiwygPluginSettings);
$this->widgetConfigMock->expects($this->any())->method('getPluginSettings')->willReturn($pluginSettings);
$config = $this->wysiwygConfig->getConfig($data);
$this->assertInstanceOf('Magento\\Framework\\Object', $config);
$this->assertEquals($expectedResults[0], $config->getData('someData'));
$this->assertEquals($expectedResults[1], $config->getData('wysiwygPluginSettings'));
$this->assertEquals($expectedResults[2], $config->getData('pluginSettings'));
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:23,代码来源:ConfigTest.php
示例8: execute
/**
* Force admin to change password
*
* @param EventObserver $observer
* @return void
*/
public function execute(EventObserver $observer)
{
if (!$this->observerConfig->isPasswordChangeForced()) {
return;
}
if (!$this->authSession->isLoggedIn()) {
return;
}
$actionList = ['adminhtml_system_account_index', 'adminhtml_system_account_save', 'adminhtml_auth_logout'];
/** @var \Magento\Framework\App\Action\Action $controller */
$controller = $observer->getEvent()->getControllerAction();
/** @var \Magento\Framework\App\RequestInterface $request */
$request = $observer->getEvent()->getRequest();
if ($this->authSession->getPciAdminUserIsPasswordExpired()) {
if (!in_array($request->getFullActionName(), $actionList)) {
if ($this->authorization->isAllowed('Magento_Backend::myaccount')) {
$controller->getResponse()->setRedirect($this->url->getUrl('adminhtml/system_account/'));
$this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_POST_DISPATCH, true);
} else {
/*
* if admin password is expired and access to 'My Account' page is denied
* than we need to do force logout with error message
*/
$this->authSession->clearStorage();
$this->session->clearStorage();
$this->messageManager->addErrorMessage(__('Your password has expired; please contact your administrator.'));
$controller->getRequest()->setDispatched(false);
}
}
}
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:38,代码来源:ForceAdminPasswordChangeObserver.php
示例9: eavAttributeChange
/**
* Update all attribute-dependant index
*
* @param \Magento\Framework\Event\Observer $observer
* @return \Magento\CatalogSearch\Model\Fulltext\Observer
*/
public function eavAttributeChange(\Magento\Framework\Event\Observer $observer)
{
$attribute = $observer->getEvent()->getAttribute();
/* @var $attribute \Magento\Eav\Model\Entity\Attribute */
$entityType = $this->_eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY);
/* @var $entityType \Magento\Eav\Model\Entity\Type */
if ($attribute->getEntityTypeId() != $entityType->getId()) {
return $this;
}
$delete = $observer->getEventName() == 'eav_entity_attribute_delete_after';
if (!$delete && !$attribute->dataHasChangedFor('is_searchable')) {
return $this;
}
$showNotice = false;
if ($delete) {
if ($attribute->getIsSearchable()) {
$showNotice = true;
}
} elseif ($attribute->dataHasChangedFor('is_searchable')) {
$showNotice = true;
}
if ($showNotice) {
$url = $this->_backendUrl->getUrl('adminhtml/system_cache');
$this->messageManager->addNotice(__('Attribute setting change related with Search Index. Please run <a href="%1">Rebuild Search Index</a> process.', $url));
}
return $this;
}
开发者ID:Atlis,项目名称:docker-magento2,代码行数:33,代码来源:Observer.php
示例10: getWidgetWindowUrl
/**
* Return Widgets Insertion Plugin Window URL
*
* @param \Magento\Framework\DataObject $config Editor element config
* @return string
*/
public function getWidgetWindowUrl($config)
{
$params = [];
$skipped = is_array($config->getData('skip_widgets')) ? $config->getData('skip_widgets') : [];
if ($config->hasData('widget_filters')) {
$all = $this->_widgetFactory->create()->getWidgets();
$filtered = $this->_widgetFactory->create()->getWidgets($config->getData('widget_filters'));
foreach ($all as $code => $widget) {
if (!isset($filtered[$code])) {
$skipped[] = $widget['@']['type'];
}
}
}
if (count($skipped) > 0) {
$params['skip_widgets'] = $this->encodeWidgetsToQuery($skipped);
}
return $this->_backendUrl->getUrl('adminhtml/widget/index', $params);
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:24,代码来源:Config.php
示例11: checkNativeTaxRules
/**
* Check to see if there are any native tax rules created that may affect AvaTax
*
* @return array
*/
public function checkNativeTaxRules()
{
$errors = [];
if ($this->avaTaxConfig->isModuleEnabled() && $this->avaTaxConfig->getTaxMode($this->storeManager->getDefaultStoreView()) != Config::TAX_MODE_NO_ESTIMATE_OR_SUBMIT && !$this->avaTaxConfig->isNativeTaxRulesIgnored()) {
$taxRules = $this->taxRuleRepository->getList($this->searchCriteriaBuilder->create());
if (count($taxRules->getItems())) {
$errors[] = __('You have %1 native Magento Tax Rule(s) configured. ' . 'Please <a href="%2">review the tax rule(s)</a> and delete any that you do not specifically want enabled. ' . 'You should only have rules setup if you want to use them as backup rules in case of AvaTax ' . 'errors (see <a href="#row_tax_avatax_error_handling_header">Error Action setting</a>) ' . 'or if you need to support VAT tax. ' . '<a href="%3">Ignore this notification</a>.', count($taxRules->getItems()), $this->backendUrl->getUrl('tax/rule'), $this->backendUrl->getUrl('avatax/tax/ignoreTaxRuleNotification'));
}
}
return $errors;
}
开发者ID:classyllama,项目名称:ClassyLlama_AvaTax,代码行数:16,代码来源:ModuleChecks.php
示例12: processLogin
/**
* Process of configuring of current auth storage when login was performed
*
* @return \Magento\Backend\Model\Auth\Session
*/
public function processLogin()
{
if ($this->getUser()) {
$this->regenerateId();
if ($this->_backendUrl->useSecretKey()) {
$this->_backendUrl->renewSecretUrls();
}
$this->setIsFirstPageAfterLogin(true);
$this->setAcl($this->_aclBuilder->getAcl());
$this->setUpdatedAt(time());
}
return $this;
}
开发者ID:Doability,项目名称:magento2dev,代码行数:18,代码来源:Session.php
示例13: getProductSorterLoadUrl
/**
* Retrieve the category product sorter load URL.
*
* @param Category $category Category.
*
* @return string
*/
private function getProductSorterLoadUrl(Category $category)
{
$storeId = $category->getStoreId();
if ($storeId === 0) {
$defaultStoreId = $this->storeManager->getDefaultStoreView()->getId();
$storeId = current(array_filter($category->getStoreIds()));
if (in_array($defaultStoreId, $category->getStoreIds())) {
$storeId = $defaultStoreId;
}
}
$urlParams = ['ajax' => true, 'store' => $storeId];
return $this->urlBuilder->getUrl('virtualcategory/category_virtual/preview', $urlParams);
}
开发者ID:smile-sa,项目名称:elasticsuite,代码行数:20,代码来源:DataProviderPlugin.php
示例14: _redirectIfNeededAfterLogin
/**
* Checks, whether Magento requires redirection after successful admin login, and redirects user, if needed
*
* @param \Magento\Framework\App\RequestInterface $request
* @return bool
*/
protected function _redirectIfNeededAfterLogin(\Magento\Framework\App\RequestInterface $request)
{
$requestUri = null;
// Checks, whether secret key is required for admin access or request uri is explicitly set
if ($this->_url->useSecretKey()) {
$requestUri = $this->_url->getUrl('*/*/*', ['_current' => true]);
} elseif ($request) {
$requestUri = $request->getRequestUri();
}
if (!$requestUri) {
return false;
}
$this->_response->setRedirect($requestUri);
$this->_actionFlag->set('', \Magento\Framework\App\ActionInterface::FLAG_NO_DISPATCH, true);
return true;
}
开发者ID:whoople,项目名称:magento2-testing,代码行数:22,代码来源:Authentication.php
示例15: _checkExpiredPassword
/**
* Check whether the latest password is expired
* Side-effect can be when passwords were changed with different lifetime configuration settings
*
* @param array $latestPassword
* @return void
*/
private function _checkExpiredPassword($latestPassword)
{
if ($latestPassword && $this->observerConfig->_isLatestPasswordExpired($latestPassword)) {
if ($this->observerConfig->isPasswordChangeForced()) {
$message = __('It\'s time to change your password.');
} else {
$myAccountUrl = $this->url->getUrl('adminhtml/system_account/');
$message = __('It\'s time to <a href="%1">change your password</a>.', $myAccountUrl);
}
$this->messageManager->addNoticeMessage($message);
$message = $this->messageManager->getMessages()->getLastAddedMessage();
if ($message) {
$message->setIdentifier('magento_user_password_expired')->setIsSticky(true);
$this->authSession->setPciAdminUserIsPasswordExpired(true);
}
}
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:24,代码来源:AuthObserver.php
示例16: getConfigSectionsArray
/**
* Iterate over all config tabs, extract sections and its subsections
* @param string $itemsSeparator
* @param string $itemPrefix
* @return array
*/
public function getConfigSectionsArray($itemsSeparator = ' ', $itemPrefix = '')
{
$sections = array();
foreach ($this->_configStructure->getTabs() as $tab) {
/** @var $tab \Magento\Config\Model\Config\Structure\Element\Tab */
foreach ($tab->getChildren() as $section) {
/** @var $section \Magento\Config\Model\Config\Structure\Element\Section */
// We need the label & url again for the sub sections
$sectionLabel = $itemPrefix . $tab->getLabel() . $itemsSeparator . $section->getLabel();
$sectionUrl = $this->_url->getUrl('adminhtml/system_config/edit', array('section' => $section->getId()));
// First add global section to the launcher items...
$sections[] = ['label' => $sectionLabel, 'value' => $sectionUrl];
foreach ($section->getChildren() as $subSection) {
/** @var $subSection \Magento\Config\Model\Config\Structure\Element\Section */
// ...then add all sub sections
$sections[] = ['label' => $sectionLabel . $itemsSeparator . $subSection->getLabel(), 'value' => $sectionUrl . '#' . $section->getId() . '_' . $subSection->getId() . '-link'];
}
}
}
return $sections;
}
开发者ID:swnsma,项目名称:magento2,代码行数:27,代码来源:Data.php
示例17: getConfig
/**
* Return Wysiwyg config as \Magento\Framework\DataObject
*
* Config options description:
*
* enabled: Enabled Visual Editor or not
* hidden: Show Visual Editor on page load or not
* use_container: Wrap Editor contents into div or not
* no_display: Hide Editor container or not (related to use_container)
* translator: Helper to translate phrases in lib
* files_browser_*: Files Browser (media, images) settings
* encode_directives: Encode template directives with JS or not
*
* @param array|\Magento\Framework\DataObject $data Object constructor params to override default config values
* @return \Magento\Framework\DataObject
*/
public function getConfig($data = [])
{
$config = new \Magento\Framework\DataObject();
$config->setData(['enabled' => $this->isEnabled(), 'hidden' => $this->isHidden(), 'use_container' => false, 'add_variables' => true, 'add_widgets' => true, 'no_display' => false, 'encode_directives' => true, 'baseStaticUrl' => $this->_assetRepo->getStaticViewFileContext()->getBaseUrl(), 'baseStaticDefaultUrl' => str_replace('index.php/', '', $this->_backendUrl->getBaseUrl()) . $this->filesystem->getUri(DirectoryList::STATIC_VIEW) . '/', 'directives_url' => $this->_backendUrl->getUrl('cms/wysiwyg/directive'), 'popup_css' => $this->_assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css'), 'content_css' => $this->_assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css'), 'width' => '100%', 'height' => '500px', 'plugins' => []]);
$config->setData('directives_url_quoted', preg_quote($config->getData('directives_url')));
if ($this->_authorization->isAllowed('Magento_Cms::media_gallery')) {
$config->addData(['add_images' => true, 'files_browser_window_url' => $this->_backendUrl->getUrl('cms/wysiwyg_images/index'), 'files_browser_window_width' => $this->_windowSize['width'], 'files_browser_window_height' => $this->_windowSize['height']]);
}
if (is_array($data)) {
$config->addData($data);
}
if ($config->getData('add_variables')) {
$settings = $this->_variableConfig->getWysiwygPluginSettings($config);
$config->addData($settings);
}
if ($config->getData('add_widgets')) {
$settings = $this->_widgetConfig->getPluginSettings($config);
$config->addData($settings);
}
return $config;
}
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:37,代码来源:Config.php
示例18: getFilesCollection
/**
* Return files
*
* @param string $path Parent directory path
* @param string $type Type of storage, e.g. image, media etc.
* @return \Magento\Framework\Data\Collection\Filesystem
*/
public function getFilesCollection($path, $type = null)
{
if ($this->_coreFileStorageDb->checkDbUsage()) {
$files = $this->_storageDatabaseFactory->create()->getDirectoryFiles($path);
/** @var \Magento\MediaStorage\Model\File\Storage\File $fileStorageModel */
$fileStorageModel = $this->_storageFileFactory->create();
foreach ($files as $file) {
$fileStorageModel->saveFile($file);
}
}
$collection = $this->getCollection($path)->setCollectDirs(false)->setCollectFiles(true)->setCollectRecursively(false)->setOrder('mtime', \Magento\Framework\Data\Collection::SORT_ORDER_ASC);
// Add files extension filter
if ($allowed = $this->getAllowedExtensions($type)) {
$collection->setFilesFilter('/\\.(' . implode('|', $allowed) . ')$/i');
}
// prepare items
foreach ($collection as $item) {
$item->setId($this->_cmsWysiwygImages->idEncode($item->getBasename()));
$item->setName($item->getBasename());
$item->setShortName($this->_cmsWysiwygImages->getShortFilename($item->getBasename()));
$item->setUrl($this->_cmsWysiwygImages->getCurrentUrl() . $item->getBasename());
if ($this->isImage($item->getBasename())) {
$thumbUrl = $this->getThumbnailUrl($item->getFilename(), true);
// generate thumbnail "on the fly" if it does not exists
if (!$thumbUrl) {
$thumbUrl = $this->_backendUrl->getUrl('cms/*/thumbnail', ['file' => $item->getId()]);
}
$size = @getimagesize($item->getFilename());
if (is_array($size)) {
$item->setWidth($size[0]);
$item->setHeight($size[1]);
}
} else {
$thumbUrl = $this->_assetRepo->getUrl(self::THUMB_PLACEHOLDER_PATH_SUFFIX);
}
$item->setThumbUrl($thumbUrl);
}
return $collection;
}
开发者ID:tingyeeh,项目名称:magento2,代码行数:46,代码来源:Storage.php
示例19: testGetConfig
/**
* @covers \Magento\Cms\Model\Wysiwyg\Config::getConfig
* @param array $data
* @param boolean $isAuthorizationAllowed
* @param array $expectedResults
*
* @dataProvider getConfigDataProvider
*/
public function testGetConfig($data, $isAuthorizationAllowed, $expectedResults)
{
$wysiwygPluginSettings = ['wysiwygPluginSettings' => 'wysiwyg is here'];
$pluginSettings = ['pluginSettings' => 'plugins are here'];
$this->backendUrlMock->expects($this->atLeastOnce())->method('getUrl')->withConsecutive(['cms/wysiwyg/directive'], ['cms/wysiwyg_images/index']);
$this->backendUrlMock->expects($this->once())->method('getBaseUrl')->willReturn('localhost/index.php/');
$this->assetRepoMock->expects($this->atLeastOnce())->method('getUrl')->withConsecutive(['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css'], ['mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css']);
$this->filesystemMock->expects($this->once())->method('getUri')->willReturn('pub/static');
/** @var \Magento\Framework\View\Asset\ContextInterface|\PHPUnit_Framework_MockObject_MockObject $contextMock */
$contextMock = $this->getMock(\Magento\Framework\View\Asset\ContextInterface::class);
$contextMock->expects($this->once())->method('getBaseUrl')->willReturn('localhost/pub/static/');
$this->assetRepoMock->expects($this->once())->method('getStaticViewFileContext')->willReturn($contextMock);
$this->authorizationMock->expects($this->atLeastOnce())->method('isAllowed')->with('Magento_Cms::media_gallery')->willReturn($isAuthorizationAllowed);
$this->variableConfigMock->expects($this->any())->method('getWysiwygPluginSettings')->willReturn($wysiwygPluginSettings);
$this->widgetConfigMock->expects($this->any())->method('getPluginSettings')->willReturn($pluginSettings);
$config = $this->wysiwygConfig->getConfig($data);
$this->assertInstanceOf('Magento\\Framework\\DataObject', $config);
$this->assertEquals($expectedResults[0], $config->getData('someData'));
$this->assertEquals($expectedResults[1], $config->getData('wysiwygPluginSettings'));
$this->assertEquals($expectedResults[2], $config->getData('pluginSettings'));
$this->assertEquals('localhost/pub/static/', $config->getData('baseStaticUrl'));
$this->assertEquals('localhost/pub/static/', $config->getData('baseStaticDefaultUrl'));
}
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:31,代码来源:ConfigTest.php
示例20: _getUploadUrl
/**
* Get url to upload files
*
* @return string
*/
protected function _getUploadUrl()
{
return $this->_url->getUrl('catalog/product_gallery/upload');
}
开发者ID:aiesh,项目名称:magento2,代码行数:9,代码来源:BaseImage.php
注:本文中的Magento\Backend\Model\UrlInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论