Returns all relations where parentId is in the param array
161945
public function findHierarchiesByParents(User $user, array $parents)
    {
        if (count($parents) === 0) {
            throw new \InvalidArgumentException('Array argument cannot be empty');
        }

        $index = 0;
        $eol = PHP_EOL;
        $parentsTest = '(';

        foreach ($parents as $parent) {
            $parentsTest .= $index > 0 ? '    OR ' : '    ';
            $parentsTest .= "p.id = {$parent}{$eol}";
            $index++;
        }
        $parentsTest .= "){$eol}";

        $dql = "
            SELECT h
            FROM Claroline\CoreBundle\Entity\Workspace\WorkspaceTagHierarchy h
            JOIN h.parent p
            WHERE h.user = :user
            AND {$parentsTest}
        ";
        $query = $this->_em->createQuery($dql);
        $query->setParameter('user', $user);

        return $query->getResult();
    }
384757
def find_all_entities(ids_or_names, parent)
      keys = ids_or_names.map { |id| CloudDatastore.dataset.key name, id }
      keys.map { |key| key.parent = parent } if parent.present?
      retry_on_exception { CloudDatastore.dataset.find_all keys }
    end
15226
private function filterParents(\stdClass $params, ApiInterface $entity) {
        $parents = array();
        foreach($params as $key => $value) {
            if(is_object($value) && get_class($value) == 'stdClass') {
                $alias = ucfirst($key);
                if(in_array($alias, $entity->getParentRelationships())) {
                    $parents[$alias] = $value;
                } else {
                    throw new Exception('Could not find the parent field: ' . $key, 400);
                }
            }
        }
        return $parents;
    }
1337960
public function findChildrenByParentId($parent_id)
    {
        $qb = $this->createQueryBuilder();
        $qb->andWhere($qb->getRootAliases()[0] . '.parent = ' . $this->addNamedParameter('parent', $parent_id, $qb))
            ->orderBy($qb->getRootAliases()[0] . '.position', 'ASC');
        return $qb->getQuery()->getResult();
    }
498273
function inheritParams(currentParams, newParams, $current, $to) {
  var parents = ancestors($current, $to), parentParams, inherited = {}, inheritList = [];

  for (var i in parents) {
    if (!parents[i].params) continue;
    // This test allows compatibility with 0.2.x and 0.3.x (optional and object params)
    parentParams = isArray(parents[i].params) ? parents[i].params : objectKeys(parents[i].params);
    if (!parentParams.length) continue;

    for (var j in parentParams) {
      if (arraySearch(inheritList, parentParams[j]) >= 0) continue;
      inheritList.push(parentParams[j]);
      inherited[parentParams[j]] = currentParams[parentParams[j]];
    }
  }
  return extend({}, inherited, newParams);
}
654894
def parents(self, id, level=None, featuretype=None, order_by=None,
                reverse=False, completely_within=False, limit=None):
        
        return self._relation(
            id, join_on='parent', join_to='child', level=level,
            featuretype=featuretype, order_by=order_by, reverse=reverse,
            limit=limit, completely_within=completely_within)
130907
public static function getUrlsByParentId($isSuper, $menuIdList, $parentId, $condition = '', $params = [], $order = 'display_order asc')
    {
        $data = static::find()
            ->normal()
            ->findByParentId($parentId)
            ->andWhere($condition, $params)
            ->active()
            ->orderBy($order)
            ->asArray()
            ->all();
        $urls = [];
        if ($data) {
            foreach ($data as $item) {
                if ($isSuper || in_array($item['menu_id'], $menuIdList)) {
                    $menuUrls = DpAdminMenuUrlRelation::getAllUrlByMenuId($item['menu_id']);
                    if ($menuUrls) {
                        foreach ($menuUrls as $menuUrl) {
                            $urls[$menuUrl['alias']] = Url::toRoute($menuUrl['route']);
                        }
                    }
                    $childrenUrls = static::getUrlsByParentId($isSuper, $menuIdList, $item['menu_id'], $condition, $params, $order);
                    if ($childrenUrls) {
                        $urls = array_merge($urls, $childrenUrls);
                    }
                }
            }
        }

        return $urls;
    }
938464
public static function flattenParams($params, $parentKey = null)
    {
        $result = [];

        foreach ($params as $key => $value) {
            $calculatedKey = $parentKey ? "{$parentKey}[{$key}]" : $key;

            if (self::isList($value)) {
                $result = array_merge($result, self::flattenParamsList($value, $calculatedKey));
            } elseif (is_array($value)) {
                $result = array_merge($result, self::flattenParams($value, $calculatedKey));
            } else {
                array_push($result, [$calculatedKey, $value]);
            }
        }

        return $result;
    }
