Skip to content

Commit

Permalink
API Remove deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabina Talipova committed Jan 23, 2023
1 parent 2024622 commit d2ff450
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 82 deletions.
32 changes: 0 additions & 32 deletions code/Model/EditableFormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

namespace SilverStripe\UserForms\Model;

use SilverStripe\Dev\Deprecation;
use SilverStripe\CMS\Controllers\CMSMain;
use SilverStripe\CMS\Controllers\CMSPageEditController;
use SilverStripe\Control\Controller;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Convert;
use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\DropdownField;
Expand All @@ -24,13 +22,11 @@
use SilverStripe\Forms\SegmentField;
use SilverStripe\Forms\TabSet;
use SilverStripe\Forms\TextField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\FieldType\DBVarchar;
use SilverStripe\ORM\HasManyList;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\ValidationException;
use SilverStripe\UserForms\Extension\UserFormFieldEditorExtension;
use SilverStripe\UserForms\Model\EditableFormField\EditableFieldGroup;
Expand Down Expand Up @@ -648,19 +644,6 @@ public function showExtraOptions()
return true;
}

/**
* Returns the Title for rendering in the front-end (with XML values escaped)
*
* @deprecated 4.12.0 Use $Title directly instead
*
* @return string
*/
public function getEscapedTitle()
{
Deprecation::notice('4.12.0', 'Use $Title directly instead');
return Convert::raw2xml($this->Title);
}

/**
* Find the numeric indicator (1.1.2) that represents it's nesting value
*
Expand Down Expand Up @@ -943,21 +926,6 @@ public function getCMSValidator()
->setRecord($this);
}

/**
* Determine effective display rules for this field.
*
* @return SS_List
* @deprecated 5.6.0 Will be removed without equivalent functionality to replace it
*/
public function EffectiveDisplayRules()
{
Deprecation::notice('5.6.0', 'Will be removed without equivalent functionality to replace it');
if ($this->Required) {
return ArrayList::create();
}
return $this->DisplayRules();
}

/**
* Extracts info from DisplayRules into array so UserDefinedForm->buildWatchJS can run through it.
* @return array|null
Expand Down
5 changes: 1 addition & 4 deletions code/Model/EditableFormField/EditableMultipleOptionField.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,9 @@ public function getCMSFields()
/**
* Duplicate a pages content. We need to make sure all the fields attached
* to that page go with it
*
* @param bool $doWrite @deprecated
* @param string $manyMany @deprecated
* {@inheritDoc}
*/
public function duplicate(bool $doWrite = true, ?array $manyMany = null): static
public function duplicate(bool $doWrite = true, array|null $relations = null): static
{
$clonedNode = parent::duplicate(true);

Expand Down
12 changes: 0 additions & 12 deletions code/Model/EditableFormField/EditableOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace SilverStripe\UserForms\Model\EditableFormField;

use SilverStripe\Dev\Deprecation;
use SilverStripe\Core\Convert;
use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Member;
use SilverStripe\Versioned\Versioned;
Expand Down Expand Up @@ -70,16 +68,6 @@ public static function set_allow_empty_values($allow)
self::$allow_empty_values = (bool) $allow;
}

/**
* @deprecated 5.0.0 Use $Title in templates instead
* @return string
*/
public function getEscapedTitle()
{
Deprecation::notice('5.0.0', 'Use $Title in templates instead');
return Convert::raw2xml($this->Title);
}

/**
* Fetches a value for $this->Value. If empty values are not allowed,
* then this will return the title in the case of an empty value.
Expand Down
34 changes: 0 additions & 34 deletions tests/php/Model/EditableFormFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
use SilverStripe\UserForms\Model\EditableFormField\EditableOption;
use SilverStripe\UserForms\Model\EditableFormField\EditableRadioField;
use SilverStripe\UserForms\Model\EditableFormField\EditableTextField;
use SilverStripe\UserForms\Model\UserDefinedForm;
use SilverStripe\Dev\Deprecation;

/**
* @package userforms
Expand Down Expand Up @@ -61,38 +59,6 @@ public function testFormFieldPermissions()
$this->assertFalse($text->canDelete());
}

public function testCustomRules()
{
if (Deprecation::isEnabled()) {
$this->markTestSkipped('Test calls deprecated code');
}
$this->logInWithPermission('ADMIN');
$form = $this->objFromFixture(UserDefinedForm::class, 'custom-rules-form');

$checkbox = $form->Fields()->find('ClassName', EditableCheckbox::class);
$field = $form->Fields()->find('ClassName', EditableTextField::class);

$rules = $checkbox->DisplayRules();

// form has 2 fields - a checkbox and a text field
// it has 1 rule - when ticked the checkbox hides the text field
$this->assertEquals(1, $rules->Count());

// EffectiveDisplayRules rule has been deprecated
$this->assertEquals($rules, $checkbox->EffectiveDisplayRules());

$checkboxRule = $rules->First();
$checkboxRule->ConditionFieldID = $field->ID;

$this->assertEquals($checkboxRule->Display, 'Hide');
$this->assertEquals($checkboxRule->ConditionOption, 'HasValue');
$this->assertEquals($checkboxRule->FieldValue, '6');

// If field is required then all custom rules are disabled
$checkbox->Required = true;
$this->assertEquals(0, $checkbox->EffectiveDisplayRules()->count());
}

public function testEditableOptionEmptyValue()
{
$option = $this->objFromFixture(EditableOption::class, 'option-1');
Expand Down

0 comments on commit d2ff450

Please sign in to comment.