Class: Saruman::Generators::Controller
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Saruman::Generators::Controller
show all
- Includes:
- Base, Thor::Actions
- Defined in:
- lib/saruman/generators/controller.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Base
#app_design_frontend_base_layout_local_xml_path, #app_design_frontend_base_layout_path, #app_design_frontend_base_path, #app_design_frontend_base_template_namespace_path, #app_design_frontend_base_template_path, #author, #block_klass_name, #combined_namespace, #command, #config_has_tag?, #controller?, #controller_block_file_path, #controller_block_path, #controller_front_name, #controller_path, #controllers, #extension_base_path, #extension_config_file_path, #extension_config_path, #extension_current_version, #extension_name_lower, #extension_temp_path, #extension_upgrade_version, #global_config_basepath, #global_config_file_path, #helper?, #helper_path, #insert_tag_at_node, #insert_xml_at_node, #model?, #model_klass_name, #model_path, #models, #name, #name_lower, #namespace, #namespace_lower, #observer?, #observers, #read_extension_config, #resource_model_klass_name, #resource_model_name, #resource_model_path, #setup_base_path, #version, #write_extension_config
Class Method Details
.source_root ⇒ Object
12
13
14
|
# File 'lib/saruman/generators/controller.rb', line 12
def self.source_root
File.dirname(__FILE__) + "/controller/templates"
end
|
Instance Method Details
#create_controller_directory ⇒ Object
30
31
32
|
# File 'lib/saruman/generators/controller.rb', line 30
def create_controller_directory
empty_directory(controller_path) unless File.directory?(controller_path)
end
|
#create_controllers ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/saruman/generators/controller.rb', line 67
def create_controllers
controllers.each do |controller|
@controller = controller
template("Controller.php", "#{controller_path}#{@controller.name}Controller.php")
if controller.create_views
empty_directory(controller_view_path(@controller.name_lower)) unless File.directory?(controller_view_path(@controller.name_lower))
empty_directory(controller_block_path) unless File.directory?(controller_block_path)
@controller_block_klass_name = "#{combined_namespace}_Block_#{@controller.name.capitalize}"
template("Block.php", controller_block_file_path(@controller.name))
controller.actions.each do |action|
@action = action
@kontroller_front_name = controller_front_name
template("view.phtml", controller_view_action_path(@controller.name_lower, @action.name))
end
app_design_frontend_base_template_namespace_path
end
end
end
|
#modify_config ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/saruman/generators/controller.rb', line 34
def modify_config
@config = read_extension_config
unless config_has_tag?("config frontend")
insert_tag_at_node("frontend", "config")
end
unless config_has_tag?("config frontend routers")
insert_tag_at_node("routers", "config frontend")
end
unless config_has_tag?("config frontend routers #{name_lower}")
insert_xml_at_node(@controller_xml_config_builder.config_frontend_routers_name_xml, "config frontend routers")
end
@controllers_with_views = controllers.select { |controller| controller.create_views == true }
if @controllers_with_views.length > 0
unless config_has_tag?("config frontend layout")
insert_xml_at_node(@controller_xml_config_builder.config_frontend_layout_xml, "config frontend")
end
unless config_has_tag?("config global blocks")
insert_xml_at_node(@controller_xml_config_builder.config_global_blocks_xml, "config global")
end
template("local.xml", app_design_frontend_base_layout_local_xml_path)
end
end
|
#validate_extension ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/saruman/generators/controller.rb', line 16
def validate_extension
unless File.directory?("#{extension_base_path}")
@error = "error"
end
unless File.exist?("#{extension_config_path}/config.xml")
@error = "error"
end
end
|
#write_changes ⇒ Object
87
88
89
|
# File 'lib/saruman/generators/controller.rb', line 87
def write_changes
write_extension_config
end
|