/** * Returns block content depends on ajax request * * @return void */ public function execute() { if (!$this->getRequest()->isAjax()) { $this->_forward('noroute'); return; } // disable profiling during private content handling AJAX call \Magento\Framework\Profiler::reset(); $currentRoute = $this->getRequest()->getRouteName(); $currentControllerName = $this->getRequest()->getControllerName(); $currentActionName = $this->getRequest()->getActionName(); $currentRequestUri = $this->getRequest()->getRequestUri(); $origRequest = $this->getRequest()->getParam('originalRequest'); $origRequest = json_decode($origRequest, true); $this->getRequest()->setRouteName($origRequest['route']); $this->getRequest()->setControllerName($origRequest['controller']); $this->getRequest()->setActionName($origRequest['action']); $this->getRequest()->setRequestUri($origRequest['uri']); /** @var \Magento\Framework\View\Element\BlockInterface[] $blocks */ $blocks = $this->_getBlocks(); $data = []; foreach ($blocks as $blockName => $blockInstance) { $data[$blockName] = $blockInstance->toHtml(); } $this->getRequest()->setRouteName($currentRoute); $this->getRequest()->setControllerName($currentControllerName); $this->getRequest()->setActionName($currentActionName); $this->getRequest()->setRequestUri($currentRequestUri); $this->getResponse()->setPrivateHeaders(\Magento\PageCache\Helper\Data::PRIVATE_MAX_AGE_CACHE); $this->translateInline->processResponseBody($data); $this->getResponse()->appendBody(json_encode($data)); }
/** * Finds requested resource and provides it to the client * * @return \Magento\Framework\App\ResponseInterface * @throws \Exception */ public function launch() { // disabling profiling when retrieving static resource \Magento\Framework\Profiler::reset(); $appMode = $this->state->getMode(); if ($appMode == \Magento\Framework\App\State::MODE_PRODUCTION) { $this->response->setHttpResponseCode(404); } else { $path = $this->request->get('resource'); $params = $this->parsePath($path); $this->state->setAreaCode($params['area']); $this->objectManager->configure($this->configLoader->load($params['area'])); $file = $params['file']; unset($params['file']); $asset = $this->assetRepo->createAsset($file, $params); $this->response->setFilePath($asset->getSourceFile()); $this->publisher->publish($asset); } return $this->response; }
protected function tearDown() { \Magento\Framework\Profiler::reset(); }
public function testResetProfiler() { $driver = $this->_getDriverMock(); $driver->expects($this->once())->method('clear')->with(null); \Magento\Framework\Profiler::add($driver); \Magento\Framework\Profiler::reset(); $this->assertAttributeEquals([], '_currentPath', 'Magento\\Framework\\Profiler'); $this->assertAttributeEquals([], '_tagFilters', 'Magento\\Framework\\Profiler'); $this->assertAttributeEquals([], '_defaultTags', 'Magento\\Framework\\Profiler'); $this->assertAttributeEquals([], '_drivers', 'Magento\\Framework\\Profiler'); $this->assertAttributeEquals(false, '_hasTagFilters', 'Magento\\Framework\\Profiler'); $this->assertAttributeEquals(0, '_pathCount', 'Magento\\Framework\\Profiler'); $this->assertAttributeEquals([], '_pathIndex', 'Magento\\Framework\\Profiler'); }