Created
March 1, 2019 06:20
-
-
Save LiamKarlMitchell/8d88c5a23df6ea71525524be422b07de to your computer and use it in GitHub Desktop.
Dumps container, referenceContainer, block and referenceBlock names and locations from Magento2 site.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$instructions = array("container", "referenceContainer", "block", "referenceBlock"); | |
foreach ($instructions as $instruction) { | |
$containers = array(); | |
$fp = fopen('debug_'.$instruction.'.txt', 'w'); | |
$command = 'egrep -r -i --include \*.xml "<'.$instruction.'".*?"name=" *'; | |
exec($command, $output); | |
$container_max_length = 1; | |
$pattern = '/(.*?):.*<'.$instruction.'.*name="(.*?)".*/'; | |
foreach ($output as $subject) { | |
preg_match($pattern, $subject, $matches); | |
$containers[$matches[2]][] = $matches[1]; | |
if (strlen($matches[2]) > $container_max_length) $container_max_length = strlen($matches[2]); | |
} | |
$n=1; | |
ksort($containers); | |
foreach ($containers as $k => $v) { | |
fprintf($fp, "%6s", "$n. "); | |
fprintf($fp, "%-".$container_max_length."s".$v[0]."\n", $k); | |
$i=1; | |
while (isset($v[$i])) { | |
fprintf($fp, " %-".$container_max_length."s".$v[$i]."\n", ""); | |
$i++; | |
} | |
$n++; | |
} | |
fclose($fp); | |
} | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can't really take credit for this, found it on Stack Overflow shared by maxagaz and just modified it to dump them all to txt file.