Возвращает список имен коллекций, которые будут затронуты при изменении порядка в иерархии.
@param IHierarchicObject|null $branch ветка, в которой происходит изменение, null в случае перемещения в корне
@return IHierarchicCollection[]
972567
protected function getCollectionsForChangingOrder(IHierarchicObject $branch = null)
    {

        $typeColumnName = $this
            ->getObjectTypeField()
            ->getColumnName();
        $parentField = $this->getParentField();

        /**
         * @var $selectBuilder ISelectBuilder
         */
        $selectBuilder = $this
            ->getMetadata()
            ->getCollectionDataSource()
            ->select($typeColumnName);
        $selectBuilder->groupBy($typeColumnName);

        if ($branch) {
            $selectBuilder
                ->where()
                ->expr($parentField->getColumnName(), '=', ':' . $parentField->getName())
                ->bindValue(':' . $parentField->getName(), $branch->getId(), $parentField->getDataType());
        } else {
            $selectBuilder
                ->where()
                ->expr($parentField->getColumnName(), 'IS', ':' . $parentField->getName())
                ->bindNull(':' . $parentField->getName());
        }

        $result = $selectBuilder->execute();

        $collections = [];

        while (null != ($row = $result->fetch())) {
            $typeInfo = $row[$typeColumnName];
            if (0 != ($pos = strpos($typeInfo, IObjectType::PATH_SEPARATOR))) {
                $collectionName = substr($typeInfo, 0, $pos);
                $collections[$collectionName] = $this
                    ->getCollectionManager()
                    ->getCollection($collectionName);
            }
        }

        if (count($collections)) {
            $collections[$this->getName()] = $this;
        }

        return $collections;
    }
663701
protected function copyBranch($branch, $parentId) {
        $Model = $this->Model;

        $copy = new $Model($branch->attributesToArray());
        $copy->parentId = $parentId;
        $copy->save();
        $parentId = $copy->id;

        foreach ( $branch->children as $child ) {
            $this->copyBranch($child, $parentId);
        }

        return $copy;
    }
944827
public function getMembershipData() {
    // @todo fix cache life time.
    $cid = __METHOD__;
    if ($cache = $this->cacheBackend->get($cid)) {
      $data = $cache->data;
    }
    else {
      $data = [];

      $daxko_branch_ids = $this->locationRepo->getAllDaxkoBranchIds();
      foreach ($daxko_branch_ids as $branch_id) {
        $data[$branch_id] = $this->daxkoClient->getMembershipTypes(['branch_id' => $branch_id]);
      }

      $this->cacheBackend->set($cid, $data);
    }

    return $data;
  }
352548
public function findBranchByNodeId(Branch $tree, $nodeId)
    {
        foreach ($tree->getChildren() as $branch) {
            if ($branch->getNodeId() == $nodeId) {
                return $branch;
            }

            // recursive search:
            $branch = $this->findBranchByNodeId($branch, $nodeId);
            if ($branch) {
                return $branch;
            }
        }

        return null;
    }
1318819
protected function getPlacesHierarchyFromHeader() {
        $head = GedcomRecord::getInstance('HEAD', $this->tree);
        $head_place = $head->getFirstFact('PLAC');
        if($head_place && $head_place_value = $head_place->getAttribute('FORM')){
            return array_reverse(array_map('trim',explode(',', $head_place_value)));
        }
        return null;
    }
890007
protected function serializeBranch(array $branch)
	{
		// Optimize away "else{}" completely
		if ($branch['structure'] === 'else'
		 && $branch['body']      === ''
		 && empty($branch['head'])
		 && empty($branch['tail']))
		{
			return '';
		}

		return $branch['structure'] . '{' . $this->serializeOutput($branch['head']) . $branch['body'] . $this->serializeOutput(array_reverse($branch['tail'])) . '}';
	}
452490
function jsonSerialize(): \stdClass {
    return (object) [
      'sourceFile' => $this->getSourceFile(),
      'branches' => ($branches = $this->getBranches()) ? $branches->jsonSerialize() : null,
      'functions' => ($functions = $this->getFunctions()) ? $functions->jsonSerialize() : null,
      'lines' => ($lines = $this->getLines()) ? $lines->jsonSerialize() : null
    ];
  }
