/config/packages/_sylius.yaml的内容
imports:
- { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" }
- { resource: "@SyliusAdminBundle/Resources/config/app/config.yml" }
- { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" }
- { resource: "@SyliusShopBundle/Resources/config/app/config.yml" }
parameters:
sylius_core.public_dir: '%kernel.project_dir%/public'
sylius_shop:
product_grid:
include_all_descendants: true
sylius_theme:
sources:
filesystem:
directories:
- "%kernel.project_dir%/themes"
sylius_addressing:
resources:
country:
classes:
model: App\Entity\Country
/src/Entity/Country.php的内容
namespace App\Entity;
use Sylius\Component\Addressing\Model\Country as BaseCountry;
class Country extends BaseCountry
{
/**
* @var bool
*/
private $flag;
/**
* @return bool|null
*/
public function getFlag(): ?bool
{
return $this->flag;
}
/**
* @param bool $flag
*/
public function setFlag(bool $flag): void
{
$this->flag = $flag;
}
}
/src/Resources/config/doctrine/Country.orm.yml的内容
App\Entity\Country:
type: entity
table: sylius_country
fields:
flag:
type: boolean
nullable: true
运行Symfony的架构更新命令后,会显示以下错误消息:
“ Sylius \ Component \ Addressing \ Model \ Country”的“ App \ Entity \ Country”类子类不是有效的实体或映射的超类。 < / p>
任何帮助将不胜感激。预先谢谢你。
答案 0 :(得分:1)
您需要像这样映射您的实体。
#config / packages / doctrine.yaml
doctrine:
orm:
mappings:
AppEntity:
type: xml
is_bundle: false
prefix: App\Entity
dir: '%project.dir%/src/Resources/config/doctrine/model'
,然后创建您的映射文件,例如。 src/Resources/config/doctrine/model/YourEntity.xml