// Lets figure out of there's a constructor for this class and pull
// arguments from the $options array if so to populate it.
$reflector = new \ReflectionClass($plugin_class); if($reflector->hasMethod('__construct')){ $arguments = $this->getInstanceArguments($reflector, $plugin_id, $plugin_definition, $configuration); $instance = $reflector->newInstanceArgs($arguments); } else{ $instance = new$plugin_class(); }
return$instance; }
/**
* Inspects the plugin class and build a list of arguments for the constructor.
*
* This is provided as a helper method so factories extending this class can
* replace this and insert their own reflection logic.
*
* @param \ReflectionClass $reflector
* The reflector object being used to inspect the plugin class.
* @param string $plugin_id
* The identifier of the plugin implementation.
* @param mixed $plugin_definition
* The definition associated with the plugin_id.
* @param array $configuration
* An array of configuration that may be passed to the instance.
*
* @return array
* An array of arguments to be passed to the constructor.
*/
if(!$class->implementsInterface($interfaceName)){ thrownewZend_Filter_Exception("Class '$className' based on basename '$classBaseName' must implement the '$interfaceName' interface"); }
// Check the number of arguments
if(count($args) != count($signature)){ returnnewIXR_Error(-32602, 'server error. wrong number of method parameters'); }
if(null !==($class = $container->getDefinition($id)->getClass())&&($r = $container->getReflectionClass($class, false)) && !$r->hasMethod($event['method'])){ if(!$r->hasMethod('__invoke')){ thrownewInvalidArgumentException(sprintf('None of the "%s" or "__invoke" methods exist for the service "%s". Please define the "method" attribute on "kernel.event_listener" tags.', $event['method'], $id)); }
/**
* Whether the class has a _remap() method.
*/ privatefunctionhasRemap(ReflectionClass $class): bool { if($class->hasMethod('_remap')){ $remap = $class->getMethod('_remap');