<commit_before><?php

abstract class CM_Response_View_Abstract extends CM_Response_Abstract {

    /**
     * @param array|null $additionalParams
     */
    public function reloadComponent(array $additionalParams = null) {
        $componentInfo = $this->_getViewInfo('CM_Component_Abstract');
        $componentId = $componentInfo['id'];
        $componentClassName = $componentInfo['className'];
        $componentParams = $componentInfo['params'];

        if ($additionalParams) {
            $componentParams = array_merge($componentParams, $additionalParams);
        }
        $component = CM_Component_Abstract::factory($componentClassName, CM_Params::factory($componentParams));

        $renderAdapter = new CM_RenderAdapter_Component($this->getRender(), $component);
        $html = $renderAdapter->fetch();

        $frontend = $this->getRender()->getGlobalResponse();
        $autoId = $frontend->getTreeRoot()->getValue()->getAutoId();

        $componentReferenceOld = 'cm.views["' . $componentId . '"]';
        $componentReferenceNew = 'cm.views["' . $autoId . '"]';
        $frontend->getOnloadHeaderJs()->append('cm.window.appendHidden(' . json_encode($html) . ');');
        $frontend->getOnloadPrepareJs()->append($componentReferenceOld . '.getParent().registerChild(' . $componentReferenceNew . ');');
        $frontend->getOnloadPrepareJs()->append($componentReferenceOld . '.replaceWithHtml(' . $componentReferenceNew . '.$el);');
        $frontend->getOnloadReadyJs()->append('cm.views["' . $autoId . '"]._ready();');
    }

    /**
     * @param CM_Params $params
     * @return array<commit_msg>Use CM_RenderAdapter_Component::factory in reloadComponent method<commit_after><?php

abstract class CM_Response_View_Abstract extends CM_Response_Abstract {

    /**
     * @param array|null $additionalParams
     */
    public function reloadComponent(array $additionalParams = null) {
        $componentInfo = $this->_getViewInfo('CM_Component_Abstract');
        $componentId = $componentInfo['id'];
        $componentClassName = $componentInfo['className'];
        $componentParams = $componentInfo['params'];

        if ($additionalParams) {
            $componentParams = array_merge($componentParams, $additionalParams);
        }
        $component = CM_Component_Abstract::factory($componentClassName, CM_Params::factory($componentParams));
        $renderAdapter = CM_RenderAdapter_Component::factory($this->getRender(), $component);
        $html = $renderAdapter->fetch();

        $frontend = $this->getRender()->getGlobalResponse();
        $autoId = $frontend->getTreeRoot()->getValue()->getAutoId();

        $componentReferenceOld = 'cm.views["' . $componentId . '"]';
        $componentReferenceNew = 'cm.views["' . $autoId . '"]';
        $frontend->getOnloadHeaderJs()->append('cm.window.appendHidden(' . json_encode($html) . ');');
        $frontend->getOnloadPrepareJs()->append($componentReferenceOld . '.getParent().registerChild(' . $componentReferenceNew . ');');
        $frontend->getOnloadPrepareJs()->append($componentReferenceOld . '.replaceWithHtml(' . $componentReferenceNew . '.$el);');
        $frontend->getOnloadReadyJs()->append('cm.views["' . $autoId . '"]._ready();');
    }

    /**
     * @param CM_Params $params
     * @return array
{'fraction_non_alphanumeric': 0.16414294367050272, 'fraction_numerical': 0.0, 'mean_word_length': 3.8645066273932254, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6597247', 'n_tokens_mistral': 900, 'n_tokens_neox': 879, 'n_words': 128}