<commit_before><?php

namespace {{ base }}DataFixtures\MongoDB;

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;

use {{ base }}Document\{{ document }};

/**
 * Load a example consultant and loads of fake data
 *
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
 * @link     http://swisscom.ch
 */
class Load{{ document }}Data extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
{
    /**
     * @private ContainerInterface
     */
    private $container;

    /**
     * {@inheritDoc}
     *
     * @param ContainerInterface $container service_container
     *
     * @return void
     */
    public function setContainer(ContainerInterface $container = null)
    {
        $this->container = $container;
    }

    /**
     * {@inheritDoc}
     *
     * @param ObjectManager $manager Object Manager
     *
     * @return void
     */
    public function load(ObjectManager $manager)
    {
        $fixtures = json_decode('{{ fixtures_json }}');
        $refName = '$ref';
        $idName = '$id';

        $formDataMapper = $this->container->get('graviton.document.service.formdatamapper');
        $formType = $this->container->get('graviton.document.form.type.document');
        $formFactory = $this->container->get('form.factory');

        $formType->initialize('{{ base }}Document\{{ document }}');

        if (count($fixtures) > 0) {
            foreach ($fixtures as $record) {

                $document = $formDataMapper->convertToFormData(
                    json_encode($record),
                    '{{ base }}Document\{{ document }}'
                );

                $form = $formFactory->create($formType, null, ['method' => 'put']);
                $form->submit($document, true);

                $thisRecord = $form->getData();

                // obvious refs..
                foreach ($record as $key => $val) {
                    if ($val instanceof \stdClass && isset($val->$refName) && isset($val->$idName)) {
                        $setterFunction = 'set'.ucfirst($key);
                        $thisRecord->$setterFunction($this->getReference($val->$refName.'-'.$val->$idName));
                    }<commit_msg>get entities in fixture loading through serializer again<commit_after><?php

namespace {{ base }}DataFixtures\MongoDB;

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;

use {{ base }}Document\{{ document }};

/**
 * Load a example consultant and loads of fake data
 *
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
 * @link     http://swisscom.ch
 */
class Load{{ document }}Data extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
{
    /**
     * @private ContainerInterface
     */
    private $container;

    /**
     * {@inheritDoc}
     *
     * @param ContainerInterface $container service_container
     *
     * @return void
     */
    public function setContainer(ContainerInterface $container = null)
    {
        $this->container = $container;
    }

    /**
     * {@inheritDoc}
     *
     * @param ObjectManager $manager Object Manager
     *
     * @return void
     */
    public function load(ObjectManager $manager)
    {
        $fixtures = json_decode('{{ fixtures_json }}');
        $refName = '$ref';
        $idName = '$id';

        $restUtils = $this->container->get('graviton.rest.restutils');

        if (count($fixtures) > 0) {
            foreach ($fixtures as $record) {

                $thisRecord = $restUtils->deserializeContent(
                    json_encode($record),
                    '{{ base }}Document\{{ document }}'
                );

                // obvious refs..
                foreach ($record as $key => $val) {
                    if ($val instanceof \stdClass && isset($val->$refName) && isset($val->$idName)) {
                        $setterFunction = 'set'.ucfirst($key);
                        $thisRecord->$setterFunction($this->getReference($val->$refName.'-'.$val->$idName));
                    }
{'fraction_non_alphanumeric': 0.13649457123864392, 'fraction_numerical': 0.00044316419233325947, 'mean_word_length': 2.432699619771863, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3112724', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1197, 'n_words': 246}