3

What does "Drupal is initializing" mean as a rule event?

1

In Drupal 7, the rule will run when hook_init() is called. As explained on the Drupal documentation page for hook_init():

This hook is run at the beginning of the page request. It is typically used to set up global parameters that are needed later in the request. When this hook is called, the theme and all modules are already loaded in memory.

This hook is not run on cached pages.

To add CSS or JS that should be present on all pages, modules should not implement this hook, but declare these files in their .info file.

0

To redirect anonymous users to login page using Rule module.

Please check the LINK. Through this I think you will achieve what you want.

0

An important fact to realize is that Drupal needs to be "initialized" on each and every page request. Drupal isn't constantly running on the server, it is only executed when needed. That is, when a request for a Drupal page comes in, your server needs to start up Drupal and "ask" Drupal to respond to the page request. Drupal will use the URL requested plus any data passed and return a rendered page in response. Then Drupal will stop running.

So in practice, the "Drupal is initializing" event occurs on each and every page request, and the event happens at the beginning of this process.

Specifically, in Drupal 8, the Rules event "Drupal is initializing" occurs when the Symfony kernel.request event is generated. This is at the very beginning of a page request, before the response has been generated. See also the Drupal KernelRequest class.

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.