/**
  * Tests uninstalling Node module removes views which are dependent on it.
  */
 public function testUninstall()
 {
     $this->moduleHandler->install(array('views'));
     $this->assertTrue(entity_load('view', 'frontpage', TRUE) === NULL, 'After installing Views, frontpage view which is dependant on the Node and Views modules does not exist.');
     $this->moduleHandler->install(array('node'));
     $this->assertTrue(entity_load('view', 'frontpage', TRUE) !== NULL, 'After installing Node, frontpage view which is dependant on the Node and Views modules exists.');
     $this->moduleHandler->uninstall(array('node'));
     $this->assertTrue(entity_load('view', 'frontpage', TRUE) === NULL, 'After uninstalling Node, frontpage view which is dependant on the Node and Views modules does not exist.');
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('ckeditor_media_embed.settings');
     $form['embed_provider'] = array('#type' => 'textfield', '#title' => $this->t('Provider URL'), '#default_value' => $config->get('embed_provider'), '#description' => $this->t('A template for the URL of the provider endpoint.
     This URL will be queried for each resource to be embedded. By default CKEditor uses the Iframely service.<br />
     <strong>Example</strong> <code>//example.com/api/oembed-proxy?resource-url={url}&callback={callback}</code><br />
     <strong>Default</strong> <code>//ckeditor.iframe.ly/api/oembed?url={url}&callback={callback}</code><br />
   '));
     if ($this->moduleHandler->moduleExists('help')) {
         $form['embed_provider']['#description'] .= $this->t('Check out the <a href=":help">help</a> page for more information.<br />', array(':help' => $this->urlGenerator->generateFromRoute('help.page', array('name' => 'ckeditor_media_embed'))));
     }
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function validate(EmbridgeAssetEntityInterface $asset, $validators = array())
 {
     // Call the validation functions specified by this function's caller.
     $errors = array();
     foreach ($validators as $function => $args) {
         if (method_exists($this, $function)) {
             array_unshift($args, $asset);
             $errors = array_merge($errors, call_user_func_array(array($this, $function), $args));
         }
     }
     // Let other modules perform validation on the new file.
     return array_merge($errors, $this->moduleHandler->invokeAll('embridge_asset_validate', array($asset)));
 }
 /**
  * {@inheritdoc}
  */
 public function checkAccess(EntityInterface $entity, Route $route, AccountInterface $account, $operation, $graph_name)
 {
     if (!$entity) {
         return FALSE;
     }
     // For now, we only have the view operation but this is not the only
     // operation so we will check anyway.
     $map = ['view' => 'view all graphs'];
     $entity_type_id = $entity->getEntityTypeId();
     $type_map = ['view' => "view {$entity_type_id} {$graph_name} graph"];
     // If the operation is not supported, do not allow access.
     if (!isset($map[$operation]) || !isset($type_map[$operation])) {
         return FALSE;
     }
     // @todo: This probably needs to be cached manually creating a cid.
     // @see: \Drupal\node\Access\NodeRevisionAccessCheck::checkAccess().
     // @todo: This needs also to check cache for cached permission.
     // @see: \Drupal\Core\Entity\EntityAccessControlHandler::access().
     $has_permission = $account->hasPermission($map[$operation]) || $account->hasPermission($type_map[$operation]);
     $access = $has_permission ? AccessResult::allowed() : AccessResult::neutral();
     $arguments = [$entity, $operation, $account, $graph_name];
     $access_array = array_merge([$access], $this->moduleHandler->invokeAll('entity_graph_access', $arguments), $this->moduleHandler->invokeAll($entity_type_id . '_graph_access', $arguments));
     $return = $this->processAccessHookResults($access_array);
     return $return->isAllowed();
 }
 /**
  * @param \Drupal\Console\Style\DrupalStyle $io
  * @param $updates
  */
 private function runUpdates(DrupalStyle $io, $updates)
 {
     foreach ($updates as $module_name => $module_updates) {
         $modulePath = $this->getApplication()->getSite()->getModulePath($this->module);
         $this->site->loadLegacyFile($modulePath . '/' . $this->module . '.install', false);
         foreach ($module_updates['pending'] as $update_number => $update) {
             if ($this->module != 'all' && $this->update_n !== null && $this->update_n != $update_number) {
                 continue;
             }
             if ($this->update_n > $module_updates['start']) {
                 $io->info($this->trans('commands.update.execute.messages.executing-required-previous-updates'));
             }
             for ($update_index = $module_updates['start']; $update_index <= $update_number; $update_index++) {
                 $io->info(sprintf($this->trans('commands.update.execute.messages.executing-update'), $update_index, $module_name));
                 try {
                     $this->moduleHandler->invoke($module_name, 'update_' . $update_index);
                 } catch (\Exception $e) {
                     watchdog_exception('update', $e);
                     $io->error($e->getMessage());
                 }
                 drupal_set_installed_schema_version($module_name, $update_index);
             }
         }
     }
 }
Example #6
0
 /**
  * @covers ::getModuleDirectories
  */
 public function testGetModuleDirectories()
 {
     $this->moduleHandler->setModuleList(array());
     $this->moduleHandler->addModule('module', 'place');
     $this->assertEquals(array('module' => DRUPAL_ROOT . '/place'), $this->moduleHandler->getModuleDirectories());
 }
Example #7
0
 /**
  * Implements \Drupal\Core\Form\FormInterface::buildForm().
  */
 public function buildForm(array $form, array &$form_state)
 {
     $form = parent::buildForm($form, $form_state);
     $config = $this->config('user.settings');
     $mail_config = $this->config('user.mail');
     $site_config = $this->config('system.site');
     // Settings for anonymous users.
     $form['anonymous_settings'] = array('#type' => 'details', '#title' => $this->t('Anonymous users'), '#open' => TRUE);
     $form['anonymous_settings']['anonymous'] = array('#type' => 'textfield', '#title' => $this->t('Name'), '#default_value' => $config->get('anonymous'), '#description' => $this->t('The name used to indicate anonymous users.'), '#required' => TRUE);
     // Administrative role option.
     $form['admin_role'] = array('#type' => 'details', '#title' => $this->t('Administrator role'), '#open' => TRUE);
     // Do not allow users to set the anonymous or authenticated user roles as the
     // administrator role.
     $roles = user_role_names(TRUE);
     unset($roles[DRUPAL_AUTHENTICATED_RID]);
     $form['admin_role']['user_admin_role'] = array('#type' => 'select', '#title' => $this->t('Administrator role'), '#empty_value' => '', '#default_value' => $config->get('admin_role'), '#options' => $roles, '#description' => $this->t('This role will be automatically assigned new permissions whenever a module is enabled. Changing this setting will not affect existing permissions.'));
     // @todo Remove this check once language settings are generalized.
     if ($this->moduleHandler->moduleExists('content_translation')) {
         $form['language'] = array('#type' => 'details', '#title' => $this->t('Language settings'), '#open' => TRUE, '#tree' => TRUE);
         $form_state['content_translation']['key'] = 'language';
         $form['language'] += content_translation_enable_widget('user', 'user', $form, $form_state);
     }
     // User registration settings.
     $form['registration_cancellation'] = array('#type' => 'details', '#title' => $this->t('Registration and cancellation'), '#open' => TRUE);
     $form['registration_cancellation']['user_register'] = array('#type' => 'radios', '#title' => $this->t('Who can register accounts?'), '#default_value' => $config->get('register'), '#options' => array(USER_REGISTER_ADMINISTRATORS_ONLY => $this->t('Administrators only'), USER_REGISTER_VISITORS => $this->t('Visitors'), USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL => $this->t('Visitors, but administrator approval is required')));
     $form['registration_cancellation']['user_email_verification'] = array('#type' => 'checkbox', '#title' => $this->t('Require email verification when a visitor creates an account.'), '#default_value' => $config->get('verify_mail'), '#description' => $this->t('New users will be required to validate their email address prior to logging into the site, and will be assigned a system-generated password. With this setting disabled, users will be logged in immediately upon registering, and may select their own passwords during registration.'));
     $form['registration_cancellation']['user_password_strength'] = array('#type' => 'checkbox', '#title' => $this->t('Enable password strength indicator'), '#default_value' => $config->get('password_strength'));
     $form['registration_cancellation']['user_cancel_method'] = array('#type' => 'radios', '#title' => $this->t('When cancelling a user account'), '#default_value' => $config->get('cancel_method'), '#description' => $this->t('Users with the %select-cancel-method or %administer-users <a href="@permissions-url">permissions</a> can override this default method.', array('%select-cancel-method' => $this->t('Select method for cancelling account'), '%administer-users' => $this->t('Administer users'), '@permissions-url' => url('admin/people/permissions'))));
     $form['registration_cancellation']['user_cancel_method'] += user_cancel_methods();
     foreach (Element::children($form['registration_cancellation']['user_cancel_method']) as $key) {
         // All account cancellation methods that specify #access cannot be
         // configured as default method.
         // @see hook_user_cancel_methods_alter()
         if (isset($form['registration_cancellation']['user_cancel_method'][$key]['#access'])) {
             $form['registration_cancellation']['user_cancel_method'][$key]['#access'] = FALSE;
         }
     }
     // Account settings.
     $filter_exists = $this->moduleHandler->moduleExists('filter');
     $form['personalization'] = array('#type' => 'details', '#title' => $this->t('Personalization'), '#open' => TRUE, '#access' => $filter_exists);
     $form['personalization']['user_signatures'] = array('#type' => 'checkbox', '#title' => $this->t('Enable signatures.'), '#default_value' => $filter_exists ? $config->get('signatures') : 0, '#access' => $filter_exists);
     // Default notifications address.
     $form['mail_notification_address'] = array('#type' => 'email', '#title' => $this->t('Notification email address'), '#default_value' => $site_config->get('mail_notification'), '#description' => $this->t("The email address to be used as the 'from' address for all account notifications listed below. If <em>'Visitors, but administrator approval is required'</em> is selected above, a notification email will also be sent to this address for any new registrations. Leave empty to use the default system email address <em>(%site-email).</em>", array('%site-email' => $site_config->get('mail'))), '#maxlength' => 180);
     $form['email'] = array('#type' => 'vertical_tabs', '#title' => $this->t('Emails'));
     // These email tokens are shared for all settings, so just define
     // the list once to help ensure they stay in sync.
     $email_token_help = $this->t('Available variables are: [site:name], [site:url], [user:name], [user:mail], [site:login-url], [site:url-brief], [user:edit-url], [user:one-time-login-url], [user:cancel-url].');
     $form['email_admin_created'] = array('#type' => 'details', '#title' => $this->t('Welcome (new user created by administrator)'), '#open' => $config->get('register') == USER_REGISTER_ADMINISTRATORS_ONLY, '#description' => $this->t('Edit the welcome email messages sent to new member accounts created by an administrator.') . ' ' . $email_token_help, '#group' => 'email');
     $form['email_admin_created']['user_mail_register_admin_created_subject'] = array('#type' => 'textfield', '#title' => $this->t('Subject'), '#default_value' => $mail_config->get('register_admin_created.subject'), '#maxlength' => 180);
     $form['email_admin_created']['user_mail_register_admin_created_body'] = array('#type' => 'textarea', '#title' => $this->t('Body'), '#default_value' => $mail_config->get('register_admin_created.body'), '#rows' => 15);
     $form['email_pending_approval'] = array('#type' => 'details', '#title' => $this->t('Welcome (awaiting approval)'), '#open' => $config->get('register') == USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, '#description' => $this->t('Edit the welcome email messages sent to new members upon registering, when administrative approval is required.') . ' ' . $email_token_help, '#group' => 'email');
     $form['email_pending_approval']['user_mail_register_pending_approval_subject'] = array('#type' => 'textfield', '#title' => $this->t('Subject'), '#default_value' => $mail_config->get('register_pending_approval.subject'), '#maxlength' => 180);
     $form['email_pending_approval']['user_mail_register_pending_approval_body'] = array('#type' => 'textarea', '#title' => $this->t('Body'), '#default_value' => $mail_config->get('register_pending_approval.body'), '#rows' => 8);
     $form['email_pending_approval_admin'] = array('#type' => 'details', '#title' => $this->t('Admin (user awaiting approval)'), '#open' => $config->get('register') == USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, '#description' => $this->t('Edit the email notifying the site administrator that there are new members awaiting administrative approval.') . ' ' . $email_token_help, '#group' => 'email');
     $form['email_pending_approval_admin']['register_pending_approval_admin_subject'] = array('#type' => 'textfield', '#title' => $this->t('Subject'), '#default_value' => $mail_config->get('register_pending_approval_admin.subject'), '#maxlength' => 180);
     $form['email_pending_approval_admin']['register_pending_approval_admin_body'] = array('#type' => 'textarea', '#title' => $this->t('Body'), '#default_value' => $mail_config->get('register_pending_approval_admin.body'), '#rows' => 8);
     $form['email_no_approval_required'] = array('#type' => 'details', '#title' => $this->t('Welcome (no approval required)'), '#open' => $config->get('register') == USER_REGISTER_VISITORS, '#description' => $this->t('Edit the welcome email messages sent to new members upon registering, when no administrator approval is required.') . ' ' . $email_token_help, '#group' => 'email');
     $form['email_no_approval_required']['user_mail_register_no_approval_required_subject'] = array('#type' => 'textfield', '#title' => $this->t('Subject'), '#default_value' => $mail_config->get('register_no_approval_required.subject'), '#maxlength' => 180);
     $form['email_no_approval_required']['user_mail_register_no_approval_required_body'] = array('#type' => 'textarea', '#title' => $this->t('Body'), '#default_value' => $mail_config->get('register_no_approval_required.body'), '#rows' => 15);
     $form['email_password_reset'] = array('#type' => 'details', '#title' => $this->t('Password recovery'), '#description' => $this->t('Edit the email messages sent to users who request a new password.') . ' ' . $email_token_help, '#group' => 'email', '#weight' => 10);
     $form['email_password_reset']['user_mail_password_reset_subject'] = array('#type' => 'textfield', '#title' => $this->t('Subject'), '#default_value' => $mail_config->get('password_reset.subject'), '#maxlength' => 180);
     $form['email_password_reset']['user_mail_password_reset_body'] = array('#type' => 'textarea', '#title' => $this->t('Body'), '#default_value' => $mail_config->get('password_reset.body'), '#rows' => 12);
     $form['email_activated'] = array('#type' => 'details', '#title' => $this->t('Account activation'), '#description' => $this->t('Enable and edit email messages sent to users upon account activation (when an administrator activates an account of a user who has already registered, on a site where administrative approval is required).') . ' ' . $email_token_help, '#group' => 'email');
     $form['email_activated']['user_mail_status_activated_notify'] = array('#type' => 'checkbox', '#title' => $this->t('Notify user when account is activated.'), '#default_value' => $config->get('notify.status_activated'));
     $form['email_activated']['settings'] = array('#type' => 'container', '#states' => array('invisible' => array('input[name="user_mail_status_activated_notify"]' => array('checked' => FALSE))));
     $form['email_activated']['settings']['user_mail_status_activated_subject'] = array('#type' => 'textfield', '#title' => $this->t('Subject'), '#default_value' => $mail_config->get('status_activated.subject'), '#maxlength' => 180);
     $form['email_activated']['settings']['user_mail_status_activated_body'] = array('#type' => 'textarea', '#title' => $this->t('Body'), '#default_value' => $mail_config->get('status_activated.body'), '#rows' => 15);
     $form['email_blocked'] = array('#type' => 'details', '#title' => $this->t('Account blocked'), '#description' => $this->t('Enable and edit email messages sent to users when their accounts are blocked.') . ' ' . $email_token_help, '#group' => 'email');
     $form['email_blocked']['user_mail_status_blocked_notify'] = array('#type' => 'checkbox', '#title' => $this->t('Notify user when account is blocked.'), '#default_value' => $config->get('notify.status_blocked'));
     $form['email_blocked']['settings'] = array('#type' => 'container', '#states' => array('invisible' => array('input[name="user_mail_status_blocked_notify"]' => array('checked' => FALSE))));
     $form['email_blocked']['settings']['user_mail_status_blocked_subject'] = array('#type' => 'textfield', '#title' => $this->t('Subject'), '#default_value' => $mail_config->get('status_blocked.subject'), '#maxlength' => 180);
     $form['email_blocked']['settings']['user_mail_status_blocked_body'] = array('#type' => 'textarea', '#title' => $this->t('Body'), '#default_value' => $mail_config->get('status_blocked.body'), '#rows' => 3);
     $form['email_cancel_confirm'] = array('#type' => 'details', '#title' => $this->t('Account cancellation confirmation'), '#description' => $this->t('Edit the email messages sent to users when they attempt to cancel their accounts.') . ' ' . $email_token_help, '#group' => 'email');
     $form['email_cancel_confirm']['user_mail_cancel_confirm_subject'] = array('#type' => 'textfield', '#title' => $this->t('Subject'), '#default_value' => $mail_config->get('cancel_confirm.subject'), '#maxlength' => 180);
     $form['email_cancel_confirm']['user_mail_cancel_confirm_body'] = array('#type' => 'textarea', '#title' => $this->t('Body'), '#default_value' => $mail_config->get('cancel_confirm.body'), '#rows' => 3);
     $form['email_canceled'] = array('#type' => 'details', '#title' => $this->t('Account canceled'), '#description' => $this->t('Enable and edit email messages sent to users when their accounts are canceled.') . ' ' . $email_token_help, '#group' => 'email');
     $form['email_canceled']['user_mail_status_canceled_notify'] = array('#type' => 'checkbox', '#title' => $this->t('Notify user when account is canceled.'), '#default_value' => $config->get('notify.status_canceled'));
     $form['email_canceled']['settings'] = array('#type' => 'container', '#states' => array('invisible' => array('input[name="user_mail_status_canceled_notify"]' => array('checked' => FALSE))));
     $form['email_canceled']['settings']['user_mail_status_canceled_subject'] = array('#type' => 'textfield', '#title' => $this->t('Subject'), '#default_value' => $mail_config->get('status_canceled.subject'), '#maxlength' => 180);
     $form['email_canceled']['settings']['user_mail_status_canceled_body'] = array('#type' => 'textarea', '#title' => $this->t('Body'), '#default_value' => $mail_config->get('status_canceled.body'), '#rows' => 3);
     return $form;
 }