繁体   English   中英

Cakephp 3.x 如何扩展蛋糕模式 class?

[英]Cakephp 3.x how do i extend the cake schema class?

我想为模式 $_fieldDefaults 数组添加一些额外的选项以用于一些记录目的。 I tried copying the class and including it in the model in place of the cake schema class but somewhere down the line the constructor is looking for an instance of the cake schema class and not accepting my class.

有谁知道是否可以简单地换出架构 class 或者我需要从头开始并创建一个新的数据库驱动程序来实现我的目标?

如果我需要创建驱动程序,是否有人有需要这样做的示例或要求列表?

作为一个侧面的想法,我也在考虑在表中声明一个新的公共 var 的想法,该表包含模式字段及其选项,然后在构建模式 function 中循环遍历它,以便我总是可以引用新变量而不是架构 object 但这听起来有点不对,但比重新发明轮子更简单。

您可能只需要在新的 class 中扩展原始 class。

<?php
namespace \your\new\class\namespace

use original\schema\class\schemaClassName

class YourNewClass extends schemaClassName {

//new code here

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM