Created
August 29, 2015 05:05
-
-
Save andrebian/14cfa386630abaac681c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function beforeFind($queryData) | |
{ | |
parent::beforeFind($queryData); | |
// Verifica se o primeiro campo da ordenação está setado | |
if (!empty($queryData['sort']) && $queryData['sort'] == 'primeiro_campo') { | |
// Caso esteja, adiciona o segundo elemento junto à ordenação padrão | |
$novoCampo = array($this->alias . '.segundo_campo' => 'asc'); | |
if (is_array($queryData['order'][0])) { | |
$queryData['order'][0] = $queryData['order'][0] + $novoCampo; | |
} else { | |
$queryData['order'][0] = $novoCampo; | |
} | |
} | |
return $queryData; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment