<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use App\Repository\UserRepository;
use DateTimeImmutable;
use DateTimeInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\PersistentCollection;
use JsonSerializable;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ApiResource(
* collectionOperations={"get", "post"},
* itemOperations={
* "get"={
* "normalization_context"={"groups"={"user:read", "user:item:get", "api_token:read", "api_token:item:get"}},
* },
* "put",
* "delete",
* },
* normalizationContext={"groups"={"user:read"}, "swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"user:write"}, "swagger_definition_name"="Write"},
* attributes={
* "formats"={"jsonld", "json", "html", "csv"}
* }
* )
* @UniqueEntity(fields={"email"})
* @ApiFilter(BooleanFilter::class, properties={"isActive", "isEmailForgotten"})
* @ApiFilter(SearchFilter::class, properties={"name": "partial", "firstName": "partial", "lastName": "partial", "email": "partial", "username": "partial"})
* @ApiFilter(PropertyFilter::class)
* @ORM\Entity(repositoryClass=UserRepository::class)
* @ORM\Entity
* @ORM\Table(name="`users`")
* @ORM\HasLifecycleCallbacks()
*/
class User implements UserInterface, \Serializable, JsonSerializable
{
private $roleTexts = array(
'ROLE_GUEST' => 'Guest',
'ROLE_CUSTOMER' => 'Customer',
'ROLE_USER' => 'User',
'ROLE_MANAGER' => 'Manager',
'ROLE_ADMIN' => 'Administrator',
'ROLE_SUPER_ADMIN' => 'Super Administrator',
);
/**
* todo: update all id columns to use strategy="IDENTITY"
*/
/**
* @ORM\Id()
* @ORM\GeneratedValue() // should be ORM\GeneratedValue(strategy="IDENTITY")
* @ORM\Column(type="integer")
* @Groups({"user:read", "user:write", "network_installation:read", "network_installation:item:get", "api_token:item:get", "department:item:get", "department:read"})
*/
private $id;
/**
* @ORM\Column(type="string", length=191, unique=true, nullable=true)
* @Groups({"user:read", "user:write"})
*/
protected $email;
/**
* @ORM\Column(type="string", length=191)
* @Groups({"user:read", "user:write", "network_installation:read", "network_installation:item:get", "api_token:item:get", "department:read", "department:item:get"})
* @var string $name
*
*/
protected $name;
/**
* @ORM\Column(type="string", length=16, nullable=true)
* @Groups({"user:read", "user:write"})
*/
protected $firstName;
/**
* @ORM\Column(type="string", length=32, nullable=true)
* @Groups({"user:read", "user:write"})
*/
protected $lastName;
/**
* @ORM\Column(type="string", length=32, nullable=true)
* @Groups({"user:read", "user:write"})
*/
protected $phoneNumber;
/**
* @ORM\Column(type="string", length=191, nullable=true)
* @Groups({"user:read", "user:write"})
*/
protected $dropboxUserId;
/**
* @ORM\Column(type="text", nullable=true)
*/
protected $dropboxLatestCursor;
/**
* @ORM\Column(type="string", length=191, nullable=true)
*/
protected $dropboxOauthToken;
/**
* @ORM\Column(type="string", length=191)
* @Groups({"user:read", "user:write"})
* @var string $role
* available roles:
* ROLE_USER
* ROLE_CUSTOMER
* ROLE_ADMIN
* ROLE_GUEST
* ROLE_MANAGER
* ROLE_SUPER_ADMIN
*/
protected $role;
/**
* @ORM\Column(type="json", nullable=true)
* @Groups({"user:read", "user:write"})
*/
protected $roles;
/**
*
*/
protected $plainPassword;
/**
* @ORM\Column(type="string", length=64, nullable=true)
*/
protected $password;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default":false})
* @Groups({"user:read", "user:write"})
*/
protected $isActive = false;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default":false})
* @Groups({"user:read", "user:write"})
*/
protected $isEmailForgotten = false;
/**
* @ORM\Column(type="string", length=64, nullable=true)
*/
protected $emailKey;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups({"user:read", "user:write"})
*/
private $lastLoggedIn;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $dateAdded;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $dateModified;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Groups({"user:read", "user:write"})
*/
private $isEmailConfirmed;
/* ~~~~~~~~~~~~~~~~ OneToOne ~~~~~~~~~~~~~~~~ */
/**
* @ORM\OneToOne(targetEntity=ApiToken::class, inversedBy="tokenUser", cascade={"persist", "remove"})
* @Groups({"user:read", "user:write"})
* todo: add to point tracker
*/
private $currentApiToken;
/* ~~~~~~~~~~~~~~~~ ManyToOne ~~~~~~~~~~~~~~~~ */
/**
* @ORM\ManyToOne(targetEntity=TecDepartment::class, inversedBy="Users", cascade={"persist"}, fetch="EXTRA_LAZY")
* @Groups({"user:read", "user:write"})
*/
private $tecDepartment;
/* ~~~~~~~~~~~~~~~~ OneToMany ~~~~~~~~~~~~~~~~ */
/**
* @ORM\OneToMany(targetEntity=ApiToken::class, mappedBy="user", orphanRemoval=true)
* @Groups({"user:item:get", "user:write"})
* todo: add to point tracker
*/
private $apiTokens;
/**
* @ORM\OneToMany(targetEntity=ApiToken::class, mappedBy="retiredBy")
* @Groups({"user:item:get", "user:write"})
* todo: add to point tracker
*/
private $retiredTokens;
/**
* @ORM\OneToMany(targetEntity="App\Entity\UserMessageQueueResult", mappedBy="user", cascade={"all"}, fetch="EXTRA_LAZY")
* @ORM\OrderBy({"viewedAt" = "DESC"})
*/
private $userMessageQueueResults;
/**
* @ORM\OneToMany(targetEntity="App\Entity\FacilityDetails", mappedBy="serviceAccountManagerUser", cascade={"persist"}, fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="service_account_managers_facility_details")
* @ORM\JoinColumn( name="service_account_manager_id", referencedColumnName="id", onDelete="cascade" )
*/
private $facilityDetailsServiceAccountManager;
/**
* @ORM\OneToMany(targetEntity="App\Entity\FacilityDetails", mappedBy="serviceCustomerManagerUser", cascade={"persist"}, fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="service_customer_managers_facility_details")
* @ORM\JoinColumn( name="service_customer_manager_id", referencedColumnName="id", onDelete="cascade" )
*/
private $facilityDetailsServiceCustomerManager;
/**
* @ORM\OneToMany(targetEntity="App\Entity\VerificationItem", mappedBy="verifyingUser", cascade={"persist"}, fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="user_verification_items")
* @ORM\JoinColumn( name="verifying_user_id", referencedColumnName="id" )
*/
private $verificationItems;
/* ~~~~~~~~~~~~~~~~ ManyToMany ~~~~~~~~~~~~~~~~ */
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Facility", inversedBy="users", cascade={"persist"}, fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="user_facility")
* @ORM\OrderBy({"name" = "ASC"})
* @ApiSubresource()
*/
private $facilities;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\NetworkInstallation", inversedBy="users", cascade={"persist"}, fetch="EXTRA_LAZY")
* @ORM\JoinTable(name="network_installations_users")
* @ORM\OrderBy({"name" = "ASC"})
* @ApiSubresource()
* @Groups({"user:read", "user:write", "user:item:get"})
*/
private $networkInstallations;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\FacilityDetails", inversedBy="customerContacts", cascade={"persist"}, fetch="EXTRA_LAZY")
*/
private $customerFacilityDetails;
/**
* @ORM\ManyToMany(targetEntity=EquipmentGroup::class, mappedBy="users")
*/
private $equipmentGroups;
/*
* @ORM\ManyToMany(targetEntity="App\Entity\Department", inversedBy="users", cascade={"persist"}, fetch="EXTRA_LAZY")
*/
// private $departments;
/* ~~~~~~~~~~~~~~~~ Magic Methods> ~~~~~~~~~~~~~~~~ */
public function __construct( array $data = null )
{
$this->isActive = true;
$this->userMessageQueueResults = new ArrayCollection();
$this->facilityDetailsServiceAccountManager = new ArrayCollection();
$this->verificationItems = new ArrayCollection();
$this->customerFacilityDetails = new ArrayCollection();
$this->apiTokens = new ArrayCollection();
$this->retiredTokens = new ArrayCollection();
if( !is_null( $data ) ){
foreach( $data as $key => $value ){
$methodName = 'set' . ucfirst( $key );
if( method_exists( $this, $methodName ) ){
$this->{$methodName}( $value );
} else {
$this->__set( $key, $value );
}
}
}
$this->equipmentGroups = new ArrayCollection();
}
/**
* @return string
*/
public function __toString(): string
{
return (string) $this->name;
}
/**
* @param string $property
* @return mixed
*/
public function __get(string $property)
{
// attempt to use the method
$methodName = 'get' . ucfirst( $property );
if( method_exists( $this, $methodName ) ){
return $this->{$methodName}( $property );
}
// attempt to use the property
if (property_exists($this, $property)) {
return $this->$property;
}
return null;
}
/**
* @param string $property
* @param mixed $value
* @return bool
*/
public function __set(string $property, $value) {
// attempt to use the method
$methodName = 'set' . ucfirst( $property );
if( method_exists( $this, $methodName ) ){
$this->{$methodName}( $value );
return true;
}
// attempt to use the property
if (property_exists($this, $property)) {
$this->$property = $value;
return true;
}
return false;
}
/**
* @return array|mixed
*/
public function jsonSerialize()
{
return array(
'id' => $this->id,
'email' => $this->email,
'name' => $this->name,
'department' => !is_null($this->department) ? $this->department->getName() : '',
'firstName' => $this->firstName,
'lastName' => $this->lastName,
'phoneNumber' => $this->phoneNumber,
'role' => $this->role,
'roleText' => array_key_exists( $this->role, $this->roleTexts ) ? $this->roleTexts[$this->role] : 'None',
'isActive' => $this->isActive,
'dropboxUserId' => $this->dropboxUserId,
'dropboxOauthToken' => $this->dropboxOauthToken,
'dropboxLatestCursor' => $this->dropboxLatestCursor,
);
}
/**
* Gets triggered every time on update
* @ORM\PreUpdate
*/
public function onPreUpdate()
{
$this->dateModified = new \DateTime("now");
}
/**
* get id
*
* @return integer
*/
public function getId(): int
{
return $this->id;
}
/**
* @param $id
* @return $this
* @deprecated id should be immutable
*/
public function setId($id): User
{
$this->id = $id;
return $this;
}
/**
* @return $this
* @deprecated this is the user!
*/
public function getUser(): User
{
return $this;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(?string $firstName): self
{
$this->firstName = $firstName;
$this->name = $this->firstName . " " . $this->lastName;
$this->username = $this->firstName . " " . $this->lastName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(?string $lastName): self
{
$this->lastName = $lastName;
$this->name = $this->firstName . " " . $this->lastName;
$this->username = $this->firstName . " " . $this->lastName;
return $this;
}
public function getPhoneNumber(): ?string
{
return $this->phoneNumber;
}
public function setPhoneNumber(?string $phoneNumber): self
{
$this->phoneNumber = $phoneNumber;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(?bool $isActive): self
{
if( $this->isEmailConfirmed ) $this->isActive = $isActive;
return $this;
}
public function getIsEmailForgotten(): ?bool
{
return $this->isEmailForgotten;
}
public function setIsEmailForgotten(?bool $isEmailForgotten): self
{
$this->isEmailForgotten = $isEmailForgotten;
return $this;
}
public function getEmailKey(): ?string
{
return $this->emailKey;
}
public function setEmailKey(?string $emailKey): self
{
$this->emailKey = $emailKey;
return $this;
}
public function getLastLoggedIn(): ?DateTimeInterface
{
return $this->lastLoggedIn;
}
public function setLastLoggedIn(): self
{
$this->lastLoggedIn = new DateTimeImmutable();
return $this;
}
public function getDropboxUserId(): ?string
{
return $this->dropboxUserId;
}
public function setDropboxUserId(?string $dropboxUserId): self
{
$this->dropboxUserId = $dropboxUserId;
return $this;
}
public function getDropboxLatestCursor(): ?string
{
return $this->dropboxLatestCursor;
}
public function setDropboxLatestCursor(?string $dropboxLatestCursor): self
{
$this->dropboxLatestCursor = $dropboxLatestCursor;
return $this;
}
public function getDropboxOauthToken(): ?string
{
return $this->dropboxOauthToken;
}
public function setDropboxOauthToken(?string $dropboxOauthToken): self
{
$this->dropboxOauthToken = $dropboxOauthToken;
return $this;
}
public function getRole(): ?string
{
return $this->role;
}
public function setRole(?string $role): self
{
$this->role = $role;
return $this;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
if( (is_null($roles) || count($roles) === 0) && !is_null( $this->role ) ) $roles[] = $this->role;
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function setName(?string $name): self
{
$nameArray = explode(' ', $name);
$familyName = array_pop($nameArray);
$givenName = implode(' ', $nameArray);
$this->name = $name;
$this->firstName = $givenName;
$this->lastName = $familyName;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function getUsername(): ?string
{
return $this->email;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getEmail()
{
$emailParts = explode(':', $this->email);
if ($emailParts[0] == 'autogenerated') {
return null;
} else {
return $this->email;
}
}
public function setEmail($email)
{
$this->email = $email;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
public function getPlainPassword(): ?string
{
return $this->plainPassword;
}
public function setPlainPassword(?string $plainPassword): self
{
$this->plainPassword = $plainPassword;
return $this;
}
public function getDateAdded(): ?DateTimeInterface
{
return $this->dateAdded;
}
public function getDateModified(): ?DateTimeInterface
{
return $this->dateModified;
}
public function setDateModified(): self
{
$this->dateModified = new DateTime("now");
return $this;
}
public function getIsEmailConfirmed(): ?bool
{
return $this->isEmailConfirmed;
}
public function setIsEmailConfirmed(?bool $isEmailConfirmed): self
{
$this->isEmailConfirmed = $isEmailConfirmed;
return $this;
}
/* ~~~~~~~~~~~~~~~~ OneToOne ~~~~~~~~~~~~~~~~ */
public function getCurrentApiToken(): ?ApiToken
{
return $this->currentApiToken;
}
public function setCurrentApiToken(?ApiToken $currentApiToken): self
{
$this->currentApiToken = $currentApiToken;
return $this;
}
/* ~~~~~~~~~~~~~~~~ ManyToOne ~~~~~~~~~~~~~~~~ */
public function getTecDepartment(): ?TecDepartment
{
return $this->tecDepartment;
}
public function setTecDepartment(?TecDepartment $tecDepartment): self
{
$this->tecDepartment = $tecDepartment;
return $this;
}
/**
* @Groups({"user:read", "user:write"})
* @return TecDepartment|null
*/
public function getDepartment(): ?TecDepartment
{
return $this->getTecDepartment();
}
/**
* @Groups({"user:read", "user:write"})
* @param TecDepartment|null $tecDepartment
* @return $this
*/
public function setDepartment(?TecDepartment $tecDepartment): self
{
return $this->setTecDepartment($tecDepartment);
}
/* ~~~~~~~~~~~~~~~~ OneToMany ~~~~~~~~~~~~~~~~ */
public function getUserMessageQueueResults(): ArrayCollection
{
return $this->userMessageQueueResults;
}
public function addUserMessageQueueResult(UserMessageQueueResult $userMessageQueueResult): self
{
if (!$this->userMessageQueueResults->contains($userMessageQueueResult)) {
$this->userMessageQueueResults[] = $userMessageQueueResult;
$userMessageQueueResult->setUser($this);
}
return $this;
}
public function removeUserMessageQueueResult(UserMessageQueueResult $userMessageQueueResult): self
{
if ($this->userMessageQueueResults->contains($userMessageQueueResult)) {
$this->userMessageQueueResults->removeElement($userMessageQueueResult);
// set the owning side to null (unless already changed)
if ($userMessageQueueResult->getUser() === $this) {
$userMessageQueueResult->setUser();
}
}
return $this;
}
public function getFacilityDetailsServiceAccountManager(): ArrayCollection
{
return $this->facilityDetailsServiceAccountManager;
}
public function addFacilityDetailsServiceAccountManager(UserMessageQueueResult $userMessageQueueResult): self
{
if (!$this->facilityDetailsServiceAccountManager->contains($userMessageQueueResult)) {
$this->facilityDetailsServiceAccountManager[] = $userMessageQueueResult;
$userMessageQueueResult->setUser($this);
}
return $this;
}
public function removeFacilityDetailsServiceAccountManager(UserMessageQueueResult $userMessageQueueResult): self
{
if ($this->facilityDetailsServiceAccountManager->contains($userMessageQueueResult)) {
$this->facilityDetailsServiceAccountManager->removeElement($userMessageQueueResult);
// set the owning side to null (unless already changed)
if ($userMessageQueueResult->getUser() === $this) {
$userMessageQueueResult->setUser();
}
}
return $this;
}
public function getFacilityDetailsServiceCustomerManager()
{
return $this->facilityDetailsServiceCustomerManager;
}
public function addFacilityDetailsServiceCustomerManager(UserMessageQueueResult $userMessageQueueResult): self
{
if (!$this->facilityDetailsServiceCustomerManager->contains($userMessageQueueResult)) {
$this->facilityDetailsServiceCustomerManager[] = $userMessageQueueResult;
$userMessageQueueResult->setUser($this);
}
return $this;
}
public function removeFacilityDetailsServiceCustomerManager(UserMessageQueueResult $userMessageQueueResult): self
{
if ($this->facilityDetailsServiceCustomerManager->contains($userMessageQueueResult)) {
$this->facilityDetailsServiceCustomerManager->removeElement($userMessageQueueResult);
// set the owning side to null (unless already changed)
if ($userMessageQueueResult->getUser() === $this) {
$userMessageQueueResult->setUser();
}
}
return $this;
}
public function getVerificationItems(): ArrayCollection
{
return $this->verificationItems;
}
public function addVerificationItem(VerificationItem $verificationItem): self
{
if (!$this->verificationItems->contains($verificationItem)) {
$this->verificationItems[] = $verificationItem;
$verificationItem->setVerifyingUser($this);
}
return $this;
}
public function removeVerificationItem(VerificationItem $verificationItem): self
{
if ($this->verificationItems->contains($verificationItem)) {
$this->verificationItems->removeElement($verificationItem);
// set the owning side to null (unless already changed)
if ($verificationItem->getVerifyingUser() === $this) {
$verificationItem->setVerifyingUser(null);
}
}
return $this;
}
/**
* @return Collection|ApiToken[]
*/
public function getApiTokens(): Collection
{
return $this->apiTokens;
}
public function addApiToken(ApiToken $apiToken): self
{
if (!$this->apiTokens->contains($apiToken)) {
$this->apiTokens[] = $apiToken;
$apiToken->setUser($this);
}
return $this;
}
public function removeApiToken(ApiToken $apiToken): self
{
if ($this->apiTokens->removeElement($apiToken)) {
// set the owning side to null (unless already changed)
if ($apiToken->getUser() === $this) {
$apiToken->setUser(null);
}
}
return $this;
}
/**
* @return Collection|ApiToken[]
*/
public function getRetiredTokens(): Collection
{
return $this->retiredTokens;
}
public function addRetiredToken(ApiToken $retiredToken): self
{
if (!$this->retiredTokens->contains($retiredToken)) {
$this->retiredTokens[] = $retiredToken;
$retiredToken->setRetiredBy($this);
}
return $this;
}
public function removeRetiredToken(ApiToken $retiredToken): self
{
if ($this->retiredTokens->removeElement($retiredToken)) {
// set the owning side to null (unless already changed)
if ($retiredToken->getRetiredBy() === $this) {
$retiredToken->setRetiredBy(null);
}
}
return $this;
}
/* ~~~~~~~~~~~~~~~~ ManyToMany ~~~~~~~~~~~~~~~~ */
/**
* @return mixed
*/
public function getFacilities()
{
return $this->facilities;
}
/**
* Add Facility
*
* @param Facility $facility
* @return User
*/
public function addFacility(Facility $facility): User
{
if (!$this->facilities->contains($facility)) {
$this->facilities[] = $facility;
$facility->addUser($this);
}
return $this;
}
/**
* Remove Facility
*
* @param Facility $facility
* @return User
*/
public function removeFacility(Facility $facility): User
{
if ($this->facilities->contains($facility)) {
$this->facilities->removeElement($facility);
// set the owning side to null (unless already changed)
if ($facility->getUsers()->contains($this)) {
$facility->removeUser($this);
}
}
return $this;
}
/**
* Get networkInstallations
*
* @return mixed
*/
public function getNetworkInstallations()
{
return $this->networkInstallations;
}
/**
* Add networkInstallation
*
* @param NetworkInstallation $networkInstallation
*
* @return User
*/
public function addNetworkInstallation(NetworkInstallation $networkInstallation): User
{
if (!$this->networkInstallations->contains($networkInstallation)) {
$this->networkInstallations[] = $networkInstallation;
$networkInstallation->addUser($this);
}
return $this;
}
/**
* Remove networkInstallation
*
* @param NetworkInstallation $networkInstallation
* @return User
*/
public function removeNetworkInstallation(NetworkInstallation $networkInstallation): User
{
if ($this->networkInstallations->contains($networkInstallation)) {
$this->networkInstallations->removeElement($networkInstallation);
// set the owning side to null (unless already changed)
if ($networkInstallation->getUsers()->contains($this)) {
$networkInstallation->removeUser($this);
}
}
return $this;
}
/**
* Get customerFacilityDetails
*
* @return mixed
*/
public function getCustomerFacilityDetails()
{
return $this->customerFacilityDetails;
}
/**
* Add customerFacilityDetails
*
* @param \App\Entity\FacilityDetails $customerFacilityDetails
*
* @return User
*/
public function addCustomerFacilityDetail(\App\Entity\FacilityDetails $customerFacilityDetails): User
{
if (!$this->customerFacilityDetails->contains($customerFacilityDetails)) {
$this->customerFacilityDetails[] = $customerFacilityDetails;
$customerFacilityDetails->addCustomerContact($this);
}
return $this;
}
/**
* Remove customerFacilityDetails
*
* @param \App\Entity\FacilityDetails $customerFacilityDetails
*
* @return User
*/
public function removeCustomerFacilityDetail(\App\Entity\FacilityDetails $customerFacilityDetails): User
{
if ($this->customerFacilityDetails->contains($customerFacilityDetails)) {
$this->customerFacilityDetails->removeElement($customerFacilityDetails);
// set the owning side to null (unless already changed)
if ($customerFacilityDetails->getCustomerContacts()->contains($this)) {
$customerFacilityDetails->removeCustomerContact($this);
}
}
return $this;
}
/**
* @return PersistentCollection|ArrayCollection
*/
/* public function getDepartments()
{
return $this->departments;
}
*/
/**
* @param array $departments
* @param bool $cascade
* @return User
*/
/* public function addDepartments(array $departments, bool $cascade = true): User
{
foreach( $departments as $department ){
$this->addDepartment( $department, $cascade );
}
return $this;
}
*/
/**
* @param Department $department
* @param bool $cascade
* @return User
*/
/* public function addDepartment(Department $department, bool $cascade = true): User
{
if( !is_null( $department ) ){
// update the inverse side
if( $cascade ) {
$department->addUser($this);
}
} else {
if ( $this->departments->contains($department) && $this->departments[$department]->getUsers()->contains( $this ) ) {
$this->departments[$department]->removeUser($this);
}
}
$this->departments[] = $department;
return $this;
}
*/
/**
* @param Department $department
* @return User
*/
/* public function removeDepartment(Department $department): User
{
if ($this->departments->contains($department)) {
$this->departments->removeElement($department);
// set the owning side to null (unless already changed)
if ($department->getUsers()->contains( $this )) {
$department->removeUser($this);
}
}
return $this;
}
*/
/**
* @param array $departments
* @return bool
*/
/* public function removeDepartments(array $departments): User
{
foreach( $departments as $department ){
if( $department instanceof Department ){
$this->removeDepartment( $department );
}
}
return $this;
}
*/
/* ~~~~~~~~~~~~~~~~ UserInterface Implementation Methods ~~~~~~~~~~~~~~~~ */
public function isEnabled(): bool
{
return $this->getIsActive();
}
public function isAccountNonExpired(): bool
{
return true;
}
public function isAccountNonLocked(): bool
{
return true;
}
public function isCredentialsNonExpired(): bool
{
return true;
}
/** @see \Serializable::serialize() */
public function serialize(): ?string
{
return serialize(
array(
$this->id,
$this->email,
$this->password,
$this->isActive,
// see section on salt below
// $this->salt,
)
);
}
/** @see \Serializable::unserialize() */
public function unserialize($serialized)
{
list (
$this->id,
$this->email,
$this->password,
$this->isActive,
// see section on salt below
// $this->salt
) = unserialize($serialized, array('allowed_classes' => false));
}
/**
* @return Collection|EquipmentGroup[]
*/
public function getEquipmentGroups(): Collection
{
return $this->equipmentGroups;
}
public function addEquipmentGroup(EquipmentGroup $equipmentGroup): self
{
if (!$this->equipmentGroups->contains($equipmentGroup)) {
$this->equipmentGroups[] = $equipmentGroup;
$equipmentGroup->addUser($this);
}
return $this;
}
public function removeEquipmentGroup(EquipmentGroup $equipmentGroup): self
{
if ($this->equipmentGroups->removeElement($equipmentGroup)) {
$equipmentGroup->removeUser($this);
}
return $this;
}
}