<commit_before><?php
/**
 * Created by PhpStorm.
 * User: alex
 * Date: 03.03.14
 * Time: 13:43
 */

namespace Geekhub\DreamBundle\DataFixtures\ORM;

use Application\Sonata\MediaBundle\DataFixtures\ORM\AbstractMediaLoader;
use DateTime;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Geekhub\DreamBundle\Entity\Dream;
use Symfony\Component\Yaml\Yaml;

class LoadDreamData extends AbstractMediaLoader implements OrderedFixtureInterface
{
    /**
     * Load data fixtures with the passed EntityManager
     *
     * @param ObjectManager $manager
     */
    public function load(ObjectManager $manager)
    {
        $dreams = Yaml::parse($this->getYmlFile());
        $tagManager = $this->container->get('fpn_tag.tag_manager');

        foreach ($dreams as $key => $dreamData) {
            $dream = new Dream();
            $this->setMediaContent(
                __DIR__.'/images/'.$dreamData['mediaPoster'].'.jpg',
                'sonata.media.provider.image',
                'dream' . $key
            );

            $dream->setMediaPoster($this->getReference('dream'.$key));
            $dream->setAuthor($this->getReference('user-'.$dreamData['author']));
            $dream->setTitle($dreamData['title']);
            $dream->setDescription($dreamData['description']);
            $dream->setPhone($dreamData['phone']);
            $dream->setExpiredDate(new DateTime ($dreamData['expiredDate']));
            $tagsObjArray = $tagManager->loadOrCreateTags($dreamData['tags']);
            $dream->setTags(null);
            $tagManager->addTags($tagsObjArray, $dream);
            $manager->persist($dream);

            $this->addReference($key, $dream);
        }
<commit_msg>Fixed tag manager at dream fixtures<commit_after><?php
/**
 * Created by PhpStorm.
 * User: alex
 * Date: 03.03.14
 * Time: 13:43
 */

namespace Geekhub\DreamBundle\DataFixtures\ORM;

use Application\Sonata\MediaBundle\DataFixtures\ORM\AbstractMediaLoader;
use DateTime;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Geekhub\DreamBundle\Entity\Dream;
use Symfony\Component\Yaml\Yaml;

class LoadDreamData extends AbstractMediaLoader implements OrderedFixtureInterface
{
    /**
     * Load data fixtures with the passed EntityManager
     *
     * @param ObjectManager $manager
     */
    public function load(ObjectManager $manager)
    {
        $dreams = Yaml::parse($this->getYmlFile());
        $tagManager = $this->container->get('geekhub.tag.tag_manager');

        foreach ($dreams as $key => $dreamData) {
            $dream = new Dream();
            $this->setMediaContent(
                __DIR__.'/images/'.$dreamData['mediaPoster'].'.jpg',
                'sonata.media.provider.image',
                'dream' . $key
            );

            $dream->setMediaPoster($this->getReference('dream'.$key));
            $dream->setAuthor($this->getReference('user-'.$dreamData['author']));
            $dream->setTitle($dreamData['title']);
            $dream->setDescription($dreamData['description']);
            $dream->setPhone($dreamData['phone']);
            $dream->setExpiredDate(new DateTime ($dreamData['expiredDate']));

            $tagManager->addTagsToEntity($dream);
            $manager->persist($dream);

            $this->addReference($key, $dream);
        }

{'fraction_non_alphanumeric': 0.1462125660598943, 'fraction_numerical': 0.005871990604815032, 'mean_word_length': 2.9026345933562427, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '1085058', 'n_tokens_mistral': 1043, 'n_tokens_neox': 972, 'n_words': 155}