Return entity configuration
@param array $entity_names
@param boolean $merge_standard
@return array
556455
public function getEntitiesConfig($entity_names=null, $merge_standard=true)
    {
        $configured_entities = $this->setup->getSynchronizerConfig('entities');
        $configured_entities = array_merge_recursive($entity_names);

        if ($entity_names === null) {
        } else {
        }
    }
573992
protected function getFQCN($entity_name)
    {
        $parts = explode(':', $entity_name);
        $entity = end($parts);

        if (1 === preg_match('/^([A-Z][a-zA-Z]+)([A-Z][a-zA-Z]+)(Bundle)$/', $parts[0], $matches)) {
            return $matches[1].'\\'.$matches[2].$matches[3].'\\Entity\\'.$entity;
        }

        return $entity_name;
    }
810649
public function setEntity($entity_name, $entity_alias)
    {
        $this->entityName = $entity_name;
        $this->entityAlias = $entity_alias;
        $this->queryBuilder->from($entity_name, $entity_alias);

        return $this;
    }
178268
private static function configEntityManager()
    {
        if (self::$entityManager) {
            return;
        }

        $isDevMode = cfg::htrFileConfigs()->devmode ?? false;
        $paths = [cfg::baseDir() . cfg::PATH_ENTITIES];

        // the connection configuration
        if ($isDevMode) {
            $dbParams = cfg::DATABASE_CONFIGS_DEV;
        } else {
            $dbParams = cfg::DATABASE_CONFIGS_PRD;
        }

        $cache = new ArrayCache();
        $reader = new AnnotationReader();
        $driver = new AnnotationDriver($reader, $paths);

        $config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
        $config->setMetadataCacheImpl($cache);
        $config->setQueryCacheImpl($cache);
        $config->setMetadataDriverImpl($driver);

        self::$entityManager = EntityManager::create($dbParams, $config);
    }
194873
final public function normalizeDatabaseParams(array $configs) : array
    {
        if (empty($configs)) {
            return $configs;
        }

        /**
         * Merge User Param
         */
        $currentUserParams = array_merge($this->defaultParams, $configs);

        $toSanity = [
            self::DB_HOST => 'dbhost',
            self::DB_USER => 'dbuser',
            self::DB_NAME => 'name',
            self::DB_PASSWORD => 'dbpass',
            self::DB_DRIVER   => 'dbdriver',
            self::DB_PATH     => 'dbpath',
            self::DB_PORT     => 'dbport',
            self::DB_PREFIX   => 'dbprefix',
            self::DB_PROTOCOL => 'dbprotocol',
            self::DB_CHARSET  => 'dbcharset',
            self::DB_COLLATE  => 'dbcollate'
        ];
        foreach ($toSanity as $key => $name) {
            if ($key === $name) {
                continue;
            }
            if (!isset($currentUserParams[$key]) && isset($currentUserParams[$name])) {
                $currentUserParams[$key] = $currentUserParams[$name];
                unset($currentUserParams[$name]);
            }
        }

        // re-sanitize
        if (!isset($currentUserParams[self::DB_PASSWORD]) && isset($currentUserParams['dbpassword'])) {
            $currentUserParams[self::DB_PASSWORD] = $currentUserParams['dbpassword'];
            unset($currentUserParams['dbpassword']);
        }

        /**
         * check if port in 3306 & empty driver
         */
        if (empty($currentUserParams[self::DB_DRIVER])
            && isset($currentUserParams[self::DB_PORT])
            && abs($currentUserParams[self::DB_PORT]) === 3306
        ) {
            $currentUserParams[self::DB_DRIVER] = 'mysql';
        }
        if (empty($currentUserParams[self::DB_DRIVER])) {
            $currentUserParams[self::DB_DRIVER] = $this->defaultDriver;
        }

        if (!empty($currentUserParams[self::DB_DRIVER])) {
            $currentUserParams[self::DB_DRIVER] = $this
                ->normalizeDatabaseDriver($this->currentUserParams[self::DB_DRIVER]);
        }

        if (!empty($currentUserParams[self::DB_DRIVER])
            && $currentUserParams[self::DB_DRIVER] == 'pdo_sqlite'
        ) {
            if (empty($currentUserParams[self::DB_PATH])) {
                if (is_string($currentUserParams[self::DB_NAME])
                    && isset($currentUserParams[self::DB_NAME])
                ) {
                    $currentUserParams[self::DB_PATH] = $currentUserParams[self::DB_NAME];
                }
            } elseif (empty($currentUserParams[self::DB_NAME])) {
                if (is_string($currentUserParams[self::DB_PATH])
                    && isset($currentUserParams[self::DB_PATH])
                ) {
                    $currentUserParams[self::DB_NAME] = $currentUserParams[self::DB_PATH];
                }
            }
        }

        $charset = self::DEFAULT_CHARSET;
        if (is_string($currentUserParams[self::DB_CHARSET])
            && strpos($currentUserParams[self::DB_CHARSET], '-') !== false
        ) {
            $currentUserParams[self::DB_CHARSET] = str_replace(
                '-',
                '',
                trim(strtoupper($currentUserParams[self::DB_CHARSET]))
            );
        }

        if (isset($currentUserParams[self::DB_COLLATE])) {
            $collate = isset($currentUserParams[self::DB_COLLATE])
                ? $currentUserParams[self::DB_COLLATE]
                : null;
            if (!is_string($collate) && $currentUserParams[self::DB_DRIVER] === 'mysql') {
                $collate = 'utf8_unicode_ci';
            }
            $collate = preg_replace('`(\-|\_)+`', '_', $collate);
            $collate = trim(strtolower($collate));
            $collateArray = explode('_', $collate);
            $charset = reset($collateArray)?: $charset;
        }

        if (!is_string($currentUserParams[self::DB_CHARSET])
            || trim($currentUserParams[self::DB_CHARSET]) === ''
        ) {
            $currentUserParams[self::DB_CHARSET] = $charset;
        }

        return $currentUserParams;
    }
