1. Go to this page and download the library: Download palabs/enum-bundle 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/ */
use PaLabs\Enum\Enum;
use \PaLabs\EnumBundle\Translator\EnumTranslator;
use Symfony\Component\HttpFoundation\Request;
class ActionEnum extends Enum {
public static ActionEnum $VIEW, $EXIT;
}
ActionEnum::init();
class FooController {
private EnumTranslator $enumTranslator;
public function __construct(EnumTranslator $enumTranslator) {
$this->enumTranslator = $enumTranslator;
}
public function fooAction(Request $request) {
return $this->enumTranslator->translate(ActionEnum::$VIEW);
}
}
use PaLabs\EnumBundle\Form\EnumType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class MyForm extends AbstractType {
public function buildForm(FormBuilderInterface $builder,array $options){
$builder->add('field', EnumType::class, [
'type'=>ActionEnum::class,
'
use Doctrine\ORM\Mapping as ORM;
use PaLabs\Enum\Enum;
class BookType extends Enum {
public static BookType $MONOGRAPHY, $THESES, $OTHER:
}
BookType::init();
class Book {
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
/**
* @ORM\Column(name="name", type="text", nullable=false)
*/
private string $name = '';
/**
* @ORM\Column(name="type", type=BookType::class, nullable=false)
*/
private BookType $type;
public function __construct() {
$this->type = BookType::$MONOGRAPHY;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.