นี่เป็นสคริปต์เล็ก ๆ ที่ฉันใช้เพื่อตรวจสอบว่าโมเดลบล็อกหรือผู้ช่วยเหลือใด ๆ ถูกเขียนทับหรือไม่ น่าเสียดายที่มันไม่ทำงานสำหรับตัวควบคุมและคำนึงถึงโมดูลที่ถูกปิดใช้งานด้วย แต่จากมุมมองของฉันนี่ไม่ใช่เรื่องใหญ่
แนวคิดหลักคือการแยกวิเคราะห์ไฟล์กำหนดค่าและค้นหา<rewrite>แท็ก สร้างไฟล์ PHP index.phpในระดับเดียวกับ มาเรียกมันrewrites.phpพร้อมเนื้อหานี้:
<?php 
$folders = array('app/code/local/', 'app/code/community/');//folders to parse
$configFiles = array();
foreach ($folders as $folder){
    $files = glob($folder.'*/*/etc/config.xml');//get all config.xml files in the specified folder
    $configFiles = array_merge($configFiles, $files);//merge with the rest of the config files
}
$rewrites = array();//list of all rewrites
foreach ($configFiles as $file){
    $dom = new DOMDocument;
    $dom->loadXML(file_get_contents($file));
    $xpath = new DOMXPath($dom);
        $path = '//rewrite/*';//search for tags named 'rewrite'
        $text = $xpath->query($path);
        foreach ($text as $rewriteElement){
            $type = $rewriteElement->parentNode->parentNode->parentNode->tagName;//what is overwritten (model, block, helper)
            $parent = $rewriteElement->parentNode->parentNode->tagName;//module identifier that is being rewritten (core, catalog, sales, ...)
            $name = $rewriteElement->tagName;//element that is rewritten (layout, product, category, order)
            foreach ($rewriteElement->childNodes as $element){
                $rewrites[$type][$parent.'/'.$name][] = $element->textContent;//class that rewrites it
            }
        }
}
echo "<pre>";print_r($rewrites);
เมื่อโทรในเบราว์เซอร์คุณควรเห็นสิ่งนี้:
Array
(
    [models] => Array
        (
            [core/layout] => Array
                (
                    [0] => Namespace_Module_Model_Core_Layout
                    [1] => Namespace1_Module1_Model_Core_Layout //if the second element is present it means there is a possible conflict
                )
            [...] => ....
        )
    [blocks] => ...
    [helpers] => ...
)
นี่หมายความว่าโมเดล'core/layout'ถูกเขียนทับโดยNamespace_Module_Model_Core_Layout
หากคุณมี 2 ค่าขึ้นไปในอาร์เรย์ ['core / layout'] หมายความว่ามีข้อขัดแย้ง
และคุณสามารถระบุโมดูลที่เขียนทับสิ่งที่อยู่บนพื้นฐานNamespaceและModule
               
              
grep