Find all the entries that reference this entry's tags.

@param integer $entry_id
@param integer $parent_field_id
@return array
172892
public function findRelatedEntries($entry_id, $parent_field_id)
    {
        // We have the entry_id of the entry that has the referenced tag values
        // Lets find out what those handles are so we can then referenced the
        // child section looking for them.
        $handles = Symphony::Database()->fetchCol('handle', sprintf("
            SELECT `handle`
            FROM `tbl_entries_data_%d`
            WHERE `entry_id` = %d
        ", $parent_field_id, $entry_id));

        $ids = Symphony::Database()->fetchCol('entry_id', sprintf("
            SELECT `entry_id`
            FROM `tbl_entries_data_%d`
            WHERE `handle` IN ('%s')
        ", $this->get('id'), implode("','", $handles)));

        return $ids;
    }
874340
public static function findByType( $parentId, $parentType, $type, $config = [] ) {

		return self::queryByType( $parentId, $parentType, $type, $config )->all();
	}
928930
public function findByParentAndSite($parentId, $siteId)
    {
        $qb = $this->createQueryBuilder();
        if ($parentId) {
            $qb->field('parent.$id')->equals(new \MongoId($parentId));
        }
        $qb->field('siteId')->equals($siteId);

        return $qb->getQuery()->execute();
     }
308950
public function find_parent_item_in_menu( $menu_items, $parent_id ) {
		foreach ( $menu_items as &$item ) {
			if ( $item->ID == $parent_id ) {
				return $item;
			}
		}
	}
921934
private function getPostSelectedTags($id, $postTypeSlug)
    {
        // get selected tags from the DB table tags_relations
        $selectedTags = [];
        $tagsRelationTable = tagsRelationTable($postTypeSlug);
        $tagsRelations = DB::table($tagsRelationTable)
            ->leftJoin('tags', $tagsRelationTable.'.tagID', 'tags.tagID')
            ->where($tagsRelationTable.'.postID', $id)
            ->select("tags.tagID", $tagsRelationTable.".language", "tags.title", "tags.slug")
            ->get();

        foreach($tagsRelations as $tagsRelation){
            if(!isset($selectedTags[$tagsRelation->language])) {
                $selectedTags[$tagsRelation->language] = [];
            }
            $selectedTags[$tagsRelation->language][] = $tagsRelation;
        }

        return $selectedTags;
    }
56855
private static function getChildrenIdRec($ids, $className, $primaryKey, $parentIdField, $recursive)
    {
        $subIds = array_map('intval', $className::find()
            ->select($primaryKey)
            ->where([ $parentIdField => $ids ])
            ->column());
        if ( $subIds ) {
            if ( $recursive ) {
                return array_merge($subIds, self::getChildrenIdRec($subIds, $className, $primaryKey, $parentIdField, true));
            } else {
                return $subIds;
            }
        } else {
            return [];
        }
    }
1362717
protected function get_parent_record() {
        global $DB;

        if (!isset($this->parentrecord)) {
            $this->parentrecord = $DB->get_record('event', ['id' => $this->parentid]);
        }

        return $this->parentrecord;
    }
62376
protected function getForeignKeyAttributesFromParent(): array
    {
        $parentMap = $this->parent->getEntityMap();

        $parentForeignRelations = $parentMap->getForeignRelationships();
        $parentPivotRelations = $parentMap->getPivotRelationships();

        // The parentRelation is the name of the relationship
        // methods on the parent entity map
        $parentRelation = $this->parentRelationship;

        if (in_array($parentRelation, $parentForeignRelations) &&
            !in_array($parentRelation, $parentPivotRelations)
        ) {
            $parentObject = $this->parent->getEntityObject();

            // Call Relationship's method on parent map
            $relationship = $parentMap->$parentRelation($parentObject);

            return $relationship->getForeignKeyValuePair($parentObject);
        }

        return [];
    }
1017295
public function moveTo($id, $parent_id) {
        $pk = $this->getRepository()->getPrimaryKey();
        $node = $this->getNode($id);

        if (!$node || $node[$this->getConfig('parentField')] == $parent_id) {
            return false;
        }

        $left = $this->getConfig('leftField');
        $right = $this->getConfig('rightField');
        $data = [];

        // Remove the node and reset others
        $this->_removeNode($id, $node[$left]);

        // Insert into parent
        if ($parent_id && ($parentNode = $this->getNode($parent_id))) {
            $data = [
                $left => $parentNode[$right],
                $right => $parentNode[$right] + 1
            ];

        // Or the root
        } else if ($lastNode = $this->getLastNode()) {
            $data = [
                $left => $lastNode[$right] + 1,
                $right => $lastNode[$right] + 2
            ];
        }

        // Move it
        $this->_moveNode(function(Query $query) use ($pk, $id) {
            $query->where($pk, $id);
        }, $data + [
            $this->getConfig('parentField') => $parent_id
        ]);

        $this->_insertNode($id, $data[$left]);

        return true;
    }
987579
public function getFieldValueByEntryAndField(Entry $entry, Field $field)
    {
        return $this->fieldValueRepo->findOneBy(['entry' => $entry, 'field' => $field]);
    }
200478
public function findAll($parentId, array $query = [])
    {
        $resource = $this->createPartialResourceUrlForList($parentId);
        $data = $this->client->get($resource, $query);

        return $this->createMany(reset($data));
    }
391673
private function get_tags( $post_id ) {
		$tag_data = get_the_tags( $post_id );
		$tag_arr  = [];
		if ( $tag_data ) {
			foreach ( $tag_data as $tag ) {
				array_push( $tag_arr, $tag->slug );
			}
		}

		return $tag_arr;
	}
1125190
public static function getTreeChild($data, $parent_id, $key = 'parent_id', $id_key = 'id') {
		$result = [];
		$args   = [$parent_id];
		do {
			$kids = [];
			$flag = false;
			foreach ($args as $fid) {
				for ($i = count($data) - 1; $i >=0 ; $i --) {
					$node = $data[$i];
					if ($node[$key] == $fid) {
						array_splice($data, $i , 1);
						$result[] = $node[$id_key];
						$kids[]   = $node[$id_key];
						$flag     = true;
					}
				}
			}
			$args = $kids;
		} while($flag === true);
		return $result;
	}
278150
public function filterParent()
    {
        $parent = $this->parent;
        $db = static::getDb();
        $query = (new Query)->select(['parent'])
            ->from(static::tableName())
            ->where('[[id]]=:id');
        while ($parent) {
            if ($this->id == $parent) {
                $this->addError('parent_name', Yii::t('admin', 'Loop detected.'));
                return;
            }
            $parent = $query->params([':id' => $parent])->scalar($db);
        }
    }
1262159
public function get(string $parent, string $name, string $entry = null)
    {
        $key = $parent. '.' . $name;
        if (!empty($entry)) {
            $key .= '.' . $entry;
        }
        return data_get($this->data, $key, null);
    }
425469
public function parents($id)
    {
        $this->index();
        $result = array();
        while ($id)
        {
            foreach ($this->index as $key => $value)
            {
                if (in_array($id, $value))
                {
                    $result[] = $id = $key;
                    break;
                }
            }
            if (!$result)
            {
                return null;
            }
        }
        $result = array_reverse($result);
        return $result;
    }
1231656
public static function findByParentCartId( $parentId, $parentType, $cartId ) {

		return self::find()->where( 'parentId=:pid AND parentType=:ptype AND cartId=:cid', [ ':pid' => $parentId, ':ptype' => $parentType, ':cid' => $cartId ] )->one();
	}