Passed
Push — develop ( 73b4e9...8d0058 )
by Daniel
05:19
created

author_contents::get_name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2018 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\content\services\topic\driver;
11
12
class author_contents implements block_interface
13
{
14
	/** @var\phpbb\language\language */
15
	protected $language;
16
17
	/** @var \phpbb\template\template */
0 ignored issues
show
Bug introduced by
The type phpbb\template\template was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
	protected $template;
19
20
	/* @var \blitze\content\services\fields */
21
	protected $fields;
22
23
	/** @var \blitze\sitemaker\services\forum\data */
0 ignored issues
show
Bug introduced by
The type blitze\sitemaker\services\forum\data was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
	protected $forum;
25
26
	/**
27
	 * Constructor
28
	 *
29
	 * @param \phpbb\language\language					$language			Language Object
30
	 * @param \phpbb\template\template					$template			Template object
31
	 * @param \blitze\content\services\fields			$fields				Content fields object
32
	 * @param \blitze\sitemaker\services\forum\data		$forum				Forum Data object
33
	*/
34
	public function __construct(\phpbb\language\language $language, \phpbb\template\template $template, \blitze\content\services\fields $fields, \blitze\sitemaker\services\forum\data $forum)
0 ignored issues
show
Bug introduced by
The type phpbb\language\language was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
35
	{
36
		$this->language = $language;
37
		$this->template = $template;
38
		$this->fields = $fields;
39
		$this->forum = $forum;
40
	}
41
42
	/**
43
	 * @inheritdoc
44
	 */
45
	public function get_name()
46
	{
47
		return 'author_contents';
48
	}
49
50
	/**
51
	 * @inheritdoc
52
	 */
53
	public function get_langname()
54
	{
55
		return 'AUTHOR_CONTENTS';
56
	}
57
58
	/**
59
	 * @param \blitze\content\model\entity\type $entity
60
	 * @param array $topic_data
61
	 * @param array $post_data
62
	 * @param array $user_cache
63
	 * @return void
64
	 */
65
	public function show_block(\blitze\content\model\entity\type $entity, array $topic_data, array $post_data, array $user_cache)
66
	{
67
		$this->forum->query()
68
			->fetch_forum($topic_data['forum_id'])
69
			->fetch_topic_poster($topic_data['topic_poster'])
70
			->fetch_custom(array(
71
				'WHERE' => array('t.topic_id <> ' . (int) $topic_data['topic_id'])
72
			))->build(true, true, false);
73
74
		$topics_data = $this->forum->get_topic_data(5);
75
		$topic_tracking_info = $this->forum->get_topic_tracking_info($topic_data['forum_id']);
76
		$content_type = $entity->get_content_name();
77
78
		$topics = array();
79
		foreach ($topics_data as $row)
80
		{
81
			$topics[] = $this->fields->get_min_topic_info($content_type, $row, $topic_tracking_info);
82
		}
83
84
		$this->template->assign_block_vars('topic_blocks', array(
85
			'TITLE'		=> $this->language->lang('AUTHOR_CONTENTS', $entity->get_content_langname(), $topic_data['topic_first_poster_name']),
86
			'TPL_NAME'	=> '@blitze_content/author_contents.html',
87
			'TOPICS'	=> $topics,
88
		));
89
	}
90
}
91