mirror of
https://github.com/moodle/moodle.git
synced 2025-04-08 09:52:42 +02:00
MDL-64820 forum: fix cibot complaints
This commit is contained in:
parent
f30f46db39
commit
446ba04650
@ -28,7 +28,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use mod_forum\local\entities\discussion as discussion_entity;
|
||||
use mod_forum\local\entities\forum as forum_entity;
|
||||
use mod_forum\local\entities\forum;
|
||||
use mod_forum\local\entities\post as post_entity;
|
||||
use mod_forum\local\factories\legacy_data_mapper as legacy_data_mapper_factory;
|
||||
use mod_forum\local\factories\exporter as exporter_factory;
|
||||
@ -38,6 +37,8 @@ use renderer_base;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Exported discussion summaries builder class.
|
||||
*
|
||||
* This class is an implementation of the builder pattern (loosely). It is responsible
|
||||
* for taking a set of related forums, discussions, and posts and generate the exported
|
||||
* version of the discussion summaries.
|
||||
@ -48,6 +49,10 @@ use stdClass;
|
||||
*
|
||||
* See this doc for more information on the builder pattern:
|
||||
* https://designpatternsphp.readthedocs.io/en/latest/Creational/Builder/README.html
|
||||
*
|
||||
* @package mod_forum
|
||||
* @copyright 2019 Mihail Geshoski <mihail@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class exported_discussion_summaries {
|
||||
/** @var renderer_base $renderer Core renderer */
|
||||
@ -100,7 +105,7 @@ class exported_discussion_summaries {
|
||||
*/
|
||||
public function build(
|
||||
stdClass $user,
|
||||
forum $forum,
|
||||
forum_entity $forum,
|
||||
array $discussions
|
||||
) : array {
|
||||
|
||||
|
@ -416,7 +416,7 @@ class renderer {
|
||||
$exportedpostsbuilder = $this->builderfactory->get_exported_posts_builder();
|
||||
$discussionentries = [];
|
||||
$postentries = [];
|
||||
foreach($discussions as $discussion) {
|
||||
foreach ($discussions as $discussion) {
|
||||
$discussionentries[] = $discussion->get_discussion();
|
||||
$discussionentriesids[] = $discussion->get_discussion()->get_id();
|
||||
$postentries[] = $discussion->get_first_post();
|
||||
@ -433,7 +433,7 @@ class renderer {
|
||||
$discussionrepliescount = $postvault->get_reply_count_for_discussion_ids($discussionentriesids);
|
||||
|
||||
array_walk($exportedposts['posts'], function($post) use ($discussionrepliescount) {
|
||||
$post->discussionrepliescount = $discussionrepliescount[$post->discussionid] ?? 0;
|
||||
$post->discussionrepliescount = $discussionrepliescount[$post->discussionid] ?? 0;
|
||||
// TODO: Find a better solution due to language differences when defining the singular and plural form.
|
||||
$post->isreplyplural = $post->discussionrepliescount != 1 ? true : false;
|
||||
});
|
||||
|
@ -91,7 +91,7 @@ class capability {
|
||||
*/
|
||||
public function can_subscribe_to_forum(stdClass $user) : bool {
|
||||
if ($this->forum->get_type() == 'single') {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return !is_guest($this->get_context(), $user) &&
|
||||
|
@ -93,6 +93,7 @@ class discussion_list {
|
||||
* @param capability_manager $capabilitymanager The managed used to check capabilities on the forum
|
||||
* @param url_factory $urlfactory The factory used to create URLs in the forum
|
||||
* @param notification[] $notifications A list of any notifications to be displayed within the page
|
||||
* @param callable|null $postprocessfortemplate Callback function to process discussion lists for templates
|
||||
*/
|
||||
public function __construct(
|
||||
forum_entity $forum,
|
||||
|
@ -47,7 +47,10 @@ class mod_forum_local_container_testcase extends advanced_testcase {
|
||||
* @covers ::get_legacy_data_mapper_factory
|
||||
*/
|
||||
public function test_get_legacy_data_mapper_factory() {
|
||||
$this->assertInstanceOf(\mod_forum\local\factories\legacy_data_mapper::class, \mod_forum\local\container::get_legacy_data_mapper_factory());
|
||||
$this->assertInstanceOf(
|
||||
\mod_forum\local\factories\legacy_data_mapper::class,
|
||||
\mod_forum\local\container::get_legacy_data_mapper_factory()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user