-
Notifications
You must be signed in to change notification settings - Fork 9
/
generate_autoload
executable file
·34 lines (25 loc) · 918 Bytes
/
generate_autoload
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
#!/usr/bin/env ruby
require 'FileUtils'
FILENAME = 'ext_autoload.php'
CLASSES = {}
def add_to_autoload(filename)
content = File.read(filename)
namespace = content.match(/namespace ([a-zA-Z0-9\\]+);\n/)
namespace = namespace[1] unless namespace.nil?
content.scan(/(class|interface) ([a-zA-Z0-9_]+) /).each do |m|
full_class_name = namespace.nil? ? m[1].downcase : "#{namespace}\\#{m[1]}".downcase
CLASSES[full_class_name] = filename
end
end
Dir.glob('Classes/**/*.php').each {|f| add_to_autoload(f) }
add_to_autoload('Classes/legacy_naming.php')
File.open(FILENAME, 'w') do |f|
f.write("<?php\n");
f.write("$extensionPath = t3lib_extMgm::extPath('t3chimp') . '/';\n");
f.write("return array(\n")
CLASSES.each do |class_name, filename|
class_name = class_name.gsub('\\', '\\\\\\')
f.write(" '#{class_name}' => $extensionPath . '#{filename}',\n")
end
f.write(");\n")
end