These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | class DMSGridFieldAddNewButton extends GridFieldAddNewButton implements GridField_HTMLProvider |
||
4 | { |
||
5 | /** |
||
6 | * The document set ID that the document should be attached to |
||
7 | * |
||
8 | * @var int |
||
9 | */ |
||
10 | protected $documentSetId; |
||
11 | |||
12 | /** |
||
13 | * Overriding the parent method to change the template that the DMS add button will be rendered with |
||
14 | * |
||
15 | * @param GridField $gridField |
||
16 | * @return array |
||
17 | */ |
||
18 | public function getHTMLFragments($gridField) |
||
19 | { |
||
20 | $singleton = singleton($gridField->getModelClass()); |
||
21 | |||
22 | if (!$singleton->canCreate()) { |
||
0 ignored issues
–
show
|
|||
23 | return array(); |
||
24 | } |
||
25 | |||
26 | if (!$this->buttonName) { |
||
27 | // provide a default button name, can be changed by calling {@link setButtonName()} on this component |
||
28 | $objectName = $singleton->i18n_singular_name(); |
||
29 | $this->buttonName = _t('GridField.Add', 'Add {name}', array('name' => $objectName)); |
||
0 ignored issues
–
show
array('name' => $objectName) is of type array<string,?,{"name":"?"}> , but the function expects a string .
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...
|
|||
30 | } |
||
31 | |||
32 | $link = singleton('DMSDocumentAddController')->Link(); |
||
33 | if ($this->getDocumentSetId()) { |
||
34 | $link = Controller::join_links($link, '?dsid=' . $this->getDocumentSetId()); |
||
35 | |||
36 | // Look for an associated page, but only share it if we're editing in a page context |
||
37 | $set = DMSDocumentSet::get()->byId($this->getDocumentSetId()); |
||
38 | if ($set && $set->exists() && $set->Page()->exists() |
||
39 | && Controller::curr() instanceof CMSPageEditController |
||
40 | ) { |
||
41 | $link = Controller::join_links($link, '?page_id=' . $set->Page()->ID); |
||
42 | } |
||
43 | } |
||
44 | |||
45 | $data = new ArrayData(array( |
||
46 | 'NewLink' => $link, |
||
47 | 'ButtonName' => $this->buttonName, |
||
48 | )); |
||
49 | |||
50 | return array( |
||
51 | $this->targetFragment => $data->renderWith('DMSGridFieldAddNewButton'), |
||
52 | ); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Set the document set ID that this document should be attached to |
||
57 | * |
||
58 | * @param int $id |
||
59 | * @return $this |
||
60 | */ |
||
61 | public function setDocumentSetId($id) |
||
62 | { |
||
63 | $this->documentSetId = $id; |
||
64 | return $this; |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Get the document set ID that this document should be attached to |
||
69 | * |
||
70 | * @return int |
||
71 | */ |
||
72 | public function getDocumentSetId() |
||
73 | { |
||
74 | return $this->documentSetId; |
||
75 | } |
||
76 | } |
||
77 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.