You are here

public function Contact::init in Production check & Production monitor 8

Initializes the check plugin.

Overrides ProdCheckBase::init

File

src/Plugin/ProdCheck/Modules/Contact.php, line 28

Class

Contact
Contact status check

Namespace

Drupal\prod_check\Plugin\ProdCheck\Modules

Code

public function init() {
  $forms = \Drupal::entityTypeManager()
    ->getStorage('contact_form')
    ->getQuery()
    ->condition('status', 1)
    ->execute();
  $this->matches = [];
  $prod_check_sitemail = $this->configFactory
    ->get('prod_check.settings')
    ->get('site_email');
  foreach ($forms as $form) {
    $entity = ContactForm::load($form);
    if ($entity) {
      foreach ($entity
        ->getRecipients() as $mail) {
        if (preg_match('/' . $prod_check_sitemail . '/i', $mail)) {
          $this->matches[] = '"' . $entity
            ->label() . ': ' . $mail . '"';
        }
      }
    }
  }
}