我目前在Symfony应用程序上使用Sylius组件,出于某种原因,我不得不扩展Sylius类以在产品上添加信息。
namespace AppBundle\Entity;
use Sylius\Component\Core\Model\Product as BaseProduct;
use Sylius\Component\Product\Model\ProductInterface;
class Product extends BaseProduct implements ProductInterface
{
但是我最终遇到以下错误:
2019/06/11 09:59:44 [error] 13#13: *2939 FastCGI sent in stderr: "PHP message: PHP Warning: require(/var/www/var/cache/dev/doctrine/orm/Proxies/__CG__SyliusComponentCoreModelProduct.php): failed to open stream: No such file or directory in /var/www/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 206
实际上,已创建了新的类代理(__CG__AppBundleEntityProduct.php),但不再创建了父类代理(__CG__SyliusComponentCoreModelProduct.php)。
我的Symfony版本。是3.4.19 我已经在Google中搜索过,堆栈溢出等等,但是提供的答案都无法解决我的问题。
我试图清除/重建缓存,使用Sylius父类“ Product / Model / Product”代替“ Core / Model / Product”,检查新类的拼写,并且已经设置了“在我的配置中为auto_generate_proxy_classes:true”。
这是我的新课的第一行:
namespace AppBundle\Entity;
use Sylius\Component\Core\Model\Product as BaseProduct;
use Sylius\Component\Core\Model\ProductTranslation;
use Sylius\Component\Product\Model\ProductTranslationInterface;
use Sylius\Component\Product\Model\ProductInterface;
use Sylius\Component\Resource\Model\TranslatableTrait;
use Sylius\Component\Resource\Model\TranslationInterface;
class Product extends BaseProduct implements ProductInterface
{
use TranslatableTrait {
__construct as private initializeTranslationsCollection;
getTranslation as private doGetTranslation;
}
/** @var string */
private $stripe_id;
/** @var string */
private $product_stripe_id;
/** getters and setters **/
/** ... **/
}
这是我的配置文件的一部分,为我的班级生成了Doctrine代理:
sylius_product:
driver: doctrine/orm
resources:
product:
classes:
model: AppBundle\Entity\Product
repository: AppBundle\Repository\ProductRepository
translation:
classes:
model: Sylius\Component\Core\Model\ProductTranslation
product_variant:
classes:
model: Sylius\Component\Core\Model\ProductVariant
controller: Sylius\Bundle\CoreBundle\Controller\ProductVariantController
repository: Sylius\Bundle\CoreBundle\Doctrine\ORM\ProductVariantRepository
product_option:
classes:
repository: Sylius\Bundle\CoreBundle\Doctrine\ORM\ProductOptionRepository
product_association_type:
classes:
repository: Sylius\Bundle\ProductBundle\Doctrine\ORM\ProductAssociationTypeRepository
我们将不胜感激。