30 public function __construct ($origin,
string $htmlMessage =
'',
int $code = 0, Throwable $previous = NULL)
32 $this->setOrigin($origin);
34 parent::__construct($htmlMessage, $code, $previous);
37 public function setOrigin ($origin)
40 $this->attribute = $origin;
41 $this->tab = $origin->getParent();
42 $this->
object = $this->tab->parent;
44 $this->attribute = NULL;
47 $this->
object = $this->tab->parent;
50 $this->
object = $origin;
51 } elseif ($origin !== NULL) {
52 trigger_error(
'Invalid origin of class '.get_class($origin));
60 public function toArray (): array
62 $array = parent::toArray();
64 if (isset($this->object->dn)) {
65 $array[
'dn'] = $this->
object->dn;
68 if (isset($this->tab)) {
69 $array[
'tab'] = get_class($this->tab);
72 if (isset($this->attribute)) {
73 $array[
'attribute'] = $this->attribute->getLdapName();
79 public function __toString ()
83 if (isset($this->object->dn)) {
84 $msg .= $this->
object->dn.
' > ';
87 if (isset($this->tab) && isset($this->tab->parent->by_name[get_class($this->tab)])) {
88 $msg .= $this->tab->parent->by_name[get_class($this->tab)].
' > ';
91 if (isset($this->attribute)) {
92 $label = $this->attribute->getLabel();
94 $msg .= $this->attribute->getLdapName();
100 return $msg.
': '.$this->getMessage();
103 public function computeMsgDialogParameters (): array
109 if (isset($this->object->dn)) {
110 $breadcrumbs[] =
htmlescape($this->object->dn);
113 if (isset($this->tab) && isset($this->tab->parent->by_name[get_class($this->tab)])) {
114 $breadcrumbs[] =
htmlescape($this->tab->parent->by_name[get_class($this->tab)]);
117 if (isset($this->attribute)) {
118 $label = $this->attribute->getLabel();
120 $breadcrumbs[] =
'<i>'.htmlescape($this->attribute->getLdapName()).
'</i>';
124 $example = $this->attribute->getExample();
127 if (!empty($breadcrumbs)) {
128 $html .= implode(
htmlescape(
' > '), $breadcrumbs);
131 $html .=
'<br/><br/>';
133 $html .= $this->htmlMessage;
136 if (!empty($example)) {
137 $html .=
'<br/><br/><i>'.htmlescape(sprintf(_(
'Example: %s'), $example)).
'</i> ';
140 return [_(
'Error'), $html, ERROR_DIALOG, FusionDirectoryError::formatTrace($this)];
146 $error->setOrigin($origin);
149 return new SimplePluginError($origin, $error->getHtmlMessage(), $error->getCode(), $error);
htmlescape(string $str)
Escape string for HTML output.
This class contains all function to manage tabs classes.
Error returned by any method of SimplePlugin.
Parent class for all errors in FusionDirectory.