MINOR Apply PSR-2 linting

This commit is contained in:
Robbie Averill 2017-09-01 13:02:18 +12:00 committed by Daniel Hensby
parent 3ee4ff4cb7
commit 0ad1fc367e
No known key found for this signature in database
GPG Key ID: 5DE415D786BBB2FD
3 changed files with 46 additions and 41 deletions

View File

@ -158,7 +158,7 @@ class GridFieldAddNewMultiClass implements GridField_HTMLProvider, GridField_URL
}
$sanitised = array();
foreach($result as $class=>$title) {
foreach ($result as $class => $title) {
$sanitised[$this->sanitiseClassName($class)] = $title;
}

View File

@ -516,11 +516,11 @@ class GridFieldOrderableRows extends RequestHandler implements
$sortTable = $this->getSortTable($list);
$additionalSQL = '';
$baseTable = $sortTable;
if(class_exists($sortTable)) {
if (class_exists($sortTable)) {
$baseTable = singleton($sortTable)->baseTable();
}
$isBaseTable = ($baseTable == $sortTable);
if(!$list instanceof ManyManyList && $isBaseTable){
if (!$list instanceof ManyManyList && $isBaseTable) {
$additionalSQL = ', "LastEdited" = NOW()';
}
@ -535,7 +535,7 @@ class GridFieldOrderableRows extends RequestHandler implements
$this->getSortTableClauseForIds($list, $id)
));
if(!$isBaseTable) {
if (!$isBaseTable) {
DB::query(sprintf(
'UPDATE "%s" SET "LastEdited" = NOW() WHERE %s',
$baseTable,
@ -570,11 +570,11 @@ class GridFieldOrderableRows extends RequestHandler implements
$additionalSQL = '';
$baseTable = $table;
if(class_exists($table)) {
if (class_exists($table)) {
$baseTable = singleton($table)->baseTable();
}
$isBaseTable = ($baseTable == $table);
if(!$list instanceof ManyManyList && $isBaseTable){
if (!$list instanceof ManyManyList && $isBaseTable) {
$additionalSQL = ', "LastEdited" = NOW()';
}
@ -591,7 +591,7 @@ class GridFieldOrderableRows extends RequestHandler implements
$this->getSortTableClauseForIds($list, $id)
));
if(!$isBaseTable) {
if (!$isBaseTable) {
DB::query(sprintf(
'UPDATE "%s" SET "LastEdited" = NOW() WHERE %s',
$baseTable,

View File

@ -13,54 +13,59 @@ use SilverStripe\Forms\GridField\GridFieldDetailForm;
use Symbiote\GridFieldExtensions\GridFieldAddNewMultiClass;
use Symbiote\GridFieldExtensions\GridFieldAddNewMultiClassHandler;
class GridFieldAddNewMultiClassWithNamespacesTest extends SapphireTest {
class GridFieldAddNewMultiClassWithNamespacesTest extends SapphireTest
{
public function testGetClassesWithNamespaces() {
$grid = new GridField('TestGridField');
$grid->setModelClass('Symbiote\\Test\\NamespacedClass');
public function testGetClassesWithNamespaces()
{
$grid = new GridField('TestGridField');
$grid->setModelClass('Symbiote\\Test\\NamespacedClass');
$component = new GridFieldAddNewMultiClass();
$component = new GridFieldAddNewMultiClass();
$this->assertEquals(
array(
'Symbiote-Test-NamespacedClass' => 'NamespacedClass'
),
$component->getClasses($grid),
'Namespaced classes are sanitised'
);
}
$this->assertEquals(
array(
'Symbiote-Test-NamespacedClass' => 'NamespacedClass'
),
$component->getClasses($grid),
'Namespaced classes are sanitised'
);
}
public function testHandleAddWithNamespaces() {
$grid = new GridField('TestGridField');
$grid->getConfig()->addComponent(new GridFieldDetailForm());
$grid->setModelClass('Symbiote\\Test\\NamespacedClass');
$grid->setForm(Form::create(Controller::create(), 'test', FieldList::create(), FieldList::create()));
public function testHandleAddWithNamespaces()
{
$grid = new GridField('TestGridField');
$grid->getConfig()->addComponent(new GridFieldDetailForm());
$grid->setModelClass('Symbiote\\Test\\NamespacedClass');
$grid->setForm(Form::create(Controller::create(), 'test', FieldList::create(), FieldList::create()));
$request = new HTTPRequest('POST', 'test');
$request->setRouteParams(array('ClassName' => 'Symbiote-Test-NamespacedClass'));
$request = new HTTPRequest('POST', 'test');
$request->setRouteParams(array('ClassName' => 'Symbiote-Test-NamespacedClass'));
$component = new GridFieldAddNewMultiClass();
$response = $component->handleAdd($grid, $request);
$record = new \ReflectionProperty(GridFieldAddNewMultiClassHandler::class, 'record');
$record->setAccessible(true);
$this->assertInstanceOf('Symbiote\\Test\\NamespacedClass', $record->getValue($response));
}
$component = new GridFieldAddNewMultiClass();
$response = $component->handleAdd($grid, $request);
$record = new \ReflectionProperty(GridFieldAddNewMultiClassHandler::class, 'record');
$record->setAccessible(true);
$this->assertInstanceOf('Symbiote\\Test\\NamespacedClass', $record->getValue($response));
}
}
/**#@+
* @ignore
*/
class NamespacedClass implements TestOnly {
public function i18n_singular_name() {
return 'NamespacedClass';
}
class NamespacedClass implements TestOnly
{
public function i18n_singular_name()
{
return 'NamespacedClass';
}
public function canCreate() {
return true;
}
public function canCreate()
{
return true;
}
}
/**#@-*/