OSS-905 PSR2 compliance

This commit is contained in:
Shoaib Ali 2015-11-07 15:42:22 +13:00
parent eee39bca4e
commit 0a19119114
9 changed files with 185 additions and 197 deletions

View File

@ -5,7 +5,6 @@
* @package widgets
*/
class WidgetContentControllerExtension extends Extension {
/**
*
* @var array
@ -27,7 +26,9 @@ class WidgetContentControllerExtension extends Extension {
*/
public function handleWidget() {
$SQL_id = $this->owner->getRequest()->param('ID');
if(!$SQL_id) return false;
if (!$SQL_id) {
return false;
}
// find WidgetArea relations
$widgetAreaRelations = array();

View File

@ -19,7 +19,6 @@
* @package widgets
*/
class WidgetController extends Controller {
/**
* @var Widget
*/
@ -116,5 +115,4 @@ class WidgetController extends Controller {
* @package widgets
*/
class Widget_Controller extends WidgetController {
}

View File

@ -9,7 +9,6 @@
* without using this class.
*/
class WidgetPageExtension extends DataExtension {
private static $db = array(
'InheritSideBar' => 'Boolean',
);
@ -60,7 +59,6 @@ class WidgetPageExtension extends DataExtension {
}
$duplicatePage->SideBarID = $duplicateWidgetArea->ID;
}
return $duplicatePage;
@ -73,5 +71,4 @@ class WidgetPageExtension extends DataExtension {
//reset the sidebar ID
$this->owner->SideBarID = 0;
}
}

View File

@ -6,7 +6,6 @@
* @package widgets
*/
class WidgetAreaEditor extends FormField {
/**
* @param string $name
* @param array $widgetClasses
@ -43,13 +42,11 @@ class WidgetAreaEditor extends FormField {
if (isset($classes['Widget'])) {
unset($classes['Widget']);
}
else if (isset($classes[0]) && $classes[0] == 'Widget') {
} elseif (isset($classes[0]) && $classes[0] == 'Widget') {
unset($classes[0]);
}
foreach ($classes as $class) {
$available = Config::inst()->get($class, 'only_available_in');
if (!empty($available) && is_array($available)) {
@ -119,7 +116,9 @@ class WidgetAreaEditor extends FormField {
}
}
if(!$this->getForm()) throw new Exception("no form");
if (!$this->getForm()) {
throw new Exception("no form");
}
$widgetData = $this->getForm()->getRequest()->requestVar('Widget');
if ($widgetData && isset($widgetData[$this->getName()])) {

View File

@ -11,7 +11,6 @@
* @package widgets
*/
class Widget extends DataObject {
/**
* @var array
*/
@ -271,8 +270,7 @@ class Widget extends DataObject {
if ($field = $fields->dataFieldByName($name)) {
$field->setValue($value);
$field->saveInto($this);
}
else {
} else {
$this->setField($name, $value);
}
}
@ -293,4 +291,3 @@ class Widget extends DataObject {
$this->write();
}
}

View File

@ -6,7 +6,6 @@
* @package widgets
*/
class WidgetArea extends DataObject {
/**
* @var array
*/
@ -80,4 +79,3 @@ class WidgetArea extends DataObject {
}
}
}

View File

@ -22,7 +22,7 @@ class WidgetAreaEditorTest extends SapphireTest {
)
);
function testFillingOneArea() {
public function testFillingOneArea() {
$data = array(
'Widget' => array(
'BottomBar' => array(
@ -53,7 +53,7 @@ class WidgetAreaEditorTest extends SapphireTest {
$this->assertEquals($page->SideBar()->Widgets()->Count(), 0);
}
function testFillingTwoAreas() {
public function testFillingTwoAreas() {
$data = array(
'Widget' => array(
'SideBar' => array(
@ -96,7 +96,7 @@ class WidgetAreaEditorTest extends SapphireTest {
$this->assertEquals($bottWidgets[0]->Title(), 'MyTestWidgetBottom');
}
function testDeletingOneWidgetFromOneArea() {
public function testDeletingOneWidgetFromOneArea() {
// First get some widgets in there
$data = array(
'Widget' => array(
@ -162,7 +162,7 @@ class WidgetAreaEditorTest extends SapphireTest {
$this->assertEquals($page->SideBar()->Widgets()->Count(), 0);
}
function testDeletingAWidgetFromEachArea() {
public function testDeletingAWidgetFromEachArea() {
// First get some widgets in there
$data = array(
'Widget' => array(
@ -222,7 +222,7 @@ class WidgetAreaEditorTest extends SapphireTest {
$this->assertEquals($page->SideBar()->Widgets()->Count(), 0);
}
function testEditingOneWidget() {
public function testEditingOneWidget() {
// First get some widgets in there
$data = array(
'Widget' => array(
@ -294,7 +294,7 @@ class WidgetAreaEditorTest extends SapphireTest {
$this->assertEquals($sideWidgets[0]->Title(), 'MyTestWidgetSide-edited');
}
function testEditingAWidgetFromEachArea() {
public function testEditingAWidgetFromEachArea() {
// First get some widgets in there
$data = array(
'Widget' => array(
@ -366,7 +366,7 @@ class WidgetAreaEditorTest extends SapphireTest {
$this->assertEquals($sideWidgets[0]->Title(), 'MyTestWidgetSide-edited');
}
function testEditAWidgetFromOneAreaAndDeleteAWidgetFromAnotherArea() {
public function testEditAWidgetFromOneAreaAndDeleteAWidgetFromAnotherArea() {
// First get some widgets in there
$data = array(
'Widget' => array(

View File

@ -4,7 +4,6 @@
* @subpackage tests
*/
class WidgetControllerTest extends FunctionalTest {
protected static $fixture_file = 'WidgetControllerTest.yml';
protected $extraDataObjects = array(
@ -12,7 +11,7 @@ class WidgetControllerTest extends FunctionalTest {
'WidgetControllerTest_Widget',
);
function testWidgetFormRendering() {
public function testWidgetFormRendering() {
$page = $this->objFromFixture('WidgetControllerTestPage', 'page1');
$page->publish('Stage', 'Live');
@ -28,7 +27,7 @@ class WidgetControllerTest extends FunctionalTest {
);
}
function testWidgetFormSubmission() {
public function testWidgetFormSubmission() {
$page = $this->objFromFixture('WidgetControllerTestPage', 'page1');
$page->publish('Stage', 'Live');
@ -64,13 +63,13 @@ class WidgetControllerTest_Widget extends Widget implements TestOnly {
* @package widgets
* @subpackage tests
*/
class WidgetControllerTest_WidgetController extends WidgetController implements TestOnly {
class WidgetControllerTest_WidgetController extends WidgetController implements TestOnly
{
private static $allowed_actions = array(
'Form'
);
function Form() {
public function Form() {
$widgetform = new Form(
$this,
'Form',
@ -85,7 +84,7 @@ class WidgetControllerTest_WidgetController extends WidgetController implements
return $widgetform;
}
function doAction($data, $form) {
public function doAction($data, $form) {
return sprintf('TestValue: %s\nWidget ID: %d',
$data['TestValue'],
$this->widget->ID

View File

@ -14,12 +14,11 @@ class WidgetControllerTestPage extends Page implements TestOnly {
* @subpackage tests
*/
class WidgetControllerTestPage_Controller extends Page_Controller implements TestOnly {
/**
* Template selection doesnt work in test folders,
* so we enforce a template name.
*/
function getViewer($action) {
public function getViewer($action) {
$templates = array('WidgetControllerTestPage');
return new SSViewer($templates);