public function addFilter($filter, ElggEntity $target = null, $priority = 500) {
		if (!$filter) {
			return $this;
		}

		while (isset($this->filters[$priority])) {
			$priority++;
		}

		$this->removeFilter($filter);

		if (!isset($target)) {
			$target = elgg_get_logged_in_user_entity();
		}

		$this->filters[$priority] = [
			'filter' => $filter,
			'target' => $target,
		];

		ksort($this->filters);

		return $this;
	}