PHP code example of tsdevelopment / doctrine-behaviors-hashidable
1. Go to this page and download the library: Download tsdevelopment/doctrine-behaviors-hashidable library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tsdevelopment / doctrine-behaviors-hashidable example snippets
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use TSDevelopment\DoctrineBehaviorsHashidable\Contract\Entity\HashidableInterface;
use TSDevelopment\DoctrineBehaviorsHashidable\Traits\HashidableTrait;
/**
* @ORM\Entity
*/
class HashidableEntity implements HashidableInterface
{
use HashidableTrait;
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @var int
*/
private $id;
public function getId(): int
{
return $this->id;
}
}
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use TSDevelopment\DoctrineBehaviorsHashidable\Contract\Entity\HashidableInterface;
use TSDevelopment\DoctrineBehaviorsHashidable\Traits\HashidableTrait;
/**
* @ORM\Entity
*/
class HashidableCustomGetterEntity implements HashidableInterface
{
use HashidableTrait;
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @var int
*/
private $customId;
public function getCustomId(): int
{
return $this->customId;
}
public function getHashidableField(): string
{
return 'customId';
}
}