Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Файл поиска использования метода getOption.
* Должен находится в корне сайта.
*/
define('MODX_API_MODE', true);
require 'index.php';
$modx->lexicon->load('resource','context','element','system_events','access','default','setting');
//echo $modx->lexicon('setting_cache_context_settings'); exit;
$count = 0;
ob_start();
foreach (['model/', 'xpdo/'] as $folder) {
$directory = new RecursiveDirectoryIterator(dirname(__FILE__) . '/core/' . $folder);
$iterator = new RecursiveIteratorIterator($directory);
foreach ($iterator as $object) {
if ($object->isFile() && $object->getExtension() == 'php') {
$content = file_get_contents($object->getPathname());
if (preg_match_all('#(modx|xpdo|this)->getOption\([\'"]?([A-z0-9._:]+)[\'"]?.*\)#', $content, $matches)) {
$options = array_filter($matches[2], function ($option) use ($modx) {
// Раскомментировать для вывода настроек, у которых есть лексиконы
// Uncomment to get system settings that have lexicons
return !isset($modx->config[$option]); // && $modx->lexicon('setting_' . $option) != 'setting_' . $option;
});
if (!empty($options)) {
$count += count($options);
echo '<h3>'. str_replace('D:\Projects\test.local\www/', '', $object->getPathname()).'<h3>';
echo "<pre>";
dump(array_unique($options));
echo "</pre>";
}
}
}
}
}
$output = ob_get_clean();
ob_flush();
echo "<h3>Всего {$count} записей!<h3>";
echo $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.