satthi/entity-column-check

CakePHP EntityColumnCheck

Installs: 27 545

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:cakephp-plugin

0.1.3 2017-02-20 10:56 UTC

This package is auto-updated.

Last update: 2024-04-22 12:05:29 UTC


README

Build Status Scrutinizer Code Quality

このプラグインはCakePHP3のEntityにおいて

  • プロパティに設定されているもの
  • DBのカラムに該当するもの
  • 特定の例外のカラム

以外のものがセットされている場合にExceptionを返すプラグインです

インストール

composer.json

{
	"require": {
		"satthi/entity-column-check": "*"
	}
}

composer install

使い方

Entity

<?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;
    }
}