Поиск рубрик
@param int $regionId
@param int $parentId
@param string $sort
@param string[] $additionalFields
@link http://api.2gis.ru/doc/2.0/catalog/rubric/list
@return Rubric[]
180392
public function getRubricList($regionId, $parentId = 0, $sort = self::SORT_NAME, array $additionalFields = array())
    {
        return $this->getInternalList(
            'catalog/rubric/list',
            'Rubric',
            array(
                'region_id' => (int)$regionId,
                'parent_id' => (int)$parentId,
                'sort' => $sort,
                'fields' => self::getArray($additionalFields),
            )
        );
    }
164064
protected function siblings($direction = '', $parentId = false, $order = 'asc')
    {
        $parentId = ($parentId === false ? $this->parent_id : $parentId);

        /**
         * @var QueryBuilder $query
         */
        $query = $this->where($this->getParentIdColumn(), '=', $parentId);

        $column = $this->getPositionColumn();

        switch ($direction) {
            case static::QUERY_ALL:
                $query->where($column, '<>', $this->position)->orderBy($column, $order);
                break;

            case static::QUERY_PREV_ALL:
                $query->where($column, '<', $this->position)->orderBy($column, $order);
                break;

            case static::QUERY_PREV_ONE:
                $query->where($column, '=', $this->position - 1);
                break;

            case static::QUERY_NEXT_ALL:
                $query->where($column, '>', $this->position)->orderBy($column, $order);
                break;

            case static::QUERY_NEXT_ONE:
                $query->where($column, '=', $this->position + 1);
                break;

            case static::QUERY_NEIGHBORS:
                $query->whereIn($column, [$this->position - 1, $this->position + 1]);
                break;

            case static::QUERY_LAST:
                $query->orderBy($column, 'desc');
                break;
        }

        if (is_int($direction)) {
            $query->where($column, '=', $direction);
        } else if (is_array($direction)) {
            $query->buildWherePosition($this->getPositionColumn(), $direction);
        }

        return $query;
    }
782347
public function geoList(
        $regionId,
        $type = array(),
        $page = null,
        $pageSize = null,
        array $additionalFields = array()
    ) {
        return $this->getInternalList(
            'geo/list',
            array(__NAMESPACE__ . '\Mappers\Geo\GeoObject', 'geoMapResolver'),
            array(
                'region_id' => $regionId,
                'type' => self::getArray($type),
                'page' => $page,
                'page_size' => $pageSize,
                'fields' => self::getArray($additionalFields),
            )
        );
    }
1125781
private function getParentsIdRec($id, $className, $primaryKey, $parentIdField)
    {
        $parentId = (int)$className::find()->select($parentIdField)->where([ $primaryKey => $id ])->scalar();
        if ( $parentId ) {
            return array_merge(self::getParentsIdRec($parentId, $className, $primaryKey, $parentIdField), [$id]);
        } else {
            return [$id];
        }
    }
1139884
private function getAdditionalRoutes(array &$sortArr)
    {
        $additionalRoutes = [];
        $event = new HomepageRenderEvent();
        $routes = $this->eventDispatcher->dispatch(HomepageRenderEvent::EVENT_NAME, $event)->getRoutes();

        if (!empty($routes)) {
            $baseRoute = $this->router->match("/");
            $baseUrl = $this->router->generate($baseRoute['_route'], [], UrlGeneratorInterface::ABSOLUTE_URL);
            foreach ($routes as $route) {
                $thisUrl = $baseUrl.$route['$ref'];
                $additionalRoutes[] = [
                    '$ref' => $thisUrl,
                    'profile' => $baseUrl.$route['profile']
                ];
                $sortArr[$thisUrl] = $thisUrl;
            }
        }

        return $additionalRoutes;
    }
1014463
public function get_question_categories($parent=null, $sort="sortorder ASC") {
        global $COURSE, $DB;
        if (is_null($parent)) {
            $categories = $DB->get_records('question_categories', array('course' => $COURSE->id), $sort);
        } else {
            $select = "parent = ? AND course = ?";
            $categories = $DB->get_records_select('question_categories', $select, array($parent, $COURSE->id), $sort);
        }
        return $categories;
    }
