diff --git a/application/Espo/Entities/User.php b/application/Espo/Entities/User.php index 5d8c108f6e..cb8a9de505 100644 --- a/application/Espo/Entities/User.php +++ b/application/Espo/Entities/User.php @@ -62,6 +62,24 @@ class User extends Person public const RELATIONSHIP_ENTITY_USER = 'EntityUser'; public const RELATIONSHIP_ENTITY_COLLABORATOR = 'EntityCollaborator'; + public function get(string $attribute): mixed + { + if ($attribute === Field::NAME) { + return $this->getNameInternal(); + } + + return parent::get($attribute); + } + + public function has(string $attribute): bool + { + if ($attribute === Field::NAME) { + return $this->hasNameInternal(); + } + + return parent::has($attribute); + } + public function isActive(): bool { return (bool) $this->get('isActive'); @@ -294,10 +312,7 @@ class User extends Person return $this->get('avatarColor'); } - /** - * @return ?string - */ - protected function _getName() + private function getNameInternal(): ?string { if (!$this->hasInContainer(Field::NAME) || !$this->getFromContainer(Field::NAME)) { if ($this->get('userName')) { @@ -308,10 +323,7 @@ class User extends Person return $this->getFromContainer(Field::NAME); } - /** - * @return bool - */ - protected function _hasName() + private function hasNameInternal(): bool { if ($this->hasInContainer(Field::NAME)) { return true; diff --git a/application/Espo/Modules/Crm/Entities/CampaignTrackingUrl.php b/application/Espo/Modules/Crm/Entities/CampaignTrackingUrl.php index 55fc1f6415..9f57eed9b9 100644 --- a/application/Espo/Modules/Crm/Entities/CampaignTrackingUrl.php +++ b/application/Espo/Modules/Crm/Entities/CampaignTrackingUrl.php @@ -38,6 +38,24 @@ class CampaignTrackingUrl extends Entity public const ACTION_SHOW_MESSAGE = 'Show Message'; + public function get(string $attribute): mixed + { + if ($attribute === 'urlToUse') { + return $this->getUrlToUseInternal(); + } + + return parent::get($attribute); + } + + public function has(string $attribute): bool + { + if ($attribute === 'urlToUse') { + return $this->hasUrlToUseInternal(); + } + + return parent::has($attribute); + } + public function getCampaignId(): ?string { return $this->get('campaignId'); @@ -67,12 +85,12 @@ class CampaignTrackingUrl extends Entity return $this->get('urlToUse'); } - protected function _getUrlToUse(): string + private function getUrlToUseInternal(): string { - return '{trackingUrl:' . $this->id . '}'; + return "{trackingUrl:$this->id}"; } - protected function _hasUrlToUse(): bool + private function hasUrlToUseInternal(): bool { return !$this->isNew(); } diff --git a/application/Espo/Modules/Crm/Entities/Lead.php b/application/Espo/Modules/Crm/Entities/Lead.php index ad8c799926..e018bcf7ab 100644 --- a/application/Espo/Modules/Crm/Entities/Lead.php +++ b/application/Espo/Modules/Crm/Entities/Lead.php @@ -47,17 +47,32 @@ class Lead extends Person public const STATUS_RECYCLED = 'Recycled'; public const STATUS_DEAD = 'Dead'; + public function get(string $attribute): mixed + { + if ($attribute === Field::NAME) { + return $this->getNameInternal(); + } + + return parent::get($attribute); + } + + public function has(string $attribute): bool + { + if ($attribute === Field::NAME) { + return $this->hasNameInternal(); + } + + return parent::has($attribute); + } + public function getStatus(): ?string { return $this->get('status'); } - /** - * @return ?string - */ - protected function _getName() + private function getNameInternal(): ?string { - if (!$this->hasInContainer('name') || !$this->getFromContainer('name')) { + if (!$this->hasInContainer(Field::NAME) || !$this->getFromContainer(Field::NAME)) { if ($this->get('accountName')) { return $this->get('accountName'); } @@ -71,15 +86,12 @@ class Lead extends Person } } - return $this->getFromContainer('name'); + return $this->getFromContainer(Field::NAME); } - /** - * @return bool - */ - protected function _hasName() + private function hasNameInternal(): bool { - if ($this->hasInContainer('name')) { + if ($this->hasInContainer(Field::NAME)) { return true; }