Returns active parent for current context.

@return null|false|array  associative: 'relation', 'key'; false for disabled filter; null for default/unset
161041
public function getListParent()
    {
        $parent = session()->get($this->getSessionKey(static::TYPE_PARENT));

        if (null === $parent) {
            return null;
        }

        if (static::PARENT_DISABLE === $parent) {
            return false;
        }

        list($relation, $key) = explode(':', $parent, 2);

        return compact('relation', 'key');
    }
1006986
public function getFolderParent()
    {
        if ($this->isRootFolder()) {
            return null;
        }

        $parents = $this->getParents($this->getSession()->getDefaultContext());

        // return the first element of the array
        $parent = reset($parents);

        if (!$parent instanceof FolderInterface) {
            return null;
        }

        return $parent;
    }
428832
public  function getParents(){
         $class = get_called_class();
         $meta = $class::getMetadata(); 
         $path = $this->{$meta['pathfield']};
         $ap = str_split($path,8);
         array_pop($ap);
         if(count($ap)==0){
             return array();
         }
         $ids = implode(",",$ap) ;
         $where = $meta["keyfield"] . " in (".$ids.")";    
         return self::find($where,$meta["keyfield"] . " desc");
         
    }
84577
public function parent()
    {
        return $this->filter([
            'lft__lt' => $this->getModel()->lft,
            'rgt__gt' => $this->getModel()->rgt,
            'level' => $this->getModel()->level - 1,
            'root' => $this->getModel()->root,
        ]);
    }
1024302
public function getParent()
    {
        $section = $this->getSection();
        if ($this->hasMainSection()) {
            if ($section->isRoot()) {
                return null;
            } elseif ($section->getParent() instanceof Section) {
                return $section->getParent()->getPage();
            } else {
                return null;
            }
        }

        return $section->getPage();
    }
1076316
protected function get_parent_context() : \context {
        global $PAGE;
        if ($this->parentcontext) {
            return $this->parentcontext;
        } else if ($PAGE->context && $PAGE->context instanceof \context_coursecat) {
            return $PAGE->context;
        }
        return \context_system::instance();
    }
1368795
public function current()
    {
        $relation = $this->finder->firstRelation($this->parent, $this->related, $this->type, $this->direction);

        return ( ! is_null($relation)) ? $this->newFromRelation($relation) : null;
    }
754553
public function getParent()
    {
        $parentID = $this->getField("ParentID");
        if ($parentID) {
            return SiteTree::get_by_id(self::class, $parentID);
        }
        return null;
    }
713174
protected function updateActiveParent()
    {
        // If no update is required, return immediately
        if ( ! request()->has('parents') && ! request()->filled('home') && ! request()->has('parent')) {
            return $this;
        }

        $separator = $this->getListParentSeparator();

        // Check for either a full hierarchy or a 'current level' update
        if (request()->has('parents') || request()->filled('home')) {

            $parents = request()->get('parents');

            if ($parents === 'all' || empty($parents)) {

                // No need to update if no current memorized parent chain
                if (count($this->listParents)) {
                    $this->clearEntireListParentHierarchy();
                }

                $defaultTopRelation = $this->getModelInformation()->list->default_top_relation;

                // Toggling display to all for relations that limit to top by default,
                // which should reset on a home reset aswell.
                if ($parents == 'all') {
                    $this->listParentRelation  = false;
                    $this->listParentRecordKey = null;
                } elseif (request()->filled('home') && $defaultTopRelation) {
                    $this->listParentRelation  = null;
                    $this->listParentRecordKey = null;
                }

            } else {

                if (is_string($parents)) {
                    $parents = explode(';', $parents);
                }

                $parents = array_values($parents);

                // No need to update if everything is the same down the chain
                if (count($this->listParents) == count($parents)) {
                    $same = true;
                    foreach ($this->listParents as $index => $currentParent) {
                        if ($currentParent->relation . $separator . $currentParent->key !== $parents[$index]) {
                            $same = false;
                            break;
                        }
                    }

                    if ($same) {
                        return $this;
                    }
                }

                $this->clearEntireListParentHierarchy();

                // Update, working backwards, starting at the current list; then re-collect the active parent chain
                $this->updateActiveParents(array_reverse($parents));
            }

        } elseif (request()->has('parent')) {

            $parent = request()->get('parent');

            // Interpret special parent values
            $parent = $this->normalizeListParentParameter($parent);

            // If nothing has changed, no need to update
            if (    ! $parent && $this->listParentRelation == $parent
                ||  $parent == $this->listParentRelation . $separator . $this->listParentRecordKey
            ) {
                return $this;
            }

            if ( ! $parent) {
                // Reset this level to its previous list parent, if any
                $this->listParentRelation  = $parent;
                $this->listParentRecordKey = null;
            } else {

                // If the parent is already present in the current history, switch to it
                if ( ! count(array_filter(
                    $this->listParents,
                    function ($checkParent) use ($parent, $separator) {
                        /** @var ListParentData $checkParent */
                        return $checkParent->relation . $separator . $checkParent->key == $parent;
                    }
                ))) {
                    // Not set yet, prepare old parent as one layer deeper

                    $this->setListParentDataInMemory(
                        $this->listParentRelation,
                        $this->listParentRecordKey,
                        $parent
                    );
                }

                list($this->listParentRelation, $this->listParentRecordKey) = explode($separator, $parent, 2);
            }
        }

        $this->storeActiveParentInSession();
        $this->collectListParentHierarchy();

        return $this;
    }
