Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
|
@ -42,6 +42,13 @@ abstract class ForumBreadcrumbBuilderBase implements BreadcrumbBuilderInterface
|
|||
*/
|
||||
protected $forumManager;
|
||||
|
||||
/**
|
||||
* The taxonomy term storage.
|
||||
*
|
||||
* @var \Drupal\taxonomy\TermStorageInterface
|
||||
*/
|
||||
protected $termStorage;
|
||||
|
||||
/**
|
||||
* Constructs a forum breadcrumb builder object.
|
||||
*
|
||||
|
|
@ -59,6 +66,7 @@ abstract class ForumBreadcrumbBuilderBase implements BreadcrumbBuilderInterface
|
|||
$this->config = $config_factory->get('forum.settings');
|
||||
$this->forumManager = $forum_manager;
|
||||
$this->setStringTranslation($string_translation);
|
||||
$this->termStorage = $entity_manager->getStorage('taxonomy_term');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class ForumListingBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
|
|||
$term_id = $term->id();
|
||||
$breadcrumb->addCacheableDependency($term);
|
||||
|
||||
$parents = $this->forumManager->getParents($term_id);
|
||||
$parents = $this->termStorage->loadAllParents($term_id);
|
||||
if ($parents) {
|
||||
foreach (array_reverse($parents) as $parent) {
|
||||
if ($parent->id() != $term_id) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class ForumNodeBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
|
|||
$breadcrumb = parent::build($route_match);
|
||||
$breadcrumb->addCacheContexts(['route']);
|
||||
|
||||
$parents = $this->forumManager->getParents($route_match->getParameter('node')->forum_tid);
|
||||
$parents = $this->termStorage->loadAllParents($route_match->getParameter('node')->forum_tid);
|
||||
if ($parents) {
|
||||
$parents = array_reverse($parents);
|
||||
foreach ($parents as $parent) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ use Drupal\Core\Form\FormStateInterface;
|
|||
|
||||
/**
|
||||
* Base form for container term edit forms.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ContainerForm extends ForumForm {
|
||||
|
||||
|
|
@ -20,9 +22,8 @@ class ContainerForm extends ForumForm {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function form(array $form, FormStateInterface $form_state) {
|
||||
$taxonomy_term = $this->entity;
|
||||
// Build the bulk of the form from the parent forum form.
|
||||
$form = parent::form($form, $form_state, $taxonomy_term);
|
||||
$form = parent::form($form, $form_state);
|
||||
|
||||
// Set the title and description of the name field.
|
||||
$form['name']['#title'] = $this->t('Container name');
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ use Drupal\taxonomy\TermInterface;
|
|||
|
||||
/**
|
||||
* Builds the form to delete a forum term.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class DeleteForm extends ConfirmFormBase {
|
||||
|
||||
|
|
@ -61,7 +63,7 @@ class DeleteForm extends ConfirmFormBase {
|
|||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$this->taxonomyTerm->delete();
|
||||
drupal_set_message($this->t('The forum %label and all sub-forums have been deleted.', ['%label' => $this->taxonomyTerm->label()]));
|
||||
$this->messenger()->addStatus($this->t('The forum %label and all sub-forums have been deleted.', ['%label' => $this->taxonomyTerm->label()]));
|
||||
$this->logger('forum')->notice('forum: deleted %label and all its sub-forums.', ['%label' => $this->taxonomyTerm->label()]);
|
||||
$form_state->setRedirectUrl($this->getCancelUrl());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ use Drupal\taxonomy\TermForm;
|
|||
|
||||
/**
|
||||
* Base form for forum term edit forms.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ForumForm extends TermForm {
|
||||
|
||||
|
|
@ -29,9 +31,8 @@ class ForumForm extends TermForm {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function form(array $form, FormStateInterface $form_state) {
|
||||
$taxonomy_term = $this->entity;
|
||||
// Build the bulk of the form from the parent taxonomy term form.
|
||||
$form = parent::form($form, $form_state, $taxonomy_term);
|
||||
$form = parent::form($form, $form_state);
|
||||
|
||||
// Set the title and description of the name field.
|
||||
$form['name']['#title'] = $this->t('Forum name');
|
||||
|
|
@ -48,7 +49,7 @@ class ForumForm extends TermForm {
|
|||
|
||||
// Our parent field is different to the taxonomy term.
|
||||
$form['parent']['#tree'] = TRUE;
|
||||
$form['parent'][0] = $this->forumParentSelect($taxonomy_term->id(), $this->t('Parent'));
|
||||
$form['parent'][0] = $this->forumParentSelect($this->entity->id(), $this->t('Parent'));
|
||||
|
||||
$form['#theme_wrappers'] = ['form__forum'];
|
||||
$this->forumFormType = $this->t('forum');
|
||||
|
|
@ -76,18 +77,18 @@ class ForumForm extends TermForm {
|
|||
$status = $term_storage->save($term);
|
||||
|
||||
$route_name = $this->urlStub == 'container' ? 'entity.taxonomy_term.forum_edit_container_form' : 'entity.taxonomy_term.forum_edit_form';
|
||||
$route_parameters = ['taxonomy_term' => $term->id()];
|
||||
$route_parameters = ['taxonomy_term' => $term->id()];
|
||||
$link = $this->l($this->t('Edit'), new Url($route_name, $route_parameters));
|
||||
$view_link = $term->link($term->getName());
|
||||
switch ($status) {
|
||||
case SAVED_NEW:
|
||||
drupal_set_message($this->t('Created new @type %term.', ['%term' => $view_link, '@type' => $this->forumFormType]));
|
||||
$this->messenger()->addStatus($this->t('Created new @type %term.', ['%term' => $view_link, '@type' => $this->forumFormType]));
|
||||
$this->logger('forum')->notice('Created new @type %term.', ['%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => $link]);
|
||||
$form_state->setValue('tid', $term->id());
|
||||
break;
|
||||
|
||||
case SAVED_UPDATED:
|
||||
drupal_set_message($this->t('The @type %term has been updated.', ['%term' => $term->getName(), '@type' => $this->forumFormType]));
|
||||
$this->messenger()->addStatus($this->t('The @type %term has been updated.', ['%term' => $term->getName(), '@type' => $this->forumFormType]));
|
||||
$this->logger('forum')->notice('Updated @type %term.', ['%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => $link]);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,13 @@ use Drupal\Core\Render\Element;
|
|||
use Drupal\Core\Url;
|
||||
use Drupal\taxonomy\Form\OverviewTerms;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\taxonomy\VocabularyInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Provides forum overview form for the forum vocabulary.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Overview extends OverviewTerms {
|
||||
|
||||
|
|
@ -45,7 +48,7 @@ class Overview extends OverviewTerms {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
public function buildForm(array $form, FormStateInterface $form_state, VocabularyInterface $taxonomy_vocabulary = NULL) {
|
||||
$forum_config = $this->config('forum.settings');
|
||||
$vid = $forum_config->get('vocabulary');
|
||||
$vocabulary = $this->entityManager->getStorage('taxonomy_vocabulary')->load($vid);
|
||||
|
|
@ -58,21 +61,30 @@ class Overview extends OverviewTerms {
|
|||
|
||||
foreach (Element::children($form['terms']) as $key) {
|
||||
if (isset($form['terms'][$key]['#term'])) {
|
||||
/** @var \Drupal\taxonomy\TermInterface $term */
|
||||
$term = $form['terms'][$key]['#term'];
|
||||
$form['terms'][$key]['term']['#url'] = Url::fromRoute('forum.page', ['taxonomy_term' => $term->id()]);
|
||||
unset($form['terms'][$key]['operations']['#links']['delete']);
|
||||
$route_parameters = $form['terms'][$key]['operations']['#links']['edit']['url']->getRouteParameters();
|
||||
|
||||
if (!empty($term->forum_container->value)) {
|
||||
$form['terms'][$key]['operations']['#links']['edit']['title'] = $this->t('edit container');
|
||||
$form['terms'][$key]['operations']['#links']['edit']['url'] = Url::fromRoute('entity.taxonomy_term.forum_edit_container_form', $route_parameters);
|
||||
$title = $this->t('edit container');
|
||||
$url = Url::fromRoute('entity.taxonomy_term.forum_edit_container_form', ['taxonomy_term' => $term->id()]);
|
||||
}
|
||||
else {
|
||||
$form['terms'][$key]['operations']['#links']['edit']['title'] = $this->t('edit forum');
|
||||
$form['terms'][$key]['operations']['#links']['edit']['url'] = Url::fromRoute('entity.taxonomy_term.forum_edit_form', $route_parameters);
|
||||
$title = $this->t('edit forum');
|
||||
$url = Url::fromRoute('entity.taxonomy_term.forum_edit_form', ['taxonomy_term' => $term->id()]);
|
||||
}
|
||||
// We don't want the redirect from the link so we can redirect the
|
||||
// delete action.
|
||||
unset($form['terms'][$key]['operations']['#links']['edit']['query']['destination']);
|
||||
|
||||
// Re-create the operations column and add only the edit link.
|
||||
$form['terms'][$key]['operations'] = [
|
||||
'#type' => 'operations',
|
||||
'#links' => [
|
||||
'edit' => [
|
||||
'title' => $title,
|
||||
'url' => $url,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +94,7 @@ class Overview extends OverviewTerms {
|
|||
// Use the existing taxonomy overview submit handler.
|
||||
$form['terms']['#empty'] = $this->t('No containers or forums available. <a href=":container">Add container</a> or <a href=":forum">Add forum</a>.', [
|
||||
':container' => $this->url('forum.add_container'),
|
||||
':forum' => $this->url('forum.add_forum')
|
||||
':forum' => $this->url('forum.add_forum'),
|
||||
]);
|
||||
return $form;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\forum;
|
||||
|
||||
use Drupal\comment\CommentInterface;
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\node\NodeInterface;
|
||||
|
|
@ -103,7 +104,7 @@ class ForumIndexStorage implements ForumIndexStorageInterface {
|
|||
':status' => CommentInterface::PUBLISHED,
|
||||
])->fetchObject();
|
||||
$this->database->update('forum_index')
|
||||
->fields( [
|
||||
->fields([
|
||||
'comment_count' => $count,
|
||||
'last_comment_timestamp' => $last_reply->created,
|
||||
])
|
||||
|
|
@ -114,7 +115,7 @@ class ForumIndexStorage implements ForumIndexStorageInterface {
|
|||
// Comments do not exist.
|
||||
// @todo This should be actually filtering on the desired node language
|
||||
$this->database->update('forum_index')
|
||||
->fields( [
|
||||
->fields([
|
||||
'comment_count' => 0,
|
||||
'last_comment_timestamp' => $node->getCreatedTime(),
|
||||
])
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ namespace Drupal\forum;
|
|||
|
||||
use Drupal\node\NodeInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Handles CRUD operations to {forum_index} table.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ class ForumManager implements ForumManagerInterface {
|
|||
'cid',
|
||||
'last_comment_uid',
|
||||
'last_comment_timestamp',
|
||||
'comment_count'
|
||||
'comment_count',
|
||||
]);
|
||||
|
||||
$query->join('forum_index', 'f', 'f.nid = n.nid');
|
||||
|
|
@ -435,7 +435,7 @@ class ForumManager implements ForumManagerInterface {
|
|||
'container' => 1,
|
||||
'parents' => [],
|
||||
'isIndex' => TRUE,
|
||||
'vid' => $vid
|
||||
'vid' => $vid,
|
||||
]);
|
||||
|
||||
// Load the tree below.
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ use Drupal\Core\Form\FormStateInterface;
|
|||
|
||||
/**
|
||||
* Configure forum settings for this site.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ForumSettingsForm extends ConfigFormBase {
|
||||
|
||||
|
|
@ -50,7 +52,7 @@ class ForumSettingsForm extends ConfigFormBase {
|
|||
1 => $this->t('Date - newest first'),
|
||||
2 => $this->t('Date - oldest first'),
|
||||
3 => $this->t('Posts - most active first'),
|
||||
4 => $this->t('Posts - least active first')
|
||||
4 => $this->t('Posts - least active first'),
|
||||
];
|
||||
$form['forum_order'] = [
|
||||
'#type' => 'radios',
|
||||
|
|
|
|||
|
|
@ -62,12 +62,12 @@ class ForumUninstallValidator implements ModuleUninstallValidatorInterface {
|
|||
if ($vocabulary->access('view')) {
|
||||
$reasons[] = $this->t('To uninstall Forum, first delete all <a href=":url">%vocabulary</a> terms', [
|
||||
'%vocabulary' => $vocabulary->label(),
|
||||
':url' => $vocabulary->url('overview-form'),
|
||||
':url' => $vocabulary->toUrl('overview-form')->toString(),
|
||||
]);
|
||||
}
|
||||
else {
|
||||
$reasons[] = $this->t('To uninstall Forum, first delete all %vocabulary terms', [
|
||||
'%vocabulary' => $vocabulary->label()
|
||||
'%vocabulary' => $vocabulary->label(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,95 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\forum\Tests\Views;
|
||||
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\views\Views;
|
||||
use Drupal\views\Tests\ViewTestBase;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
|
||||
/**
|
||||
* Tests the forum integration into views.
|
||||
*
|
||||
* @group forum
|
||||
*/
|
||||
class ForumIntegrationTest extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['forum_test_views'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = ['test_forum_index'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), ['forum_test_views']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests the integration.
|
||||
*/
|
||||
public function testForumIntegration() {
|
||||
// Create a forum.
|
||||
$entity_manager = $this->container->get('entity.manager');
|
||||
$term = $entity_manager->getStorage('taxonomy_term')->create(['vid' => 'forums', 'name' => $this->randomMachineName()]);
|
||||
$term->save();
|
||||
|
||||
$comment_storage = $entity_manager->getStorage('comment');
|
||||
|
||||
// Create some nodes which are part of this forum with some comments.
|
||||
$nodes = [];
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$node = $this->drupalCreateNode(['type' => 'forum', 'taxonomy_forums' => [$term->id()], 'sticky' => $i == 0 ? NodeInterface::STICKY : NodeInterface::NOT_STICKY]);
|
||||
$nodes[] = $node;
|
||||
}
|
||||
|
||||
$account = $this->drupalCreateUser(['skip comment approval']);
|
||||
$this->drupalLogin($account);
|
||||
|
||||
$comments = [];
|
||||
foreach ($nodes as $index => $node) {
|
||||
for ($i = 0; $i <= $index; $i++) {
|
||||
$comment = $comment_storage->create(['entity_type' => 'node', 'entity_id' => $node->id(), 'field_name' => 'comment_forum']);
|
||||
$comment->save();
|
||||
$comments[$comment->get('entity_id')->target_id][$comment->id()] = $comment;
|
||||
}
|
||||
}
|
||||
|
||||
$view = Views::getView('test_forum_index');
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = [];
|
||||
$expected_result[] = [
|
||||
'nid' => $nodes[0]->id(),
|
||||
'sticky' => NodeInterface::STICKY,
|
||||
'comment_count' => 1.
|
||||
];
|
||||
$expected_result[] = [
|
||||
'nid' => $nodes[1]->id(),
|
||||
'sticky' => NodeInterface::NOT_STICKY,
|
||||
'comment_count' => 2.
|
||||
];
|
||||
$expected_result[] = [
|
||||
'nid' => $nodes[2]->id(),
|
||||
'sticky' => NodeInterface::NOT_STICKY,
|
||||
'comment_count' => 3.
|
||||
];
|
||||
$column_map = [
|
||||
'nid' => 'nid',
|
||||
'forum_index_sticky' => 'sticky',
|
||||
'forum_index_comment_count' => 'comment_count',
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $expected_result, $column_map);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue