publicKey = $this->generateToken(64); $this->tag = $this->publicKey; $this->formForgeFields = new ArrayCollection(); $this->active = false; $this->deleted = false; } public function setDefault(LinguisticaTradItem $name){ $this->setName($name); } /** * @param int $length * @return bool|string */ private function generateToken($length = 64){ $hash = ""; while(strlen($hash) < $length){ try { $hash .= hash('sha512', random_bytes($length)); } catch (\Exception $e) { $hash .= hash('sha512', mt_rand(0,$length*10000)); } } return substr($hash, 0,$length); } /** * use to change the pk if its not unique */ public function regeneratePublicKey(){ $this->publicKey = $this->generateToken(); } /** * Get id * * @return int */ public function getId() { return $this->id; } /** * @return string */ public function getPublicKey(): string { return $this->publicKey; } /** * @param CustomCompanyServiceInterface $companyService * @return FormForgeReasonBase */ public function setCompanyService(CustomCompanyServiceInterface $companyService): FormForgeReasonBase { $this->companyService = $companyService; return $this; } /** * @return CustomCompanyServiceInterface */ public function getCompanyService(): CustomCompanyServiceInterface { return $this->companyService; } /** * @param CustomUserGroupInterface $selfGroup * @return FormForgeReasonBase */ public function setSelfGroup(CustomUserGroupInterface $selfGroup): FormForgeReasonBase { $this->selfGroup = $selfGroup; return $this; } /** * @return CustomUserGroupInterface */ public function getSelfGroup(): CustomUserGroupInterface { return $this->selfGroup; } /** * @param LinguisticaTradItem $name * @return FormForgeReasonBase */ public function setName(LinguisticaTradItem $name): FormForgeReasonBase { $this->name = $name; return $this; } /** * @return LinguisticaTradItem */ public function getName(): LinguisticaTradItem { return $this->name; } /** * @param FormForgeFieldInterface $formForgeField * @return Collection */ public function addFormForgeField(FormForgeFieldInterface $formForgeField): Collection { if(!$this->formForgeFields->contains($formForgeField)){ $this->formForgeFields->add($formForgeField); } return $this->formForgeFields; } /** * @param FormForgeFieldInterface $formForgeField * @return Collection */ public function removeFormForgeField(FormForgeFieldInterface $formForgeField): Collection { if($this->formForgeFields->contains($formForgeField)){ $this->formForgeFields->removeElement($formForgeField); } return $this->formForgeFields; } /** * @return Collection */ public function getFormForgeFields(): Collection { return $this->formForgeFields; } /** * @param string $description|null * @return FormForgeReasonBase */ public function setDescription(?string $description): FormForgeReasonBase { $this->description = $description; return $this; } /** * @return string|null ?string */ public function getDescription(): ?string { return $this->description; } /** * @param bool $active * @return FormForgeReasonBase */ public function setActive(bool $active): FormForgeReasonBase { $this->active = $active; return $this; } /** * @return bool */ public function isActive(): bool { return $this->active; } /** * @param bool $deleted * @return FormForgeReasonBase */ public function setDeleted(bool $deleted): FormForgeReasonBase { $this->deleted = $deleted; return $this; } /** * @return bool */ public function isDeleted(): bool { return $this->deleted; } public function getActive(): ?bool { return $this->active; } /** * @return string|null */ public function getTag(): ?string { return $this->tag; } /** * @param string|null $tag * @return FormForgeReasonBase */ public function setTag(?string $tag): FormForgeReasonBase { $this->tag = $tag; return $this; } }