diff --git a/core/modules/aggregator/src/Tests/AddFeedTest.php b/core/modules/aggregator/src/Tests/AddFeedTest.php index 21238f1..bbeae85 100644 --- a/core/modules/aggregator/src/Tests/AddFeedTest.php +++ b/core/modules/aggregator/src/Tests/AddFeedTest.php @@ -18,6 +18,7 @@ class AddFeedTest extends AggregatorTestBase { */ function testAddFeed() { $feed = $this->createFeed(); + $feed->refreshItems(); // Check feed data. $this->assertUrl(\Drupal::url('aggregator.feed_add', [], ['absolute' => TRUE]), [], 'Directed to correct url.'); diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 0c4fa43..399ff30 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -102,6 +102,38 @@ function forum_theme() { } /** + * Implements hook_menu_local_tasks(). + */ +function forum_menu_local_tasks(&$data, $route_name) { + // Add action link to 'node/add/forum' on 'forum' sub-pages. + if (in_array($route_name, array('forum.index', 'forum.page'))) { + $forum_term = \Drupal::routeMatch()->getParameter('taxonomy_term'); + $vid = \Drupal::config('forum.settings')->get('vocabulary'); + $links = array(); + // Loop through all bundles for forum taxonomy vocabulary field. + $field_map = \Drupal::entityManager()->getFieldMap(); + foreach ($field_map['node']['taxonomy_forums']['bundles'] as $type) { + if (\Drupal::entityManager()->getAccessControlHandler('node')->createAccess($type)) { + $links[$type] = array( + '#theme' => 'menu_local_action', + '#link' => array( + 'title' => t('Add new @node_type', array('@node_type' => entity_load('node_type', $type)->label())), + 'route_name' => 'node.add', + 'route_parameters' => ['node_type' => $type], + ), + ); + if ($forum_term && $forum_term->bundle() == $vid) { + // We are viewing a forum term (specific forum), append the tid to the + // url. + $links[$type]['#link']['localized_options']['query']['forum_id'] = $forum_term->id(); + } + } + } + $data['actions'] += $links; + } +} + +/** * Implements hook_entity_type_build(). */ function forum_entity_type_build(array &$entity_types) {