Skip to content

Circular Dependency when using ScopeConfigInterface in Constructor for certain objects #2807

@ghost

Description

I was trying to read some backend config using the ScopeConfigInterface.

di.xml
< preference for="Magento\Framework\Logger\Monolog" type="Foo\Log\Helper\Data" /  > 
public function __constructor(
    Magento\Framework\App\Config\ScopeConfigInterface $config
) {
   config->getValue('dev/debug/remote_server_host');
}

Error:::
Circular dependency: Magento\Config\Model\Config\Backend\Encrypted depends on Magento\Framework\Model\Context and vice versa.

When I use the same code, but using another preference in di.xml I can read the config as expected.

Example
(just for testing)
< preference for="Magento\Cms\Controller\Index\Index" type="Foo\Log\Helper\Data" / >

Is this an issue with dependency compiliation because it is only possible to use ScopeConfigInterface on certain objects?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions