Completed
Push — master ( 5d0790...aab733 )
by James
02:44
created

CustomLumberjack::updateCMSFields()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 11
nc 2
nop 1
1
<?php
2
class CustomLumberjack extends Lumberjack {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
3
4
  /**
5
	 * This is responsible for adding the child pages tab and gridfield.
6
   * CUSTOM: Customised to make the GridField tab first.
7
	 *
8
	 * @param FieldList $fields
9
	 */
10
	public function updateCMSFields(FieldList $fields) {
11
		$excluded = $this->owner->getExcludedSiteTreeClassNames();
12
		if(!empty($excluded)) {
13
			$pages = $this->getLumberjackPagesForGridfield($excluded);
14
			$gridField = new GridField(
15
				"ChildPages",
16
				$this->getLumberjackTitle(),
17
				$pages,
18
				$this->getLumberjackGridFieldConfig()
19
			);
20
21
			$tab = new Tab('ChildPages', $this->getLumberjackTitle(), $gridField);
22
			// $fields->insertAfter($tab, 'Main');
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
23
			$fields->insertBefore($tab, 'Main'); // Only modified line
0 ignored issues
show
Documentation introduced by
'Main' is of type string, but the function expects a object<FormField>.

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...
24
		}
25
	}
26
  
27
}