Create a child job with current client and parser
@param JobConfig $config
@param array $parentResults
@return static[]
487182
private function createChild(JobConfig $config, array $parentResults) : array
    {
        // Clone and reset Scroller
        $scroller = clone $this->scroller;
        $scroller->reset();

        $params = [];
        $placeholders = !empty($config->getConfig()['placeholders']) ? $config->getConfig()['placeholders'] : [];
        if (empty($placeholders)) {
            $this->logger->warning("No 'placeholders' set for '" . $config->getConfig()['endpoint'] . "'");
        }

        foreach ($placeholders as $placeholder => $field) {
            $params[$placeholder] = $this->getPlaceholder($placeholder, $field, $parentResults);
        }

        // Add parent params as well (for 'tagging' child-parent data)
        // Same placeholder in deeper nesting replaces parent value
        if (!empty($this->parentParams)) {
            $params = array_replace($this->parentParams, $params);
        }
        $params = $this->flattenParameters($params);

        $jobs = [];
        foreach ($params as $index => $param) {
            // Clone the config to prevent overwriting the placeholder(s) in endpoint
            $job = new static(
                clone $config,
                $this->client,
                $this->parser,
                $this->logger,
                $scroller,
                $this->attributes,
                $this->metadata,
                $this->compatLevel
            );
            $job->setParams($param);
            $job->setParentResults($parentResults);
            $jobs[] = $job;
        }
        return $jobs;
    }
243184
protected function dbalLoad(array $config, ContainerBuilder $container)
    {
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
        $loader->load('dbal.xml');

        if (empty($config['default_connection'])) {
            $keys                         = array_keys($config['connections']);
            $config['default_connection'] = reset($keys);
        }

        $this->defaultConnection = $config['default_connection'];

        $container->setAlias('database_connection', sprintf('doctrine.dbal.%s_connection', $this->defaultConnection));
        $container->getAlias('database_connection')->setPublic(true);
        $container->setAlias('doctrine.dbal.event_manager', new Alias(sprintf('doctrine.dbal.%s_connection.event_manager', $this->defaultConnection), false));

        $container->setParameter('doctrine.dbal.connection_factory.types', $config['types']);

        $connections = [];

        foreach (array_keys($config['connections']) as $name) {
            $connections[$name] = sprintf('doctrine.dbal.%s_connection', $name);
        }

        $container->setParameter('doctrine.connections', $connections);
        $container->setParameter('doctrine.default_connection', $this->defaultConnection);

        foreach ($config['connections'] as $name => $connection) {
            $this->loadDbalConnection($name, $connection, $container);
        }
    }
1148547
public function getFollowersIdList( $parentId, $config = [] ) {

	$type = $config[ 'type' ] ?? IFollower::TYPE_FOLLOW;

        return self::findList( [  'column' => 'modelId', 'conditions' => [ 'type' => $type, 'active' => true, 'parentId' => $parentId ] ] );
    }
192419
public function jobConfigurationProperties(
        $projectId,
        array $config,
        $location
    ) {
        $this->config = array_replace_recursive([
            'projectId' => $projectId,
            'jobReference' => ['projectId' => $projectId]
        ], $config);

        if ($location && !isset($this->config['jobReference']['location'])) {
            $this->config['jobReference']['location'] = $location;
        }

        if (!isset($this->config['jobReference']['jobId'])) {
            $this->config['jobReference']['jobId'] = $this->generateJobId();
        }
    }
86685
public function createByParams( $params = [], $config = [] ) {

		$parentId	= isset( $params[ 'parentId' ] ) ? $params[ 'parentId' ] : null;
		$parentType	= isset( $params[ 'parentType' ] ) ? $params[ 'parentType' ] : null;

		$title	= isset( $params[ 'title' ] ) ? $params[ 'title' ] : null;
		$token	= isset( $params[ 'token' ] ) ? $params[ 'token' ] : Yii::$app->security->generateRandomString();
		$type	= isset( $params[ 'type' ] ) ? $params[ 'type' ] : null;

		$user = Yii::$app->user->getIdentity();

		$cart = $this->getModelObject();

		$cart->title = $title;

		if( empty( $cart->title ) ) {

			$cart->generateName();
		}

		$cart->createdBy	= isset( $user ) ? $user->id : null;
		$cart->parentId		= $parentId;
		$cart->parentType	= $parentType;
		$cart->type			= $type;
		$cart->status		= Cart::STATUS_ACTIVE;
		$cart->token		= $token;

		$cart->save();

		return $cart;
	}
