cakephp / docs

CakePHP CookBook
http://book.cakephp.org
Other
679 stars 2.58k forks source link

Fix schema type to be adjustable at runtime. #7955

Closed dereuromark closed 2 weeks ago

dereuromark commented 2 weeks ago

Refs https://github.com/cakephp/cakephp/issues/18024

for a quick fix in docs to be in sync with the other example already on that page further up:

To use this type you need to specify which column is associated to which BackedEnum inside the table class::

    use \Cake\Database\Type\EnumType;
    use \App\Model\Enum\ArticleStatus;

    // in src/Model/Table/ArticlesTable.php
    public function initialize(array $config): void
    {
        $this->getSchema()->setColumnType('status', EnumType::from(ArticleStatus::class));
    }