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