PHP code example of ufo-tech / doctrine-helper
1. Go to this page and download the library: Download ufo-tech/doctrine-helper 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/ */
ufo-tech / doctrine-helper example snippets
namespace App;
enum MyEnum: string
{
case CASE_1 = 'My case 1';
case CASE_2 = 'My case 2';
}
namespace App\DBAL;
use BackedEnum;
use App\MyEnum;
class MyEnumType extends AbstractEnumType
{
protected string|BackedEnum $enum = MyEnum::class;
}
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
#[ORM\Table(name: 'demo')]
class Demo
{
#[ORM\Column(type: MyEnum::class, nullable: false)]
protected string $case;
public function __construct(MyEnum $case)
{
$this->case = $case->value;
}
public function changeCase(MyEnum $case): void
{
$this->type = $case->value;
}
public function getCase(): string
{
return $this->case;
}
}