本文整理汇总了PHP中system_rebuild_module_data函数的典型用法代码示例。如果您正苦于以下问题:PHP system_rebuild_module_data函数的具体用法?PHP system_rebuild_module_data怎么用?PHP system_rebuild_module_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了system_rebuild_module_data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkDependencies
/**
* @param array $dependencies
* @return array
*/
private function checkDependencies(array $dependencies)
{
$this->getDrupalHelper()->loadLegacyFile('/core/modules/system/system.module');
$client = $this->getHttpClient();
$localModules = array();
$modules = system_rebuild_module_data();
foreach ($modules as $module_id => $module) {
array_push($localModules, basename($module->subpath));
}
$checkDependencies = ['local_modules' => [], 'drupal_modules' => [], 'no_modules' => []];
foreach ($dependencies as $module) {
if (in_array($module, $localModules)) {
$checkDependencies['local_modules'][] = $module;
} else {
$response = $client->head('https://www.drupal.org/project/' . $module);
$header_link = explode(';', $response->getHeader('link'));
if (empty($header_link[0])) {
$checkDependencies['no_modules'][] = $module;
} else {
$checkDependencies['drupal_modules'][] = $module;
}
}
}
return $checkDependencies;
}
示例2: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
// Install all core themes.
sort($this->allThemes);
$this->container->get('theme_installer')->install($this->allThemes);
// Enable all core modules.
$all_modules = system_rebuild_module_data();
$all_modules = array_filter($all_modules, function ($module) {
// Filter contrib, hidden, already enabled modules and modules in the
// Testing package.
if ($module->origin !== 'core' || !empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing') {
return FALSE;
}
return TRUE;
});
$this->allModules = array_keys($all_modules);
$this->allModules[] = 'system';
sort($this->allModules);
$this->container->get('module_installer')->install($this->allModules);
$this->themeHandler = $this->container->get('theme_handler');
$this->themeInitialization = $this->container->get('theme.initialization');
$this->themeManager = $this->container->get('theme.manager');
$this->libraryDiscovery = $this->container->get('library.discovery');
}
示例3: helpLinksAsList
/**
* Provides a formatted list of available help topics.
*
* @return string
* A string containing the formatted list.
*/
protected function helpLinksAsList()
{
$module_info = system_rebuild_module_data();
$modules = array();
foreach ($this->moduleHandler()->getImplementations('help') as $module) {
if ($this->moduleHandler()->invoke($module, 'help', array("help.page.{$module}", $this->routeMatch))) {
$modules[$module] = $module_info[$module]->info['name'];
}
}
asort($modules);
// Output pretty four-column list.
$count = count($modules);
$break = ceil($count / 4);
$column = array('#type' => 'container', 'links' => array('#theme' => 'item_list'), '#attributes' => array('class' => array('layout-column', 'quarter')));
$output = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', 0 => $column);
$i = 0;
$current_column = 0;
foreach ($modules as $module => $name) {
$output[$current_column]['links']['#items'][] = $this->l($name, new Url('help.page', array('name' => $module)));
if (($i + 1) % $break == 0 && $i + 1 != $count) {
$current_column++;
$output[$current_column] = $column;
}
$i++;
}
return $output;
}
示例4: setUp
/**
* Implements setUp().
*/
function setUp($modules = array())
{
if (!isset($this->time)) {
$this->time = time();
}
$this->timeLimit = 1000;
parent::setUp();
if (!module_exists('forum_access')) {
module_enable(array('acl', 'chain_menu_access', 'forum_access'), FALSE);
}
$this->assertTrue(module_exists('acl'), t('Module %module enabled!', array('%module' => 'acl')), 'Setup');
$this->assertTrue(module_exists('chain_menu_access'), t('Module %module enabled!', array('%module' => 'chain_menu_access')), 'Setup');
$this->assertTrue(module_exists('forum_access'), t('Module %module enabled!', array('%module' => 'forum_access')), 'Setup');
$modules = array('devel', 'devel_node_access') + $modules;
$files = system_rebuild_module_data();
$available_modules = array();
foreach ($modules as $module) {
if (!empty($files[$module]) && !module_exists($module)) {
$available_modules[] = $module;
}
}
if (!empty($available_modules)) {
module_enable($available_modules);
}
parent::resetAll();
$this->accesses = array('view', 'create', 'update', 'delete');
}
示例5: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
// Get a list of all available modules.
$modules = system_rebuild_module_data();
$uninstallable = array_filter($modules, function ($module) use($modules) {
return empty($modules[$module->getName()]->info['required']) && drupal_get_installed_schema_version($module->getName()) > SCHEMA_UNINSTALLED && $module->getName() !== 'devel';
});
$form['filters'] = array('#type' => 'container', '#attributes' => array('class' => array('table-filter', 'js-show')));
$form['filters']['text'] = array('#type' => 'search', '#title' => $this->t('Search'), '#size' => 30, '#placeholder' => $this->t('Enter module name'), '#attributes' => array('class' => array('table-filter-text'), 'data-table' => '#devel-reinstall-form', 'autocomplete' => 'off', 'title' => $this->t('Enter a part of the module name or description to filter by.')));
// Only build the rest of the form if there are any modules available to
// uninstall;
if (empty($uninstallable)) {
return $form;
}
$header = array('name' => $this->t('Name'), 'description' => $this->t('Description'));
$rows = array();
foreach ($uninstallable as $module) {
$name = $module->info['name'] ?: $module->getName();
$rows[$module->getName()] = array('name' => array('data' => array('#type' => 'inline_template', '#template' => '<label class="module-name table-filter-text-source">{{ module_name }}</label>', '#context' => array('module_name' => $name))), 'description' => array('data' => $module->info['description'], 'class' => array('description')));
}
$form['reinstall'] = array('#type' => 'tableselect', '#header' => $header, '#options' => $rows, '#js_select' => FALSE, '#empty' => $this->t('No modules are available to uninstall.'));
$form['#attached']['library'][] = 'system/drupal.system.modules';
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Reinstall'));
return $form;
}
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$status = $input->getOption('status');
$type = $input->getOption('type');
if (strtolower($status) == 'enabled') {
$status = 1;
} elseif (strtolower($status) == 'disabled') {
$status = 0;
} else {
$status = -1;
}
if (strtolower($type) == 'core') {
$type = 'core';
} elseif (strtolower($type) == 'no-core') {
$type = '';
} else {
$type = null;
}
$tableHeader = [$this->trans('commands.module.debug.messages.id'), $this->trans('commands.module.debug.messages.name'), $this->trans('commands.module.debug.messages.status'), $this->trans('commands.module.debug.messages.package'), $this->trans('commands.module.debug.messages.schema-version'), $this->trans('commands.module.debug.messages.origin')];
$tableRows = [];
$modules = system_rebuild_module_data();
foreach ($modules as $module_id => $module) {
if ($status >= 0 && $status != $module->status) {
continue;
}
if ($type !== null && $type !== $module->origin) {
continue;
}
$module_status = $module->status ? $this->trans('commands.module.debug.messages.enabled') : $this->trans('commands.module.debug.messages.disabled');
$schema_version = drupal_get_installed_schema_version($module_id) != -1 ? drupal_get_installed_schema_version($module_id) : '';
$tableRows[] = [$module_id, $module->info['name'], $module_status, $module->info['package'], $schema_version, $module->origin];
}
$io->table($tableHeader, $tableRows, 'compact');
}
示例7: helpLinksAsList
/**
* Provides a formatted list of available help topics.
*
* @return string
* A string containing the formatted list.
*/
protected function helpLinksAsList()
{
$module_info = system_rebuild_module_data();
$modules = array();
foreach ($this->moduleHandler()->getImplementations('help') as $module) {
if ($this->moduleHandler()->invoke($module, 'help', array("help.page.{$module}", $this->routeMatch))) {
$modules[$module] = $module_info[$module]->info['name'];
}
}
asort($modules);
// Output pretty four-column list.
$count = count($modules);
$break = ceil($count / 4);
$output = '<div class="clearfix"><div class="help-items"><ul>';
$i = 0;
foreach ($modules as $module => $name) {
$output .= '<li>' . $this->l($name, new Url('help.page', array('name' => $module))) . '</li>';
if (($i + 1) % $break == 0 && $i + 1 != $count) {
$output .= '</ul></div><div class="help-items' . ($i + 1 == $break * 3 ? ' help-items-last' : '') . '"><ul>';
}
$i++;
}
$output .= '</ul></div></div>';
return $output;
}
示例8: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$this->get('site')->loadLegacyFile('/core/modules/system/system.module');
$status = strtolower($input->getOption('status'));
$type = strtolower($input->getOption('type'));
$modules = strtolower($input->getArgument('module'));
if ($modules) {
$config = $this->getApplication()->getConfig();
$repo = $config->get('application.composer.repositories.default');
foreach ($modules as $module) {
$url = sprintf('%s/packages/drupal/%s.json', $config->get('application.composer.packages.default'), $module);
try {
$data = $this->getApplication()->getHttpClientHelper()->getUrlAsJson($repo . $url);
} catch (\Exception $e) {
$io->error(sprintf($this->trans('commands.module.debug.messages.no-results'), $module));
return 1;
}
$tableHeader = ['<info>' . $data->package->name . '</info>'];
$tableRows = [];
$tableRows[] = [$data->package->description];
$tableRows[] = ['<comment>' . $this->trans('commands.module.debug.messages.total-downloads') . '</comment>', $data->package->downloads->total];
$tableRows[] = ['<comment>' . $this->trans('commands.module.debug.messages.total-monthly') . '</comment>', $data->package->downloads->monthly];
$tableRows[] = ['<comment>' . $this->trans('commands.module.debug.messages.total-daily') . '</comment>', $data->package->downloads->daily];
$io->table($tableHeader, $tableRows, 'compact');
}
return 0;
}
if ($status == 'installed') {
$status = 1;
} elseif ($status == 'uninstalled') {
$status = 0;
} else {
$status = -1;
}
if ($type == 'core') {
$type = 'core';
} elseif ($type == 'no-core') {
$type = '';
} else {
$type = null;
}
$tableHeader = [$this->trans('commands.module.debug.messages.id'), $this->trans('commands.module.debug.messages.name'), $this->trans('commands.module.debug.messages.package'), $this->trans('commands.module.debug.messages.version'), $this->trans('commands.module.debug.messages.schema-version'), $this->trans('commands.module.debug.messages.status'), $this->trans('commands.module.debug.messages.origin')];
$tableRows = [];
$modules = system_rebuild_module_data();
foreach ($modules as $module_id => $module) {
if ($status >= 0 && $status != $module->status) {
continue;
}
if ($type !== null && $type !== $module->origin) {
continue;
}
$module_status = $module->status ? $this->trans('commands.module.debug.messages.installed') : $this->trans('commands.module.debug.messages.uninstalled');
$module_origin = $module->origin ? $module->origin : 'no core';
$schema_version = drupal_get_installed_schema_version($module_id) != -1 ? drupal_get_installed_schema_version($module_id) : '';
$tableRows[] = [$module_id, $module->info['name'], $module->info['package'], $module->info['version'], $schema_version, $module_status, $module_origin];
}
$io->table($tableHeader, $tableRows, 'compact');
}
示例9: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state)
{
$role_names = array();
$role_permissions = array();
foreach ($this->getRoles() as $role_name => $role) {
// Retrieve role names for columns.
$role_names[$role_name] = String::checkPlain($role->label());
// Fetch permissions for the roles.
$role_permissions[$role_name] = $role->getPermissions();
}
// Store $role_names for use when saving the data.
$form['role_names'] = array('#type' => 'value', '#value' => $role_names);
// Render role/permission overview:
$options = array();
$module_info = system_rebuild_module_data();
$hide_descriptions = system_admin_compact_mode();
// Get a list of all the modules implementing a hook_permission() and sort by
// display name.
$modules = array();
foreach ($this->moduleHandler->getImplementations('permission') as $module) {
$modules[$module] = $module_info[$module]->info['name'];
}
asort($modules);
$form['system_compact_link'] = array('#theme' => 'system_compact_link');
$form['permissions'] = array('#type' => 'table', '#header' => array($this->t('Permission')), '#id' => 'permissions', '#sticky' => TRUE);
foreach ($role_names as $name) {
$form['permissions']['#header'][] = array('data' => $name, 'class' => array('checkbox'));
}
foreach ($modules as $module => $display_name) {
if ($permissions = $this->moduleHandler->invoke($module, 'permission')) {
// Module name.
$form['permissions'][$module] = array(array('#wrapper_attributes' => array('colspan' => count($role_names) + 1, 'class' => array('module'), 'id' => 'module-' . $module), '#markup' => $module_info[$module]->info['name']));
foreach ($permissions as $perm => $perm_item) {
// Fill in default values for the permission.
$perm_item += array('description' => '', 'restrict access' => FALSE, 'warning' => !empty($perm_item['restrict access']) ? $this->t('Warning: Give to trusted roles only; this permission has security implications.') : '');
$options[$perm] = $perm_item['title'];
// Show the permission description.
if (!$hide_descriptions) {
$user_permission_description = $perm_item['description'];
// Append warning message.
if (!empty($perm_item['warning'])) {
$user_permission_description .= ' <em class="permission-warning">' . $perm_item['warning'] . '</em>';
}
}
$form['permissions'][$perm]['description'] = array('#wrapper_attributes' => array('class' => array('permission')), '#type' => 'item', '#markup' => $perm_item['title'], '#description' => $user_permission_description);
$options[$perm] = '';
foreach ($role_names as $rid => $name) {
$form['permissions'][$perm][$rid] = array('#title' => $name . ': ' . $perm_item['title'], '#title_display' => 'invisible', '#wrapper_attributes' => array('class' => array('checkbox')), '#type' => 'checkbox', '#default_value' => in_array($perm, $role_permissions[$rid]) ? 1 : 0, '#attributes' => array('class' => array('rid-' . $rid)), '#parents' => array($rid, $perm));
}
}
}
}
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save permissions'));
$form['#attached']['library'][] = 'user/drupal.user.permissions';
return $form;
}
示例10: calculateDependencies
protected function calculateDependencies($modules)
{
$this->site->loadLegacyFile('/core/modules/system/system.module');
$moduleList = system_rebuild_module_data();
$dependencies = [];
foreach ($modules as $moduleName) {
$module = $moduleList[$moduleName];
$dependencies = array_unique(array_merge($dependencies, $this->validator->getUninstalledModules(array_keys($module->requires) ?: [])));
}
return array_diff($dependencies, $modules);
}
示例11: testSystemInfoAlter
/**
* Tests that theme .info.yml data is rebuild after enabling a module.
*
* Tests that info data is rebuilt after a module that implements
* hook_system_info_alter() is enabled. Also tests if core *_list() functions
* return freshly altered info.
*/
function testSystemInfoAlter()
{
\Drupal::state()->set('module_test.hook_system_info_alter', TRUE);
$info = system_rebuild_module_data();
$this->assertFalse(isset($info['node']->info['required']), 'Before the module_test is installed the node module is not required.');
// Enable the test module.
\Drupal::service('module_installer')->install(array('module_test'), FALSE);
$this->assertTrue(\Drupal::moduleHandler()->moduleExists('module_test'), 'Test module is enabled.');
$info = system_rebuild_module_data();
$this->assertTrue($info['node']->info['required'], 'After the module_test is installed the node module is required.');
}
示例12: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
// @todo ModuleInstaller calls system_rebuild_module_data which is part of
// system.module, see https://www.drupal.org/node/2208429.
include_once $this->root . '/core/modules/system/system.module';
// Set up the state values so we know where to find the files when running
// drupal_get_filename().
// @todo Remove as part of https://www.drupal.org/node/2186491
system_rebuild_module_data();
}
示例13: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$composer = $input->getOption('composer');
$module = $input->getArgument('module');
$this->get('site')->loadLegacyFile('/core/modules/system/system.module');
$coreExtension = $this->getDrupalService('config.factory')->getEditable('core.extension');
$moduleInstaller = $this->getDrupalService('module_installer');
// Get info about modules available
$moduleData = system_rebuild_module_data();
$moduleList = array_combine($module, $module);
if ($composer) {
//@TODO: check with Composer if the module is previously required in composer.json!
foreach ($module as $moduleItem) {
$command = sprintf('composer remove drupal/%s ', $moduleItem);
$shellProcess = $this->get('shell_process');
if ($shellProcess->exec($command)) {
$io->success(sprintf($this->trans('commands.module.uninstall.messages.composer-success'), $moduleItem));
}
}
}
if ($missingModules = array_diff_key($moduleList, $moduleData)) {
$io->error(sprintf($this->trans('commands.module.uninstall.messages.missing'), implode(', ', $module), implode(', ', $missingModules)));
return 1;
}
$installedModules = $coreExtension->get('module') ?: array();
if (!($moduleList = array_intersect_key($moduleList, $installedModules))) {
$io->info($this->trans('commands.module.uninstall.messages.nothing'));
return 0;
}
if (!($force = $input->getOption('force'))) {
$dependencies = [];
while (list($module) = each($moduleList)) {
foreach (array_keys($moduleData[$module]->required_by) as $dependency) {
if (isset($installedModules[$dependency]) && !isset($moduleList[$dependency]) && $dependency != $profile) {
$dependencies[] = $dependency;
}
}
}
if (!empty($dependencies)) {
$io->error(sprintf($this->trans('commands.module.uninstall.messages.dependents'), implode(', ', $module), implode(', ', $dependencies)));
return 1;
}
}
try {
$moduleInstaller->uninstall($moduleList);
$io->info(sprintf($this->trans('commands.module.uninstall.messages.success'), implode(', ', $moduleList)));
} catch (\Exception $e) {
$io->error($e->getMessage());
return 1;
}
$this->get('chain_queue')->addCommand('cache:rebuild', ['cache' => 'discovery']);
}
示例14: discoverExtensions
/**
* @param string $type
* @return \Drupal\Core\Extension\Extension[]
*/
public function discoverExtensions($type = 'module')
{
$this->getDrupalHelper()->loadLegacyFile('/core/modules/system/system.module');
system_rebuild_module_data();
/*
* @see Remove DrupalExtensionDiscovery subclass once
* https://www.drupal.org/node/2503927 is fixed.
*/
$discovery = new DrupalExtensionDiscovery(\Drupal::root());
$discovery->reset();
return $discovery->scan($type);
}
示例15: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$this->getDrupalHelper()->loadLegacyFile('/core/modules/system/system.module');
$extension_config = $this->getConfigFactory()->getEditable('core.extension');
$moduleInstaller = $this->getModuleInstaller();
// Get info about modules available
$module_data = system_rebuild_module_data();
$module = $input->getArgument('module');
$modules = array_filter(array_map('trim', explode(',', $module)));
$module_list = array_combine($modules, $modules);
// Determine if some module request is missing
if ($missing_modules = array_diff_key($module_list, $module_data)) {
$io->error(sprintf($this->trans('commands.module.uninstall.messages.missing'), implode(', ', $modules), implode(', ', $missing_modules)));
return true;
}
// Only process currently installed modules.
$installed_modules = $extension_config->get('module') ?: array();
if (!($module_list = array_intersect_key($module_list, $installed_modules))) {
$io->info($this->trans('commands.module.uninstall.messages.nothing'));
return true;
}
$force = $input->getOption('force');
if (!$force) {
// Calculate $dependents
$dependents = array();
while (list($module) = each($module_list)) {
foreach (array_keys($module_data[$module]->required_by) as $dependent) {
// Skip already uninstalled modules.
if (isset($installed_modules[$dependent]) && !isset($module_list[$dependent]) && $dependent != $profile) {
$dependents[] = $dependent;
}
}
}
// Error if there are missing dependencies
if (!empty($dependents)) {
$io->error(sprintf($this->trans('commands.module.uninstall.messages.dependents'), implode(', ', $modules), implode(', ', $dependents)));
return true;
}
}
// Installing modules
try {
// Uninstall the modules.
$moduleInstaller->uninstall($module_list);
$io->info(sprintf($this->trans('commands.module.uninstall.messages.success'), implode(', ', $modules)));
} catch (\Exception $e) {
$io->error($e->getMessage());
return;
}
// Run cache rebuild to see changes in Web UI
$this->getChain()->addCommand('cache:rebuild', ['cache' => 'discovery']);
}