listener::add_permissions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
/**
3
 *
4
 * Precise Similar Topics
5
 *
6
 * @copyright (c) 2013 Matt Friedman
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace vse\similartopics\event;
12
13
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\EventD...ventSubscriberInterface 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...
14
15
/**
16
 * Event listener
17
 */
18
class listener implements EventSubscriberInterface
19
{
20
	/** @var \vse\similartopics\core\similar_topics */
21
	protected $similar_topics;
22
23
	/**
24
	 * Constructor
25
	 *
26
	 * @access public
27
	 * @param \vse\similartopics\core\similar_topics $similar_topics
28
	 */
29
	public function __construct(\vse\similartopics\core\similar_topics $similar_topics)
30
	{
31
		$this->similar_topics = $similar_topics;
32
	}
33
34
	/**
35
	 * Assign functions defined in this class to event listeners in the core
36
	 *
37
	 * @static
38
	 * @access public
39
	 * @return array
40
	 */
41
	public static function getSubscribedEvents()
42
	{
43
		return [
44
			'core.viewtopic_modify_page_title'		=> 'display_similar_topics',
45
			'core.permissions'						=> 'add_permissions',
46
		];
47
	}
48
49
	/**
50
	 * Display similar topics
51
	 *
52
	 * @access public
53
	 * @param \phpbb\event\data $event The event object
0 ignored issues
show
Bug introduced by
The type phpbb\event\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...
54
	 */
55
	public function display_similar_topics($event)
56
	{
57
		// Return early if similar topics is disabled
58
		if (!$this->similar_topics->is_available())
59
		{
60
			return;
61
		}
62
63
		$this->similar_topics->display_similar_topics($event['topic_data']);
64
	}
65
66
	/**
67
	 * Add custom permissions language variables
68
	 *
69
	 * @access public
70
	 * @param \phpbb\event\data $event The event object
71
	 */
72
	public function add_permissions($event)
73
	{
74
		$event->update_subarray('permissions', 'u_similar_topics', [
75
			'lang' => 'ACL_U_SIMILARTOPICS',
76
			'cat' => 'misc'
77
		]);
78
	}
79
}
80