Wire::hasHook() method

Returns true if the method or property is hooked, false if it isn’t.

  • This method checks for both static hooks and local hooks.
  • Accepts a method() or property name as an argument.
  • Class context is assumed to be the current class this method is called on.
  • Also considers the class parents for hooks.

Example

if($pages->hasHook('find()')) {
  // the Pages::find() method is hooked
}

Usage

$bool = $wire->hasHook(string $name);

Arguments

NameType(s)Description
namestring

Method() name or property name:

  • If checking for a hooked method, it should be in the form method().
  • If checking for a hooked property, it should be in the form property.

Return value

bool

True if this class instance has the hook, false if not.

Exceptions

Method can throw exceptions on error:

  • WireException - When you try to call it with a Class::something() type method, which is not supported.


Wire methods and properties

API reference based on ProcessWire core version 3.0.236

Latest news

  • ProcessWire Weekly #554
    In the 554th issue of ProcessWire Weekly we'll check out the latest core updates, introduce a couple of new third party modules, and more. Read on!
    Weekly.pw / 21 December 2024
  • Custom Fields Module
    This week we look at a new ProFields module named Custom Fields. This module provides a way to rapidly build out ProcessWire fields that contain any number of subfields/properties within them.
    Blog / 30 August 2024
  • Subscribe to weekly ProcessWire news

“Yesterday I sent the client a short documentation for their ProcessWire-powered website. Today all features already used with no questions. #cmsdoneright—Marc Hinse, Web designer/developer