Skip to content

Instantly share code, notes, and snippets.

@mraspor
Created October 8, 2014 18:12
Show Gist options
  • Save mraspor/b1fd651bda969451b905 to your computer and use it in GitHub Desktop.
Save mraspor/b1fd651bda969451b905 to your computer and use it in GitHub Desktop.
Modified Message class extends from Phalcon\Validation\Message to enable translation.Translation service needs to be set in DI. Don't forget to add correct namespace to your $loader.
<?php
namespace Library\Validation;
use Phalcon\DI;
/**
* Class Message
*
* This is a modification of the default Validation/Message class
* Modified to return a translated message
*
* User: mraspor
* Date: 10/8/14
* Time: 5:00 PM
*
* @package Library\Validation
*/
class Message extends \Phalcon\Validation\Message {
/**
* @return mixed
*/
public function getMessage()
{
$di = DI::getDefault();
return $di->get('translation')->_($this->_message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment