Merge pull request #60 from helpfulrobot/convert-to-psr-2
Converted to PSR-2
This commit is contained in:
commit
10b84002b3
|
@ -9,7 +9,8 @@
|
|||
* @package forms
|
||||
* @subpackage fields
|
||||
*/
|
||||
class StringTagField extends DropdownField {
|
||||
class StringTagField extends DropdownField
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
|
@ -43,14 +44,16 @@ class StringTagField extends DropdownField {
|
|||
* @param array|SS_List $source
|
||||
* @param array|SS_List $value
|
||||
*/
|
||||
public function __construct($name, $title = '', $source = array(), $value = array()) {
|
||||
public function __construct($name, $title = '', $source = array(), $value = array())
|
||||
{
|
||||
parent::__construct($name, $title, $source, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getShouldLazyLoad() {
|
||||
public function getShouldLazyLoad()
|
||||
{
|
||||
return $this->shouldLazyLoad;
|
||||
}
|
||||
|
||||
|
@ -59,7 +62,8 @@ class StringTagField extends DropdownField {
|
|||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setShouldLazyLoad($shouldLazyLoad) {
|
||||
public function setShouldLazyLoad($shouldLazyLoad)
|
||||
{
|
||||
$this->shouldLazyLoad = $shouldLazyLoad;
|
||||
|
||||
return $this;
|
||||
|
@ -68,7 +72,8 @@ class StringTagField extends DropdownField {
|
|||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLazyLoadItemLimit() {
|
||||
public function getLazyLoadItemLimit()
|
||||
{
|
||||
return $this->lazyLoadItemLimit;
|
||||
}
|
||||
|
||||
|
@ -77,7 +82,8 @@ class StringTagField extends DropdownField {
|
|||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setLazyLoadItemLimit($lazyLoadItemLimit) {
|
||||
public function setLazyLoadItemLimit($lazyLoadItemLimit)
|
||||
{
|
||||
$this->lazyLoadItemLimit = $lazyLoadItemLimit;
|
||||
|
||||
return $this;
|
||||
|
@ -86,7 +92,8 @@ class StringTagField extends DropdownField {
|
|||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getIsMultiple() {
|
||||
public function getIsMultiple()
|
||||
{
|
||||
return $this->isMultiple;
|
||||
}
|
||||
|
||||
|
@ -95,7 +102,8 @@ class StringTagField extends DropdownField {
|
|||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setIsMultiple($isMultiple) {
|
||||
public function setIsMultiple($isMultiple)
|
||||
{
|
||||
$this->isMultiple = $isMultiple;
|
||||
|
||||
return $this;
|
||||
|
@ -104,7 +112,8 @@ class StringTagField extends DropdownField {
|
|||
/**
|
||||
* @return null|DataObject
|
||||
*/
|
||||
public function getRecord() {
|
||||
public function getRecord()
|
||||
{
|
||||
if ($this->record) {
|
||||
return $this->record;
|
||||
}
|
||||
|
@ -121,7 +130,8 @@ class StringTagField extends DropdownField {
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setRecord(DataObject $record) {
|
||||
public function setRecord(DataObject $record)
|
||||
{
|
||||
$this->record = $record;
|
||||
|
||||
return $this;
|
||||
|
@ -130,7 +140,8 @@ class StringTagField extends DropdownField {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function Field($properties = array()) {
|
||||
public function Field($properties = array())
|
||||
{
|
||||
Requirements::css(TAG_FIELD_DIR . '/css/select2.min.css');
|
||||
Requirements::css(TAG_FIELD_DIR . '/css/TagField.css');
|
||||
|
||||
|
@ -161,14 +172,16 @@ class StringTagField extends DropdownField {
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getSuggestURL() {
|
||||
protected function getSuggestURL()
|
||||
{
|
||||
return Controller::join_links($this->Link(), 'suggest');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayList
|
||||
*/
|
||||
protected function getOptions() {
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = ArrayList::create();
|
||||
|
||||
$source = $this->getSource();
|
||||
|
@ -195,7 +208,8 @@ class StringTagField extends DropdownField {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setValue($value, $source = null) {
|
||||
public function setValue($value, $source = null)
|
||||
{
|
||||
if (is_string($value)) {
|
||||
$value = explode(',', $value);
|
||||
}
|
||||
|
@ -215,7 +229,8 @@ class StringTagField extends DropdownField {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAttributes() {
|
||||
public function getAttributes()
|
||||
{
|
||||
return array_merge(
|
||||
parent::getAttributes(),
|
||||
array('name' => $this->getName() . '[]')
|
||||
|
@ -225,7 +240,8 @@ class StringTagField extends DropdownField {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function saveInto(DataObjectInterface $record) {
|
||||
public function saveInto(DataObjectInterface $record)
|
||||
{
|
||||
parent::saveInto($record);
|
||||
|
||||
$name = $this->getName();
|
||||
|
@ -241,7 +257,8 @@ class StringTagField extends DropdownField {
|
|||
*
|
||||
* @return SS_HTTPResponse
|
||||
*/
|
||||
public function suggest(SS_HTTPRequest $request) {
|
||||
public function suggest(SS_HTTPRequest $request)
|
||||
{
|
||||
$responseBody = Convert::raw2json(
|
||||
array('items' => array())
|
||||
);
|
||||
|
@ -274,7 +291,8 @@ class StringTagField extends DropdownField {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getTags($term) {
|
||||
protected function getTags($term)
|
||||
{
|
||||
$record = $this->getRecord();
|
||||
|
||||
if (!$record) {
|
||||
|
@ -315,8 +333,8 @@ class StringTagField extends DropdownField {
|
|||
* @param Validator $validator
|
||||
* @return bool
|
||||
*/
|
||||
public function validate($validator) {
|
||||
public function validate($validator)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* @package forms
|
||||
* @subpackage fields
|
||||
*/
|
||||
class TagField extends DropdownField {
|
||||
class TagField extends DropdownField
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
|
@ -45,14 +46,16 @@ class TagField extends DropdownField {
|
|||
* @param null|DataList $source
|
||||
* @param null|DataList $value
|
||||
*/
|
||||
public function __construct($name, $title = '', $source = null, $value = null) {
|
||||
public function __construct($name, $title = '', $source = null, $value = null)
|
||||
{
|
||||
parent::__construct($name, $title, $source, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getShouldLazyLoad() {
|
||||
public function getShouldLazyLoad()
|
||||
{
|
||||
return $this->shouldLazyLoad;
|
||||
}
|
||||
|
||||
|
@ -61,7 +64,8 @@ class TagField extends DropdownField {
|
|||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setShouldLazyLoad($shouldLazyLoad) {
|
||||
public function setShouldLazyLoad($shouldLazyLoad)
|
||||
{
|
||||
$this->shouldLazyLoad = $shouldLazyLoad;
|
||||
|
||||
return $this;
|
||||
|
@ -70,7 +74,8 @@ class TagField extends DropdownField {
|
|||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLazyLoadItemLimit() {
|
||||
public function getLazyLoadItemLimit()
|
||||
{
|
||||
return $this->lazyLoadItemLimit;
|
||||
}
|
||||
|
||||
|
@ -79,7 +84,8 @@ class TagField extends DropdownField {
|
|||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setLazyLoadItemLimit($lazyLoadItemLimit) {
|
||||
public function setLazyLoadItemLimit($lazyLoadItemLimit)
|
||||
{
|
||||
$this->lazyLoadItemLimit = $lazyLoadItemLimit;
|
||||
|
||||
return $this;
|
||||
|
@ -88,7 +94,8 @@ class TagField extends DropdownField {
|
|||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getIsMultiple() {
|
||||
public function getIsMultiple()
|
||||
{
|
||||
return $this->isMultiple;
|
||||
}
|
||||
|
||||
|
@ -97,7 +104,8 @@ class TagField extends DropdownField {
|
|||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setIsMultiple($isMultiple) {
|
||||
public function setIsMultiple($isMultiple)
|
||||
{
|
||||
$this->isMultiple = $isMultiple;
|
||||
|
||||
return $this;
|
||||
|
@ -106,7 +114,8 @@ class TagField extends DropdownField {
|
|||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getCanCreate() {
|
||||
public function getCanCreate()
|
||||
{
|
||||
return $this->canCreate;
|
||||
}
|
||||
|
||||
|
@ -115,7 +124,8 @@ class TagField extends DropdownField {
|
|||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setCanCreate($canCreate) {
|
||||
public function setCanCreate($canCreate)
|
||||
{
|
||||
$this->canCreate = $canCreate;
|
||||
|
||||
return $this;
|
||||
|
@ -124,7 +134,8 @@ class TagField extends DropdownField {
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTitleField() {
|
||||
public function getTitleField()
|
||||
{
|
||||
return $this->titleField;
|
||||
}
|
||||
|
||||
|
@ -133,7 +144,8 @@ class TagField extends DropdownField {
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTitleField($titleField) {
|
||||
public function setTitleField($titleField)
|
||||
{
|
||||
$this->titleField = $titleField;
|
||||
|
||||
return $this;
|
||||
|
@ -142,7 +154,8 @@ class TagField extends DropdownField {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function Field($properties = array()) {
|
||||
public function Field($properties = array())
|
||||
{
|
||||
Requirements::css(TAG_FIELD_DIR . '/css/select2.min.css');
|
||||
Requirements::css(TAG_FIELD_DIR . '/css/TagField.css');
|
||||
|
||||
|
@ -173,14 +186,16 @@ class TagField extends DropdownField {
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getSuggestURL() {
|
||||
protected function getSuggestURL()
|
||||
{
|
||||
return Controller::join_links($this->Link(), 'suggest');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayList
|
||||
*/
|
||||
protected function getOptions() {
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = ArrayList::create();
|
||||
|
||||
$source = $this->getSource();
|
||||
|
@ -221,7 +236,8 @@ class TagField extends DropdownField {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setValue($value, $source = null) {
|
||||
public function setValue($value, $source = null)
|
||||
{
|
||||
if ($source instanceof DataObject) {
|
||||
$name = $this->getName();
|
||||
|
||||
|
@ -242,7 +258,8 @@ class TagField extends DropdownField {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAttributes() {
|
||||
public function getAttributes()
|
||||
{
|
||||
return array_merge(
|
||||
parent::getAttributes(),
|
||||
array('name' => $this->getName() . '[]')
|
||||
|
@ -252,7 +269,8 @@ class TagField extends DropdownField {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function saveInto(DataObjectInterface $record) {
|
||||
public function saveInto(DataObjectInterface $record)
|
||||
{
|
||||
parent::saveInto($record);
|
||||
|
||||
$name = $this->getName();
|
||||
|
@ -304,7 +322,8 @@ class TagField extends DropdownField {
|
|||
* @param string $term
|
||||
* @return DataObject
|
||||
*/
|
||||
protected function getOrCreateTag($term) {
|
||||
protected function getOrCreateTag($term)
|
||||
{
|
||||
// Check if existing record can be found
|
||||
$source = $this->getSource();
|
||||
$titleField = $this->getTitleField();
|
||||
|
@ -330,7 +349,8 @@ class TagField extends DropdownField {
|
|||
*
|
||||
* @return SS_HTTPResponse
|
||||
*/
|
||||
public function suggest(SS_HTTPRequest $request) {
|
||||
public function suggest(SS_HTTPRequest $request)
|
||||
{
|
||||
$tags = $this->getTags($request->getVar('term'));
|
||||
|
||||
$response = new SS_HTTPResponse();
|
||||
|
@ -347,7 +367,8 @@ class TagField extends DropdownField {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getTags($term) {
|
||||
protected function getTags($term)
|
||||
{
|
||||
/**
|
||||
* @var DataList $source
|
||||
*/
|
||||
|
@ -380,8 +401,8 @@ class TagField extends DropdownField {
|
|||
* @param Validator $validator
|
||||
* @return bool
|
||||
*/
|
||||
public function validate($validator) {
|
||||
public function validate($validator)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
/**
|
||||
* @mixin PHPUnit_Framework_TestCase
|
||||
*/
|
||||
class StringTagFieldTest extends SapphireTest {
|
||||
class StringTagFieldTest extends SapphireTest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -16,7 +17,8 @@ class StringTagFieldTest extends SapphireTest {
|
|||
'StringTagFieldTestBlogPost',
|
||||
);
|
||||
|
||||
function testItSavesTagsOnNewRecords() {
|
||||
public function testItSavesTagsOnNewRecords()
|
||||
{
|
||||
$record = $this->getNewStringTagFieldTestBlogPost('BlogPost1');
|
||||
|
||||
$field = new StringTagField('Tags');
|
||||
|
@ -33,14 +35,16 @@ class StringTagFieldTest extends SapphireTest {
|
|||
*
|
||||
* @return StringTagFieldTestBlogPost
|
||||
*/
|
||||
protected function getNewStringTagFieldTestBlogPost($name) {
|
||||
protected function getNewStringTagFieldTestBlogPost($name)
|
||||
{
|
||||
return $this->objFromFixture(
|
||||
'StringTagFieldTestBlogPost',
|
||||
$name
|
||||
);
|
||||
}
|
||||
|
||||
function testItSavesTagsOnExistingRecords() {
|
||||
public function testItSavesTagsOnExistingRecords()
|
||||
{
|
||||
$record = $this->getNewStringTagFieldTestBlogPost('BlogPost1');
|
||||
$record->write();
|
||||
|
||||
|
@ -51,7 +55,8 @@ class StringTagFieldTest extends SapphireTest {
|
|||
$this->assertEquals('Tag1,Tag2', $record->Tags);
|
||||
}
|
||||
|
||||
function testItSuggestsTags() {
|
||||
public function testItSuggestsTags()
|
||||
{
|
||||
$record = $this->getNewStringTagFieldTestBlogPost('BlogPost2');
|
||||
|
||||
$field = new StringTagField('Tags');
|
||||
|
@ -100,7 +105,8 @@ class StringTagFieldTest extends SapphireTest {
|
|||
*
|
||||
* @return SS_HTTPRequest
|
||||
*/
|
||||
protected function getNewRequest(array $parameters) {
|
||||
protected function getNewRequest(array $parameters)
|
||||
{
|
||||
return new SS_HTTPRequest(
|
||||
'get',
|
||||
'StringTagFieldTestController/StringTagFieldTestForm/fields/Tags/suggest',
|
||||
|
@ -112,7 +118,8 @@ class StringTagFieldTest extends SapphireTest {
|
|||
/**
|
||||
* @property string $Tags
|
||||
*/
|
||||
class StringTagFieldTestBlogPost extends DataObject implements TestOnly {
|
||||
class StringTagFieldTestBlogPost extends DataObject implements TestOnly
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
|
@ -123,11 +130,13 @@ class StringTagFieldTestBlogPost extends DataObject implements TestOnly {
|
|||
);
|
||||
}
|
||||
|
||||
class StringTagFieldTestController extends Controller implements TestOnly {
|
||||
class StringTagFieldTestController extends Controller implements TestOnly
|
||||
{
|
||||
/**
|
||||
* @return Form
|
||||
*/
|
||||
public function StringTagFieldTestForm() {
|
||||
public function StringTagFieldTestForm()
|
||||
{
|
||||
$fields = new FieldList(
|
||||
$tagField = new StringTagField('Tags')
|
||||
);
|
||||
|
@ -143,7 +152,8 @@ class StringTagFieldTestController extends Controller implements TestOnly {
|
|||
* @param DataObject $dataObject
|
||||
* @param Form $form
|
||||
*/
|
||||
public function StringTagFieldTestFormSubmit(DataObject $dataObject, Form $form) {
|
||||
public function StringTagFieldTestFormSubmit(DataObject $dataObject, Form $form)
|
||||
{
|
||||
$form->saveInto($dataObject);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
/**
|
||||
* @mixin PHPUnit_Framework_TestCase
|
||||
*/
|
||||
class TagFieldTest extends SapphireTest {
|
||||
class TagFieldTest extends SapphireTest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -17,7 +18,8 @@ class TagFieldTest extends SapphireTest {
|
|||
'TagFieldTestBlogPost',
|
||||
);
|
||||
|
||||
function testItSavesLinksToNewTagsOnNewRecords() {
|
||||
public function testItSavesLinksToNewTagsOnNewRecords()
|
||||
{
|
||||
$record = $this->getNewTagFieldTestBlogPost('BlogPost1');
|
||||
|
||||
$field = new TagField('Tags', '', new DataList('TagFieldTestBlogTag'));
|
||||
|
@ -37,7 +39,8 @@ class TagFieldTest extends SapphireTest {
|
|||
*
|
||||
* @return TagFieldTestBlogPost
|
||||
*/
|
||||
protected function getNewTagFieldTestBlogPost($name) {
|
||||
protected function getNewTagFieldTestBlogPost($name)
|
||||
{
|
||||
return $this->objFromFixture(
|
||||
'TagFieldTestBlogPost',
|
||||
$name
|
||||
|
@ -48,7 +51,8 @@ class TagFieldTest extends SapphireTest {
|
|||
* @param array $expected
|
||||
* @param TagFieldTestBlogPost $record
|
||||
*/
|
||||
protected function compareExpectedAndActualTags(array $expected, TagFieldTestBlogPost $record) {
|
||||
protected function compareExpectedAndActualTags(array $expected, TagFieldTestBlogPost $record)
|
||||
{
|
||||
$this->compareTagLists($expected, $record->Tags());
|
||||
}
|
||||
|
||||
|
@ -58,7 +62,8 @@ class TagFieldTest extends SapphireTest {
|
|||
* @param array $expected
|
||||
* @param DataList $actualSource
|
||||
*/
|
||||
protected function compareTagLists(array $expected, DataList $actualSource) {
|
||||
protected function compareTagLists(array $expected, DataList $actualSource)
|
||||
{
|
||||
$actual = array_values($actualSource->map('ID', 'Title')->toArray());
|
||||
|
||||
sort($expected);
|
||||
|
@ -70,7 +75,8 @@ class TagFieldTest extends SapphireTest {
|
|||
);
|
||||
}
|
||||
|
||||
public function testItSavesLinksToNewTagsOnExistingRecords() {
|
||||
public function testItSavesLinksToNewTagsOnExistingRecords()
|
||||
{
|
||||
$record = $this->getNewTagFieldTestBlogPost('BlogPost1');
|
||||
$record->write();
|
||||
|
||||
|
@ -84,7 +90,8 @@ class TagFieldTest extends SapphireTest {
|
|||
);
|
||||
}
|
||||
|
||||
public function testItSavesLinksToExistingTagsOnNewRecords() {
|
||||
public function testItSavesLinksToExistingTagsOnNewRecords()
|
||||
{
|
||||
$record = $this->getNewTagFieldTestBlogPost('BlogPost1');
|
||||
|
||||
$field = new TagField('Tags', '', new DataList('TagFieldTestBlogTag'));
|
||||
|
@ -99,7 +106,8 @@ class TagFieldTest extends SapphireTest {
|
|||
);
|
||||
}
|
||||
|
||||
public function testItSavesLinksToExistingTagsOnExistingRecords() {
|
||||
public function testItSavesLinksToExistingTagsOnExistingRecords()
|
||||
{
|
||||
$record = $this->getNewTagFieldTestBlogPost('BlogPost1');
|
||||
$record->write();
|
||||
|
||||
|
@ -116,7 +124,8 @@ class TagFieldTest extends SapphireTest {
|
|||
/**
|
||||
* Ensure that {@see TagField::saveInto} respects existing tags
|
||||
*/
|
||||
public function testSaveDuplicateTags() {
|
||||
public function testSaveDuplicateTags()
|
||||
{
|
||||
$record = $this->getNewTagFieldTestBlogPost('BlogPost2');
|
||||
$record->write();
|
||||
$tag2ID = $this->idFromFixture('TagFieldTestBlogTag', 'Tag2');
|
||||
|
@ -151,7 +160,8 @@ class TagFieldTest extends SapphireTest {
|
|||
$this->assertContains($tag2ID, TagFieldTestBlogTag::get()->column('ID'));
|
||||
}
|
||||
|
||||
function testItSuggestsTags() {
|
||||
public function testItSuggestsTags()
|
||||
{
|
||||
$field = new TagField('Tags', '', new DataList('TagFieldTestBlogTag'));
|
||||
|
||||
/**
|
||||
|
@ -198,7 +208,8 @@ class TagFieldTest extends SapphireTest {
|
|||
/**
|
||||
* Tests that TagField supports pre-filtered data sources
|
||||
*/
|
||||
public function testRestrictedSuggestions() {
|
||||
public function testRestrictedSuggestions()
|
||||
{
|
||||
$source = TagFieldTestBlogTag::get()->exclude('Title', 'Tag2');
|
||||
$field = new TagField('Tags', '', $source);
|
||||
|
||||
|
@ -238,7 +249,8 @@ class TagFieldTest extends SapphireTest {
|
|||
*
|
||||
* @return SS_HTTPRequest
|
||||
*/
|
||||
protected function getNewRequest(array $parameters) {
|
||||
protected function getNewRequest(array $parameters)
|
||||
{
|
||||
return new SS_HTTPRequest(
|
||||
'get',
|
||||
'TagFieldTestController/TagFieldTestForm/fields/Tags/suggest',
|
||||
|
@ -246,7 +258,8 @@ class TagFieldTest extends SapphireTest {
|
|||
);
|
||||
}
|
||||
|
||||
function testItDisplaysValuesFromRelations() {
|
||||
public function testItDisplaysValuesFromRelations()
|
||||
{
|
||||
$record = $this->getNewTagFieldTestBlogPost('BlogPost1');
|
||||
$record->write();
|
||||
|
||||
|
@ -266,7 +279,8 @@ class TagFieldTest extends SapphireTest {
|
|||
$this->assertEquals($field->Value(), array(1 => 1, 2 => 2));
|
||||
}
|
||||
|
||||
function testItIgnoresNewTagsIfCannotCreate() {
|
||||
public function testItIgnoresNewTagsIfCannotCreate()
|
||||
{
|
||||
$record = new TagFieldTestBlogPost();
|
||||
$record->write();
|
||||
|
||||
|
@ -288,7 +302,8 @@ class TagFieldTest extends SapphireTest {
|
|||
}
|
||||
}
|
||||
|
||||
class TagFieldTestBlogTag extends DataObject implements TestOnly {
|
||||
class TagFieldTestBlogTag extends DataObject implements TestOnly
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -312,7 +327,8 @@ class TagFieldTestBlogTag extends DataObject implements TestOnly {
|
|||
/**
|
||||
* @method ManyManyList Tags()
|
||||
*/
|
||||
class TagFieldTestBlogPost extends DataObject implements TestOnly {
|
||||
class TagFieldTestBlogPost extends DataObject implements TestOnly
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
|
@ -329,11 +345,13 @@ class TagFieldTestBlogPost extends DataObject implements TestOnly {
|
|||
);
|
||||
}
|
||||
|
||||
class TagFieldTestController extends Controller implements TestOnly {
|
||||
class TagFieldTestController extends Controller implements TestOnly
|
||||
{
|
||||
/**
|
||||
* @return Form
|
||||
*/
|
||||
public function TagFieldTestForm() {
|
||||
public function TagFieldTestForm()
|
||||
{
|
||||
$fields = new FieldList(
|
||||
$tagField = new TagField('Tags', '', new DataList('TagFieldTestBlogTag'))
|
||||
);
|
||||
|
@ -349,7 +367,8 @@ class TagFieldTestController extends Controller implements TestOnly {
|
|||
* @param DataObject $dataObject
|
||||
* @param Form $form
|
||||
*/
|
||||
public function TagFieldTestFormSubmit(DataObject $dataObject, Form $form) {
|
||||
public function TagFieldTestFormSubmit(DataObject $dataObject, Form $form)
|
||||
{
|
||||
$form->saveInto($dataObject);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue