-1

Looking at the documentation for hook_query_alter(), I see that the parameter is reported to implement QueryAlterableInterface; looking at the code of _node_query_node_access_alter(), called by an implementation of hook_query_TAG_alter(), I notice that it is using methods not defined in the QueryAlterableInterface interface, such as $query->getTables().

If I implement hook_query_alter(), or hook_query_TAG_alter(), what methods should I use, and which methods can I effectively use?

2

In core, QueryAlterableInterface is extended by SelectQueryInterface, which is where you'll find SelectQueryInterface::getTables().

SelectQuery and SelectQueryExtender in turn implement SelectQueryInterface, and by extension, QueryAlterableInterface.

  • I guess that the argument for that hook should be defined as QueryAlterableInterface $query, then; the current definition would imply that you cannot count on methods implemented in SelectQueryInterface. – kiamlaluno Aug 19 '11 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.