For a very large project, the loss of speed will be offset by a modularity gain and, if done correctly, scalability. This function is very simple, very small and can be used to turn on any php and then execute it without the need for a long if () else or case switch. Now this may be more intense than the case switch statement, but for a large project, this function is ideal.
function trnFeature_getFeature($feature = 'default', $options = array()) {
$path = __DIR__ . "/features/{$feature}/{$feature}";
if(!file_exists($path . '.inc')) {
return false;
}
include_once $path . '.inc';
$feature_fn = "trnFeature_" . $feature . "_featureInit";
if(function_exists($feature_fn)) {
$output = $feature_fn($options);
} else {
return false;
}
return $output;
}
source
share