我是 symfony 4 的新手,并试图为 yml nelmio/alice 编写我自己的函数,但在我运行之后bin/console doctrine:fixtures:load
,我得到了这个错误:
在 DeepCopy.php 第 177 行:
“ReflectionClass”类是不可克隆的。
这是我的 fixtures.yml 文件:
App\Entity\Post:
post_{1..10}:
title: <customFunction()>
这是我的 AppFixture.php 文件:
<?php
namespace App\DataFixtures;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Nelmio\Alice\Loader\NativeLoader;
class AppFixtures extends Fixture
{
public function load(ObjectManager $manager)
{
$loader = new NativeLoader();
$objectSet = $loader->loadFile(__DIR__.'/Fixtures.yml',
[
'providers' => [$this]
]
)->getObjects();
foreach($objectSet as $object) {
$manager->persist($object);
}
$manager->flush();
}
public function customFunction() {
// Some Calculations
return 'Yep! I have got my bonus';
}
}