You are here

function _imageapi_optimize_get_methods in Image Optimize (or ImageAPI Optimize) 6

Same name and namespace in other branches
  1. 7 imageapi_optimize.module \_imageapi_optimize_get_methods()

Gets all implemented methods by ImageAPI and contrib modules. This function takes a dozens of miliseconds CPU times.

1 call to _imageapi_optimize_get_methods()
imageapi_optimize_init in ./imageapi_optimize.module
Implements hook_init().
1 string reference to '_imageapi_optimize_get_methods'
imageapi_optimize_settings_form in ./imageapi_optimize.module
Settings form for the toolkit.

File

./imageapi_optimize.module, line 282
Image optimize functionalities

Code

function _imageapi_optimize_get_methods() {
  $methods = array();
  $prefix = variable_get('imageapi_optimize_toolkit', '') . '_image_';

  // Load ImageAPI methods that can be located in external files
  // managed by the ImageCache module.
  if (module_exists('imagecache')) {
    foreach (imagecache_action_definitions() as $definition) {
      if (isset($definition['file'])) {
        require_once './' . $definition['file'];
      }
    }
  }
  $funcs = get_defined_functions();
  foreach ($funcs['user'] as $func) {
    if (strpos($func, $prefix) === 0) {
      $method = substr($func, strlen($prefix));
      if (!in_array($method, array(
        'open',
        'close',
      ))) {
        $methods[] = $method;
      }
    }
  }
  cache_set('imageapi_optimize:methods', $methods);
  watchdog('imageapi', 'Refresh ImageAPI methods');
  return $methods;
}