This commit is contained in:
Yuri Kuznetsov
2024-11-14 21:27:55 +02:00
parent 5308e1d531
commit acd2869876
3 changed files with 64 additions and 22 deletions
+20 -8
View File
@@ -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;
@@ -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();
}
+23 -11
View File
@@ -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;
}