@@ -77,6 +77,12 @@ protected function invokeCommands(array $commands) {
77
77
* The exit code of the command.
78
78
*/
79
79
protected function invokeCommand ($ command_name , array $ args = []) {
80
+
81
+ // Skip invocation of disabled commands.
82
+ if ($ this ->isCommandDisabled ($ command_name )) {
83
+ return 0 ;
84
+ }
85
+
80
86
/** @var \Robo\Application $application */
81
87
$ application = $ this ->getContainer ()->get ('application ' );
82
88
$ command = $ application ->find ($ command_name );
@@ -88,6 +94,40 @@ protected function invokeCommand($command_name, array $args = []) {
88
94
return $ returnCode ;
89
95
}
90
96
97
+ /**
98
+ * Gets an array of commands that have been configured to be disabled.
99
+ *
100
+ * @return array
101
+ * A flat array of disabled commands.
102
+ */
103
+ protected function getDisabledCommands () {
104
+ $ disabled_commands_config = $ this ->getConfigValue ('disable-targets ' );
105
+ if ($ disabled_commands_config ) {
106
+ $ disabled_commands = ArrayManipulator::flattenMultidimensionalArray ($ disabled_commands_config , ': ' );
107
+ return $ disabled_commands ;
108
+ }
109
+ return [];
110
+ }
111
+
112
+ /**
113
+ * Determines if a command has been disabled via disable-targets.
114
+ *
115
+ * @param string $command
116
+ * The command name.
117
+ *
118
+ * @return bool
119
+ * TRUE if the command is disabled.
120
+ */
121
+ protected function isCommandDisabled ($ command ) {
122
+ $ disabled_commands = $ this ->getDisabledCommands ();
123
+ if (is_array ($ disabled_commands ) && array_key_exists ($ command , $ disabled_commands ) && $ disabled_commands [$ command ]) {
124
+ $ this ->output ()->writeln ("The $ command command is disabled. " );
125
+ return TRUE ;
126
+ }
127
+
128
+ return FALSE ;
129
+ }
130
+
91
131
/**
92
132
* Invokes a given 'target-hooks' hook, typically defined in project.yml.
93
133
*
0 commit comments