Populate entities with feed entries using hydrator.

@param string $entityName

@throws \RuntimeException if entity name does not exists

@return array
343102
public function populate($entityName)
    {
        if (!class_exists($entityName)) {
            throw new \RuntimeException(sprintf('Entity %s does not exists.', $entityName));
        }

        $feed = $this->get();

        return $this->hydrator->hydrate($feed, $entityName);
    }
280697
protected function load($filename)
    {
        $this->catalog = array();

        $fp = fopen($filename, 'rb', false);
        if ($fp === false) {
            throw new \RuntimeException("Could not read $filename");
        }

        $data = fread($fp, 20);
        if (strlen($data) != 20) {
            throw new \RuntimeException('Invalid file');
        }

        $magic = substr($data, 0, 4);
        if ($magic === "\x95\x04\x12\xde") {
            $dword = 'N';
        } elseif ($magic === "\xde\x12\x04\x95") {
            $dword = 'V';
        } else {
            throw new \RuntimeException('Invalid file');
        }

        list(, $revision) = unpack("@4/${dword}", $data);

        if ($revision !== 0) {
            throw new \RuntimeException('Invalid file');
        }

        list(, $count, $origOffset, $transOffset) = unpack("@8/${dword}3", $data);

        fseek($fp, $origOffset);
        $origEntries = array();
        for ($i = 0; $i < $count; $i++) {
            $origEntries[] = unpack("${dword}2", fread($fp, 8));
        }

        fseek($fp, $transOffset);
        $transEntries = array();
        for ($i = 0; $i < $count; $i++) {
            $transEntries[] = unpack("${dword}2", fread($fp, 8));
        }

        for ($i = 0; $i < $count; $i++) {
            fseek($fp, $origEntries[$i][2]);
            $msgid = $origEntries[$i][1] > 0 ? fread($fp, $origEntries[$i][1]) : "";
            fseek($fp, $transEntries[$i][2]);
            $translations = $transEntries[$i][1] > 0 ? explode("\x00", fread($fp, $transEntries[$i][1])) : "";

            $ctx = self::NO_CONTEXT;
            if (($pos = strpos($msgid, self::NO_CONTEXT)) !== false) {
                $ctx = (string) substr($msgid, 0, $pos);
                $msgid = (string) substr($msgid, $pos + 1);
            }

            $this->catalog[$ctx][$msgid] = $translations;
        }
    }
292253
protected function prepareInsertData($entity) : array
    {
        $data = parent::prepareInsertData($entity);

        // Populate the discriminator column
        $discColumn = $this->class->discriminatorColumn;
        $tableName  = $discColumn->getTableName();
        $columnName = $discColumn->getColumnName();

        $this->columns[$columnName] = $discColumn;

        $data[$tableName][$columnName] = $this->class->discriminatorValue;

        return $data;
    }
948080
public static function getContents($filename)
    {
        $contents = file_get_contents($filename);
        if ($contents === false) {
            throw new \RuntimeException("Cannot read the file: " . $filename);
        }

        return $contents;
    }
408505
public function getArray($className = null)
    {
        $this->parseDefer();
        if(!$this->isSuccess)
        {
            throw new \RuntimeException('Result is not success!');
        }
        $result = $this->statement->fetchAll();
        if(false === $result)
        {
            return null;
        }

        if(null === $className)
        {
            $className = $this->modelClass;
        }
        if(null === $className)
        {
            return $result;
        }
        else
        {
            $list = [];
            $isModelClass = is_subclass_of($className, Model::class);
            $supportIEvent = is_subclass_of($className, IEvent::class);
            foreach($result as $item)
            {
                if($isModelClass)
                {
                    $object = BeanFactory::newInstance($className, $item);
                }
                else
                {
                    $object = $item;
                }
                if($supportIEvent)
                {
                    $object->trigger(ModelEvents::AFTER_QUERY, [
                        'model'      =>  $object,
                    ], $object, AfterQueryEventParam::class);
                }
                $list[] = $object;
            }
            return $list;
        }
    }
796598
public function getDatabaseMetadata(string $databaseName): DatabaseMetadata
    {
        if (!array_key_exists($databaseName, $this->databaseMetadataList)) {
            throw new \RuntimeException('Server "' . $this->host . '" doesn\'t contain database "' . $databaseName . '"');
        }

        return $this->databaseMetadataList[$databaseName];
    }