1338135
protected function _getSubTree(Model $model, $id = null) {
		$result = [];
		$parentField = $this->_getBehaviorConfig($model, 'parent');
		$leftField = $this->_getBehaviorConfig($model, 'left');
		if (($parentField === null) || ($leftField === null)) {
			return $result;
		}

		$conditions = [
			$model->alias . '.' . $parentField => null
		];
		if (!empty($id)) {
			$conditions[$model->alias . '.' . $parentField] = (int)$id;
		}
		if ($model->Behaviors->Tree->settings[$model->alias]['scope'] !== '1 = 1') {
			$conditions[] = $model->Behaviors->Tree->settings[$model->alias]['scope'];
		}

		$fields = [
			$model->alias . '.' . $model->primaryKey,
		];
		$order = [
			$model->alias . '.' . $leftField => 'asc'
		];
		$model->recursive = -1;
		$data = $model->find('list', compact('conditions', 'fields', 'order'));
		if (!empty($data)) {
			$result = array_keys($data);
		}

		return $result;
	}
1266456
public function getProgramsByBranchAndCategory($branch_id, $category) {
    $cid = __METHOD__ . $branch_id . md5($category);
    if ($cache = $this->cache->get($cid)) {
      return $cache->data;
    }

    $params = [
      'branch' => $branch_id,
      'tag' => $category,
    ];

    $data = [];
    $result = $this->client->getSessions($params);
    foreach ($result as $item) {
      $program = new \stdClass();
      $program->id = $item->programId;
      $program->name = $item->programName;
      $data[] = $program;
    }

    $this->cache->set($cid, $data);
    return $data;
  }
1061501
protected function collectBranch()
    {
        $branchesResult = $this->command->getBranches();

        foreach ($branchesResult as $result) {
            if (strpos($result, '* ') === 0) {
                $exploded = explode('* ', $result, 2);

                return $exploded[1];
            }
        }

        throw new \RuntimeException();
    }
816475
public function getBranches($which = self::BRANCHES_LOCAL)
    {
        $which       = (int)$which;
        $arguments  = array(
            '--no-color'
        );

        $local  = (($which & self::BRANCHES_LOCAL) == self::BRANCHES_LOCAL);
        $remote = (($which & self::BRANCHES_REMOTE) == self::BRANCHES_REMOTE);

        if ($local && $remote) {
            $arguments[] = '-a';
        } else if ($remote) {
            $arguments[] = '-r';
        }

        /** @var $result CallResult */
        $result = $this->getGit()->{'branch'}($this->getRepositoryPath(), $arguments);
        $result->assertSuccess(
            sprintf('Cannot retrieve branch from "%s"', $this->getRepositoryPath())
        );

        $output = rtrim($result->getStdOut());
        if (empty($output)) {
            return array();
        }

        $branches = array_map(function($b) {
            $line   = rtrim($b);
            if (strpos($line, '* ') === 0) {
                $line   = substr($line, 2);
            }
            $line   = ltrim($line);
            return $line;
        }, explode("\n", $output));
        return $branches;
    }
357098
protected function getValuesPerCodeBranch()
	{
		$values = [];
		foreach ($this->branchesCode as $value => $branchCode)
		{
			$values[$branchCode][] = $value;
		}

		return $values;
	}
604382
def branches(self):
        """"""
        return [(r['name'], self.vpathto(r['name'])) for r in self.remotes if r['kind'] == 'heads']
272377
public static function getHierarchySiblings($code)
    {
        if ($code === '') {
            return [];
        }

        $parent = static::getHierarchyParent($code);
        $hierarchyField = static::getHierarchyField();
        return static::query()->whereStartsWith($hierarchyField, $parent, strlen($code))->values($hierarchyField);
    }
731195
protected static function getOrganizationRoles(OrganizationInterface $organization, $roleHierarchy = null)
    {
        $roles = [];

        if ($organization instanceof RoleableInterface && $organization instanceof OrganizationInterface) {
            $roles = self::buildOrganizationRoles([], $organization);

            if ($roleHierarchy instanceof RoleHierarchyInterface) {
                $roles = RoleUtil::formatNames($roleHierarchy->getReachableRoles($roles));
            }
        }

        return $roles;
    }
426789
public function listBranches(): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/branches', $this->getOwner(),
            $this->getRepo()));
    }
943655
public function getMainBranch()
    {
        $filtered = array_filter(
            $this->getBranches(),
            function (Branch $branch) {
                return $branch->getCurrent();
            }
        );
        sort($filtered);

        return $filtered[0];
    }