コード例 #1
0
ファイル: Wysiwyg.php プロジェクト: Atlis/docker-magento2
    /**
     * Retrieve additional html and put it at the end of element html
     *
     * @return string
     */
    public function getAfterElementHtml()
    {
        $html = parent::getAfterElementHtml();
        if ($this->getIsWysiwygEnabled()) {
            $disabled = $this->getDisabled() || $this->getReadonly();
            $html .= $this->_layout->createBlock('Magento\\Backend\\Block\\Widget\\Button', '', array('data' => array('label' => __('WYSIWYG Editor'), 'type' => 'button', 'disabled' => $disabled, 'class' => $disabled ? 'disabled action-wysiwyg' : 'action-wysiwyg', 'onclick' => 'catalogWysiwygEditor.open(\'' . $this->_backendData->getUrl('catalog/product/wysiwyg') . '\', \'' . $this->getHtmlId() . '\')')))->toHtml();
            $html .= <<<HTML
<script type="text/javascript">
jQuery('#{$this->getHtmlId()}')
    .addClass('wysiwyg-editor')
    .data(
        'wysiwygEditor',
        new tinyMceWysiwygSetup(
            '{$this->getHtmlId()}',
             {
                settings: {
                    theme_advanced_buttons1 : 'bold,italic,|,justifyleft,justifycenter,justifyright,|,' +
                        'fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,|,code',
                    theme_advanced_buttons2: null,
                    theme_advanced_buttons3: null,
                    theme_advanced_buttons4: null,
                    theme_advanced_statusbar_location: null
                }
            }
        ).turnOn()
    );
</script>
HTML;
        }
        return $html;
    }
コード例 #2
0
 /**
  * Delete cookie with reason of logout
  *
  * @return $this
  */
 public function deleteLogoutReasonCookie()
 {
     $metaData = $this->createCookieMetaData();
     $metaData->setPath('/' . $this->backendData->getAreaFrontName())->setDuration(-1);
     $this->phpCookieManager->setPublicCookie(self::LOGOUT_REASON_CODE_COOKIE_NAME, '', $metaData);
     return $this;
 }
コード例 #3
0
 /**
  * Process path info
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @param string $pathInfo
  * @return string
  */
 public function process(\Magento\Framework\App\RequestInterface $request, $pathInfo)
 {
     $pathParts = explode('/', ltrim($pathInfo, '/'), 2);
     $firstPart = $pathParts[0];
     if ($firstPart != $this->_helper->getAreaFrontName()) {
         return $this->_subject->process($request, $pathInfo);
     }
     return $pathInfo;
 }
コード例 #4
0
ファイル: Tabs.php プロジェクト: tingyeeh/magento2
 /**
  * @param \Magento\Backend\Block\Template\Context $context
  * @param \Magento\Config\Model\Config\Structure $configStructure
  * @param \Magento\Backend\Helper\Data $backendHelper
  * @param array $data
  */
 public function __construct(\Magento\Backend\Block\Template\Context $context, \Magento\Config\Model\Config\Structure $configStructure, \Magento\Backend\Helper\Data $backendHelper, array $data = [])
 {
     $this->_backendHelper = $backendHelper;
     parent::__construct($context, $data);
     $this->_tabs = $configStructure->getTabs();
     $this->setId('system_config_tabs');
     $this->setTitle(__('Configuration'));
     $this->_currentSectionId = $this->getRequest()->getParam('section');
     $this->_backendHelper->addPageHelpUrl($this->getRequest()->getParam('section') . '/');
 }
コード例 #5
0
 /**
  * Log out user and redirect him to new admin custom url
  *
  * @return void
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 public function afterCustomUrlChanged()
 {
     if (is_null($this->_coreRegistry->registry('custom_admin_path_redirect'))) {
         return;
     }
     $this->_authSession->destroy();
     $route = $this->_backendData->getAreaFrontName();
     $this->_response->setRedirect($this->_storeManager->getStore()->getBaseUrl() . $route)->sendResponse();
     exit(0);
 }
コード例 #6
0
 /**
  * Log out user and redirect him to new admin custom url
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->_coreRegistry->registry('custom_admin_path_redirect') === null) {
         return;
     }
     $this->_authSession->destroy();
     $route = $this->_backendData->getAreaFrontName();
     $this->_response->setRedirect($this->_storeManager->getStore()->getBaseUrl() . $route)->sendResponse();
     exit(0);
 }
コード例 #7
0
 /**
  * Log out user and redirect to new admin custom url
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  * @SuppressWarnings(PHPMD.ExitExpression)
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     if ($this->_coreRegistry->registry('custom_admin_path_redirect') === null) {
         return;
     }
     $this->_authSession->destroy();
     $adminUrl = $this->_backendData->getHomePageUrl();
     $this->_response->setRedirect($adminUrl)->sendResponse();
     exit(0);
 }
コード例 #8
0
ファイル: NoRouteHandler.php プロジェクト: aiesh/magento2
 /**
  * Check and process no route request
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return bool
  */
 public function process(\Magento\Framework\App\RequestInterface $request)
 {
     $requestPathParams = explode('/', trim($request->getPathInfo(), '/'));
     $areaFrontName = array_shift($requestPathParams);
     if ($areaFrontName == $this->helper->getAreaFrontName()) {
         $moduleName = $this->routeConfig->getRouteFrontName('adminhtml');
         $actionNamespace = 'noroute';
         $actionName = 'index';
         $request->setModuleName($moduleName)->setControllerName($actionNamespace)->setActionName($actionName);
         return true;
     }
     return false;
 }
コード例 #9
0
    /**
     * Retrieve additional html and put it at the end of element html
     *
     * @return string
     */
    public function getAfterElementHtml()
    {
        $config = $this->_wysiwygConfig->getConfig();
        $config = json_encode($config->getData());
        $html = parent::getAfterElementHtml();
        if ($this->getIsWysiwygEnabled()) {
            $disabled = $this->getDisabled() || $this->getReadonly();
            $html .= $this->_layout->createBlock('Magento\\Backend\\Block\\Widget\\Button', '', ['data' => ['label' => __('WYSIWYG Editor'), 'type' => 'button', 'disabled' => $disabled, 'class' => 'action-wysiwyg', 'onclick' => 'catalogWysiwygEditor.open(\'' . $this->_backendData->getUrl('catalog/product/wysiwyg') . '\', \'' . $this->getHtmlId() . '\')']])->toHtml();
            $html .= <<<HTML
<script>
require([
    'jquery',
    'mage/adminhtml/wysiwyg/tiny_mce/setup'
], function(jQuery){

var config = {$config},
    editor;

jQuery.extend(config, {
    settings: {
        theme_advanced_buttons1 : 'bold,italic,|,justifyleft,justifycenter,justifyright,|,' +
            'fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,|,code',
        theme_advanced_buttons2: null,
        theme_advanced_buttons3: null,
        theme_advanced_buttons4: null,
        theme_advanced_statusbar_location: null
    },
    files_browser_window_url: false
});

editor = new tinyMceWysiwygSetup(
    '{$this->getHtmlId()}',
    config
);

editor.turnOn();

jQuery('#{$this->getHtmlId()}')
    .addClass('wysiwyg-editor')
    .data(
        'wysiwygEditor',
        editor
    );
});
</script>
HTML;
        }
        return $html;
    }
コード例 #10
0
ファイル: Catalog.php プロジェクト: aiesh/magento2
 /**
  * Load search results
  *
  * @return $this
  */
 public function load()
 {
     $result = array();
     if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
         $this->setResults($result);
         return $this;
     }
     $collection = $this->_catalogSearchData->getQuery()->getSearchCollection()->addAttributeToSelect('name')->addAttributeToSelect('description')->addBackendSearchFilter($this->getQuery())->setCurPage($this->getStart())->setPageSize($this->getLimit())->load();
     foreach ($collection as $product) {
         $description = strip_tags($product->getDescription());
         $result[] = array('id' => 'product/1/' . $product->getId(), 'type' => __('Product'), 'name' => $product->getName(), 'description' => $this->string->substr($description, 0, 30), 'url' => $this->_adminhtmlData->getUrl('catalog/product/edit', array('id' => $product->getId())));
     }
     $this->setResults($result);
     return $this;
 }
