Bitrix-D7  20.0.0
main/lib/orm/data/result.php
См. документацию.
1 <?php
2 /**
3  * Bitrix Framework
4  * @package bitrix
5  * @subpackage main
6  * @copyright 2001-2012 Bitrix
7  */
8 
9 namespace Bitrix\Main\ORM\Data;
10 
14 
16 {
17  /** @var bool */
18  protected $wereErrorsChecked = false;
19 
20  /** @var EntityObject */
21  protected $object;
22 
23  public function __construct()
24  {
26  }
27 
28  /**
29  * @return EntityObject
30  */
31  public function getObject()
32  {
33  return $this->object;
34  }
35 
36  /**
37  * @param EntityObject $object
38  */
39  public function setObject($object)
40  {
41  $this->object = $object;
42  }
43 
44  /**
45  * Returns result status
46  * Within the core and events should be called with internalCall flag
47  *
48  * @param bool $internalCall
49  *
50  * @return bool
51  */
52  public function isSuccess($internalCall = false)
53  {
54  if (!$internalCall && !$this->wereErrorsChecked)
55  {
56  $this->wereErrorsChecked = true;
57  }
58 
59  return parent::isSuccess();
60  }
61 
62  /**
63  * Returns an array of Error objects
64  *
65  * @return EntityError[]|FieldError[]
66  */
67  public function getErrors()
68  {
69  $this->wereErrorsChecked = true;
70 
71  return parent::getErrors();
72  }
73 
74  /**
75  * Returns array of strings with error messages
76  *
77  * @return array
78  */
79  public function getErrorMessages()
80  {
81  $this->wereErrorsChecked = true;
82 
83  return parent::getErrorMessages();
84  }
85 
86  public function __destruct()
87  {
88  if (!$this->isSuccess && !$this->wereErrorsChecked)
89  {
90  // nobody interested in my errors :(
91  // make a warning (usually it should be written in log)
92  trigger_error(join('; ', $this->getErrorMessages()), E_USER_WARNING);
93  }
94  }
95 }
Bitrix\Main\ORM\Data\Result\__destruct
__destruct()
Definition: main/lib/orm/data/result.php:86
Bitrix\Main\ORM\Data\Result\setObject
setObject($object)
Definition: main/lib/orm/data/result.php:39
Bitrix\Main\ORM\Data\Result\$wereErrorsChecked
$wereErrorsChecked
Definition: main/lib/orm/data/result.php:18
Bitrix\Main\ORM\Data\Result\$object
$object
Definition: main/lib/orm/data/result.php:21
Bitrix\Main\ORM\Objectify\EntityObject
Definition: entityobject.php:47
Bitrix\Main\ORM\Fields\FieldError
Definition: fielderror.php:13
Bitrix\Main\getErrors
getErrors()
Getting array of errors.
Definition: errorableimplementation.php:34
Bitrix\Main\ORM\Data
Definition: addresult.php:9
Bitrix\Main\ORM\Data\Result\isSuccess
isSuccess($internalCall=false)
Returns result status Within the core and events should be called with internalCall flag.
Definition: main/lib/orm/data/result.php:52
Bitrix\Main\ORM\Data\Result\getObject
getObject()
Definition: main/lib/orm/data/result.php:31
Bitrix\Main\ORM\EntityError
Definition: entityerror.php:11
Bitrix\Sender\Connector\__construct
__construct(Base $connector)
Constructor.
Definition: resultview.php:40
Bitrix\Main\ORM\Data\Result\__construct
__construct()
Definition: main/lib/orm/data/result.php:23
Bitrix\Main\ORM\Data\Result\getErrorMessages
getErrorMessages()
Returns array of strings with error messages.
Definition: main/lib/orm/data/result.php:79
Bitrix\Main\Result\isSuccess
isSuccess()
Returns the result status.
Definition: main/lib/result.php:34
Bitrix\Main\ORM\Data\Result
Definition: main/lib/orm/data/result.php:15
Bitrix\Main\ORM\Data\Result\getErrors
getErrors()
Returns an array of Error objects.
Definition: main/lib/orm/data/result.php:67