LoginSignup
1
2

More than 3 years have passed since last update.

EC-CUBE4のEntityを書く時の作法

Posted at

カスタマイズでもプラグインでも、Entityを書く時はclassの存在チェックをしよう、というのは@tao-sさんのブログにて指摘済み。

// 前略
if (!class_exists(NewEntity::class)) {
    class NewEntity extends AbstractEntity
    {
        // 後略

これだと階層が無駄に増えるし、早期returnで良くない?と思って以下のコードを書いたんです。

// 前略
if (!class_exists(NewEntity::class)) {
    return;
}

class NewEntity extends AbstractEntity
{
    // 後略

そしたらですね、Entityのプロキシを生成した時に…

// 前略

    return;


class NewEntity extends AbstractEntity
{
    // 後略

ifが消えていきなりreturnするファイルになってしまいました。

横着せずに元のコードに従って書きましょうねというお話。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2