本文整理汇总了PHP中Drupal\Core\Extension\ModuleHandlerInterface::invokeAll方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleHandlerInterface::invokeAll方法的具体用法?PHP ModuleHandlerInterface::invokeAll怎么用?PHP ModuleHandlerInterface::invokeAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Extension\ModuleHandlerInterface
的用法示例。
在下文中一共展示了ModuleHandlerInterface::invokeAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getActiveHelp
/**
* Returns the help associated with the active menu item.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*/
protected function getActiveHelp(Request $request)
{
// Do not show on a 403 or 404 page.
if ($request->attributes->has('exception')) {
return '';
}
$help = $this->moduleHandler->invokeAll('help', array($this->routeMatch->getRouteName(), $this->routeMatch));
return $help ? implode("\n", $help) : '';
}
示例2: buildInfo
/**
* Builds up all element information.
*/
protected function buildInfo()
{
$info = $this->moduleHandler->invokeAll('element_info');
foreach ($info as $element_type => $element) {
$info[$element_type]['#type'] = $element_type;
}
// Allow modules to alter the element type defaults.
$this->moduleHandler->alter('element_info', $info);
return $info;
}
示例3: onBundleDelete
/**
* {@inheritdoc}
*/
public function onBundleDelete($bundle, $entity_type_id)
{
$this->entityTypeBundleInfo->clearCachedBundles();
// Notify the entity storage.
$storage = $this->entityTypeManager->getStorage($entity_type_id);
if ($storage instanceof EntityBundleListenerInterface) {
$storage->onBundleDelete($bundle, $entity_type_id);
}
// Invoke hook_entity_bundle_delete() hook.
$this->moduleHandler->invokeAll('entity_bundle_delete', [$entity_type_id, $bundle]);
$this->entityFieldManager->clearCachedFieldDefinitions();
}
示例4: build
/**
* {@inheritdoc}
*/
public function build()
{
// Do not show on a 403 or 404 page.
if ($this->request->attributes->has('exception')) {
return [];
}
$help = $this->moduleHandler->invokeAll('help', array($this->routeMatch->getRouteName(), $this->routeMatch));
$build = [];
// Remove any empty strings from $help.
foreach (array_filter($help) as $item) {
// Convert strings to #markup render arrays so that they will XSS admin
// filtered.
$build[] = is_array($item) ? $item : ['#markup' => $item];
}
return $build;
}
示例5: getRankings
/**
* Gathers ranking definitions from hook_ranking().
*
* @return array
* An array of ranking definitions.
*/
protected function getRankings()
{
if (!$this->rankings) {
$this->rankings = $this->moduleHandler->invokeAll('ranking');
}
return $this->rankings;
}
示例6: processQueues
/**
* Processes cron queues.
*/
protected function processQueues()
{
// Grab the defined cron queues.
$queues = $this->moduleHandler->invokeAll('queue_info');
$this->moduleHandler->alter('queue_info', $queues);
foreach ($queues as $queue_name => $info) {
if (isset($info['cron'])) {
// Make sure every queue exists. There is no harm in trying to recreate
// an existing queue.
$this->queueFactory->get($queue_name)->createQueue();
$callback = $info['worker callback'];
$end = time() + (isset($info['cron']['time']) ? $info['cron']['time'] : 15);
$queue = $this->queueFactory->get($queue_name);
while (time() < $end && ($item = $queue->claimItem())) {
try {
call_user_func_array($callback, array($item->data));
$queue->deleteItem($item);
} catch (SuspendQueueException $e) {
// If the worker indicates there is a problem with the whole queue,
// release the item and skip to the next queue.
$queue->releaseItem($item);
watchdog_exception('cron', $e);
// Skip to the next queue.
continue 2;
} catch (\Exception $e) {
// In case of any other kind of exception, log it and leave the item
// in the queue to be processed again later.
watchdog_exception('cron', $e);
}
}
}
}
}
示例7: addFromEntity
/**
* {@inheritdoc}
*/
public function addFromEntity(NodeInterface $node)
{
// Loop for handling the multi-Newsletter options.
foreach ($node->simplenews_issue as $simplenews_issue) {
$newsletter = $simplenews_issue->entity;
$handler = $simplenews_issue->handler;
$handler_settings = $simplenews_issue->handler_settings;
$recipient_handler = simplenews_get_recipient_handler($newsletter, $handler, $handler_settings);
// To send the newsletter, the node id and target email addresses.
// are stored in the spool.
// Only subscribed recipients are stored in the spool (status = 1).
$select = $recipient_handler->buildRecipientQuery();
$select->addExpression('\'node\'', 'entity_type');
$select->addExpression($node->id(), 'entity_id');
$select->addExpression(SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED, 'status');
$select->addExpression(REQUEST_TIME, 'timestamp');
$select->condition('s.id', db_select('simplenews_mail_spool', 'r')->fields('r', array('snid'))->condition('entity_id', $node->id(), '='), 'NOT IN');
$simplenews_issue->subscribers = simplenews_count_subscriptions($simplenews_issue->target_id);
$this->connection->insert('simplenews_mail_spool')->from($select)->execute();
// Update simplenews newsletter status to send pending.
$simplenews_issue->status = SIMPLENEWS_STATUS_SEND_PENDING;
// Notify other modules that a newsletter was just spooled.
$this->moduleHandler->invokeAll('simplenews_spooled', array($node));
}
}
示例8: testGetAllBundleInfo
/**
* Tests the getAllBundleInfo() method.
*
* @covers ::getAllBundleInfo
*/
public function testGetAllBundleInfo()
{
$this->moduleHandler->invokeAll('entity_bundle_info')->willReturn([]);
$this->moduleHandler->alter('entity_bundle_info', Argument::type('array'))->willReturn(NULL);
$apple = $this->prophesize(EntityTypeInterface::class);
$apple->getLabel()->willReturn('Apple');
$apple->getBundleOf()->willReturn(NULL);
$banana = $this->prophesize(EntityTypeInterface::class);
$banana->getLabel()->willReturn('Banana');
$banana->getBundleOf()->willReturn(NULL);
$this->setUpEntityTypeDefinitions(['apple' => $apple, 'banana' => $banana]);
$this->cacheBackend->get('entity_bundle_info:en')->willReturn(FALSE);
$this->cacheBackend->set('entity_bundle_info:en', Argument::any(), Cache::PERMANENT, ['entity_types', 'entity_bundles'])->will(function () {
$this->get('entity_bundle_info:en')->willReturn((object) ['data' => 'cached data'])->shouldBeCalled();
})->shouldBeCalled();
$this->cacheTagsInvalidator->invalidateTags(['entity_bundles'])->shouldBeCalled();
$this->typedDataManager->clearCachedDefinitions()->shouldBeCalled();
$expected = ['apple' => ['apple' => ['label' => 'Apple']], 'banana' => ['banana' => ['label' => 'Banana']]];
$bundle_info = $this->entityTypeBundleInfo->getAllBundleInfo();
$this->assertSame($expected, $bundle_info);
$bundle_info = $this->entityTypeBundleInfo->getAllBundleInfo();
$this->assertSame($expected, $bundle_info);
$this->entityTypeBundleInfo->clearCachedBundles();
$bundle_info = $this->entityTypeBundleInfo->getAllBundleInfo();
$this->assertSame('cached data', $bundle_info);
}
示例9: save
/**
* {@inheritdoc}
*/
public function save(array $link)
{
$link += array('access' => 1, 'status' => 1, 'status_override' => 0, 'lastmod' => 0, 'priority' => XMLSITEMAP_PRIORITY_DEFAULT, 'priority_override' => 0, 'changefreq' => 0, 'changecount' => 0, 'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED);
// Allow other modules to alter the link before saving.
$this->moduleHandler->alter('xmlsitemap_link', $link);
// Temporary validation checks.
// @todo Remove in final?
if ($link['priority'] < 0 || $link['priority'] > 1) {
trigger_error(t('Invalid sitemap link priority %priority.<br />@link', array('%priority' => $link['priority'], '@link' => var_export($link, TRUE))), E_USER_ERROR);
}
if ($link['changecount'] < 0) {
trigger_error(t('Negative changecount value. Please report this to <a href="@516928">@516928</a>.<br />@link', array('@516928' => 'http://drupal.org/node/516928', '@link' => var_export($link, TRUE))), E_USER_ERROR);
$link['changecount'] = 0;
}
// Check if this is a changed link and set the regenerate flag if necessary.
if (!$this->state->get('xmlsitemap_regenerate_needed')) {
$this->checkChangedLink($link, NULL, TRUE);
}
$queryStatus = \Drupal::database()->merge('xmlsitemap')->key(array('type' => $link['type'], 'id' => $link['id']))->fields(array('loc' => $link['loc'], 'subtype' => $link['subtype'], 'access' => $link['access'], 'status' => $link['status'], 'status_override' => $link['status_override'], 'lastmod' => $link['lastmod'], 'priority' => $link['priority'], 'priority_override' => $link['priority_override'], 'changefreq' => $link['changefreq'], 'changecount' => $link['changecount'], 'language' => $link['language']))->execute();
switch ($queryStatus) {
case Merge::STATUS_INSERT:
$this->moduleHandler->invokeAll('xmlsitemap_link_insert', array($link));
break;
case Merge::STATUS_UPDATE:
$this->moduleHandler->invokeAll('xmlsitemap_link_update', array($link));
break;
}
return $link;
}
示例10: delete
/**
* {@inheritdoc}
*/
public function delete($conditions)
{
if (!$conditions) {
return;
}
$path = $this->load($conditions);
$query = $this->db->delete('url_alias');
foreach ($conditions as $field => $value) {
if ($field == 'source' || $field == 'alias') {
// Use LIKE for case-insensitive matching (still stupid).
$query->condition($field, $this->db->escapeLike($value), 'LIKE');
} else {
if ('langcode' === $field) {
// Drupal 7 compat
$field = 'language';
}
$query->condition($field, $value);
}
}
$deleted = $query->execute();
// @todo Switch to using an event for this instead of a hook.
$this->moduleHandler->invokeAll('path_delete', [$path]);
\Drupal::service('path.alias_manager')->cacheClear();
return $deleted;
}
示例11: getAllBundleInfo
/**
* {@inheritdoc}
*/
public function getAllBundleInfo()
{
if (empty($this->bundleInfo)) {
$langcode = $this->languageManager->getCurrentLanguage()->getId();
if ($cache = $this->cacheGet("entity_bundle_info:{$langcode}")) {
$this->bundleInfo = $cache->data;
} else {
$this->bundleInfo = $this->moduleHandler->invokeAll('entity_bundle_info');
foreach ($this->entityTypeManager->getDefinitions() as $type => $entity_type) {
// First look for entity types that act as bundles for others, load them
// and add them as bundles.
if ($bundle_entity_type = $entity_type->getBundleEntityType()) {
foreach ($this->entityTypeManager->getStorage($bundle_entity_type)->loadMultiple() as $entity) {
$this->bundleInfo[$type][$entity->id()]['label'] = $entity->label();
}
} elseif (!isset($this->bundleInfo[$type])) {
$this->bundleInfo[$type][$type]['label'] = $entity_type->getLabel();
}
}
$this->moduleHandler->alter('entity_bundle_info', $this->bundleInfo);
$this->cacheSet("entity_bundle_info:{$langcode}", $this->bundleInfo, Cache::PERMANENT, ['entity_types', 'entity_bundles']);
}
}
return $this->bundleInfo;
}
示例12: getDefinedLanguageTypesInfo
/**
* {@inheritdoc}
*/
public function getDefinedLanguageTypesInfo()
{
if (!isset($this->languageTypesInfo)) {
$info = $this->moduleHandler->invokeAll('language_types_info');
// Let other modules alter the list of language types.
$this->moduleHandler->alter('language_types_info', $info);
$this->languageTypesInfo = $info;
}
return $this->languageTypesInfo;
}
示例13: delete
/**
* {@inheritdoc}
*/
public function delete($conditions)
{
$path = $this->load($conditions);
$query = $this->connection->delete('url_alias');
foreach ($conditions as $field => $value) {
$query->condition($field, $value);
}
$deleted = $query->execute();
// @todo Switch to using an event for this instead of a hook.
$this->moduleHandler->invokeAll('path_delete', array($path));
return $deleted;
}
示例14: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state)
{
foreach ($this->mapper->getConfigNames() as $name) {
$this->languageManager->getLanguageConfigOverride($this->language->id, $name)->delete();
}
// Flush all persistent caches.
$this->moduleHandler->invokeAll('cache_flush');
foreach (Cache::getBins() as $service_id => $cache_backend) {
$cache_backend->deleteAll();
}
drupal_set_message($this->t('@language translation of %label was deleted', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->name)));
$form_state['redirect_route'] = $this->getCancelUrl();
}
示例15: uninstall
/**
* {@inheritdoc}
*/
public function uninstall(array $theme_list)
{
$extension_config = $this->configFactory->getEditable('core.extension');
$theme_config = $this->configFactory->getEditable('system.theme');
$list = $this->listInfo();
foreach ($theme_list as $key) {
if (!isset($list[$key])) {
throw new \InvalidArgumentException("Unknown theme: {$key}.");
}
if ($key === $theme_config->get('default')) {
throw new \InvalidArgumentException("The current default theme {$key} cannot be uninstalled.");
}
if ($key === $theme_config->get('admin')) {
throw new \InvalidArgumentException("The current admin theme {$key} cannot be uninstalled.");
}
// Base themes cannot be uninstalled if sub themes are installed, and if
// they are not uninstalled at the same time.
// @todo https://www.drupal.org/node/474684 and
// https://www.drupal.org/node/1297856 themes should leverage the module
// dependency system.
if (!empty($list[$key]->sub_themes)) {
foreach ($list[$key]->sub_themes as $sub_key => $sub_label) {
if (isset($list[$sub_key]) && !in_array($sub_key, $theme_list, TRUE)) {
throw new \InvalidArgumentException("The base theme {$key} cannot be uninstalled, because theme {$sub_key} depends on it.");
}
}
}
}
$this->cssCollectionOptimizer->deleteAll();
$current_theme_data = $this->state->get('system.theme.data', array());
foreach ($theme_list as $key) {
// The value is not used; the weight is ignored for themes currently.
$extension_config->clear("theme.{$key}");
// Remove the theme from the current list.
unset($this->list[$key]);
// Update the current theme data accordingly.
unset($current_theme_data[$key]);
// Reset theme settings.
$theme_settings =& drupal_static('theme_get_setting');
unset($theme_settings[$key]);
// @todo Remove system_list().
$this->systemListReset();
// Remove all configuration belonging to the theme.
$this->configManager->uninstall('theme', $key);
}
$extension_config->save();
$this->state->set('system.theme.data', $current_theme_data);
$this->resetSystem();
$this->moduleHandler->invokeAll('themes_uninstalled', [$theme_list]);
}