Returns related entries from an element limited to a section.

@param ElementInterface $element
@param Section $section
@param string $field

@return Entry[]
320527
public function getRelatedEntries(ElementInterface $element, Section $section, string $field): array
    {
        $query = Entry::find();

        $query->section = $section;
        $query->limit = null;
        $query->status = null;
        $query->enabledForSite = null;
        $query->relatedTo = [
            'targetElement' => $element,
            'field' => $field,
        ];

        return $query->all();
    }
760884
private function findSibling(Collection $elements, SortableInterface $current, $next = false)
    {
        if ($next) {
            $sibling = $elements->filter(function (SortableInterface $s) use ($current) {
                return $s->getPosition() > $current->getPosition();
            })->first();
        } else {
            $sibling = $elements->filter(function (SortableInterface $s) use ($current) {
                return $s->getPosition() < $current->getPosition();
            })->last();
        }

        return $sibling ?: null;
    }
307908
public Record []
getSectionArray(int section) {
	if (sections[section] == null)
		return emptyRecordArray;
	List l = sections[section];
	return (Record []) l.toArray(new Record[l.size()]);
}
1254838
public function getEntries( $section )
	{
		if( !isset( $this->list[$section] ) )
			throw new InvalidArgumentException( 'Invalid Section "'.$section.'".' );
		return array_values( $this->list[$section] );
	}
37534
private function parseSectionFromHeaderAndItemAsArray(
        array $header,
        string $section,
        array $item
    ) {
        return array_intersect_key(
            $item,
            array_flip($header[$section] ?? [])
        );
    }
718518
public function getEntryById(string $sectionHandle, string $id): JsonResponse
    {
        $request = $this->requestStack->getCurrentRequest();

        $optionsResponse = $this->preFlightOptions($request, self::ALLOWED_HTTP_METHODS);
        if ($optionsResponse) {
            return $optionsResponse;
        }

        $this->dispatcher->dispatch(
            ApiFetchEntry::NAME,
            new ApiFetchEntry($request, $sectionHandle)
        );

        if ($abort = $this->shouldAbort($request)) {
            return $abort;
        }

        try {
            $section = $this->sectionManager->readByHandle(Handle::fromString($sectionHandle));

            try {
                $this->cache->start(
                    $section->getConfig()->getFullyQualifiedClassName(),
                    $this->getFields(),
                    self::CACHE_CONTEXT_GET_ENTRY_BY_ID,
                    $id
                );
            } catch (\Psr\Cache\InvalidArgumentException $exception) {
                //
            }

            if ($this->cache->isHit()) {
                return new JsonResponse(
                    $this->cache->get(),
                    JsonResponse::HTTP_OK,
                    $this->getDefaultResponseHeaders($request)
                );
            }

            $entry = $this->readSection->read(ReadOptions::fromArray([
                ReadOptions::SECTION => $sectionHandle,
                ReadOptions::ID => (int)$id
            ]))->current();

            $responseData = $this->serialize->toArray($request, $entry);
            $jsonResponse = new JsonResponse(
                $responseData,
                JsonResponse::HTTP_OK,
                $this->getDefaultResponseHeaders($request)
            );

            $this->dispatcher->dispatch(
                ApiEntryFetched::NAME,
                new ApiEntryFetched($request, $responseData, $jsonResponse, $entry)
            );

            if ($abort = $this->shouldAbort($request)) {
                return $abort;
            }

            $this->cache->set($responseData);

            return $jsonResponse;
        } catch (\Exception $exception) {
            return $this->errorResponse($request, $exception);
        }
    }
994227
protected function setExcluded(SectionInterface $section, array $definition)
    {
        if (isset($definition[static::CONFIG_EXCLUDED]) && $definition[static::CONFIG_EXCLUDED]) {
            $section->markAsExcluded();
        }
    }
621960
public static function getSectionMediaElements($key = null) {
		if(!is_null($key)) {
			return self::$_sectionMedia[$key];
		} else {
			$arrImages = self::$_sectionMedia['images'];
			$arrObjects = self::$_sectionMedia['embeddings'];
			$arrLinks = self::$_sectionMedia['links'];
			return array_merge($arrImages, $arrObjects, $arrLinks);
		}
	}
