<commit_before><?php

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

class Sth_Di_Model_Config extends Mage_Core_Model_Config
{
    /**
     * @var ContainerBuilder
     */
    private $_container;

    /**
     * Class construct
     *
     * @param mixed $sourceData
     */
    public function __construct($sourceData = null)
    {
        parent::__construct($sourceData);
    }

    /**
     * Gets an object from the DI Container
     *
     * @param string $reference
     * @return mixed
     */
    public function getFromContainer($reference)
    {
        if (null === $this->_container) {
            $this->_initContainer();
        }

        return $this->_container->get($reference, ContainerBuilder::NULL_ON_INVALID_REFERENCE);
    }

    /**
     * Initialises the DI container
     */
    private function _initContainer()
    {
        $this->_container = new ContainerBuilder();
        $loader = new XmlFileLoader($this->_container, new FileLocator($this->getOptions()->getEtcDir()));
        $loader->load('services.xml');
    }
}<commit_msg>load services.xml from modules<commit_after><?php

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

class Sth_Di_Model_Config extends Mage_Core_Model_Config
{
    /**
     * @var ContainerBuilder
     */
    protected $_container;

    /**
     * Class construct
     *
     * @param mixed $sourceData
     */
    public function __construct($sourceData = null)
    {
        parent::__construct($sourceData);
    }

    /**
     * Gets an object from the DI Container
     *
     * @param string $reference
     * @return mixed
     */
    public function getFromContainer($reference)
    {
        if (null === $this->_container) {
            $this->_initContainer();
        }

        return $this->_container->get($reference, ContainerBuilder::NULL_ON_INVALID_REFERENCE);
    }

    /**
     * Initialises the DI container
     */
    protected function _initContainer()
    {
        $this->_container = new ContainerBuilder();

        $this->_loadServicesXmlForPath(
            $this->getOptions()->getEtcDir()
        );

        $modulesWithServices = array_keys(
            $this->getNode('sth_di')->asArray()
        );

        foreach ($modulesWithServices as $moduleName) {
            if ( ! $this->getNode('modules/' . $moduleName)->is('active')) {
                continue;
            }

            $this->_loadServicesXmlForPath(
                $this->getModuleDir('etc', $moduleName)
            );
        }
    }

    /**
     * @param string $path
     */
    protected function _loadServicesXmlForPath($path)
    {
        $loader = new XmlFileLoader(
            $this->_container,
            new FileLocator($path)
        );

        $loader->load('services.xml');
    }
}
{'fraction_non_alphanumeric': 0.12097042206713193, 'fraction_numerical': 0.0, 'mean_word_length': 2.329646017699115, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 3}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '519502', 'n_tokens_mistral': 835, 'n_tokens_neox': 817, 'n_words': 152}