コード例 #11
0
 /**
  * Redirect into response section
  *
  * @return void
  */
 protected function redirectSection()
 {
     $this->actionFlag->expects($this->once())->method('get')->with('', \Magento\Backend\App\AbstractAction::FLAG_IS_URLS_CHECKED)->will($this->returnValue(true));
     $this->sessionMock->expects($this->once())->method('setIsUrlNotice')->with(true);
     $this->helperMock->expects($this->once())->method('getUrl')->will($this->returnValue('redirect-path'));
     $this->responseMock->expects($this->once())->method('setRedirect');
 }
コード例 #12
0
 /**
  * @param array $indexerIds
  * @param \Exception $exception
  * @param array $expectsExceptionValues
  * @dataProvider executeDataProvider
  */
 public function testExecute($indexerIds, $exception, $expectsExceptionValues)
 {
     $this->model = new \Magento\Indexer\Controller\Adminhtml\Indexer\MassChangelog($this->contextMock);
     $this->request->expects($this->any())->method('getParam')->with('indexer_ids')->will($this->returnValue($indexerIds));
     if (!is_array($indexerIds)) {
         $this->messageManager->expects($this->once())->method('addError')->with(__('Please select indexers.'))->will($this->returnValue(1));
     } else {
         $this->objectManager->expects($this->any())->method('get')->with('Magento\\Framework\\Indexer\\IndexerRegistry')->will($this->returnValue($this->indexReg));
         $indexerInterface = $this->getMockForAbstractClass('Magento\\Framework\\Indexer\\IndexerInterface', ['setScheduled'], '', false);
         $this->indexReg->expects($this->any())->method('get')->with(1)->will($this->returnValue($indexerInterface));
         if ($exception !== null) {
             $indexerInterface->expects($this->any())->method('setScheduled')->with(true)->will($this->throwException($exception));
         } else {
             $indexerInterface->expects($this->any())->method('setScheduled')->with(true)->will($this->returnValue(1));
         }
         $this->messageManager->expects($this->any())->method('addSuccess')->will($this->returnValue(1));
         if ($exception !== null) {
             $this->messageManager->expects($this->exactly($expectsExceptionValues[2]))->method('addError')->with($exception->getMessage());
             $this->messageManager->expects($this->exactly($expectsExceptionValues[1]))->method('addException')->with($exception, "We couldn't change indexer(s)' mode because of an error.");
         }
     }
     $this->helper->expects($this->any())->method("getUrl")->willReturn("magento.com");
     $this->response->expects($this->any())->method("setRedirect")->willReturn(1);
     $this->model->executeInternal();
 }
コード例 #13
0
ファイル: Order.php プロジェクト: aiesh/magento2
 /**
  * Load search results
  *
  * @return $this
  */
 public function load()
 {
     $result = array();
     if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
         $this->setResults($result);
         return $this;
     }
     $query = $this->getQuery();
     //TODO: add full name logic
     $collection = $this->_collectionFactory->create()->addAttributeToSelect('*')->addAttributeToSearchFilter(array(array('attribute' => 'increment_id', 'like' => $query . '%'), array('attribute' => 'billing_firstname', 'like' => $query . '%'), array('attribute' => 'billing_lastname', 'like' => $query . '%'), array('attribute' => 'billing_telephone', 'like' => $query . '%'), array('attribute' => 'billing_postcode', 'like' => $query . '%'), array('attribute' => 'shipping_firstname', 'like' => $query . '%'), array('attribute' => 'shipping_lastname', 'like' => $query . '%'), array('attribute' => 'shipping_telephone', 'like' => $query . '%'), array('attribute' => 'shipping_postcode', 'like' => $query . '%')))->setCurPage($this->getStart())->setPageSize($this->getLimit())->load();
     foreach ($collection as $order) {
         $result[] = array('id' => 'order/1/' . $order->getId(), 'type' => __('Order'), 'name' => __('Order #%1', $order->getIncrementId()), 'description' => $order->getBillingFirstname() . ' ' . $order->getBillingLastname(), 'form_panel_title' => __('Order #%1 (%2)', $order->getIncrementId(), $order->getBillingFirstname() . ' ' . $order->getBillingLastname()), 'url' => $this->_adminhtmlData->getUrl('sales/order/view', array('order_id' => $order->getId())));
     }
     $this->setResults($result);
     return $this;
 }
