mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
ENH Add generic types (#1261)
This commit is contained in:
parent
5e6e8735ea
commit
ca972ff5f2
@ -60,7 +60,6 @@ class UserDefinedFormAdmin extends LeftAndMain
|
||||
*/
|
||||
private static function getRestrictedAccessField(string $folder, string $title)
|
||||
{
|
||||
/** @var TextField $textField */
|
||||
$textField = TextField::create('CreateFolder', '');
|
||||
|
||||
/** @var Folder $formSubmissionsFolder */
|
||||
@ -121,7 +120,6 @@ class UserDefinedFormAdmin extends LeftAndMain
|
||||
if ($editableFormField instanceof EditableFileField) {
|
||||
$folderId = $editableFormField->FolderID;
|
||||
}
|
||||
/** @var Folder $folder */
|
||||
$folder = Folder::get()->byID($folderId);
|
||||
if (!$folder) {
|
||||
$folder = $this->getFormSubmissionFolder();
|
||||
@ -222,7 +220,6 @@ class UserDefinedFormAdmin extends LeftAndMain
|
||||
if (!$id) {
|
||||
throw new HTTPResponse_Exception(_t(__CLASS__.'.INVALID_REQUEST', 'This request was invalid.'), 400);
|
||||
}
|
||||
/** @var EditableFileField $editableFileField */
|
||||
$editableFormField = EditableFormField::get()->byID($id);
|
||||
if (!$editableFormField) {
|
||||
$editableFormField = Versioned::get_by_stage(EditableFormField::class, Versioned::DRAFT)->byID($id);
|
||||
@ -276,7 +273,6 @@ class UserDefinedFormAdmin extends LeftAndMain
|
||||
{
|
||||
$folderID = $this->getRequest()->requestVar('FolderID');
|
||||
if ($folderID) {
|
||||
/** @var Folder $folder */
|
||||
$folder = Folder::get()->byID($folderID);
|
||||
if (!$folder) {
|
||||
throw new HTTPResponse_Exception(_t(__CLASS__.'.INVALID_REQUEST', 'This request was invalid.'), 400);
|
||||
|
@ -38,7 +38,7 @@ use Swift_RfcComplianceException;
|
||||
/**
|
||||
* Controller for the {@link UserDefinedForm} page type.
|
||||
*
|
||||
* @package userforms
|
||||
* @extends PageController<UserDefinedForm>
|
||||
*/
|
||||
class UserDefinedFormController extends PageController
|
||||
{
|
||||
@ -200,7 +200,6 @@ class UserDefinedFormController extends PageController
|
||||
$watch = [];
|
||||
|
||||
if ($formFields) {
|
||||
/** @var EditableFormField $field */
|
||||
foreach ($formFields as $field) {
|
||||
if ($result = $field->formatDisplayRules()) {
|
||||
$watch[] = $result;
|
||||
|
@ -23,6 +23,8 @@ use SilverStripe\UserForms\UserForm;
|
||||
* certain amount of manual checking is required to ensure that upgrades are performed smoothly.
|
||||
*
|
||||
* @internal This API is likely to be removed in later major versions of silverstripe/userforms
|
||||
*
|
||||
* @extends DataExtension<UserDefinedForm>
|
||||
*/
|
||||
class UpgradePolymorphicExtension extends DataExtension
|
||||
{
|
||||
|
@ -15,6 +15,7 @@ use SilverStripe\Forms\GridField\GridFieldDetailForm;
|
||||
use SilverStripe\Forms\GridField\GridFieldToolbarHeader;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\UserForms\Form\GridFieldAddClassesButton;
|
||||
use SilverStripe\UserForms\Model\EditableFormField;
|
||||
use SilverStripe\UserForms\Model\EditableFormField\EditableFieldGroup;
|
||||
@ -228,11 +229,11 @@ class UserFormFieldEditorExtension extends DataExtension
|
||||
/**
|
||||
* When duplicating a UserDefinedForm, duplicate all of its fields and display rules
|
||||
*
|
||||
* @see \SilverStripe\ORM\DataObject::duplicate
|
||||
* @param \SilverStripe\ORM\DataObject $oldPage
|
||||
* @see DataObject::duplicate
|
||||
* @param DataObject $oldPage
|
||||
* @param bool $doWrite
|
||||
* @param string $manyMany
|
||||
* @return \SilverStripe\ORM\DataObject
|
||||
* @return DataObject
|
||||
*/
|
||||
public function onAfterDuplicate($oldPage, $doWrite, $manyMany)
|
||||
{
|
||||
|
@ -10,11 +10,12 @@ use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\Queries\SQLUpdate;
|
||||
use SilverStripe\UserForms\Control\UserDefinedFormController;
|
||||
use SilverStripe\UserForms\Model\Submission\SubmittedFileField;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
|
||||
/**
|
||||
* @property string $UserFormUpload
|
||||
* @method SubmittedFileField SubmittedFileField()
|
||||
*
|
||||
* @extends DataExtension<File&static>
|
||||
*/
|
||||
class UserFormFileExtension extends DataExtension
|
||||
{
|
||||
@ -45,7 +46,6 @@ class UserFormFileExtension extends DataExtension
|
||||
*/
|
||||
public function updateTrackedFormUpload(&$value): void
|
||||
{
|
||||
/** @var File|Versioned|UserFormFileExtension $file */
|
||||
$file = $this->owner;
|
||||
if ($file->UserFormUpload != self::USER_FORM_UPLOAD_UNKNOWN) {
|
||||
$value = $file->UserFormUpload == self::USER_FORM_UPLOAD_TRUE;
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\UserForms\Extensions;
|
||||
|
||||
use SilverStripe\Admin\Forms\UsedOnTable;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\UserForms\Model\EditableFormField;
|
||||
@ -11,10 +12,11 @@ use SilverStripe\UserForms\Model\UserDefinedForm;
|
||||
|
||||
/**
|
||||
* Update DataObjects on the file "Used On" table
|
||||
*
|
||||
* @extends Extension<UsedOnTable>
|
||||
*/
|
||||
class UsedOnTableExtension extends Extension
|
||||
{
|
||||
|
||||
/**
|
||||
* Link submitted file fields to their parent page
|
||||
*
|
||||
@ -26,7 +28,6 @@ class UsedOnTableExtension extends Extension
|
||||
if (!($dataObject instanceof SubmittedFileField)) {
|
||||
return;
|
||||
}
|
||||
/** @var SubmittedForm $submittedForm */
|
||||
$submittedForm = $dataObject->Parent();
|
||||
if (!$submittedForm) {
|
||||
$dataObject = null;
|
||||
|
@ -33,8 +33,6 @@ class UserFormsCheckboxSetField extends CheckboxSetField
|
||||
/**
|
||||
* jQuery validate requires that the value of the option does not contain
|
||||
* the actual value of the input.
|
||||
*
|
||||
* @return ArrayList
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
|
@ -40,7 +40,6 @@ abstract class UserFormsCompositeField extends CompositeField implements UserFor
|
||||
if (get_class($field) === EditableFormField::class || !$field->getFormField()) {
|
||||
return $this;
|
||||
}
|
||||
/** @var EditableFormField $formField */
|
||||
$formField = $field->getFormField();
|
||||
|
||||
// Save this field
|
||||
|
@ -152,7 +152,6 @@ class EditableCustomRule extends DataObject
|
||||
*/
|
||||
public function buildExpression()
|
||||
{
|
||||
/** @var EditableFormField $formFieldWatch */
|
||||
$formFieldWatch = $this->ConditionField();
|
||||
//Encapsulated the action to the object
|
||||
$action = $formFieldWatch->getJsEventHandler();
|
||||
|
@ -950,10 +950,8 @@ class EditableFormField extends DataObject
|
||||
];
|
||||
|
||||
// Check for field dependencies / default
|
||||
/** @var EditableCustomRule $rule */
|
||||
foreach ($this->DisplayRules() as $rule) {
|
||||
// Get the field which is effected
|
||||
/** @var EditableFormField $formFieldWatch */
|
||||
$formFieldWatch = DataObject::get_by_id(EditableFormField::class, $rule->ConditionFieldID);
|
||||
// Skip deleted fields
|
||||
if (!$formFieldWatch) {
|
||||
|
@ -122,7 +122,6 @@ class EditableMultipleOptionField extends EditableFormField
|
||||
$clonedNode = parent::duplicate(true);
|
||||
|
||||
foreach ($this->Options() as $field) {
|
||||
/** @var EditableOption $newField */
|
||||
$newField = $field->duplicate(false);
|
||||
$newField->ParentID = $clonedNode->ID;
|
||||
$newField->Version = 0;
|
||||
|
@ -464,7 +464,6 @@ class EmailRecipient extends DataObject
|
||||
// Check all rules
|
||||
$isAnd = $this->CustomRulesCondition === 'And';
|
||||
foreach ($customRules as $customRule) {
|
||||
/** @var EmailRecipientCondition $customRule */
|
||||
$matches = $customRule->matches($data);
|
||||
if ($isAnd && !$matches) {
|
||||
return false;
|
||||
@ -715,7 +714,7 @@ class EmailRecipient extends DataObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataList|null
|
||||
* @return DataList<EditableMultipleOptionField>|null
|
||||
*/
|
||||
protected function getMultiOptionFields()
|
||||
{
|
||||
@ -726,7 +725,7 @@ class EmailRecipient extends DataObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayList|null
|
||||
* @return ArrayList<EditableFormField>|null
|
||||
*/
|
||||
protected function getValidSubjectFields()
|
||||
{
|
||||
@ -745,7 +744,7 @@ class EmailRecipient extends DataObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataList|null
|
||||
* @return DataList<EditableEmailField>|null
|
||||
*/
|
||||
protected function getValidEmailFromFields()
|
||||
{
|
||||
@ -758,7 +757,7 @@ class EmailRecipient extends DataObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayList|DataList|null
|
||||
* @return ArrayList<EditableFormField>|DataList<EditableFormField>|null
|
||||
*/
|
||||
protected function getValidEmailToFields()
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ class UserFormRecipientItemRequest extends GridFieldDetailForm_ItemRequest
|
||||
/**
|
||||
* Get some placeholder field values to display in the preview
|
||||
*
|
||||
* @return ArrayList
|
||||
* @return ArrayList<ArrayData>
|
||||
*/
|
||||
protected function getPreviewFieldData()
|
||||
{
|
||||
|
@ -560,7 +560,7 @@ limit 100
|
||||
* Returns DataList object containing every
|
||||
* uploaded file record
|
||||
*
|
||||
* @return DataList
|
||||
* @return DataList<SubmittedFileField>
|
||||
*/
|
||||
private function getCountQuery()
|
||||
{
|
||||
|
@ -30,7 +30,6 @@ class UserFormsColumnCleanTask extends MigrationTask
|
||||
*/
|
||||
public function run($request)
|
||||
{
|
||||
/** @var \SilverStripe\ORM\DataObjectSchema $schema */
|
||||
$schema = DataObject::getSchema();
|
||||
|
||||
foreach ($this->tables as $db) {
|
||||
|
@ -350,7 +350,7 @@ SQL;
|
||||
* Converts the RelationList to an ArrayList so that manipulation
|
||||
* of the original source data isn't possible.
|
||||
*
|
||||
* @return ArrayList
|
||||
* @return ArrayList<EmailRecipient>
|
||||
*/
|
||||
public function FilteredEmailRecipients($data = null, $form = null)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user