public function findHashed(Query $query, array $options) {
		$field = $this->_config['field'];
		if (!$field) {
			return $query;
		}

		$idField = $this->_primaryKey;

		$query->formatResults(function ($results) use ($field, $idField) {
			$newResult = [];

			$results->each(function ($row, $key) use ($field, $idField, &$newResult) {
				if (!empty($row[$idField])) {
					$row[$field] = $this->encodeId($row[$idField]);
					if ($row instanceof EntityInterface) {
						$row->setDirty($field, false);
					}
					$newResult[] = $row;
				} elseif (is_string($row)) {
					$newResult[$this->encodeId($key)] = $row;
				} else {
					$newResult[] = $row;
				}
			});

			return new Collection($newResult);
		});

		if (!empty($options[static::HID])) {
			$id = $this->decodeHashid($options[static::HID]);
			$query->where([$idField => $id]);
		}

		$first = $this->_config['findFirst'] === true ? 'first' : $this->_config['findFirst'];
		if (!$first || !empty($options['noFirst'])) {
			return $query;
		}
		return $query->first();
	}
public function findHashed(Query $query, array $options) {
		$field = $this->_config['field'];
		if (!$field) {
			return $query;
		}

		$idField = $this->_primaryKey;

		$query->formatResults(function ($results) use ($field, $idField) {
			$newResult = [];

			$results->each(function ($row, $key) use ($field, $idField, &$newResult) {
				if (!empty($row[$idField])) {
					$row[$field] = $this->encodeId($row[$idField]);
					if ($row instanceof EntityInterface) {
						$row->setDirty($field, false);
					}
					$newResult[] = $row;
				} elseif (is_string($row)) {
					$newResult[$this->encodeId($key)] = $row;
				} else {
					$newResult[] = $row;
				}
			});

			return new Collection($newResult);
		});

		if (!empty($options[static::HID])) {
			$id = $this->decodeHashid($options[static::HID]);
			$query->where([$idField => $id]);
		}

		$first = $this->_config['findFirst'] === true ? 'first' : $this->_config['findFirst'];
		if (!$first || !empty($options['noFirst'])) {
			return $query;
		}
		return $query->first();
	}
public function findHashed ( Query $ query , array $ options ) { $ field = $ this -> _config [ 'field' ] ; if ( ! $ field ) { return $ query ; } $ idField = $ this -> _primaryKey ; $ query -> formatResults ( function ( $ results ) use ( $ field , $ idField ) { $ newResult = [ ] ; $ results -> each ( function ( $ row , $ key ) use ( $ field , $ idField , & $ newResult ) { if ( ! empty ( $ row [ $ idField ] ) ) { $ row [ $ field ] = $ this -> encodeId ( $ row [ $ idField ] ) ; if ( $ row instanceof EntityInterface ) { $ row -> setDirty ( $ field , false ) ; } $ newResult [ ] = $ row ; } elseif ( is_string ( $ row ) ) { $ newResult [ $ this -> encodeId ( $ key ) ] = $ row ; } else { $ newResult [ ] = $ row ; } } ) ; return new Collection ( $ newResult ) ; } ) ; if ( ! empty ( $ options [ static :: HID ] ) ) { $ id = $ this -> decodeHashid ( $ options [ static :: HID ] ) ; $ query -> where ( [ $ idField => $ id ] ) ; } $ first = $ this -> _config [ 'findFirst' ] === true ? 'first' : $ this -> _config [ 'findFirst' ] ; if ( ! $ first || ! empty ( $ options [ 'noFirst' ] ) ) { return $ query ; } return $ query -> first ( ) ; }
Custom finder for hashids field.

Options:
- hid (required), best to use HashidBehavior::HID constant
- noFirst (optional, to leave the query open for adjustments, no first() called)

@param \Cake\ORM\Query $query Query.
@param array $options Array of options as described above
@return \Cake\ORM\Query|\Cake\Datasource\EntityInterface
Custom finder for hashids field .