From 193b8fcd0d284b943809303ca5c05c474c6842af Mon Sep 17 00:00:00 2001 From: Grzegorz Rola <grola@seostudio.pl> Date: Mon, 13 Aug 2018 13:45:03 +0200 Subject: [PATCH] added method: get_hookable_instance_by_class_name --- src/Plugin/HookableParent.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Plugin/HookableParent.php b/src/Plugin/HookableParent.php index 937ff77..5aca378 100644 --- a/src/Plugin/HookableParent.php +++ b/src/Plugin/HookableParent.php @@ -23,6 +23,22 @@ trait HookableParent { $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. */ -- GitLab