satthi / entity-column-check
CakePHP EntityColumnCheck
0.1.3
2017-02-20 10:56 UTC
Requires
- cakephp/cakephp: ~3.0
Requires (Dev)
- cakephp/cakephp-codesniffer: dev-master
- phpunit/phpunit: *
This package is auto-updated.
Last update: 2024-09-22 13:00:19 UTC
README
此插件是用于在CakePHP3的Entity中,当属性设置与数据库列不匹配时,除了特定的例外列外,将返回Exception的插件
- 属性设置的
- 对应数据库的列
- 特定异常的列
以外的列被设置时,会返回Exception
安装
composer.json
{
"require": {
"satthi/entity-column-check": "*"
}
}
composer install
使用方法
实体
<?php namespace App\Model\Entity; use Cake\ORM\Entity; use EntityColumnCheck\Model\Entity\EntityColumnCheckTrait; class Topic extends Entity { // 追加項目 use EntityColumnCheckTrait; protected $_accessible = [ '*' => true, 'id' => false ]; // 例外として設定するカラム protected $entityColumnCheckAllowField = [ 'file', 'img' ]; //&getメソッドをoverride public function &get($property) { $value = parent::get($property); $this->getEntityColumnCheck($property); return $value; } }