From efe2b2d212fa64ffd81797c36003e6f56653fdf6 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 15 Jul 2021 23:12:03 -0700 Subject: [PATCH] (REF) APIv4 FieldSpec - Extract GuiSpecTrait (label, inputType, inputAttrs, helpPre, helpPost) --- Civi/Api4/Service/Spec/FieldSpec.php | 94 +-------------------- Civi/Schema/Traits/GuiSpecTrait.php | 120 +++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 91 deletions(-) create mode 100644 Civi/Schema/Traits/GuiSpecTrait.php diff --git a/Civi/Api4/Service/Spec/FieldSpec.php b/Civi/Api4/Service/Spec/FieldSpec.php index 47ec136f7e..3fb247e15c 100644 --- a/Civi/Api4/Service/Spec/FieldSpec.php +++ b/Civi/Api4/Service/Spec/FieldSpec.php @@ -13,23 +13,21 @@ namespace Civi\Api4\Service\Spec; use Civi\Schema\Traits\BasicSpecTrait; +use Civi\Schema\Traits\GuiSpecTrait; class FieldSpec { // BasicSpecTrait: name, title, description use BasicSpecTrait; + // GuiSpecTrait: label, inputType, inputAttrs, helpPre, helpPost + use GuiSpecTrait; /** * @var mixed */ public $defaultValue; - /** - * @var string - */ - public $label; - /** * @var string */ @@ -70,16 +68,6 @@ class FieldSpec { */ public $dataType; - /** - * @var string - */ - public $inputType; - - /** - * @var array - */ - public $inputAttrs = []; - /** * @var string[] */ @@ -95,16 +83,6 @@ class FieldSpec { */ public $serialize; - /** - * @var string - */ - public $helpPre; - - /** - * @var string - */ - public $helpPost; - /** * @var array */ @@ -176,24 +154,6 @@ class FieldSpec { return $this; } - /** - * @return string - */ - public function getLabel() { - return $this->label; - } - - /** - * @param string $label - * - * @return $this - */ - public function setLabel($label) { - $this->label = $label; - - return $this; - } - /** * @param string $entity * @@ -308,40 +268,6 @@ class FieldSpec { return $this->permission; } - /** - * @return string - */ - public function getInputType() { - return $this->inputType; - } - - /** - * @param string $inputType - * @return $this - */ - public function setInputType($inputType) { - $this->inputType = $inputType; - - return $this; - } - - /** - * @return array - */ - public function getInputAttrs() { - return $this->inputAttrs; - } - - /** - * @param array $inputAttrs - * @return $this - */ - public function setInputAttrs($inputAttrs) { - $this->inputAttrs = $inputAttrs; - - return $this; - } - /** * @param string[] $operators * @return $this @@ -428,20 +354,6 @@ class FieldSpec { return $this; } - /** - * @param string|NULL $helpPre - */ - public function setHelpPre($helpPre) { - $this->helpPre = is_string($helpPre) && strlen($helpPre) ? $helpPre : NULL; - } - - /** - * @param string|NULL $helpPost - */ - public function setHelpPost($helpPost) { - $this->helpPost = is_string($helpPost) && strlen($helpPost) ? $helpPost : NULL; - } - /** * @param string $tableName * @return $this diff --git a/Civi/Schema/Traits/GuiSpecTrait.php b/Civi/Schema/Traits/GuiSpecTrait.php new file mode 100644 index 0000000000..1a1db81e42 --- /dev/null +++ b/Civi/Schema/Traits/GuiSpecTrait.php @@ -0,0 +1,120 @@ +label; + } + + /** + * @return string + */ + public function getInputType() { + return $this->inputType; + } + + /** + * @param string $inputType + * + * @return $this + */ + public function setInputType($inputType) { + $this->inputType = $inputType; + return $this; + } + + /** + * @return array + */ + public function getInputAttrs() { + return $this->inputAttrs; + } + + /** + * @param array $inputAttrs + * + * @return $this + */ + public function setInputAttrs($inputAttrs) { + $this->inputAttrs = $inputAttrs; + return $this; + } + + /** + * @param string $label + * + * @return $this + */ + public function setLabel($label) { + $this->label = $label; + return $this; + } + + /** + * @param string|NULL $helpPre + */ + public function setHelpPre($helpPre) { + $this->helpPre = is_string($helpPre) && strlen($helpPre) ? $helpPre : NULL; + } + + /** + * @param string|NULL $helpPost + */ + public function setHelpPost($helpPost) { + $this->helpPost = is_string($helpPost) && strlen($helpPost) ? $helpPost : NULL; + } + +} -- 2.25.1