/** * {@inheritdoc} */ public function getFieldPathsByAttribute($attributeName, $attributeValue) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getFieldPathsByAttribute'); if (!$pluginInfo) { return parent::getFieldPathsByAttribute($attributeName, $attributeValue); } else { return $this->___callPlugins('getFieldPathsByAttribute', func_get_args(), $pluginInfo); } }
/** * Collect all system config paths where current template is currently used * * @return array */ public function getSystemConfigPathsWhereCurrentlyUsed() { $templateId = $this->getId(); if (!$templateId) { return []; } $templatePaths = $this->structure->getFieldPathsByAttribute('source_model', 'Magento\\Config\\Model\\Config\\Source\\Email\\Template'); if (!count($templatePaths)) { return []; } $configData = $this->_getResource()->getSystemConfigByPathsAndTemplateId($templatePaths, $templateId); foreach ($templatePaths as $path) { if ($this->scopeConfig->getValue($path, ScopeConfigInterface::SCOPE_TYPE_DEFAULT) == $templateId) { foreach ($configData as $data) { if ($data['path'] == $path) { continue 2; // don't add final fallback value if it was found in stored config } } $configData[] = ['scope' => ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 'path' => $path]; } } return $configData; }
/** * Collect all system config paths where current template is currently used * * @return array */ public function getSystemConfigPathsWhereUsedCurrently() { $templateId = $this->getId(); if (!$templateId) { return []; } $templatePaths = $this->_structure->getFieldPathsByAttribute('source_model', 'Magento\\Config\\Model\\Config\\Source\\Email\\Template'); if (!count($templatePaths)) { return []; } $configData = $this->_getResource()->getSystemConfigByPathsAndTemplateId($templatePaths, $templateId); if (!$configData) { return []; } return $configData; }
/** * @param $attributeName * @param $attributeValue * @param $paths * @dataProvider getFieldPathsByAttributeDataProvider */ public function testGetFieldPathsByAttribute($attributeName, $attributeValue, $paths) { $this->assertEquals($paths, $this->_model->getFieldPathsByAttribute($attributeName, $attributeValue)); }