public static function ResourceManager::isValidCallback in RESTful 7.2
Determine if a callback is valid.
Parameters
mixed $callback: There are 3 ways to define a callback:
- String with a function name. Ex: 'drupal_map_assoc'.
- An array containing an object and a method name of that object. Ex: array($this, 'format').
- An array containing any of the methods before and an array of parameters to pass to the callback. Ex: array(array($this, 'processing'), array('param1', 2))
Return value
bool TRUE if the provided callback can be used in static::executeCallback.
Overrides ResourceManagerInterface::isValidCallback
1 call to ResourceManager::isValidCallback()
- Resource::getControllerFromPath in src/
Plugin/ resource/ Resource.php - Return the controller for a given path.
File
- src/
Resource/ ResourceManager.php, line 197 - Contains \Drupal\restful\Resource\ResourceManager.
Class
Namespace
Drupal\restful\ResourceCode
public static function isValidCallback($callback) {
// Valid callbacks are:
// - 'function_name'
// - 'SomeClass::someStaticMethod'
// - array('function_name', array('param1', 2))
// - array($this, 'methodName')
// - array(array($this, 'methodName'), array('param1', 2))
if (!is_callable($callback)) {
if (is_array($callback) && count($callback) == 2 && is_array($callback[1])) {
return static::isValidCallback($callback[0]);
}
return FALSE;
}
return TRUE;
}