666921
protected function getEntityInfo($sortableEntities, $entityName)
    {
        $relation = false;

        $entityConfig = $entityName ? array_get($sortableEntities, $entityName, false) : false;

        if (is_array($entityConfig)) {
            $entityClass = $entityConfig['entity'];
            $relation = !empty($entityConfig['relation']) ? $entityConfig['relation'] : false;
        } else {
            $entityClass = $entityConfig;
        }

        return [$entityClass, $relation];
    }
300919
public function findDataByNames(array $names, array $modCombinationIds = []): array
    {
        $result = [];
        if (count($names) > 0) {
            $columns = [
                'm.id AS id',
                'm.name AS name',
                'mc.order AS order'
            ];

            $queryBuilder = $this->entityManager->createQueryBuilder();
            $queryBuilder->select($columns)
                         ->from(Machine::class, 'm')
                         ->innerJoin('m.modCombinations', 'mc')
                         ->andWhere('m.name IN (:names)')
                         ->setParameter('names', array_values($names));

            if (count($modCombinationIds) > 0) {
                $queryBuilder->andWhere('mc.id IN (:modCombinationIds)')
                             ->setParameter('modCombinationIds', array_values($modCombinationIds));
            }
            $result = $this->mapMachineDataResult($queryBuilder->getQuery()->getResult());
        }
        return $result;
    }
1114596
protected function createEntityList(array $entities_data)
    {
        $type_map = [];
        foreach ($this->getOption(self::OPTION_REFERENCE_MODULES, []) as $type) {
            $type_map[$type->getEntityType()] = $type;
        }

        $collection = new EntityList();
        ksort($entities_data);
        foreach ($entities_data as $entity_data) {
            if (!isset($entity_data[self::OBJECT_TYPE])) {
                $this->throwError('missing_doc_type', [], IncidentInterface::CRITICAL);
                continue;
            }

            $reference_type = $entity_data[self::OBJECT_TYPE];
            unset($entity_data['@type']);

            if ($reference_type{0} !== '\\') {
                $reference_type = '\\' . $reference_type;
            }
            if (!isset($type_map[$reference_type])) {
                $this->throwError(
                    'invalid_doc_type',
                    array('type' => @$entity_data[self::OBJECT_TYPE]),
                    IncidentInterface::NOTICE
                );
                continue;
            }

            $reference_type = $type_map[$reference_type];
            $collection->push($reference_type->createEntity($entity_data));
        }

        return $collection;
    }
776091
public static function getEntityManager($db = null, $context = 'shared')
    {
        // Get db config info from file
        $dbConfig = \erdiko\core\Helper::getConfig("database", $context);
        if($db == null)
            $db = $dbConfig['default'];
        $dbParams = $dbConfig['connections'][$db];
        $dbParams['dbname'] = $dbParams['database'];
        $dbParams['user'] = $dbParams['username'];

        $paths = array(ERDIKO_ROOT.$dbConfig['entities']);
        $isDevMode = isset($dbConfig['is_dev_mode']) ? (bool)$dbConfig['is_dev_mode'] : false;
        $config = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
        
        // Create and return the entity manager
        return \Doctrine\ORM\EntityManager::create($dbParams, $config);
    }
