当前位置: 首页>>代码示例>>PHP>>正文


PHP ModuleHandlerInterface::install方法代码示例

本文整理汇总了PHP中Drupal\Core\Extension\ModuleHandlerInterface::install方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleHandlerInterface::install方法的具体用法?PHP ModuleHandlerInterface::install怎么用?PHP ModuleHandlerInterface::install使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Extension\ModuleHandlerInterface的用法示例。


在下文中一共展示了ModuleHandlerInterface::install方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $modules = array_filter($form_state['values']['list']);
     $this->moduleHandler->uninstall($modules, FALSE);
     $this->moduleHandler->install($modules, FALSE);
     drupal_set_message(t('Uninstalled and installed: %names.', array('%names' => implode(', ', $modules))));
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:DevelReinstall.php

示例2: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Retrieve a list of modules to install and their dependencies.
     $modules = $this->buildModuleList($form_state);
     // Check if we have to install any dependencies. If there is one or more
     // dependencies that are not installed yet, redirect to the confirmation
     // form.
     if (!empty($modules['dependencies']) || !empty($modules['missing'])) {
         // Write the list of changed module states into a key value store.
         $account = $this->currentUser()->id();
         $this->keyValueExpirable->setWithExpire($account, $modules, 60);
         // Redirect to the confirmation form.
         $form_state->setRedirect('system.modules_list_confirm');
         // We can exit here because at least one modules has dependencies
         // which we have to prompt the user for in a confirmation form.
         return;
     }
     // Gets list of modules prior to install process.
     $before = $this->moduleHandler->getModuleList();
     // There seem to be no dependencies that would need approval.
     if (!empty($modules['install'])) {
         $this->moduleHandler->install(array_keys($modules['install']));
     }
     // Gets module list after install process, flushes caches and displays a
     // message if there are changes.
     if ($before != $this->moduleHandler->getModuleList()) {
         drupal_set_message(t('The configuration options have been saved.'));
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:32,代码来源:ModulesListForm.php

示例3: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->config('system.site')->set('name', $form_state->getValue('site_name'))->set('mail', $form_state->getValue('site_mail'))->save();
     $this->config('system.date')->set('timezone.default', $form_state->getValue('date_default_timezone'))->set('country.default', $form_state->getValue('site_default_country'))->save();
     $account_values = $form_state->getValue('account');
     // Enable update.module if this option was selected.
     $update_status_module = $form_state->getValue('update_status_module');
     if ($update_status_module[1]) {
         $this->moduleHandler->install(array('file', 'update'), FALSE);
         // Add the site maintenance account's email address to the list of
         // addresses to be notified when updates are available, if selected.
         if ($update_status_module[2]) {
             // Reset the configuration factory so it is updated with the new module.
             $this->resetConfigFactory();
             $this->config('update.settings')->set('notification.emails', array($account_values['mail']))->save();
         }
     }
     // We precreated user 1 with placeholder values. Let's save the real values.
     $account = $this->userStorage->load(1);
     $account->init = $account->mail = $account_values['mail'];
     $account->roles = $account->getRoles();
     $account->activate();
     $account->timezone = $form_state->getValue('date_default_timezone');
     $account->pass = $account_values['pass'];
     $account->name = $account_values['name'];
     $account->save();
     // Record when this install ran.
     $this->state->set('install_time', $_SERVER['REQUEST_TIME']);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:32,代码来源:SiteConfigureForm.php

示例4: testCustomBundleFieldUsage

 /**
  * Tests making use of a custom bundle field.
  */
 public function testCustomBundleFieldUsage()
 {
     // Check that an entity with bundle entity_test does not have the custom
     // field.
     $this->moduleHandler->install(array('entity_bundle_field_test'), FALSE);
     $storage = $this->entityManager->getStorage('entity_test');
     $entity = $storage->create(['type' => 'entity_test']);
     $this->assertFalse($entity->hasField('custom_field'));
     // Check that the custom bundle has the defined custom field and check
     // saving and deleting of custom field data.
     $entity = $storage->create(['type' => 'custom']);
     $this->assertTrue($entity->hasField('custom_field'));
     $entity->custom_field->value = 'swanky';
     $entity->save();
     $storage->resetCache();
     $entity = $storage->load($entity->id());
     $this->assertEqual($entity->custom_field->value, 'swanky', 'Entity was saved correct.y');
     $entity->custom_field->value = 'cozy';
     $entity->save();
     $storage->resetCache();
     $entity = $storage->load($entity->id());
     $this->assertEqual($entity->custom_field->value, 'cozy', 'Entity was updated correctly.');
     $entity->delete();
     $table = $storage->_fieldTableName($entity->getFieldDefinition('custom_field'));
     $result = $this->database->select($table, 'f')->fields('f')->condition('f.entity_id', $entity->id())->execute();
     $this->assertFalse($result->fetchAssoc(), 'Field data has been deleted');
     // Create another entity to test that values are marked as deleted when a
     // bundle is deleted.
     $entity = $storage->create(['type' => 'custom', 'custom_field' => 'new']);
     $entity->save();
     entity_test_delete_bundle('custom');
     $table = $storage->_fieldTableName($entity->getFieldDefinition('custom_field'));
     $result = $this->database->select($table, 'f')->condition('f.entity_id', $entity->id())->condition('deleted', 1)->countQuery()->execute();
     $this->assertEqual(1, $result->fetchField(), 'Field data has been deleted');
     // @todo Test field purge and table deletion once supported.
     // $this->assertFalse($this->database->schema()->tableExists($table), 'Custom field table was deleted');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:40,代码来源:EntityBundleFieldTest.php

示例5: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Remove the key value store entry.
     $account = $this->currentUser()->id();
     $this->keyValueExpirable->delete($account);
     // Gets list of modules prior to install process.
     $before = $this->moduleHandler->getModuleList();
     // Install the given modules.
     if (!empty($this->modules['install'])) {
         $this->moduleHandler->install(array_keys($this->modules['install']));
     }
     // Gets module list after install process, flushes caches and displays a
     // message if there are changes.
     if ($before != $this->moduleHandler->getModuleList()) {
         drupal_set_message($this->t('The configuration options have been saved.'));
     }
     $form_state->setRedirectUrl($this->getCancelUrl());
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:21,代码来源:ModulesListConfirmForm.php


注:本文中的Drupal\Core\Extension\ModuleHandlerInterface::install方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。