コード例 #14
0
ファイル: Customer.php プロジェクト: pradeep-wagento/magento2
 /**
  * Load search results
  *
  * @return $this
  */
 public function load()
 {
     $result = [];
     if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
         $this->setResults($result);
         return $this;
     }
     $this->searchCriteriaBuilder->setCurrentPage($this->getStart());
     $this->searchCriteriaBuilder->setPageSize($this->getLimit());
     $searchFields = ['firstname', 'lastname', 'company'];
     $filters = [];
     foreach ($searchFields as $field) {
         $filters[] = $this->filterBuilder->setField($field)->setConditionType('like')->setValue($this->getQuery() . '%')->create();
     }
     $this->searchCriteriaBuilder->addFilters($filters);
     $searchCriteria = $this->searchCriteriaBuilder->create();
     $searchResults = $this->customerRepository->getList($searchCriteria);
     foreach ($searchResults->getItems() as $customer) {
         $customerAddresses = $customer->getAddresses();
         /** Look for a company name defined in default billing address */
         $company = null;
         foreach ($customerAddresses as $customerAddress) {
             if ($customerAddress->getId() == $customer->getDefaultBilling()) {
                 $company = $customerAddress->getCompany();
                 break;
             }
         }
         $result[] = ['id' => 'customer/1/' . $customer->getId(), 'type' => __('Customer'), 'name' => $this->_customerViewHelper->getCustomerName($customer), 'description' => $company, 'url' => $this->_adminhtmlData->getUrl('customer/index/edit', ['id' => $customer->getId()])];
     }
     $this->setResults($result);
     return $this;
 }
コード例 #15
0
ファイル: SaveTest.php プロジェクト: pradeep-wagento/magento2
 public function testExecute()
 {
     $firstElement = 'firstElement';
     $symbolsDataArray = [$firstElement];
     $redirectUrl = 'redirectUrl';
     $this->requestMock->expects($this->once())->method('getParam')->with('custom_currency_symbol')->willReturn($symbolsDataArray);
     $this->helperMock->expects($this->once())->method('getUrl')->with('*');
     $this->redirectMock->expects($this->once())->method('getRedirectUrl')->willReturn($redirectUrl);
     $this->currencySymbolMock->expects($this->once())->method('setCurrencySymbolsData')->with($symbolsDataArray);
     $this->responseMock->expects($this->once())->method('setRedirect');
     $this->filterManagerMock->expects($this->once())->method('stripTags')->with($firstElement)->willReturn($firstElement);
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\CurrencySymbol\\Model\\System\\Currencysymbol')->willReturn($this->currencySymbolMock);
     $this->objectManagerMock->expects($this->once())->method('get')->with('Magento\\Framework\\Filter\\FilterManager')->willReturn($this->filterManagerMock);
     $this->messageManagerMock->expects($this->once())->method('addSuccess')->with(__('You applied the custom currency symbols.'));
     $this->action->execute();
 }
コード例 #16
0
ファイル: Url.php プロジェクト: Doability/magento2dev
 /**
  * Return backend area front name, defined in configuration
  *
  * @return string
  */
 public function getAreaFrontName()
 {
     if (!$this->_getData('area_front_name')) {
         $this->setData('area_front_name', $this->_backendHelper->getAreaFrontName());
     }
     return $this->_getData('area_front_name');
 }
