src/Model/Table/TaggedTable.php
public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary) {
		$order = $query->clause('order');
		if ($order !== null) {
			return $query;
		}

		if (!isset($this->order)) {
			$contain = $query->getContain();
			if (!isset($contain[$this->Tags->getAlias()])) {
				return $query;
			}

			$order = [$this->Tags->getAlias() . '.label' => 'ASC'];
		} else {
			$order = $this->order;
		}

		if (!empty($order)) {
			$query->order($order);
		}

		return $query;
	}
public function beforeFind(Event $event, Query $query, ArrayObject $options, $primary) {
		$order = $query->clause('order');
		if ($order !== null) {
			return $query;
		}

		if (!isset($this->order)) {
			$contain = $query->getContain();
			if (!isset($contain[$this->Tags->getAlias()])) {
				return $query;
			}

			$order = [$this->Tags->getAlias() . '.label' => 'ASC'];
		} else {
			$order = $this->order;
		}

		if (!empty($order)) {
			$query->order($order);
		}

		return $query;
	}
public function beforeFind ( Event $ event , Query $ query , ArrayObject $ options , $ primary ) { $ order = $ query -> clause ( 'order' ) ; if ( $ order !== null ) { return $ query ; } if ( ! isset ( $ this -> order ) ) { $ contain = $ query -> getContain ( ) ; if ( ! isset ( $ contain [ $ this -> Tags -> getAlias ( ) ] ) ) { return $ query ; } $ order = [ $ this -> Tags -> getAlias ( ) . '.label' => 'ASC' ] ; } else { $ order = $ this -> order ; } if ( ! empty ( $ order ) ) { $ query -> order ( $ order ) ; } return $ query ; }
Sets the default ordering.

If you don't want that, don't call parent when overwriting it in extending classes
or just set the order to an empty array. This will only trigger for order clause of null.

@param \Cake\Event\Event $event
@param \Cake\ORM\Query $query
@param \ArrayObject $options
@param bool $primary
@return \Cake\ORM\Query
Sets the default ordering .