916915
public function postUninstall($module_name) {
    // Get install and optional configs list for module_name.
    $module_path = drupal_get_path('module', $module_name);
    $file_storage_install = new FileStorage($module_path . '/config/install');
    $module_install_configs = $file_storage_install->listAll();
    $file_storage_optional = new FileStorage($module_path . '/config/optional');
    $module_optional_configs = $file_storage_optional->listAll();
    // Find entity bundles based on configs list.
    $entity_bundles_list = $this->getEntityBundles($module_install_configs);
    foreach ($entity_bundles_list as $data) {
      // Delete entity data for bundle and config entity type.
      $this->removeEntityBundle($data['entity_type'], $data['config_entity_type'], $data['bundle'], $data['bundle_field']);
    }
    $this->removeModuleConfigs(array_merge($module_install_configs, $module_optional_configs));
  }
1336308
public static function getSchedulesAClassContentDeletions(EntityManager $em, $exclude_base_element = false)
    {
        $entities = array();
        foreach ($em->getUnitOfWork()->getScheduledEntityDeletions() as $entity) {
            if ($entity instanceof AbstractClassContent &&
                (!$exclude_base_element || !$entity->isElementContent())) {
                $entities[] = $entity;
            }
        }

        return $entities;
    }
553432
protected function getYamlConfig($config_name)
    {
        if ($this->configStorage->exists($config_name)) {
            $configuration = $this->configStorage->read($config_name);
            $configurationEncoded = Yaml::encode($configuration);
        }

        return $configurationEncoded;
    }
115383
def [](entity_set_name)
      xpath_query = "//EntityContainer/EntitySet[@Name='#{entity_set_name}']"
      entity_set_node = metadata.xpath(xpath_query).first
      raise ArgumentError, "Unknown Entity Set: #{entity_set_name}" if entity_set_node.nil?
      container_name = entity_set_node.parent.attributes['Name'].value
      entity_type_name = entity_set_node.attributes['EntityType'].value.gsub(/#{namespace}\./, '')
      OData::EntitySet.new(name: entity_set_name,
                           namespace: namespace,
                           type: entity_type_name.to_s,
                           service_name: name,
                           container: container_name)
    end
1188891
protected function getFieldParams($fieldName = null, $entityName = null, $isOrmEntityDefs = false, $returns = null)
    {
        if (!isset($fieldName)) {
            $fieldName = $this->getFieldName();
        }
        if (!isset($entityName)) {
            $entityName = $this->getEntityName();
        }

        $entityDefs = $this->getDefs($isOrmEntityDefs);

        if (isset($entityDefs[$entityName]) && isset($entityDefs[$entityName]['fields'][$fieldName])) {
            return $entityDefs[$entityName]['fields'][$fieldName];
        }

        return $returns;
    }
1214502
public function findByTypesAndNames(array $namesByTypes, array $modCombinationIds = []): array
    {
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder->select('i')
                     ->from(Item::class, 'i');

        $index = 0;
        $conditions = [];
        foreach ($namesByTypes as $type => $names) {
            $conditions[] = '(i.type = :type' . $index . ' AND i.name IN (:names' . $index . '))';
            $queryBuilder->setParameter('type' . $index, $type)
                         ->setParameter('names' . $index, array_values($names));
            ++$index;
        }

        $result = [];
        if ($index > 0) {
            $queryBuilder->andWhere('(' . implode(' OR ', $conditions) . ')');

            if (count($modCombinationIds) > 0) {
                $queryBuilder->innerJoin('i.modCombinations', 'mc')
                             ->andWhere('mc.id IN (:modCombinationIds)')
                             ->setParameter('modCombinationIds', array_values($modCombinationIds));
            }
            $result = $queryBuilder->getQuery()->getResult();
        }
        return $result;
    }
759086
private static function mergeConfig(array $extra)
    {
        return array_merge([
            'include'              => [],
            'require'              => [],
            'recurse'              => true,
            'replace'              => false,
            'ignore-duplicates'    => false,
            'prepend-repositories' => false,
            'merge-dev'            => true,
            'merge-extra'          => false,
            'merge-extra-deep'     => false,
            'merge-scripts'        => false,
        ], $extra['merge-plugin'] ?? []);
    }
640608
private function getMappedEntities(EntityManagerInterface $entityManager)
    {
        $entityClassNames = $entityManager
            ->getConfiguration()
            ->getMetadataDriverImpl()
            ->getAllClassNames();

        if ( ! $entityClassNames) {
            throw new \InvalidArgumentException(
                'You do not have any mapped Doctrine ORM entities according to the current configuration. '.
                'If you have entities or mapping files you should check your mapping configuration for errors.'
            );
        }

        return $entityClassNames;
    }