360240
private function getSectionsNumbers(array $sections): array
    {
        $sectionsNumbers = array_column($sections, 'id');

        return array_combine($sectionsNumbers, array_fill_keys($sectionsNumbers, false));
    }
643219
public function validateSections(ElementInterface $element)
	{
		$value = $element->getFieldValue($this->handle);

		if (!is_array($value)) {
			$value = [$value];
		}

		$sections = $this->getSections();

		foreach ($value as $section) {
			if (!isset($sections[$section])) {
				$element->addError($this->handle, Craft::t('section-field', 'Invalid section selected.'));
			}
		}
	}
1312451
public function getSection($section, $default = '')
    {
        $context = $this->_context;

        if (isset($context->sections[$section])) {
            return $context->sections[$section];
        } else {
            return $default;
        }
    }
184663
function fetchSectionObject( $sectionID = false, $sectionIdentifier = false )
    {
        if( $sectionID !== false )
        {
            if( $sectionIdentifier !== false )
            {
                $sectionObject = null;
            }
            else
            {
                $sectionObject = eZSection::fetch( $sectionID );
            }
        }
        else
        {
            if( $sectionIdentifier === false )
            {
                $sectionObject = null;
            }
            else
            {
                $sectionObject = eZSection::fetchByIdentifier( $sectionIdentifier );
            }
        }
        if ( $sectionObject === null )
            return array( 'error' => array( 'error_type' => 'kernel',
                                            'error_code' => eZError::KERNEL_NOT_FOUND ) );
        return array( 'result' => $sectionObject );
    }
1278420
public function getTags($id = false, array $array = [], $section, $modelClass = __CLASS__)
    {
        $tags = [$section, $modelClass];

        if ($id) {
            $tags[] = $modelClass . 'id' . $id;
        }

        if ($array) {
            foreach ($array as $relation) {
                $tags[] = $relation;
            }
        }

        return $tags;
    }
75983
public function getFieldsWithoutSection()
    {
        $matchedFields = array();
        foreach ($this->fields as $fieldName => $field) {
            if (!isset($field['options']['section']) || $field['options']['section'] === null || $field['options']['section'] === '') {
                $matchedFields[$fieldName] = $field;
            }
        }

        return $matchedFields;
    }
1004775
private function setSelectedRelationshipsTo(
        string $sectionHandle,
        string $fieldHandle,
        array $fieldInfo,
        int $id
    ): array {
        /** @var CommonSectionInterface $editing */
        $editing = $this->readSection->read(
            ReadOptions::fromArray([
                ReadOptions::SECTION => $sectionHandle,
                ReadOptions::ID => (int)$id
            ])
        )->current();

        try {
            $method = $this->handleToPropertyName($fieldHandle, $editing::FIELDS);
            $relationshipsEntityMethod = 'get' . ucfirst($method);
            $related = $editing->{$relationshipsEntityMethod}();
            if (!is_null($related)) {
                $relatedIds = [];
                if (is_iterable($related)) {
                    /** @var CommonSectionInterface $relation */
                    foreach ($related as $relation) {
                        $relatedIds[] = $relation->getId();
                    }
                } else {
                    $relatedIds[] = $related->getId();
                }
                foreach ($fieldInfo[$fieldHandle][$fieldInfo[$fieldHandle]['to']] as &$relatable) {
                    if (!empty($relatable['id']) && in_array($relatable['id'], $relatedIds)) {
                        $relatable['selected'] = true;
                    }
                }
            }
        } catch (\Exception $exception) {
            // Empty because we can just return the fieldInfo the way it was if the above fails
        }

        return $fieldInfo;
    }
888236
public static function getEntryByHandle($element)
    {
        $section = Craft::$app->sections->getSectionByHandle($element['section']);
        if ($section) {

            $query = Entry::find();
            $query->sectionId($section->id);
            $query->slug($element['slug']);
            $entry = $query->one();

            if ($entry) {
                return $entry;
            }
        }

        return false;
    }
105967
public function findSection($name, Section $parent = null)
    {
        if (is_null($parent)) {
            $parent = $this->getRootSection();
        }

        return $parent->findSection($name);
    }