You could implement a custom DQL function. This is an example of something that might work with MySQL's order by field
functionality:
class CustomOrder extends FunctionNode
{
public $field = null;
public $customerOrder = null;
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->field = $parser->StringPrimary()
$parser->match(Lexer::T_COMMA);
$this->secondDateExpression = $parser->StringPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
return 'FIELD(' .
$this->field->dispatch($sqlWalker) . ', ' .
$this->customOrder->dispatch($sqlWalker) .
')';
}
}
Which you would call like this Order By CustomOrder('status', "'new', 'moderation', 'archive'")
in your DQL query.
I think that doing a custom sort in PHP is equally valid for your use case unless you are reusing the custom order function in many places.