コード例 #17
0
ファイル: Attribute.php プロジェクト: aiesh/magento2
 /**
  * @param \Magento\Framework\App\Helper\Context $context
  * @param \Magento\Framework\App\Route\Config $routeConfig
  * @param \Magento\Framework\Locale\ResolverInterface $locale
  * @param \Magento\Backend\Model\UrlInterface $backendUrl
  * @param \Magento\Backend\Model\Auth $auth
  * @param \Magento\Backend\App\Area\FrontNameResolver $frontNameResolver
  * @param \Magento\Framework\Math\Random $mathRandom
  * @param \Magento\Eav\Model\Config $eavConfig
  * @param \Magento\Backend\Model\Session $session
  * @param \Magento\Catalog\Model\Resource\Product\CollectionFactory $productsFactory
  */
 public function __construct(\Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Route\Config $routeConfig, \Magento\Framework\Locale\ResolverInterface $locale, \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\Backend\Model\Auth $auth, \Magento\Backend\App\Area\FrontNameResolver $frontNameResolver, \Magento\Framework\Math\Random $mathRandom, \Magento\Eav\Model\Config $eavConfig, \Magento\Backend\Model\Session $session, \Magento\Catalog\Model\Resource\Product\CollectionFactory $productsFactory)
 {
     $this->_eavConfig = $eavConfig;
     $this->_session = $session;
     $this->_productsFactory = $productsFactory;
     parent::__construct($context, $routeConfig, $locale, $backendUrl, $auth, $frontNameResolver, $mathRandom);
 }
コード例 #18
0
 /**
  * @param string $path
  * @param array $arguments
  * @param int $index
  */
 protected function prepareRedirect($path, $arguments, $index)
 {
     $this->actionFlag->expects($this->any())->method('get')->with('', 'check_url_settings')->will($this->returnValue(true));
     $this->session->expects($this->any())->method('setIsUrlNotice')->with(true);
     $url = $path . '/' . (!empty($arguments) ? $arguments['shipment_id'] : '');
     $this->helper->expects($this->at($index))->method('getUrl')->with($path, $arguments)->will($this->returnValue($url));
     $this->response->expects($this->at($index))->method('setRedirect')->with($url);
 }
コード例 #19
0
ファイル: ImagesTest.php プロジェクト: Doability/magento2dev
 /**
  * @param string $baseUrl
  * @param string $fileName
  * @param bool $isUsingStaticUrls
  * @param string $expectedHtml
  * @dataProvider providerGetImageHtmlDeclaration
  */
 public function testGetImageHtmlDeclaration($baseUrl, $fileName, $isUsingStaticUrls, $expectedHtml)
 {
     $directive = '{{media url="/' . $fileName . '"}}';
     $this->generalSettingsGetImageHtmlDeclaration($baseUrl, $isUsingStaticUrls);
     $this->urlEncoderMock->expects($this->any())->method('encode')->with($directive)->willReturn($directive);
     $this->backendDataMock->expects($this->any())->method('getUrl')->with('cms/wysiwyg/directive', ['___directive' => $directive])->willReturn($directive);
     $this->assertEquals($expectedHtml, $this->imagesHelper->getImageHtmlDeclaration($fileName));
 }
コード例 #20
0
 /**
  * @param int $cmId
  */
 protected function prepareRedirect($cmId)
 {
     $this->actionFlag->expects($this->once())->method('get')->with('', 'check_url_settings')->will($this->returnValue(true));
     $this->session->expects($this->once())->method('setIsUrlNotice')->with(true);
     $path = 'sales/order_creditmemo/view';
     $this->response->expects($this->once())->method('setRedirect')->with($path . '/' . $cmId);
     $this->helper->expects($this->atLeastOnce())->method('getUrl')->with($path, ['creditmemo_id' => $cmId])->will($this->returnValue($path . '/' . $cmId));
 }
コード例 #21
0
 /**
  * @return void
  */
 public function testExecute()
 {
     $successMessage = 'All other open sessions for this account were terminated.';
     $this->sessionsManager->expects($this->once())->method('logoutOtherUserSessions');
     $this->messageManager->expects($this->once())->method('addSuccess')->with($successMessage);
     $this->messageManager->expects($this->never())->method('addError');
     $this->messageManager->expects($this->never())->method('addException');
     $this->responseMock->expects($this->once())->method('setRedirect');
     $this->actionFlagMock->expects($this->once())->method('get')->with('', \Magento\Backend\App\AbstractAction::FLAG_IS_URLS_CHECKED);
     $this->backendHelperMock->expects($this->once())->method('getUrl');
     $this->controller->execute();
 }
