I'm new to symfony 4 and tried to write my own function for yml nelmio/alice, but after I ran bin/console doctrine:fixtures:load
, I got this error:
In DeepCopy.php line 177:
The class "ReflectionClass" is not cloneable.
Here is my fixtures.yml file:
App\Entity\Post:
post_{1..10}:
title: <customFunction()>
Here is my AppFixture.php file:
<?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';
}
}