-
Notifications
You must be signed in to change notification settings - Fork 11
/
magento-config-check-syntax
executable file
·52 lines (46 loc) · 1.47 KB
/
magento-config-check-syntax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env php
<?php
//
// Check to make sure that all config files for a module are valid XML.
// Otherwise, Magento will often silently refuse to load them.
//
// @author Joseph Mastey <joseph.mastey@gmail.com>
// @author $Author$
// @version $Id$
// @copyright Copyright (c) JRM Ventures LLC, 2010-
require_once("lib/base.php");
require_once("lib/xml.php");
switch(count($server->argv)) {
case 2:
$module = $server->argv[1];
break;
default:
print_help();
break;
}
# attempt to auto-detect a module
if(0 == strcmp("-", $module)) {
$module = current_module("local");
}
try {
$module_path = module_path($module);
$files = `ls $magento/app/code/$module_path/etc`;
$files = explode("\n", $files);
foreach($files as $file) {
if(!$file) { continue; }
print "Checking $file\n";
$elem = @simplexml_load_file("$magento/app/code/$module_path/etc/$file");
if(!$elem) {
throw new Exception("Parser failed while attempting to parse $file!! You suck!");
}
}
print "\nAll files seem to be valid XML.\n";
} catch( Exception $em_all ) {
print_error($em_all->getMessage()."\n");
}
function putdocs() {
return array(
"Check to make sure that a module's configuration files are valid XML",
"Usage: magento-config-check-syntax module",
);
}