1053531
public function assignTo($parent, array $config = []) {
		foreach ($config as $key => $val) {
			$this->{'_' . $key} = $val;
		}
		$this->_parent =& $parent;
	}
665736
public static function setResponseDataRelationshipSelfLinks($propertyName, array &$mappings, array &$parent)
    {
        $data = [];
        $parentType = $parent[Serializer::CLASS_IDENTIFIER_KEY];

        if (\is_scalar($parentType) && !empty($mappings[$parentType])) {
            $copy = $parent;
            RecursiveFormatterHelper::formatScalarValues($copy);
            if (!empty($copy[Serializer::CLASS_IDENTIFIER_KEY])) {
                unset($copy[Serializer::CLASS_IDENTIFIER_KEY]);
            }

            $idProperties = array_keys($copy);
            foreach ($idProperties as &$property) {
                $property = sprintf('{%s}', $property);
            }
            $idValues = array_values($copy);

            if (!empty($mappings[$parentType]) && !empty($selfLink = $mappings[$parentType]->getRelationshipSelfUrl($propertyName))) {
                $url = self::buildUrl($mappings, $idProperties, $idValues, $selfLink, $parentType);

                if ($url !== $selfLink) {
                    $data[JsonApiTransformer::SELF_LINK][JsonApiTransformer::LINKS_HREF] = $url;
                }
            }
        }

        return $data;
    }
958228
public function findOrCreateChildJob($jobName, Job $rootJob)
    {
        if (!$jobName) {
            throw new \LogicException('Job name must not be empty');
        }

        $rootJob = $this->jobStorage->findJobById($rootJob->getId());
        $job = $this->jobStorage->findChildJobByName($jobName, $rootJob);

        if ($job) {
            return $job;
        }

        $job = $this->jobStorage->createJob();
        $job->setStatus(Job::STATUS_NEW);
        $job->setName($jobName);
        $job->setCreatedAt(new \DateTime());
        $job->setRootJob($rootJob);

        $this->saveJob($job);

        $this->sendCalculateRootJobStatusEvent($job);

        return $job;
    }
318983
private function getParams(JobConfig $jobConfig)
    {
        $params = [$this->pageParam => $this->page];
        if (!empty($this->limitParam) && !is_null($this->getLimit($jobConfig))) {
            $params[$this->limitParam] = $this->getLimit($jobConfig);
        }

        $config = $jobConfig->getConfig();
        $config['params'] = array_replace(
            $jobConfig->getParams(),
            $params
        );
        return $config;
    }
811552
public static function findByParent( $parentId, $parentType, $config = [] ) {

		return self::queryByParent( $parentId, $parentType, $config )->all();
	}
963592
public function newParentNames(string $child_name, string $parent_sex): array
    {
        if ($parent_sex === 'M' && preg_match(self::REGEX_SPFX_SURN, $child_name, $match)) {
            return array_filter([
                'NAME' => $match['NAME'],
                'SPFX' => $match['SPFX'],
                'SURN' => $match['SURN'],
            ]);
        }

        return [
            'NAME' => '//',
        ];
    }
325063
private function buildTree(array $parentEntities)
    {
        foreach ($parentEntities as $parentEntity) {
            if (isset($this->entityOverride[$parentEntity])) {
                $parentEntity = $this->entityOverride[$parentEntity];
            }

            $parentMeta = $this->metadata[$parentEntity];
            $parentConfiguration = $parentMeta->getConfiguration();

            foreach ($parentConfiguration['children'] as $key => $childEntity) {
                if (isset($this->entityOverride[$childEntity])) {
                    $childEntity = $this->entityOverride[$childEntity];
                }
                if (!isset($this->metadata[$childEntity])) {
                    unset($parentConfiguration['children'][$key]);

                    continue;
                }

                $childMeta = $this->metadata[$childEntity];
                $associated = false;

                foreach ($childMeta->getMappings() as $property => $mapping) {
                    if (!$childMeta->isAssociation($property)
                        || ($mapping['targetEntity'] !== $parentEntity && !in_array($mapping['targetEntity'], class_parents($parentEntity)))
                    ) {
                        continue;
                    }

                    $childMeta->setParent(new AssociatedMetadata($property, $parentMeta));
                    $parentMeta->addChild(new AssociatedMetadata($property, $childMeta));
                    $associated = true;

                    if (null !== $mapping['inversedBy']) {
                        break;
                    }
                }
                if (!$associated) {
                    throw new MetadataException(
                        sprintf('Entity "%s" is not associated with entity "%s".', $childEntity, $parentEntity)
                    );
                }
            }

            $this->buildTree($parentConfiguration['children']);
        }
    }
