Hi,
I want to create constants in model.
I want to access them in table and entity.
Now I create them in Entity and when I need them in Table I call newEntity() to access them.
I guess there is another - better way.
Example:
here are the constants decalred int the entity.
class Banners extends Entity{
use ThumbTrait;
const IMG_FOLDER = ‘banners’;
const UPLOAD_PATH = IMG_DIR . self::IMG_FOLDER;
const THUMB_PATH = self::UPLOAD_PATH . DS . ‘thumb’;
}
I need the same constants in table
class BannersTable extends Table{
public function initialize(array $config){
parent::initialize($config);
$entity = $this->newEntity(); //calling entity to use its constants
$this->addBehavior('UploadFile', [
'path_thumb' => $entity::THUMB_PATH, //I take constants from entity
'path_upload' => $entity::UPLOAD_PATH, , //I take constants from entity
'upload_field' => ['upload_field']
]);
}
}
Is there a better way to use same constants in Entity and Table? - I guess there is