1235594
public function getParent($parentId)
    {
        if ($parentId && isset($this->site->pages[$parentId])) {
            return $this->site->pages[$parentId];
        }

        return [];
    }
1050943
public function getDocuments($orderId, $locale)
    {
        $documents = array();
        /** @var SalesDependencyClassInterface $dependency */
        foreach ($this->dependencyClasses as $dependency) {
            // add to documents array
            $documents = array_merge($documents, $dependency->getDocuments($orderId, $locale));
        }

        return $documents;
    }
761781
public function sortAlphabetically($parentId = false, $direction = SORT_ASC)
    {
        $query = call_user_func("$this->ownerClassName::find")
            ->select($this->primaryKey)
            ->orderBy([ $this->titleField => $direction ]);
        if ( $parentId !== false ) {
            $query->where([ $this->parentIdField => $parentId ]);
        }
        $data = array_map('intval', $query->column());
        foreach ( $data as $i => $id ) {
            call_user_func("$this->ownerClassName::updateAll",
                [ $this->sortField => ($i + 1) * 100 ],
                [ $this->primaryKey => $id ]);
        }
        $this->invalidateTagDependency();
    }
768689
public static function findChild( $parentId, $parentType, $childId ) {

		return self::find()->where( 'parentId=:pid AND parentType=:type AND childId=:cid', [ ':pid' => $parentId, ':type' => $parentType, ':cid' => $childId ] )->one();
	}
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);
    }
499786
public function deleteByParent( $parentId, $parentType ) {

		//$modelClass	= static::$modelClass;

		//return $modelClass::deleteByParent( $parentId, $parentType );

		$models	= $this->getByParent( $parentId, $parentType );

		foreach ( $models as $model ) {

			$this->delete( $model );
		}
	}
1310513
protected function getLowerRoles(array $elements, $parentId = 0, &$return = [])
    {
        foreach ($elements as $element) {
            if ($element['parent_id'] != $parentId) {
                continue;
            }
            $children = $this->getLowerRoles($elements, $element['id'], $return);
            if ($children) {
                foreach ($children as $child) {
                    $return[] = $child['id'];
                }
            }
            $return[] = $element['id'];
        }

        return array_filter($return);
    }
1100492
public function getListByIds($ids, array $additionalFields = array())
    {
        return $this->getInternalList(
            'region/get',
            'Region',
            array(
                'id' => self::getArray($ids),
                'fields' => self::getArray($additionalFields)
            )
        );
    }
75344
public function move($fileIDs, $parentID)
    {
        if (is_array($fileIDs)) {
            $fileIDs = implode(',', $fileIDs);
        }

        $data = [
            'file_ids'  => $fileIDs,
            'parent_id' => $parentID
        ];

        return $this->post('files/move', $data, \true);
    }
1375052
public function getNameValueMapByType( $parentId, $parentType, $type ) {

		$config = [];

		$config[ 'conditions' ][ 'parentId' ]	= $parentId;
		$config[ 'conditions' ][ 'parentType' ] = $parentType;
		$config[ 'conditions' ][ 'type' ]		= $type;

		return $this->getNameValueMap( $config );
	}
724352
public function createFromArray( $parentId, $parentType, $tags ) {

		foreach( $tags as $tagName ) {

			$tagName = trim( $tagName );

			if( empty( $tagName ) ) {

				continue;
			}

			$tag = $this->tagService->getFirstByNameType( $tagName, $parentType );

			if( !isset( $tag ) ) {

				$tag = $this->tagService->createByParams( [ 'siteId' => Yii::$app->core->siteId, 'name' => ucfirst( $tagName ), 'type' => $parentType ] );
			}

			$modelTag = $this->getFirstByParentModelId( $parentId, $parentType, $tag->id );

			// Create if does not exist
			if( empty( $modelTag ) ) {

				$this->createByParams( [ 'modelId' => $tag->id, 'parentId' => $parentId, 'parentType' => $parentType, 'order' => 0, 'active' => true ] );
			}
			// Activate if already exist
			else {

				$this->activate( $modelTag );
			}
		}
	}