コード例 #22
0
 /**
  * Retrieve value element chooser URL
  *
  * @return string
  */
 public function getValueElementChooserUrl()
 {
     $url = false;
     switch ($this->getAttribute()) {
         case 'sku':
         case 'category_ids':
             $url = 'catalog_rule/promo_widget/chooser/attribute/' . $this->getAttribute();
             if ($this->getJsFormObject()) {
                 $url .= '/form/' . $this->getJsFormObject();
             }
             break;
         default:
             break;
     }
     return $url !== false ? $this->_backendData->getUrl($url) : '';
 }
コード例 #23
0
ファイル: Images.php プロジェクト: pavelnovitsky/magento2
 /**
  * Prepare Image insertion declaration for Wysiwyg or textarea(as_is mode)
  *
  * @param string $filename Filename transferred via Ajax
  * @param bool $renderAsTag Leave image HTML as is or transform it to controller directive
  * @return string
  */
 public function getImageHtmlDeclaration($filename, $renderAsTag = false)
 {
     $fileurl = $this->getCurrentUrl() . $filename;
     $mediaUrl = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
     $mediaPath = str_replace($mediaUrl, '', $fileurl);
     $directive = sprintf('{{media url="%s"}}', $mediaPath);
     if ($renderAsTag) {
         $html = sprintf('<img src="%s" alt="" />', $this->isUsingStaticUrlsAllowed() ? $fileurl : $directive);
     } else {
         if ($this->isUsingStaticUrlsAllowed()) {
             $html = $fileurl;
             // $mediaPath;
         } else {
             $directive = $this->_coreData->urlEncode($directive);
             $html = $this->_backendData->getUrl('cms/wysiwyg/directive', array('___directive' => $directive));
         }
     }
     return $html;
 }
コード例 #24
0
 /**
  * Execute method.
  */
 public function execute()
 {
     $code = $this->getRequest()->getParam('code', false);
     $userId = $this->getRequest()->getParam('state');
     //load admin user
     $adminUser = $this->adminUser->create()->load($userId);
     //app code and admin user must be present
     if ($code && $adminUser->getId()) {
         $clientId = $this->scopeConfig->getValue(\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CLIENT_ID);
         $clientSecret = $this->scopeConfig->getValue(\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CLIENT_SECRET_ID);
         //callback uri if not set custom
         $redirectUri = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB, true);
         $redirectUri .= 'connector/email/callback';
         $data = 'client_id=' . $clientId . '&client_secret=' . $clientSecret . '&redirect_uri=' . $redirectUri . '&grant_type=authorization_code' . '&code=' . $code;
         //callback url
         $url = $this->config->getTokenUrl();
         //@codingStandardsIgnoreStart
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_TIMEOUT, 10);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
         curl_setopt($ch, CURLOPT_POST, count($data));
         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
         curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded']);
         $response = json_decode(curl_exec($ch));
         if ($response === false) {
             $this->helper->error('Error Number: ' . curl_errno($ch), []);
         }
         if (isset($response->error)) {
             $this->helper->error('OAUTH failed ' . $response->error, []);
         } elseif (isset($response->refresh_token)) {
             //save the refresh token to the admin user
             $adminUser->setRefreshToken($response->refresh_token)->save();
         }
         //@codingStandardsIgnoreEnd
     }
     //redirect to automation index page
     $this->_redirect($this->adminHelper->getUrl('dotdigitalgroup_email/studio'));
 }
