Skip to content

Commit

Permalink
API Remove deprecated code (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
sabina-talipova authored Jan 25, 2023
1 parent 5b26bd0 commit 6f203a3
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 54 deletions.
15 changes: 0 additions & 15 deletions src/StringTagField.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
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;
Expand Down Expand Up @@ -34,13 +33,6 @@ class StringTagField extends DropdownField
'suggest',
];

/**
* @var bool Triggers a write call within the saveInto function if enabled
*
* @deprecated 3.0.0 Will be removed without equivalent functionality to replace it
*/
private static $immediate_write_enabled = true;

/**
* @var bool
*/
Expand Down Expand Up @@ -280,13 +272,6 @@ public function saveInto(DataObjectInterface $record)
$name = $this->getName();

$record->$name = $this->dataValue();

$immediate_write_enabled = Deprecation::withNoReplacement(function () {
return self::config()->get('immediate_write_enabled');
});
if ($immediate_write_enabled) {
$record->write();
}
}

/**
Expand Down
39 changes: 0 additions & 39 deletions tests/StringTagFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use SilverStripe\Forms\Form;
use SilverStripe\TagField\StringTagField;
use SilverStripe\TagField\Tests\Stub\StringTagFieldTestBlogPost;
use SilverStripe\Dev\Deprecation;

class StringTagFieldTest extends SapphireTest
{
Expand Down Expand Up @@ -62,44 +61,6 @@ public function testItSavesTagsOnExistingRecords()
$this->assertEquals('Tag1,Tag2', $record->Tags);
}

public function testImmediateWriteEnabled()
{
if (Deprecation::isEnabled()) {
$this->markTestSkipped('Test calls deprecated code');
}
$record = $this->getNewStringTagFieldTestBlogPost('BlogPost1');
$record->write();

StringTagField::config()->set('immediate_write_enabled', true);

$field = new StringTagField('Tags');
$field->setValue(['Tag1', 'Tag2']);
$field->saveInto($record);

$this->assertEquals('Tag1,Tag2', StringTagFieldTestBlogPost::get()->byID($record->ID)->Tags);
}

public function testImmediateWriteDisabled()
{
if (Deprecation::isEnabled()) {
$this->markTestSkipped('Test calls deprecated code');
}
$record = $this->getNewStringTagFieldTestBlogPost('BlogPost1');
$record->write();

StringTagField::config()->set('immediate_write_enabled', false);

$field = new StringTagField('Tags');
$field->setValue(['Tag1', 'Tag2']);
$field->saveInto($record);

$this->assertNull(StringTagFieldTestBlogPost::get()->byID($record->ID)->Tags);

$record->write();

$this->assertEquals('Tag1,Tag2', StringTagFieldTestBlogPost::get()->byID($record->ID)->Tags);
}

public function testItSuggestsTags()
{
$field = new StringTagField('SomeField', 'Some field', ['Tag1', 'Tag2'], []);
Expand Down

0 comments on commit 6f203a3

Please sign in to comment.