1079791
private function parseElementNodes($children, $parentName = null)
    {
        $result = [];

        foreach ($children as $child) {
            $prefix = $child->prefix ?: null;
            $oname  = $this->normalizeKey($child->nodeName);
            $name   = $this->prefixKey($oname, $prefix);

            if (isset($result[$name])) {
                $this->parseSetResultNodes($child, $name, $result);
                continue;
            }

            $this->parseUnsetResultNodes($child, $name, $oname, $parentName, $result, $prefix);
        }

        return $result;
    }
346983
public static function buildHttpQuery($data, ?string $parent = null): array
    {
        $result = [];

        if (is_object($data)) {
            $data = get_object_vars($data);
        }

        foreach ($data as $key => $value) {
            if ($parent) {
                $new_key = sprintf('%s[%s]', $parent, $key);
            } else {
                $new_key = $key;
            }

            if (!$value instanceof CURLFile && (is_array($value) || is_object($value))) {
                $result = array_merge($result, self::buildHttpQuery($value, $new_key));
            } else {
                $result[$new_key] = $value;
            }
        }

        return $result;
    }
1366567
public function create(CreateStruct $createStruct, array $parentTag = null)
    {
        try {
            return $this->innerGateway->create($createStruct, $parentTag);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
464373
public function createWithParent( $parent, $config = [] ) {

		$modelClass	= static::$modelClass;

		$parentId	= $config[ 'parentId' ];
		$parentType	= $config[ 'parentType' ];
		$type		= isset( $config[ 'type' ] ) ? $config[ 'type' ] : $parent->type;
		$order		= isset( $config[ 'order' ] ) ? $config[ 'order' ] : 0;

		$file = null;

		switch( $parent->type ) {

			case 'image': {

				$file = $this->fileService->saveImage( $parent );
			}
			// TODO: Add case to save cross-browser compatible videos
			default: {

				$file = $this->fileService->saveFile( $parent );
			}
		}

		$model = new $modelClass;

		$model->modelId		= $file->id;
		$model->parentId	= $parentId;
		$model->parentType	= $parentType;

		$model->type	= $type;
		$model->order	= $order;
		$model->active	= true;

		return parent::create( $model );
	}
283876
protected function buildDataJoinsMany(ConfigInterface $config, array $joinKeys)
    {
        //~ Search for keys
        $keys = '';
        $joinKeys = array_flip($joinKeys);
        foreach ($this->columns as $column) {
            if (!isset($joinKeys[$column->getName()])) {
                continue;
            }

            $keys .= '
            $mapper->addWhere(\'' . $column->getName() . '\', $this->' . $column->getMethodNameGet() .'());';
        }

        if (empty($keys)) {
            throw new \LogicException('Empty keys list for join all method !');
        }

        $propertyCacheName = 'joinManyCache' . $config->getClassname();
        $this->vars['properties'] .= '

    /**
     * @var ' . $config->getClassname() . '[] $' . $propertyCacheName . '
     */
     protected $' . $propertyCacheName . ' = null;';

        //~ Generate method
        return '
    /**
     * Get list of ' . $config->getClassname() . ' data objects.
     *
     * @param  bool $isForceReload
     * @return ' . $config->getClassname() . '[]
     */
    public function getAll' . $config->getClassname() . '($isForceReload = false)
    {
        if ($isForceReload || null === $this->' . $propertyCacheName . ') {
            $mapper = new ' . $config->getClassname() . 'Mapper($this->dependencyContainer->getDatabase(\'' . $config->getDbConfig() . '\'));' .
            $keys . '

            $this->' . $propertyCacheName . ' = $mapper->select();
        }
        
        return $this->' . $propertyCacheName . ';
    }
';
    }