Created
October 16, 2017 00:04
-
-
Save adrian-martinez-interactiv4/d0f598faa682e8f915e966543e581391 to your computer and use it in GitHub Desktop.
Adminhtml get url test, place in Magento root folder and execute it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Magento\Framework\App\Area; | |
require __DIR__ . '/app/bootstrap.php'; | |
class AdminhtmlGetUrlTestApp extends \Magento\Framework\App\Http implements \Magento\Framework\AppInterface | |
{ | |
public function launch() | |
{ | |
$this->_state->setAreaCode(Area::AREA_ADMINHTML); | |
$this->_objectManager->configure($this->_configLoader->load(Area::AREA_ADMINHTML)); | |
$this->_request->setRouteName('catalog'); | |
$this->_request->setControllerName('product_set'); | |
$this->_request->setActionName('index'); | |
$originalParams = [ | |
'sort' => 'set_name', | |
'dir' => 'desc', | |
'filter' => 'c2V0X25hbWU9YQ==', | |
]; | |
foreach ($originalParams as $paramName => $paramValue) { | |
$this->_request->setParam($paramName, $paramValue); | |
} | |
/** @var \Magento\Framework\UrlInterface $urlBuilder */ | |
$urlBuilder = $this->_objectManager->get(\Magento\Framework\UrlInterface::class); | |
if (!isset($params['_current'])) { | |
$params['_current'] = true; | |
} | |
// Expected same result for all of them, variables with symbols that can be url encoded get messed up | |
$urls = []; | |
$urls[] = $urlBuilder->getUrl('*/*/*', $params); | |
$urls[] = $urlBuilder->getUrl('*/*/*', $params); | |
$urls[] = $urlBuilder->getUrl('*/*/*', $params); | |
$urls[] = $urlBuilder->getUrl('*/*/*', $params); | |
$this->_response->setBody(implode(PHP_EOL, $urls)); | |
//the method must end with this line | |
return $this->_response; | |
} | |
public function catchException(\Magento\Framework\App\Bootstrap $bootstrap, \Exception $exception) | |
{ | |
return false; | |
} | |
} | |
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); | |
/** @var \Magento\Framework\App\Http $app */ | |
$app = $bootstrap->createApplication('AdminhtmlGetUrlTestApp'); | |
$bootstrap->run($app); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment