You are here

function captcha_install in CAPTCHA 8

Same name and namespace in other branches
  1. 5.3 captcha.install \captcha_install()
  2. 6.2 captcha.install \captcha_install()
  3. 6 captcha.install \captcha_install()
  4. 7 captcha.install \captcha_install()

Implements hook_install().

File

./captcha.install, line 111
Install, update and uninstall functions for the CAPTCHA module.

Code

function captcha_install() {
  if (!\Drupal::service('config.installer')
    ->isSyncing()) {
    $form_ids = [];

    // Add form_ids of all currently known node types too.
    foreach (node_type_get_names() as $type => $name) {
      $form_ids[] = 'node_' . $type . '_form';
    }
    $captcha_storage = \Drupal::entityTypeManager()
      ->getStorage('captcha_point');
    foreach ($form_ids as $form_id) {
      $values = [
        'formId' => $form_id,
        'captchaType' => 'default',
        'status' => FALSE,
      ];
      $captcha_storage
        ->create($values)
        ->save();
    }
  }
}