1280371
public static function parent()
    {
        if (!self::$activeTraitMethod) {
            throw new \BadMethodCallException("next:parent() call is only allowed in trait calls");
        }
        $arguments = func_get_args();

        return call_user_func(self::$activeTraitMethod, $arguments);
    }
925634
public function getParentAssociationMapping()
    {
        // NEXT_MAJOR: remove array check
        if (\is_array($this->parentAssociationMapping) && $this->getParent()) {
            $parent = $this->getParent()->getCode();

            if (\array_key_exists($parent, $this->parentAssociationMapping)) {
                return $this->parentAssociationMapping[$parent];
            }

            throw new \InvalidArgumentException(sprintf(
                "There's no association between %s and %s.",
                $this->getCode(),
                $this->getParent()->getCode()
            ));
        }

        // NEXT_MAJOR: remove this line
        return $this->parentAssociationMapping;
    }
540107
private function getParentClient()
    {
        $client = AdapterUtil::getPropertyValue($this, 'client');

        return null !== $client ? $client : AdapterUtil::getPropertyValue($this, 'lazyClient');
    }
699471
public function getParent()
    {
        if ($this->path === '/') {
            return null;
        }

        return $this->nodeDataRepository->findOneByPath($this->parentPath, $this->workspace);
    }
212927
public function key()
    {
        if (!$this->valid()) {
            return null;
        }

        if ($this->mode & self::KEY_AS_KEY) {
            return parent::key();
        }

        return $this->cursor;
    }
127651
public function topParent()
    {
        $topParent = $this->parent();

        if (!$topParent) {
            return null;
        }

        while (true) {
            $theParent = $topParent->parent();
            if ($theParent !== null && $theParent->parent() !== null) {
                $topParent = $theParent;
            } else {
                break;
            }
        }

        return $topParent;
    }
925674
public function getParent()
	{
		if ( ! $this->hasParent()) {
			return null;
		}
		$parents = $this->getAncestors(1);
		if ( ! isset($parents[0])) {
			$dump = static::dump($this);
			throw new Exception\InvalidStructure("Parent node was not found for {$dump} but must exist");
		}
		$parent = $parents[0];
		
		return $parent;
	}
600193
public function getAssociationContext()
    {
        $context = Symphony::Engine()->Page->getContext();
        $associations = $context['associations']['parent'];
        $field_association = array();
        $count = 0;

        if (!empty($associations)) {
            $associationsCount = count($associations);
            for ($i = 0; $i < $associationsCount; $i++) {
                if ($associations[$i]['child_section_field_id'] == $this->get('id')) {
                    if ($count === 0) {
                        $field_association = $associations[$i];
                        $count++;
                    } else {
                        $field_association['parent_section_id'] .= '|' . $associations[$i]['parent_section_id'];
                        $field_association['parent_section_field_id'] .= '|' . $associations[$i]['parent_section_field_id'];
                    }
                }
            }
        }

        return $field_association;
    }