コード例 #25
0
ファイル: ResetPasswordTest.php プロジェクト: opexsw/magento2
 public function testResetPasswordActionSendEmail()
 {
     $customerId = 1;
     $email = '*****@*****.**';
     $websiteId = 1;
     $redirectLink = 'customer/*/edit';
     $this->_request->expects($this->once())->method('getParam')->with($this->equalTo('customer_id'), $this->equalTo(0))->will($this->returnValue($customerId));
     $customer = $this->getMockForAbstractClass('\\Magento\\Customer\\Api\\Data\\CustomerInterface', ['getId', 'getEmail', 'getWebsiteId']);
     $customer->expects($this->once())->method('getEmail')->will($this->returnValue($email));
     $customer->expects($this->once())->method('getWebsiteId')->will($this->returnValue($websiteId));
     $this->_customerRepositoryMock->expects($this->once())->method('getById')->with($customerId)->will($this->returnValue($customer));
     // verify initiatePasswordReset() is called
     $this->_customerAccountManagementMock->expects($this->once())->method('initiatePasswordReset')->with($email, AccountManagement::EMAIL_REMINDER, $websiteId);
     // verify success message
     $this->messageManager->expects($this->once())->method('addSuccess')->with($this->equalTo('Customer will receive an email with a link to reset password.'));
     // verify redirect
     $this->_helper->expects($this->any())->method('getUrl')->with($this->equalTo('customer/*/edit'), $this->equalTo(['id' => $customerId, '_current' => true]))->will($this->returnValue($redirectLink));
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with($redirectLink, ['id' => $customerId, '_current' => true]);
     $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Redirect', $this->_testedObject->execute());
 }
コード例 #26
0
 public function testResetPasswordActionSendEmail()
 {
     $customerId = 1;
     $email = "*****@*****.**";
     $websiteId = 1;
     $redirectLink = 'http://example.com';
     $this->_request->expects($this->once())->method('getParam')->with($this->equalTo('customer_id'), $this->equalTo(0))->will($this->returnValue($customerId));
     $customerBuilder = $this->getMock('\\Magento\\Customer\\Service\\V1\\Data\\CustomerBuilder', [], [], '', false);
     $data = ['id' => $customerId, 'email' => $email, 'website_id' => $websiteId];
     $customerBuilder->expects($this->once())->method('getData')->will($this->returnValue($data));
     $customer = new \Magento\Customer\Service\V1\Data\Customer($customerBuilder);
     $this->_acctServiceMock->expects($this->once())->method('getCustomer')->with($customerId)->will($this->returnValue($customer));
     // verify initiatePasswordReset() is called
     $this->_acctServiceMock->expects($this->once())->method('initiatePasswordReset')->with($email, CustomerAccountServiceInterface::EMAIL_REMINDER, $websiteId);
     // verify success message
     $this->messageManager->expects($this->once())->method('addSuccess')->with($this->equalTo('Customer will receive an email with a link to reset password.'));
     // verify redirect
     $this->_helper->expects($this->any())->method('getUrl')->with($this->equalTo('customer/*/edit'), $this->equalTo(array('id' => $customerId, '_current' => true)))->will($this->returnValue($redirectLink));
     $this->_response->expects($this->once())->method('setRedirect')->with($this->equalTo($redirectLink));
     $this->_testedObject->execute();
 }
コード例 #27
0
ファイル: DataTest.php プロジェクト: Doability/magento2dev
 public function testGetHomePageUrl()
 {
     $this->assertStringEndsWith('index.php/backend/admin/', $this->_helper->getHomePageUrl(), 'Incorrect home page URL');
 }
コード例 #28
0
 /**
  * Test generate unique token for reset password confirmation link
  *
  * @covers \Magento\User\Helper\Data::generateResetPasswordLinkToken
  */
 public function testGenerateResetPasswordLinkToken()
 {
     $actual = $this->_helper->generateResetPasswordLinkToken();
     $this->assertGreaterThan(15, strlen($actual));
 }
コード例 #29
0
ファイル: Edit.php プロジェクト: tingyeeh/magento2
 /**
  * Add delete button
  *
  * @return void
  */
 protected function _addDeleteButton()
 {
     $this->addButton('delete', ['label' => __('Delete'), 'onclick' => 'deleteConfirm(' . json_encode(__('Are you sure you want to do this?')) . ',' . json_encode($this->_adminhtmlData->getUrl('adminhtml/*/delete', ['id' => $this->getUrlRewrite()->getId()])) . ')', 'class' => 'scalable delete', 'level' => -1]);
 }
コード例 #30
0
ファイル: Form.php プロジェクト: kidaa30/magento2-platformsh
 /**
  * Form post init
  *
  * @param \Magento\Framework\Data\Form $form
  * @return $this
  */
 protected function _formPostInit($form)
 {
     $form->setAction($this->_adminhtmlData->getUrl('adminhtml/*/save', ['id' => $this->_getModel()->getId()]));
     return $this;
 }