651216
private function getChildIds($parentIds)
    {
        $qb = $this->createQueryBuilder('roleHierarchy');

        $qb->select('roleHierarchy.childRoleId')
            ->where($qb->expr()->in( 'roleHierarchy.parentRoleId', $parentIds))
            ->indexBy('roleHierarchy', 'roleHierarchy.childRoleId');

        $childRoleIds =  $qb->getQuery()->getArrayResult();

        return array_keys($childRoleIds);
    }
800304
protected function hasOneOrManyDeepFromRelations(array $relations)
    {
        if (is_array($relations[0])) {
            $relations = $relations[0];
        }

        $related = null;
        $through = [];
        $foreignKeys = [];
        $localKeys = [];

        foreach ($relations as $i => $relation) {
            $method = $this->hasOneOrManyDeepRelationMethod($relation);

            [$through, $foreignKeys, $localKeys] = $this->$method($relation, $through, $foreignKeys, $localKeys);

            if ($i === count($relations) - 1) {
                $related = get_class($relation->getRelated());
            } else {
                $through[] = get_class($relation->getRelated());
            }
        }

        return [$related, $through, $foreignKeys, $localKeys];
    }
740380
public function getParents($id)
    {
        $nodes = [];
        $tree = array_column($this->_tree, null, 'id');//var_dump($tree);exit;
        foreach ($tree as $key => $value) {
            if ($tree[$id][$this->_parentSign] == $value['id']) {
                $nodes[] = $value;
            }
        }
        return $nodes;
    }
1235594
public function getParent($parentId)
    {
        if ($parentId && isset($this->site->pages[$parentId])) {
            return $this->site->pages[$parentId];
        }

        return [];
    }
803016
private function parentRelation()
    {
        if ($this->parent && method_exists($this->parent, $this->parent_to_self)) {
            return $this->parent->{$this->parent_to_self}();
        }

        return false;
    }
1147175
private function parseLinks(
        SchemaInterface $parentSchema,
        $parentData,
        string $relationshipName,
        iterable $schemaLinks,
        bool $addSelfLink,
        bool $addRelatedLink
    ): iterable {
        $gotSelf    = false;
        $gotRelated = false;

        foreach ($schemaLinks as $name => $link) {
            \assert($link instanceof LinkInterface);
            if ($name === LinkInterface::SELF) {
                \assert($gotSelf === false);
                $gotSelf     = true;
                $addSelfLink = false;
            } elseif ($name === LinkInterface::RELATED) {
                \assert($gotRelated === false);
                $gotRelated     = true;
                $addRelatedLink = false;
            }

            yield $name => $link;
        }

        if ($addSelfLink === true) {
            $link = $parentSchema->getRelationshipSelfLink($parentData, $relationshipName);
            yield LinkInterface::SELF => $link;
            $gotSelf = true;
        }
        if ($addRelatedLink === true) {
            $link = $parentSchema->getRelationshipRelatedLink($parentData, $relationshipName);
            yield LinkInterface::RELATED => $link;
            $gotRelated = true;
        }

        // spec: check links has at least one of the following: self or related
        \assert($gotSelf || $gotRelated);
    }
294157
public static function _getRelation ($obj, $path, $params = array ())
	{
		
		foreach ($path as $class => $name)
		{
			
			$class		= get_class ($obj);
			$childClass	= $class::$attributes[$name]['relation'];
			
			if ($obj->iget ($name))
			{
				$params['where'][]	= array ($childClass::$pk, $obj->iget ($name));
				$obj	= $childClass::_Read ($params);
			}
			else
			{
				return FALSE;
			}
			
		}
		
		return $obj;
		
	}
1249670
private function getDeletionPreventingParents() {
        $parentEntities = array();
        foreach($this->getModelBuilder()->getRelationships() as $relationship) {
            if($relationship->isPlural() && !$relationship->isNullable() && $relationship->getAction() != 'ACTION_CASCADE') {
                $parentEntities[] = $relationship->getAlias();
            }
        }

        return $parentEntities;
    }
336386
public function getAllParents(array $options = []): array
    {
        $options = array_replace(
            [
                'indexById'     => false,
                'skipIds'       => []
            ],
            $options
        );
        $parents = [];
        $ids = [$this->getId()];

        /** @var NodeInterface $parent */
        foreach ($this->getParents() as $id => $parent) {
            if (in_array($id, $options['skipIds'])) {
                continue;
            }

            $ids[] = $id;

            if ($options['indexById']) {
                $parents[$id] = $parent;
            } else {
                $parents[] = $parent;
            }

            $parents = array_merge(
                $parents,
                $parent->getAllParents(array_merge($options, ['skipIds' => $ids]))
            );
        }

        return $parents;
    }