Skip to content
Snippets Groups Projects
Commit 193b8fcd authored by Grzegorz Rola's avatar Grzegorz Rola
Browse files

added method: get_hookable_instance_by_class_name

parent 1d98f903
Branches
Tags
1 merge request!15added method: get_hookable_instance_by_class_name
Pipeline #7540 failed
...@@ -23,6 +23,22 @@ trait HookableParent { ...@@ -23,6 +23,22 @@ trait HookableParent {
$this->hookable_objects[] = $hookable_object; $this->hookable_objects[] = $hookable_object;
} }
/**
* Get hookable instance.
*
* @param string $class_name Class name.
*
* @return false|Hookable
*/
public function get_hookable_instance_by_class_name( $class_name ) {
foreach ( $this->hookable_objects as $hookable_object ) {
if ( $hookable_object instanceof $class_name ) {
return $hookable_object;
}
}
return false;
}
/** /**
* Run hooks method on all hookable objects. * Run hooks method on all hookable objects.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment