Completed
Push — feature/ss4-upgrade ( f41a3f )
by
unknown
10:12
created

AuthorsController::Title()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace SilverStripe\Addons\Controllers;
4
5
use SilverStripe\Addons\Model\AddonAuthor;
6
use SilverStripe\Control\Controller;
7
use SilverStripe\Control\Director;
8
9
/**
10
 * Handles displaying package authors.
11
 */
12
class AuthorsController extends SiteController 
13
{
14
15
	private static $url_handlers = [
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
16
		'$AuthorID!' => 'author'
17
	];
18
19
	private static $allowed_actions = [
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
20
		'index',
21
		'author'
22
	];
23
24
	public function index() 
25
	{
26
		return $this->renderWith(['Authors', 'Page']);
27
	}
28
29
	public function author($request) 
30
	{
31
		$id = $request->param('AuthorID');
32
		$author = AddonAuthor::get()->byID($id);
33
34
		if (!$author) {
35
			$this->httpError(404);
36
		}
37
38
		return new AuthorController($this, $author);
0 ignored issues
show
Documentation introduced by
$author is of type null|object<SilverStripe\ORM\DataObject>, but the function expects a object<SilverStripe\Addons\Model\AddonAuthor>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
39
	}
40
41
	public function Title() 
42
	{
43
		return 'Authors';
44
	}
45
46
	public function Link() 
47
	{
48
		return Controller::join_links(Director::baseURL(), 'authors');
49
	}
50
51
	public function Authors() 
52
	{
53
		return AddonAuthor::get();
54
	}
55
56
}
57