entity setters and getters
This commit is contained in:
@@ -95,14 +95,59 @@ class Person extends Entity
|
||||
return $this->getValueObject('phoneNumber');
|
||||
}
|
||||
|
||||
public function setEmailAddressGroup(EmailAddressGroup $group): void
|
||||
public function getName(): ?string
|
||||
{
|
||||
$this->setValueObject('emailAddress', $group);
|
||||
return $this->get('name');
|
||||
}
|
||||
|
||||
public function setPhoneNumberGroup(PhoneNumberGroup $group): void
|
||||
public function getFirstName(): ?string
|
||||
{
|
||||
return $this->get('firstName');
|
||||
}
|
||||
|
||||
public function getLastName(): ?string
|
||||
{
|
||||
return $this->get('lastName');
|
||||
}
|
||||
|
||||
public function getMiddleName(): ?string
|
||||
{
|
||||
return $this->get('middleName');
|
||||
}
|
||||
|
||||
public function setFirstName(?string $firstName): self
|
||||
{
|
||||
$this->set('firstName', $firstName);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setLastName(?string $lastName): self
|
||||
{
|
||||
$this->set('lastName', $lastName);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMiddleName(?string $middleName): self
|
||||
{
|
||||
$this->set('middleName', $middleName);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEmailAddressGroup(EmailAddressGroup $group): self
|
||||
{
|
||||
$this->setValueObject('emailAddress', $group);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPhoneNumberGroup(PhoneNumberGroup $group): self
|
||||
{
|
||||
$this->setValueObject('phoneNumber', $group);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAddress(): Address
|
||||
@@ -110,8 +155,10 @@ class Person extends Entity
|
||||
return $this->getValueObject('address');
|
||||
}
|
||||
|
||||
public function setAddress(Address $address): void
|
||||
public function setAddress(Address $address): self
|
||||
{
|
||||
$this->setValueObject('address', $address);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,15 @@ namespace Espo\Entities;
|
||||
|
||||
use Espo\Core\ORM\Entity;
|
||||
|
||||
use Espo\Core\Field\LinkParent;
|
||||
|
||||
class Attachment extends Entity
|
||||
{
|
||||
public const ENTITY_TYPE = 'Attachment';
|
||||
|
||||
/**
|
||||
* Multiple attachment can refer to one file. Source ID is an original attachment.
|
||||
*/
|
||||
public function getSourceId(): ?string
|
||||
{
|
||||
$sourceId = $this->get('sourceId');
|
||||
@@ -50,4 +55,86 @@ class Attachment extends Entity
|
||||
{
|
||||
return $this->get('storage');
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->get('name');
|
||||
}
|
||||
|
||||
public function getSize(): ?int
|
||||
{
|
||||
return $this->get('size');
|
||||
}
|
||||
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->get('type');
|
||||
}
|
||||
|
||||
public function getTargetField(): ?string
|
||||
{
|
||||
return $this->get('field');
|
||||
}
|
||||
|
||||
public function getParent(): ?LinkParent
|
||||
{
|
||||
return $this->getValueObject('parent');
|
||||
}
|
||||
|
||||
public function getRelated(): ?LinkParent
|
||||
{
|
||||
return $this->getValueObject('related');
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiple attachment can refer to one file. Source ID is an original attachment.
|
||||
*/
|
||||
public function setSourceId(?string $sourceId): self
|
||||
{
|
||||
$this->set('sourceId', $sourceId);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setName(?string $name): self
|
||||
{
|
||||
$this->set('name', $name);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setType(?string $type): self
|
||||
{
|
||||
$this->set('type', $type);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setContents(?string $contents): self
|
||||
{
|
||||
$this->set('contents', $contents);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTargetField(?string $field): self
|
||||
{
|
||||
$this->set('field', $field);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setParent(?LinkParent $parent): self
|
||||
{
|
||||
$this->setValueObject('parent', $parent);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRelated(?LinkParent $related): self
|
||||
{
|
||||
$this->setValueObject('related', $related);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ use Espo\Entities\Attachment;
|
||||
use Espo\Services\Email as EmailService;
|
||||
use Espo\Repositories\Email as EmailRepository;
|
||||
|
||||
use Espo\Core\Field\LinkParent;
|
||||
|
||||
class Email extends Entity
|
||||
{
|
||||
public const ENTITY_TYPE = 'Email';
|
||||
@@ -312,9 +314,11 @@ class Email extends Entity
|
||||
return $this->get('subject');
|
||||
}
|
||||
|
||||
public function setSubject(?string $subject): void
|
||||
public function setSubject(?string $subject): self
|
||||
{
|
||||
$this->set('subject', $subject);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBody(): ?string
|
||||
@@ -322,9 +326,11 @@ class Email extends Entity
|
||||
return $this->get('body');
|
||||
}
|
||||
|
||||
public function setBody(?string $body): void
|
||||
public function setBody(?string $body): self
|
||||
{
|
||||
$this->set('body', $body);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isHtml(): ?bool
|
||||
@@ -332,55 +338,69 @@ class Email extends Entity
|
||||
return $this->get('isHtml');
|
||||
}
|
||||
|
||||
public function setIsHtml(bool $isHtml = true): void
|
||||
public function setIsHtml(bool $isHtml = true): self
|
||||
{
|
||||
$this->set('isHtml', $isHtml);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setIsPlain(bool $isPlain = true): void
|
||||
public function setIsPlain(bool $isPlain = true): self
|
||||
{
|
||||
$this->set('isHtml', !$isPlain);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFromAddress(?string $address): void
|
||||
public function setFromAddress(?string $address): self
|
||||
{
|
||||
$this->set('from', $address);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addToAddress(string $address): void
|
||||
public function addToAddress(string $address): self
|
||||
{
|
||||
$list = $this->getToAddressList();
|
||||
|
||||
$list[] = $address;
|
||||
|
||||
$this->set('to', implode(';', $list));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addCcAddress(string $address): void
|
||||
public function addCcAddress(string $address): self
|
||||
{
|
||||
$list = $this->getCcAddressList();
|
||||
|
||||
$list[] = $address;
|
||||
|
||||
$this->set('cc', implode(';', $list));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addBccAddress(string $address): void
|
||||
public function addBccAddress(string $address): self
|
||||
{
|
||||
$list = $this->getBccAddressList();
|
||||
|
||||
$list[] = $address;
|
||||
|
||||
$this->set('bcc', implode(';', $list));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addReplyToAddress(string $address): void
|
||||
public function addReplyToAddress(string $address): self
|
||||
{
|
||||
$list = $this->getReplyToAddressList();
|
||||
|
||||
$list[] = $address;
|
||||
|
||||
$this->set('replyTo', implode(';', $list));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFromAddress(): ?string
|
||||
@@ -464,9 +484,11 @@ class Email extends Entity
|
||||
return explode(';', $value);
|
||||
}
|
||||
|
||||
public function setDummyMessageId(): void
|
||||
public function setDummyMessageId(): self
|
||||
{
|
||||
$this->set('messageId', 'dummy:' . Util::generateId());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMessageId(): ?string
|
||||
@@ -474,6 +496,18 @@ class Email extends Entity
|
||||
return $this->get('messageId');
|
||||
}
|
||||
|
||||
public function getParent(): ?LinkParent
|
||||
{
|
||||
return $this->getValueObject('parent');
|
||||
}
|
||||
|
||||
public function setParent(?LinkParent $parent): self
|
||||
{
|
||||
$this->setValueObject('parent', $parent);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function getEmailRepository(): EmailRepository
|
||||
{
|
||||
return $this->entityManager->getRepository(self::ENTITY_TYPE);
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
|
||||
namespace Espo\Entities;
|
||||
|
||||
use Espo\Core\Field\LinkParent;
|
||||
|
||||
use stdClass;
|
||||
|
||||
class Notification extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
public const ENTITY_TYPE = 'Notification';
|
||||
@@ -46,4 +50,58 @@ class Notification extends \Espo\Core\ORM\Entity
|
||||
public const TYPE_MESSAGE = 'Message';
|
||||
|
||||
public const TYPE_SYSTEM = 'System';
|
||||
|
||||
public function setMessage(?string $message): self
|
||||
{
|
||||
$this->set('message', $message);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setType(string $type): self
|
||||
{
|
||||
$this->set('type', $type);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setData(stdClass $data): self
|
||||
{
|
||||
$this->set('data', $data);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUserId(string $userId): self
|
||||
{
|
||||
$this->set('userId', $userId);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRelated(): ?LinkParent
|
||||
{
|
||||
return $this->getValueObject('related');
|
||||
}
|
||||
|
||||
public function setRelated(?LinkParent $related): self
|
||||
{
|
||||
$this->setValueObject('related', $related);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRelatedType(?string $relatedType): self
|
||||
{
|
||||
$this->set('relatedType', $relatedType);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRelatedId(?string $relatedId): self
|
||||
{
|
||||
$this->set('relatedId', $relatedId);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,23 +67,29 @@ class Sms extends Entity implements SmsInterface
|
||||
return $this->get('status');
|
||||
}
|
||||
|
||||
public function setBody(?string $body): void
|
||||
public function setBody(?string $body): self
|
||||
{
|
||||
$this->set('body', $body);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFromNumber(?string $number): void
|
||||
public function setFromNumber(?string $number): self
|
||||
{
|
||||
$this->set('from', $number);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addToNumber(string $number): void
|
||||
public function addToNumber(string $number): self
|
||||
{
|
||||
$list = $this->getToNumberList();
|
||||
|
||||
$list[] = $number;
|
||||
|
||||
$this->set('to', implode(';', $list));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFromNumber(): ?string
|
||||
@@ -118,13 +124,15 @@ class Sms extends Entity implements SmsInterface
|
||||
return explode(';', $value);
|
||||
}
|
||||
|
||||
public function setAsSent(): void
|
||||
public function setAsSent(): self
|
||||
{
|
||||
$this->set('status', self::STATUS_SENT);
|
||||
|
||||
if (!$this->get('dateSent')) {
|
||||
$this->set('dateSent', DateTime::createNow()->getString());
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function getSmsRepository(): SmsRepository
|
||||
|
||||
@@ -31,6 +31,9 @@ namespace Espo\Entities;
|
||||
|
||||
use Espo\Core\Entities\Person;
|
||||
|
||||
use Espo\Core\Field\Link;
|
||||
use Espo\Core\Field\LinkMultiple;
|
||||
|
||||
class User extends Person
|
||||
{
|
||||
public const ENTITY_TYPE = 'User';
|
||||
@@ -96,12 +99,48 @@ class User extends Person
|
||||
return $this->get('type') === 'super-admin';
|
||||
}
|
||||
|
||||
public function getRoles(): LinkMultiple
|
||||
{
|
||||
return $this->getValueObject('roles');
|
||||
}
|
||||
|
||||
public function getDefaultTeam(): ?Link
|
||||
{
|
||||
return $this->getValueObject('defaultTeam');
|
||||
}
|
||||
|
||||
public function getTeams(): LinkMultiple
|
||||
{
|
||||
return $this->getValueObject('teams');
|
||||
}
|
||||
|
||||
public function getTeamIdList(): array
|
||||
{
|
||||
return $this->getLinkMultipleIdList('teams');
|
||||
}
|
||||
|
||||
public function loadAccountField()
|
||||
public function setDefaultTeam(?Link $defaultTeam): self
|
||||
{
|
||||
$this->setValueObject('defaultTeam', $defaultTeam);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTeams(LinkMultiple $teams): self
|
||||
{
|
||||
$this->setValueObject('teams', $teams);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRoles(LinkMultiple $roles): self
|
||||
{
|
||||
$this->setValueObject('roles', $roles);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function loadAccountField(): void
|
||||
{
|
||||
if ($this->get('contactId')) {
|
||||
$contact = $this->getEntityManager()->getEntity('Contact', $this->get('contactId'));
|
||||
@@ -113,6 +152,23 @@ class User extends Person
|
||||
}
|
||||
}
|
||||
|
||||
public function setTitle(?string $title): ?string
|
||||
{
|
||||
$this->set('title', $title);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle(): ?string
|
||||
{
|
||||
return $this->get('title');
|
||||
}
|
||||
|
||||
public function getUserName(): ?string
|
||||
{
|
||||
return $this->get('userName');
|
||||
}
|
||||
|
||||
protected function _getName()
|
||||
{
|
||||
if (!$this->hasInContainer('name') || !$this->getFromContainer('name')) {
|
||||
|
||||
@@ -40,6 +40,18 @@ class Account extends Entity
|
||||
{
|
||||
public const ENTITY_TYPE = 'Account';
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->get('name');
|
||||
}
|
||||
|
||||
public function setName(?string $name): self
|
||||
{
|
||||
$this->set('name', $name);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEmailAddressGroup(): EmailAddressGroup
|
||||
{
|
||||
return $this->getValueObject('emailAddress');
|
||||
@@ -50,14 +62,18 @@ class Account extends Entity
|
||||
return $this->getValueObject('phoneNumber');
|
||||
}
|
||||
|
||||
public function setEmailAddressGroup(EmailAddressGroup $group): void
|
||||
public function setEmailAddressGroup(EmailAddressGroup $group): self
|
||||
{
|
||||
$this->setValueObject('emailAddress', $group);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPhoneNumberGroup(PhoneNumberGroup $group): void
|
||||
public function setPhoneNumberGroup(PhoneNumberGroup $group): self
|
||||
{
|
||||
$this->setValueObject('phoneNumber', $group);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBillingAddress(): Address
|
||||
@@ -65,9 +81,11 @@ class Account extends Entity
|
||||
return $this->getValueObject('billingAddress');
|
||||
}
|
||||
|
||||
public function setBillingAddress(Address $address): void
|
||||
public function setBillingAddress(Address $address): self
|
||||
{
|
||||
$this->setValueObject('billingAddress', $address);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShippingAddress(): Address
|
||||
@@ -75,8 +93,10 @@ class Account extends Entity
|
||||
return $this->getValueObject('shippingAddress');
|
||||
}
|
||||
|
||||
public function setShippingAddress(Address $address): void
|
||||
public function setShippingAddress(Address $address): self
|
||||
{
|
||||
$this->setValueObject('shippingAddress', $address);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,14 +39,28 @@ class Opportunity extends Entity
|
||||
{
|
||||
public const ENTITY_TYPE = 'Opportunity';
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->get('name');
|
||||
}
|
||||
|
||||
public function setName(?string $name): self
|
||||
{
|
||||
$this->set('name', $name);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAmount(): ?Currency
|
||||
{
|
||||
return $this->getValueObject('amount');
|
||||
}
|
||||
|
||||
public function setAmount(?Currency $amount): void
|
||||
public function setAmount(?Currency $amount): self
|
||||
{
|
||||
$this->setValueObject('amount', $amount);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCloseDate(): ?Date
|
||||
@@ -54,8 +68,10 @@ class Opportunity extends Entity
|
||||
return $this->getValueObject('closeDate');
|
||||
}
|
||||
|
||||
public function setCloseDate(?Date $closeDate): void
|
||||
public function setCloseDate(?Date $closeDate): self
|
||||
{
|
||||
$this->setValueObject('closeDate', $closeDate);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user