-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [#13114] - Added messages component and relevant interface * [#13114] - Added message exception * [#13114] - Added messages collection (renamed from group) * [#13114] - Removed message objects from validation * [#13114] - Removed the group class in favor of the messages one * [#13114] - Replace of Group with Messages object * [#13114] - Removed model messageinterface; Refactored model message; Corrected use reference * [#13114] - Corrected class extend * [#13114] - Test corrections * [#13114] - Corrected methods/objects * [#13114] - More test corrections * [#13114] - Fixing tests * [#13114] - Corrected order in adding messages with a model * [#13114] - Correcting more tests * [#13114] - Removed the Mvc\Model\Message class - using the Messages\Message * [#13114] - Updated the changelog * [#13114] - Added JsonSerializable interface in Message and Messages * [#13114] - Corrected noobie typo * [#13114] - More noobie typos * [#13114] - Changed the variable type * [#13114] - Forgot the implements :/ * [#13114] - Corrected test * [#13114] - Changed the var type * [#13114] - Array initialization that was missing
- Loading branch information
1 parent
ca61578
commit f1331fc
Showing
62 changed files
with
498 additions
and
599 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
/* | ||
+------------------------------------------------------------------------+ | ||
| Phalcon Framework | | ||
+------------------------------------------------------------------------+ | ||
| Copyright (c) 2011-present Phalcon Team (http://www.phalconphp.com) | | ||
+------------------------------------------------------------------------+ | ||
| This source file is subject to the New BSD License that is bundled | | ||
| with this package in the file LICENSE.txt. | | ||
| | | ||
| If you did not receive a copy of the license and are unable to | | ||
| obtain it through the world-wide-web, please send an email | | ||
| to [email protected] so we can send you a copy immediately. | | ||
+------------------------------------------------------------------------+ | ||
| Authors: Phalcon Team <[email protected]> | | ||
+------------------------------------------------------------------------+ | ||
*/ | ||
|
||
namespace Phalcon\Messages; | ||
|
||
/** | ||
* Phalcon\Validation\Exception | ||
* | ||
* Exceptions thrown in Phalcon\Messages\* classes will use this class | ||
* | ||
*/ | ||
class Exception extends \Phalcon\Exception | ||
{ | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
+------------------------------------------------------------------------+ | ||
| Phalcon Framework | | ||
+------------------------------------------------------------------------+ | ||
| Copyright (c) 2011-2017 Phalcon Team (https://phalconphp.com) | | ||
| Copyright (c) 2011-present Phalcon Team (http://www.phalconphp.com) | | ||
+------------------------------------------------------------------------+ | ||
| This source file is subject to the New BSD License that is bundled | | ||
| with this package in the file LICENSE.txt. | | ||
|
@@ -12,21 +12,20 @@ | |
| obtain it through the world-wide-web, please send an email | | ||
| to [email protected] so we can send you a copy immediately. | | ||
+------------------------------------------------------------------------+ | ||
| Authors: Andres Gutierrez <[email protected]> | | ||
| Eduar Carvajal <[email protected]> | | ||
| Authors: Phalcon Team <[email protected]> | | ||
+------------------------------------------------------------------------+ | ||
*/ | ||
|
||
namespace Phalcon\Validation; | ||
namespace Phalcon\Messages; | ||
|
||
use Phalcon\Validation\MessageInterface; | ||
use Phalcon\Messages\MessageInterface; | ||
|
||
/** | ||
* Phalcon\Validation\Message | ||
* Phalcon\Messages\Message | ||
* | ||
* Encapsulates validation info generated in the validation process | ||
* Stores a message from various components | ||
*/ | ||
class Message implements MessageInterface | ||
class Message implements MessageInterface, \JsonSerializable | ||
{ | ||
|
||
protected _type; | ||
|
@@ -38,7 +37,7 @@ class Message implements MessageInterface | |
protected _code; | ||
|
||
/** | ||
* Phalcon\Validation\Message constructor | ||
* Phalcon\Messages\Message constructor | ||
*/ | ||
public function __construct(string! message, var field = null, string type = null, int code = null) | ||
{ | ||
|
@@ -49,73 +48,86 @@ class Message implements MessageInterface | |
} | ||
|
||
/** | ||
* Sets message type | ||
* Returns the message code | ||
*/ | ||
public function setType(string! type) -> <Message> | ||
public function getCode() -> int | ||
{ | ||
let this->_type = type; | ||
return this; | ||
return this->_code; | ||
} | ||
|
||
/** | ||
* Returns message type | ||
* Returns field name related to message | ||
* | ||
* @return mixed | ||
*/ | ||
public function getType() -> string | ||
public function getField() | ||
{ | ||
return this->_type; | ||
return this->_field; | ||
} | ||
|
||
/** | ||
* Sets verbose message | ||
* Returns verbose message | ||
*/ | ||
public function setMessage(string! message) -> <Message> | ||
public function getMessage() -> string | ||
{ | ||
let this->_message = message; | ||
return this; | ||
return this->_message; | ||
} | ||
|
||
/** | ||
* Returns verbose message | ||
* Returns message type | ||
*/ | ||
public function getMessage() -> string | ||
public function getType() -> string | ||
{ | ||
return this->_message; | ||
return this->_type; | ||
} | ||
|
||
/** | ||
* Serializes the object for json_encode | ||
*/ | ||
public function jsonSerialize() -> array | ||
{ | ||
return [ | ||
"field": this->_field, | ||
"message": this->_message, | ||
"type": this->_type, | ||
"code": this->_code | ||
]; | ||
} | ||
|
||
/** | ||
* Sets field name related to message | ||
* Sets code for the message | ||
*/ | ||
public function setField(var field) -> <Message> | ||
public function setCode(int code) -> <Message> | ||
{ | ||
let this->_field = field; | ||
let this->_code = code; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns field name related to message | ||
* | ||
* @return mixed | ||
* Sets field name related to message | ||
*/ | ||
public function getField() | ||
public function setField(var field) -> <Message> | ||
{ | ||
return this->_field; | ||
let this->_field = field; | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets code for the message | ||
* Sets verbose message | ||
*/ | ||
public function setCode(int code) -> <Message> | ||
public function setMessage(string! message) -> <Message> | ||
{ | ||
let this->_code = code; | ||
let this->_message = message; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns the message code | ||
* Sets message type | ||
*/ | ||
public function getCode() -> int | ||
public function setType(string! type) -> <Message> | ||
{ | ||
return this->_code; | ||
let this->_type = type; | ||
return this; | ||
} | ||
|
||
/** | ||
|
@@ -127,10 +139,10 @@ class Message implements MessageInterface | |
} | ||
|
||
/** | ||
* Magic __set_state helps to recover messages from serialization | ||
* Magic __set_state helps to re-build messages variable exporting | ||
*/ | ||
public static function __set_state(array! message) -> <Message> | ||
{ | ||
return new self(message["_message"], message["_field"], message["_type"]); | ||
return new self(message["_message"], message["_field"], message["_type"], message["_code"]); | ||
} | ||
} |
Oops, something went wrong.