9190
public function getEntities(array $options = [], $hydrationMode = AbstractQuery::HYDRATE_OBJECT)
    {
        $options = EntityRepositoryOptionsResolver::createAndResolve($options);
        return $this->getQueryBuilder($options['filters'], $options['sorting'])
            ->getQuery()
            ->execute(null, $hydrationMode);
    }
695864
private function getEntityByClass($className)
    {
        if (!isset($this->entities[ $className ])) {
            $entity                       = new Entity($this, $className);
            $this->entities[ $className ] = $entity;

            $this->metadataDriver->readEntityMetadata($entity);
        }

        return $this->entities[ $className ];
    }
463362
private function getObjectManager($entityClassname)
    {
        $objectManager = $this->getContainer()->get('doctrine')->getManagerForClass($entityClassname);
        if ($objectManager) {
            return $objectManager;
        }

        $objectManager = $this->getContainer()->get('doctrine_mongodb')->getManagerForClass($entityClassname);
        if ($objectManager) {
            return $objectManager;
        }

        throw new \RuntimeException(sprintf('Class "%s" is not a managed entity', $entityClassname));
    }
106824
public static function getScheduledEntityInsertionsByClassname(EntityManager $em, $classnames)
    {
        $entities = array();
        $classnames = (array) $classnames;

        foreach ($em->getUnitOfWork()->getScheduledEntityInsertions() as $entity) {
            if (true === in_array(ClassUtils::getRealClass($entity), $classnames)) {
                $entities[] = $entity;
            }
        }

        return $entities;
    }
833843
protected function loadConfigFromFile($filename)
    {
        $contents = file_get_contents($filename);
        if ($contents === false) {
            throw new \RuntimeException('Failed to read config file: ' . $filename);
        }

        return (array) Yaml::parse($contents);
    }
289416
public function getEntityStructure($entityClassName)
    {
        if ($entityClassName instanceof Entity) {
            $reflection = new \ReflectionClass($entityClassName);
            $entityClassName = $reflection->getName();
        }

        if (! $this->isRegistered($entityClassName)) {
            $this->registerEntity($entityClassName);
        }
        return $this->entities[$entityClassName];
    }
270000
public function load($filename)
    {
        $json = file_get_contents($filename);
        if (false === $json) {
            throw new \RuntimeException("Unable to load file {$filename}");
        } elseif ($json === '') {
            return;
        }

        $data = \GuzzleHttp\json_decode($json, true);
        if (is_array($data)) {
            foreach (json_decode($json, true) as $cookie) {
                $this->setCookie(new SetCookie($cookie));
            }
        } elseif (strlen($data)) {
            throw new \RuntimeException("Invalid cookie file: {$filename}");
        }
    }
851237
protected function entityToArray($entity, HydratorInterface $hydrator = null)
    {
        if (is_array($entity)) {
            return $entity; // cut down on duplicate code
        } elseif (is_object($entity)) {
            if (!$hydrator) {
                $hydrator = $this->getHydrator();
            }
            return $hydrator->extract($entity);
        }
        throw new Exception\InvalidArgumentException('Entity passed to db mapper should be an array or object.');
    }
65725
public function getRepositories(array $entityNames)
    {
        $repositoryCollection = new EntityRepositoryCollection($this);
        foreach ($entityNames as $entityName) {
            $repositoryCollection->addRepository($this->getRepository($entityName));
        }
        return $repositoryCollection;
    }
1227777
protected function getChoicesByEntity($entityName)
    {
        $choices = [];
        foreach ($this->em->getRepository($entityName)->findAll() as $choice) {
            $choices[(string) $choice] = $choice->getId();
        }

        return $choices;
    }
926893
public static function getScheduledEntityUpdatesByClassname(EntityManager $em, $classnames)
    {
        $entities = array();
        $classnames = (array) $classnames;

        foreach ($em->getUnitOfWork()->getScheduledEntityUpdates() as $entity) {
            if (true === in_array(ClassUtils::getRealClass($entity), $classnames)) {
                $entities[] = $entity;
            }
        }

        return $entities;
    }