LoginSignup
0
0

ECCUBE4.2系でmake:entityコマンドを使用してCustomize配下にEntityを作成させる。[メモ]

Last updated at Posted at 2024-02-28
bin/console make:entity Test

だと下記のようなエラーが出る。

Cannot find the entity manager for class "App\Entity\Customize"

下記だととりあえず動きそう。

bin/console make:entity Customize\\Entity\\Test --regenerate

Entityファイルの作成だけだと上記で良さそうだが、実際はフィールドを追加してgetter,setterを自動生成してくれるところまでやりたい。

https://symfony.com/bundles/SymfonyMakerBundle/current/index.html#configuration
これを読むと設定ファイルを追加すれば良さそう。

下記を追加。

config/packages/dev/maker.yaml
maker:
    root_namespace: 'Customize'

Test.phpにフィールドを追加

Customize\Entity\Test.php
/**
 * @var \DateTime
 *
 * @ORM\Column(name="create_date", type="datetimetz")
 */
private $create_date;
php bin/console m:e --overwrite --regenerate

を実行し、

Enter a class or namespace to regenerate [Customize\Entity]:
 >

と聞かれるので、Enter

Customize\Entity\Test.php
public function getCreateDate(): ?\DateTimeInterface
{
    return $this->create_date;
}

public function setCreateDate(\DateTimeInterface $create_date): self
{
    $this->create_date = $create_date;

    return $this;
}

上記が自動生成されたのでやりたいところまでできた気がする。

参考:https://github.com/symfony/maker-bundle/issues/133

0
0
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
0
0