Skip to content

configuration getters - method name and intent consistency #935

@ghost

Description

This reopens #443

Throughout the code base there are a few different approaches to naming methods when retrieving a configuration setting. From app/code/Magento/Tax/Helper/Data.php

/**
 * Get configuration setting "Apply Discount On Prices Including Tax" value
 *
 * @param  null|string|bool|int|Store $store
 * @return bool
 */
public function discountTax($store = null)
{
    return $this->_config->discountTax($store);
}

/**
 * Get value of "Apply Tax On" custom/original price configuration settings
 *
 * @param  null|string|bool|int|Store $store
 * @return string|null
 */
public function getTaxBasedOn($store = null)
{
    return $this->_scopeConfig->getValue(
        Config::CONFIG_XML_PATH_BASED_ON,
        \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
        $store
    );
}

/**
 * Check if tax can be applied to custom price
 *
 * @param  null|string|bool|int|Store $store
 * @return bool
 */
public function applyTaxOnCustomPrice($store = null)
{
    return (int) $this->_scopeConfig->getValue(
        Config::CONFIG_XML_PATH_APPLY_ON,
        \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
        $store
    ) == 0;
}

Some other examples:
app/code/Magento/Backend/Block/Page/System/Config/Robots/Reset.php

public function getRobotsDefaultCustomInstructions()
{
    return trim((string)$this->_scopeConfig->getValue(
        self::XML_PATH_ROBOTS_DEFAULT_CUSTOM_INSTRUCTIONS, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT
    ));
}

app/code/Magento/Backend/Block/Page/Notices.php

public function displayDemoNotice()
{
    return $this->_scopeConfig->getValue('design/head/demonotice', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
}

app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php

protected function _isManageStock()
{
    return $this->_scopeConfig->isSetFlag(
        \Magento\CatalogInventory\Model\Configuration::XML_PATH_MANAGE_STOCK,
        \Magento\Store\Model\ScopeInterface::SCOPE_STORE
    );
}

It will be a lot easier to work with Magento if one approach is chosen and consistently used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: Format is not validGate 1 Failed. Automatic verification of issue format is failed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions