Skip to content
Snippets Groups Projects
Commit 24df72bf authored by Liam Morland's avatar Liam Morland
Browse files

Issue #3280431: Create FillPdfForm::getDefaultEntityType()

parent 9118efe3
No related branches found
No related tags found
No related merge requests found
...@@ -222,6 +222,14 @@ class FillPdfForm extends ContentEntityBase implements FillPdfFormInterface { ...@@ -222,6 +222,14 @@ class FillPdfForm extends ContentEntityBase implements FillPdfFormInterface {
} }
} }
/**
* {@inheritdoc}
*/
public function getDefaultEntityType(): ?string {
$default_entity_type = $this->get('default_entity_type');
return count($default_entity_type) ? $default_entity_type->first()->value : NULL;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
...@@ -9,6 +9,14 @@ namespace Drupal\fillpdf; ...@@ -9,6 +9,14 @@ namespace Drupal\fillpdf;
*/ */
interface FillPdfFormInterface extends ExportableContentEntityInterface { interface FillPdfFormInterface extends ExportableContentEntityInterface {
/**
* Returns the default entity type ID for this FillPdfForm.
*
* @return string|null
* The entity type ID or NULL if there is none set.
*/
public function getDefaultEntityType(): ?string;
/** /**
* Returns all FillPdfFormFields associated with this FillPdfForm. * Returns all FillPdfFormFields associated with this FillPdfForm.
* *
......
...@@ -147,9 +147,7 @@ class FillPdfFormForm extends ContentEntityForm { ...@@ -147,9 +147,7 @@ class FillPdfFormForm extends ContentEntityForm {
$form['title']['token_tree'] = $this->adminFormHelper->getAdminTokenForm(); $form['title']['token_tree'] = $this->adminFormHelper->getAdminTokenForm();
// @todo Encapsulate this logic into a ::getDefaultEntityType() method on FillPdfForm $default_entity_type = $fillpdf_form->getDefaultEntityType();
$stored_default_entity_type = $fillpdf_form->get('default_entity_type');
$default_entity_type = count($stored_default_entity_type) ? $stored_default_entity_type->first()->value : NULL;
$form['default_entity_type'] = [ $form['default_entity_type'] = [
'#type' => 'select', '#type' => 'select',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment