-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
エンティティ継承機能を追加 #1817
エンティティ継承機能を追加 #1817
Conversation
※ extended_entitiesを記述する場所を考えていなかったため
※ extended_entities.ymlで拡張するエンティティを列挙する
ありがとうございます。 |
Association Override という方法もあるようです。 もうちょっと簡潔に書けたら嬉しいんですけどね 😟 |
方向としては何かしらこういうのできるといいですよね!
となっていますが、どこかからの流用になるのでしょうか? |
https://github.com/pjarmalavicius/PjEntityExtendBundle こちらがベースですか?Symfonyでもこんなのあったんですね。 |
Association Override だと、純粋にフィールドの追加ができないですね。たぶん、そういうポリシーなんでしょう。。。 こんなクラスを namespace Eccube2\Entity;
/**
* Product の拡張
* @Entity(repositoryClass="Eccube2\Repository\ProductRepository")
*/
class Product extends \Eccube\Entity\Product
{
/**
* @Column(name="extended_parameter", type="string")
*/
protected $extendedParameter;
} 以下のように schema-tool 叩いたら、 dtb_product に extended_parameter が追加される、とかできたらいいなぁと思って模索してるんですけどね。
継承ではなく、trait を使って、柔軟に拡張できたらもっと嬉しいんですけど。 |
https://github.com/izayoi256/ExtendEntity を試してみましたが、
Inheritance Mapping などの正攻法でやるか、 フィールド名で正規化する等の対応が必要かもしれません 😟 |
@nanasess |
一旦 ClassMetadata を Yaml 形式に吐き出して、 |
Inheritance Mapping を使えば、 Doctrine の標準機能だけで継承を実現できそうです。 |
@izayoi256 EC-CUBE 3.1に向けては、 |
機能概要
本体やプラグインのエンティティの継承が可能になります。
説明
次のリポジトリを参照して下さい。 https://github.com/izayoi256/ExtendEntity
本体で継承する場合は
extended_entities.yml.dist
に継承元エンティティを列挙して下さい。