mirror of
https://github.com/silverstripe/silverstripe-tagfield
synced 2024-10-22 11:05:32 +02:00
Merge pull request #222 from creative-commoners/pulls/2/stop-using-depr
API Stop using deprecated API
This commit is contained in:
commit
b5e7981aac
@ -6,6 +6,7 @@ use Iterator;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\Forms\Validator;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
@ -281,7 +282,10 @@ class StringTagField extends DropdownField
|
||||
|
||||
$record->$name = $this->dataValue();
|
||||
|
||||
if (self::config()->get('immediate_write_enabled')) {
|
||||
$immediate_write_enabled = Deprecation::withNoReplacement(function () {
|
||||
return self::config()->get('immediate_write_enabled');
|
||||
});
|
||||
if ($immediate_write_enabled) {
|
||||
$record->write();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\TagField\StringTagField;
|
||||
use SilverStripe\TagField\Tests\Stub\StringTagFieldTestBlogPost;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
|
||||
class StringTagFieldTest extends SapphireTest
|
||||
{
|
||||
@ -63,10 +64,13 @@ class StringTagFieldTest extends SapphireTest
|
||||
|
||||
public function testImmediateWriteEnabled()
|
||||
{
|
||||
if (Deprecation::isEnabled()) {
|
||||
$this->markTestSkipped('Test calls deprecated code');
|
||||
}
|
||||
$record = $this->getNewStringTagFieldTestBlogPost('BlogPost1');
|
||||
$record->write();
|
||||
|
||||
StringTagField::config()->update('immediate_write_enabled', true);
|
||||
StringTagField::config()->set('immediate_write_enabled', true);
|
||||
|
||||
$field = new StringTagField('Tags');
|
||||
$field->setValue(['Tag1', 'Tag2']);
|
||||
@ -77,10 +81,13 @@ class StringTagFieldTest extends SapphireTest
|
||||
|
||||
public function testImmediateWriteDisabled()
|
||||
{
|
||||
if (Deprecation::isEnabled()) {
|
||||
$this->markTestSkipped('Test calls deprecated code');
|
||||
}
|
||||
$record = $this->getNewStringTagFieldTestBlogPost('BlogPost1');
|
||||
$record->write();
|
||||
|
||||
StringTagField::config()->update('immediate_write_enabled', false);
|
||||
StringTagField::config()->set('immediate_write_enabled', false);
|
||||
|
||||
$field = new StringTagField('Tags');
|
||||
$field->setValue(['Tag1', 'Tag2']);
|
||||
|
Loading…
Reference in New Issue
Block a user