/** * @param FilterInterface $filter * @param bool $isNegation * @param string $query * @return string * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ private function processQueryWithField(FilterInterface $filter, $isNegation, $query) { $currentStoreId = $this->scopeResolver->getScope()->getId(); $attribute = $this->config->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $filter->getField()); $select = $this->getSelect(); $table = $attribute->getBackendTable(); if ($filter->getField() == 'price') { $query = str_replace('price', 'min_price', $query); $select->from(['main_table' => $this->resource->getTableName('catalog_product_index_price')], 'entity_id')->where($query); } elseif ($filter->getField() == 'category_ids') { return 'category_index.category_id = ' . $filter->getValue(); } else { if ($attribute->isStatic()) { $select->from(['main_table' => $table], 'entity_id')->where($query); } else { if ($filter->getType() == FilterInterface::TYPE_TERM) { $field = $filter->getField(); $mapper = function ($value) use($field, $isNegation) { return ($isNegation ? '-' : '') . $this->attributePrefix . $field . '_' . $value; }; if (is_array($filter->getValue())) { $value = implode(' ', array_map($mapper, $filter->getValue())); } else { $value = $mapper($filter->getValue()); } return 'MATCH (data_index) AGAINST (' . $this->getConnection()->quote($value) . ' IN BOOLEAN MODE)'; } $ifNullCondition = $this->getConnection()->getIfNullSql('current_store.value', 'main_table.value'); $select->from(['main_table' => $table], 'entity_id')->joinLeft(['current_store' => $table], 'current_store.attribute_id = main_table.attribute_id AND current_store.store_id = ' . $currentStoreId, null)->columns([$filter->getField() => $ifNullCondition])->where('main_table.attribute_id = ?', $attribute->getAttributeId())->where('main_table.store_id = ?', \Magento\Store\Model\Store::DEFAULT_STORE_ID)->having($query); } } return 'search_index.product_id IN ( select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter )'; }
/** * @param FilterInterface $filter * @param bool $isNegation * @param string $query * @param QueryContainer $queryContainer * @return string */ private function processQueryWithField(FilterInterface $filter, $isNegation, $query, QueryContainer $queryContainer) { $currentStoreId = $this->scopeResolver->getScope()->getId(); $attribute = $this->config->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $filter->getField()); $select = $this->getConnection()->select(); $table = $attribute->getBackendTable(); if ($filter->getField() == 'price') { $query = str_replace('price', 'min_price', $query); $select->from(['main_table' => $this->resource->getTableName('catalog_product_index_price')], 'entity_id')->where($query); } elseif ($filter->getField() == 'category_ids') { return 'category_index.category_id = ' . $filter->getValue(); } else { if ($attribute->isStatic()) { $select->from(['main_table' => $table], 'entity_id')->where($query); } else { if ($filter->getType() == FilterInterface::TYPE_TERM) { if (is_array($filter->getValue())) { $value = sprintf('%s IN (%s)', $isNegation ? 'NOT' : '', implode(',', $filter->getValue())); } else { $value = ($isNegation ? '!' : '') . '= ' . $filter->getValue(); } $filterQuery = sprintf('cpie.store_id = %d AND cpie.attribute_id = %d AND cpie.value %s', $this->scopeResolver->getScope()->getId(), $attribute->getId(), $value); $queryContainer->addFilter($filterQuery); return ''; } $ifNullCondition = $this->getConnection()->getIfNullSql('current_store.value', 'main_table.value'); $select->from(['main_table' => $table], 'entity_id')->joinLeft(['current_store' => $table], 'current_store.attribute_id = main_table.attribute_id AND current_store.store_id = ' . $currentStoreId, null)->columns([$filter->getField() => $ifNullCondition])->where('main_table.attribute_id = ?', $attribute->getAttributeId())->where('main_table.store_id = ?', \Magento\Store\Model\Store::DEFAULT_STORE_ID)->having($query); } } return 'search_index.entity_id IN ( select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter )'; }
/** * {@inheritdoc} */ public function getScope($scopeId = null) { $scope = $this->scopeResolver->getScope($scopeId); if (!$scope instanceof \Magento\Framework\Url\ScopeInterface) { throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Invalid scope object')); } return $scope; }
/** * Get scope id by code * * @param Dimension $dimension * @return int */ private function getScopeId($dimension) { if (is_numeric($dimension->getValue())) { return $dimension->getValue(); } else { return $this->scopeResolver->getScope($dimension->getValue())->getId(); } }
/** * @param Dimension $dimension * @return string */ private function generateExpression(Dimension $dimension) { $field = $dimension->getName(); $value = $dimension->getValue(); if ('scope' === $field) { $field = self::STORE_FIELD_NAME; $value = $this->scopeResolver->getScope($value)->getId(); } return $this->conditionManager->generateCondition('search_index.' . $field, '=', $value); }
/** * @param Dimension $dimension * @param AdapterInterface $adapter * @return string */ private function generateExpression(Dimension $dimension, AdapterInterface $adapter) { $identifier = $dimension->getName(); $value = $dimension->getValue(); if (self::DEFAULT_DIMENSION_NAME === $identifier) { $identifier = self::STORE_FIELD_NAME; $value = $this->scopeResolver->getScope($value)->getId(); } return sprintf('%s = %s', $adapter->quoteIdentifier($identifier), $adapter->quote($value)); }
/** * {@inheritdoc} */ public function search(SearchCriteriaInterface $searchCriteria) { $this->requestBuilder->setRequestName($searchCriteria->getRequestName()); $scope = $this->scopeResolver->getScope(); $this->requestBuilder->bindDimension('scope', $scope); foreach ($searchCriteria->getFilterGroups() as $filterGroup) { foreach ($filterGroup->getFilters() as $filter) { $this->addFieldToFilter($filter->getField(), $filter->getValue()); } } $this->requestBuilder->setFrom($searchCriteria->getCurrentPage() * $searchCriteria->getPageSize()); $this->requestBuilder->setSize($searchCriteria->getPageSize()); $request = $this->requestBuilder->create(); $searchResponse = $this->searchEngine->search($request); return $this->searchResponseBuilder->build($searchResponse)->setSearchCriteria($searchCriteria); }
/** * @param FilterInterface $filter * @param bool $isNegation * @param string $query * @return string */ private function processQueryWithField(FilterInterface $filter, $isNegation, $query) { /** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */ $attribute = $this->config->getAttribute(Product::ENTITY, $filter->getField()); if ($filter->getField() === 'price') { $resultQuery = str_replace($this->connection->quoteIdentifier('price'), $this->connection->quoteIdentifier('price_index.min_price'), $query); } elseif ($filter->getField() === 'category_ids') { return 'category_ids_index.category_id = ' . $filter->getValue(); } elseif ($attribute->isStatic()) { $alias = $this->tableMapper->getMappingAlias($filter); $resultQuery = str_replace($this->connection->quoteIdentifier($attribute->getAttributeCode()), $this->connection->quoteIdentifier($alias . '.' . $attribute->getAttributeCode()), $query); } elseif ($filter->getType() === FilterInterface::TYPE_TERM && in_array($attribute->getFrontendInput(), ['select', 'multiselect'], true)) { $alias = $this->tableMapper->getMappingAlias($filter); if (is_array($filter->getValue())) { $value = sprintf('%s IN (%s)', $isNegation ? 'NOT' : '', implode(',', $filter->getValue())); } else { $value = ($isNegation ? '!' : '') . '= ' . $filter->getValue(); } $resultQuery = sprintf('%1$s.value %2$s', $alias, $value); } else { $table = $attribute->getBackendTable(); $select = $this->connection->select(); $ifNullCondition = $this->connection->getIfNullSql('current_store.value', 'main_table.value'); $currentStoreId = $this->scopeResolver->getScope()->getId(); $select->from(['main_table' => $table], 'entity_id')->joinLeft(['current_store' => $table], 'current_store.attribute_id = main_table.attribute_id AND current_store.store_id = ' . $currentStoreId, null)->columns([$filter->getField() => $ifNullCondition])->where('main_table.attribute_id = ?', $attribute->getAttributeId())->where('main_table.store_id = ?', Store::DEFAULT_STORE_ID)->having($query); $resultQuery = 'search_index.entity_id IN ( select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter )'; } return $resultQuery; }
/** * Functions returns array with price formatting info * * @return array */ public function getPriceFormat() { $format = \Zend_Locale_Data::getContent($this->_localeResolver->getLocaleCode(), 'currencynumber'); $symbols = \Zend_Locale_Data::getList($this->_localeResolver->getLocaleCode(), 'symbols'); $pos = strpos($format, ';'); if ($pos !== false) { $format = substr($format, 0, $pos); } $format = preg_replace("/[^0\\#\\.,]/", "", $format); $totalPrecision = 0; $decimalPoint = strpos($format, '.'); if ($decimalPoint !== false) { $totalPrecision = strlen($format) - (strrpos($format, '.') + 1); } else { $decimalPoint = strlen($format); } $requiredPrecision = $totalPrecision; $t = substr($format, $decimalPoint); $pos = strpos($t, '#'); if ($pos !== false) { $requiredPrecision = strlen($t) - $pos - $totalPrecision; } if (strrpos($format, ',') !== false) { $group = $decimalPoint - strrpos($format, ',') - 1; } else { $group = strrpos($format, '.'); } $integerRequired = strpos($format, '.') - strpos($format, '0'); $result = array('pattern' => $this->_scopeResolver->getScope()->getCurrentCurrency()->getOutputFormat(), 'precision' => $totalPrecision, 'requiredPrecision' => $requiredPrecision, 'decimalSymbol' => $symbols['decimal'], 'groupSymbol' => $symbols['group'], 'groupLength' => $group, 'integerRequired' => $integerRequired); return $result; }
/** * Functions returns array with price formatting info * * @return array * @SuppressWarnings(PHPMD.NPathComplexity) */ public function getPriceFormat() { $localeData = (new DataBundle())->get($this->_localeResolver->getLocale()); $format = $localeData['NumberElements']['latn']['patterns']['currencyFormat'] ?: explode(';', $localeData['NumberPatterns'][1])[0]; $decimalSymbol = $localeData['NumberElements']['latn']['symbols']['decimal'] ?: $localeData['NumberElements'][0]; $groupSymbol = $localeData['NumberElements']['latn']['symbols']['group'] ?: $localeData['NumberElements'][1]; $pos = strpos($format, ';'); if ($pos !== false) { $format = substr($format, 0, $pos); } $format = preg_replace("/[^0\\#\\.,]/", "", $format); $totalPrecision = 0; $decimalPoint = strpos($format, '.'); if ($decimalPoint !== false) { $totalPrecision = strlen($format) - (strrpos($format, '.') + 1); } else { $decimalPoint = strlen($format); } $requiredPrecision = $totalPrecision; $t = substr($format, $decimalPoint); $pos = strpos($t, '#'); if ($pos !== false) { $requiredPrecision = strlen($t) - $pos - $totalPrecision; } if (strrpos($format, ',') !== false) { $group = $decimalPoint - strrpos($format, ',') - 1; } else { $group = strrpos($format, '.'); } $integerRequired = strpos($format, '.') - strpos($format, '0'); $result = ['pattern' => $this->_scopeResolver->getScope()->getCurrentCurrency()->getOutputFormat(), 'precision' => $totalPrecision, 'requiredPrecision' => $requiredPrecision, 'decimalSymbol' => $decimalSymbol, 'groupSymbol' => $groupSymbol, 'groupLength' => $group, 'integerRequired' => $integerRequired]; return $result; }
/** * @param \Magento\CatalogSearch\Model\Adapter\Mysql\Aggregation\DataProvider $subject * @param callable $proceed * @param BucketInterface $bucket * @param Dimension[] $dimensions * * @return Select * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundGetDataSet(\Magento\CatalogSearch\Model\Adapter\Mysql\Aggregation\DataProvider $subject, \Closure $proceed, BucketInterface $bucket, array $dimensions) { if ($bucket->getField() == 'category_ids') { $currentScope = $dimensions['scope']->getValue(); $currentScopeId = $this->scopeResolver->getScope($currentScope)->getId(); $currenCategory = $this->layer->getCurrentCategory(); $derivedTable = $this->getSelect(); $derivedTable->from(['main_table' => $this->resource->getTableName('catalog_category_product_index')], ['entity_id' => 'product_id', 'value' => 'category_id'])->where('main_table.store_id = ?', $currentScopeId); if (!empty($currenCategory)) { $derivedTable->join(['category' => $this->resource->getTableName('catalog_category_entity')], 'main_table.category_id = category.entity_id', [])->where('`category`.`path` LIKE ?', $currenCategory->getPath() . '%')->where('`category`.`level` > ?', $currenCategory->getLevel()); } $select = $this->getSelect(); $select->from(['main_table' => $derivedTable]); return $select; } return $proceed($bucket, $dimensions); }
/** * Detect and apply design for the area * * @param \Magento\Framework\App\RequestInterface $request * @return void */ public function detectDesign($request = null) { if ($this->_code == self::AREA_FRONTEND) { $isDesignException = $request && $this->_applyUserAgentDesignException($request); if (!$isDesignException) { $this->_design->loadChange($this->_scopeResolver->getScope()->getId())->changeDesign($this->_getDesign()); } } }
/** * Retrieve array of allowed currencies * * @return array */ protected function _getAllowedCurrencies() { if ($this->_appState->isInstalled()) { $allowed = $this->_scopeResolver->getScope()->getAllowedCurrencies(); } else { $allowed = $this->_config->getAllowedCurrencies(); } return $allowed; }
/** * @param PriceBox $subject * @return string */ private function getTaxRateIds(PriceBox $subject) { $rateIds = []; $customerSession = $this->customerSession; $billingAddress = $customerSession->getDefaultTaxBillingAddress(); $shippingAddress = $customerSession->getDefaultTaxShippingAddress(); $customerTaxClassId = $customerSession->getCustomerTaxClassId(); if (!empty($billingAddress)) { $billingAddress = new \Magento\Framework\DataObject($billingAddress); } if (!empty($shippingAddress)) { $shippingAddress = new \Magento\Framework\DataObject($shippingAddress); } if (!empty($billingAddress) || !empty($shippingAddress)) { $rateRequest = $this->getTaxCalculation()->getRateRequest($billingAddress, $shippingAddress, $customerTaxClassId, $this->scopeResolver->getScope()->getId(), $this->customerSession->getCustomerId()); $rateRequest->setProductClassId($subject->getSaleableItem()->getTaxClassId()); $rateIds = $this->getTaxCalculation()->getResource()->getRateIds($rateRequest); } return implode('_', $rateIds); }
/** * @param Dimension[] $dimensions * @return string[] */ private function prepareDimensions(array $dimensions) { $preparedDimensions = []; foreach ($dimensions as $dimension) { if ('scope' === $dimension->getName()) { continue; } $preparedDimensions[] = $this->conditionManager->generateCondition($dimension->getName(), '=', $this->dimensionScopeResolver->getScope($dimension->getValue())->getId()); } return $preparedDimensions; }
/** * @param FilterInterface $filter * @param string $query * @param Attribute $attribute * @return string */ private function processRangeNumeric(FilterInterface $filter, $query, $attribute) { $tableSuffix = $attribute->getBackendType() === 'decimal' ? '_decimal' : ''; $table = $this->resource->getTableName("catalog_product_index_eav{$tableSuffix}"); $select = $this->connection->select(); $currentStoreId = $this->scopeResolver->getScope()->getId(); $select->from(['main_table' => $table], 'entity_id')->columns([$filter->getField() => 'main_table.value'])->where('main_table.attribute_id = ?', $attribute->getAttributeId())->where('main_table.store_id = ?', $currentStoreId)->having($query); $resultQuery = 'search_index.entity_id IN ( select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter )'; return $resultQuery; }
/** * Creates block object based on data and add it to the layout * * @param Layout\Reader\Context $readerContext * @param Context $generatorContext * @return $this * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function process(Layout\Reader\Context $readerContext, Layout\Generator\Context $generatorContext) { $scheduledStructure = $readerContext->getScheduledStructure(); $layout = $generatorContext->getLayout(); $structure = $generatorContext->getStructure(); /** @var $blocks \Magento\Framework\View\Element\AbstractBlock[] */ $blocks = []; $blockActions = []; // Instantiate blocks and collect all actions data foreach ($scheduledStructure->getElements() as $elementName => $element) { list($type, $data) = $element; if ($type === self::TYPE) { try { $block = $this->generateBlock($scheduledStructure, $structure, $elementName); $blocks[$elementName] = $block; $layout->setBlock($elementName, $block); if (!empty($data['actions'])) { $blockActions[$elementName] = $data['actions']; } } catch (\Exception $e) { $this->handleRenderException($e); unset($blocks[$elementName]); } } } // Set layout instance to all generated block (trigger _prepareLayout method) foreach ($blocks as $elementName => $block) { try { $block->setLayout($layout); $this->eventManager->dispatch('core_layout_block_create_after', ['block' => $block]); } catch (\Exception $e) { $this->handleRenderException($e); $layout->setBlock($elementName, $this->exceptionHandlerBlockFactory->create(['blockName' => $elementName])); unset($blockActions[$elementName]); } $scheduledStructure->unsetElement($elementName); } // Run all actions after layout initialization foreach ($blockActions as $elementName => $actions) { try { foreach ($actions as $action) { list($methodName, $actionArguments, $configPath, $scopeType) = $action; if (empty($configPath) || $this->scopeConfig->isSetFlag($configPath, $scopeType, $this->scopeResolver->getScope())) { $this->generateAction($blocks[$elementName], $methodName, $actionArguments); } } } catch (\Exception $e) { $this->handleRenderException($e); $layout->setBlock($elementName, $this->exceptionHandlerBlockFactory->create(['blockName' => $elementName])); } } return $this; }
/** * {@inheritdoc} */ public function getDataSet(BucketInterface $bucket, array $dimensions) { $currentScope = $dimensions['scope']->getValue(); $attribute = $this->eavConfig->getAttribute(Product::ENTITY, $bucket->getField()); if ($attribute->getAttributeCode() == 'price') { /** @var \Magento\Store\Model\Store $store */ $store = $this->scopeResolver->getScope($currentScope); if (!$store instanceof \Magento\Store\Model\Store) { throw new \RuntimeException('Illegal scope resolved'); } $table = $this->resource->getTableName('catalog_product_index_price'); $select = $this->getSelect(); $select->from(['main_table' => $table], null)->columns([BucketInterface::FIELD_VALUE => 'main_table.min_price'])->where('main_table.customer_group_id = ?', $this->customerSession->getCustomerGroupId())->where('main_table.website_id = ?', $store->getWebsiteId()); } else { $currentScopeId = $this->scopeResolver->getScope($currentScope)->getId(); $select = $this->getSelect(); $table = $this->resource->getTableName('catalog_product_index_eav' . ($attribute->getBackendType() == 'decimal' ? '_decimal' : '')); $select->from(['main_table' => $table], ['value'])->where('main_table.attribute_id = ?', $attribute->getAttributeId())->where('main_table.store_id = ? ', $currentScopeId); } return $select; }
/** * Remove comma from price on JPY * * @param \Magento\Framework\Locale\Format $subject * @param $value * @return array */ public function beforeGetNumber(Format $subject, $value) { $currency = $this->_scopeResolver->getScope()->getCurrentCurrency(); $locale = $this->_localeResolver->getLocale(); $format = $subject->getPriceFormat($locale, $currency->getCode()); if ($currency->getCode() == 'JPY') { if ($format['groupSymbol'] == '.') { $value = preg_replace('/\\./', '', $value); $value = preg_replace('/,/', '.', $value); } else { $value = preg_replace('/,/', '', $value); } } return [$value]; }
/** * {@inheritdoc} */ public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null) { if (!$scope instanceof \Magento\Framework\App\ScopeInterface) { $scope = $this->_scopeResolver->getScope($scope); } $scopeTimeStamp = $this->scopeTimeStamp($scope); $fromTimeStamp = strtotime($dateFrom); $toTimeStamp = strtotime($dateTo); if ($dateTo) { // fix date YYYY-MM-DD 00:00:00 to YYYY-MM-DD 23:59:59 $toTimeStamp += 86400; } $result = false; if (!$this->_dateTime->isEmptyDate($dateFrom) && $scopeTimeStamp < $fromTimeStamp) { } elseif (!$this->_dateTime->isEmptyDate($dateTo) && $scopeTimeStamp > $toTimeStamp) { } else { $result = true; } return $result; }
/** * Build structure that is based on scheduled structure * * @param ScheduledStructure $scheduledStructure * @param Data\Structure $structure * @return $this */ protected function buildStructure(ScheduledStructure $scheduledStructure, Data\Structure $structure) { //Schedule all element into nested structure while (false === $scheduledStructure->isStructureEmpty()) { $this->helper->scheduleElement($scheduledStructure, $structure, key($scheduledStructure->getStructure())); } $scheduledStructure->flushPaths(); foreach ($scheduledStructure->getListToMove() as $elementToMove) { $this->moveElementInStructure($scheduledStructure, $structure, $elementToMove); } foreach ($scheduledStructure->getListToRemove() as $elementToRemove) { $this->removeElement($scheduledStructure, $structure, $elementToRemove); } foreach ($scheduledStructure->getIfconfigList() as $elementToCheckConfig) { list($configPath, $scopeType) = $scheduledStructure->getIfconfigElement($elementToCheckConfig); if (!empty($configPath) && !$this->scopeConfig->isSetFlag($configPath, $scopeType, $this->scopeResolver->getScope())) { $this->removeIfConfigElement($scheduledStructure, $structure, $elementToCheckConfig); } } return $this; }
/** * Join matches to collection * * @param AbstractDb $collection * @param string $field * * @return $this */ public function joinMatches($collection, $field = 'e.entity_id') { $requestBuilder = $this->requestBuilderFactory->create(); $queryText = $this->queryFactory->get()->getQueryText(); $requestBuilder->bind('search_term', $queryText); $requestBuilder->bindDimension('scope', $this->scopeResolver->getScope()); $requestBuilder->setRequestName($this->index->getCode()); $queryRequest = $requestBuilder->create(); $queryResponse = $this->searchEngine->search($queryRequest); $temporaryStorage = $this->temporaryStorageFactory->create(); if ($field == 'ID') { //external connection (need improve detection) $ids = [0]; foreach ($queryResponse->getIterator() as $item) { $ids[] = $item->getId(); } $collection->getSelect()->where(new \Zend_Db_Expr("{$field} IN (" . implode(',', $ids) . ")")); } else { $table = $temporaryStorage->storeDocuments($queryResponse->getIterator()); $collection->getSelect()->joinInner(['search_result' => $table->getName()], $field . ' = search_result.' . TemporaryStorage::FIELD_ENTITY_ID, []); } return $this; }
/** * @param PriceBox $subject * @param string $result * @return string * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterGetCacheKey(PriceBox $subject, $result) { return implode('-', [$result, $this->priceCurrency->getCurrencySymbol(), $this->dateTime->scopeDate($this->scopeResolver->getScope()->getId())->format('Ymd'), $this->scopeResolver->getScope()->getId(), $this->customerSession->getCustomerGroupId()]); }
/** * Retrieve current store identifier * * @return int */ protected function getStoreId() { return $this->scopeResolver->getScope($this->scope)->getId(); }
/** * Retrieve scope code * * @return string */ protected function getScope() { $scope = $this->getConfig('area') == 'adminhtml' ? 'admin' : null; return $this->_scopeResolver->getScope($scope)->getCode(); }
/** * Return URL for ajax requests * * @return string */ protected function getAjaxUrl() { return $this->url->getUrl($this->translatorRoute, ['_secure' => $this->scopeResolver->getScope()->isCurrentlySecure()]); }
/** * Run action defined in layout update * * @param \Magento\Framework\View\Layout\Element $node * @param \Magento\Framework\View\Layout\Element $parent * @return void */ protected function _generateAction($node, $parent) { $configPath = $node->getAttribute('ifconfig'); if ($configPath && !$this->_scopeConfig->isSetFlag($configPath, $this->scopeType, $this->scopeResolver->getScope())) { return; } $method = $node->getAttribute('method'); $parentName = $node->getAttribute('block'); if (empty($parentName)) { $parentName = $parent->getElementName(); } $profilerKey = 'BLOCK_ACTION:' . $parentName . '>' . $method; \Magento\Framework\Profiler::start($profilerKey); $block = $this->getBlock($parentName); if (!empty($block)) { $args = $this->_parseArguments($node); $args = $this->_evaluateArguments($args); call_user_func_array(array($block, $method), $args); } \Magento\Framework\Profiler::stop($profilerKey); }
/** * Return URL for ajax requests * * @return string */ protected function _getAjaxUrl() { return $this->_url->getUrl('translation/ajax/index', ['_secure' => $this->_scopeResolver->getScope()->isCurrentlySecure(), \Magento\DesignEditor\Helper\Data::TRANSLATION_MODE => $this->_helper->getTranslationMode()]); }