| 1: | <?php |
| 2: | namespace TIC\MailBundle\Entity; |
| 3: | |
| 4: | use Doctrine\ORM\Mapping as ORM; |
| 5: | use TIC\MailBundle\Repository\MaillogRepository as EntityRepo; |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | class Maillog |
| 13: | { |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | private $id; |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | private $template; |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | private $locale; |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | private $returnPath; |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | private $mailFrom; |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: | private $mailRcpt; |
| 48: | |
| 49: | |
| 50: | |
| 51: | |
| 52: | private $mailBcc; |
| 53: | |
| 54: | |
| 55: | |
| 56: | |
| 57: | private $subject; |
| 58: | |
| 59: | |
| 60: | |
| 61: | |
| 62: | private $body; |
| 63: | |
| 64: | |
| 65: | |
| 66: | |
| 67: | private $contentType; |
| 68: | |
| 69: | |
| 70: | |
| 71: | |
| 72: | |
| 73: | |
| 74: | |
| 75: | |
| 76: | |
| 77: | private $messageId; |
| 78: | |
| 79: | |
| 80: | |
| 81: | |
| 82: | private $sendCode; |
| 83: | |
| 84: | |
| 85: | |
| 86: | |
| 87: | private $errorMsg; |
| 88: | |
| 89: | |
| 90: | |
| 91: | |
| 92: | private $origin; |
| 93: | |
| 94: | |
| 95: | |
| 96: | |
| 97: | private $createdAt; |
| 98: | |
| 99: | |
| 100: | |
| 101: | |
| 102: | public function __construct(array $data = null) |
| 103: | { |
| 104: | $this->origin = isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : \implode(" ", $_SERVER["argv"]); |
| 105: | $this->createdAt = new \DateTime("now"); |
| 106: | if ($data !== null) $this->loadData($data); |
| 107: | } |
| 108: | |
| 109: | public function __toString() |
| 110: | { |
| 111: | return \sprint("[%s] %s", $this->createdAt->format('Y-m-d H:i:s'), $this->subject); |
| 112: | } |
| 113: | |
| 114: | public function loadData(array $data = []): void |
| 115: | { |
| 116: | foreach ($data as $field => $value) { |
| 117: | $mutator = "set" . \ucfirst($field); |
| 118: | if (! \method_exists($this, $mutator)) continue; |
| 119: | |
| 120: | |
| 121: | \call_user_func(array($this, $mutator), $value); |
| 122: | } |
| 123: | } |
| 124: | |
| 125: | |
| 126: | |
| 127: | |
| 128: | |
| 129: | |
| 130: | |
| 131: | |
| 132: | |
| 133: | public function setMailFrom($mailFrom): self |
| 134: | { |
| 135: | if (\is_array($mailFrom)) $mailFrom = \implode(', ', $mailFrom); |
| 136: | $this->mailFrom = $mailFrom; |
| 137: | return $this; |
| 138: | } |
| 139: | |
| 140: | |
| 141: | |
| 142: | |
| 143: | |
| 144: | |
| 145: | public function setMailRcpt($mailRcpt): self |
| 146: | { |
| 147: | if (\is_array($mailRcpt)) $mailRcpt = \implode(', ', $mailRcpt); |
| 148: | $this->mailRcpt = $mailRcpt; |
| 149: | return $this; |
| 150: | } |
| 151: | |
| 152: | |
| 153: | |
| 154: | |
| 155: | |
| 156: | |
| 157: | public function setMailBcc($mailBcc): self |
| 158: | { |
| 159: | if (\is_array($mailBcc)) $mailBcc = \implode(', ', $mailBcc); |
| 160: | $this->mailBcc = $mailBcc; |
| 161: | return $this; |
| 162: | } |
| 163: | |
| 164: | |
| 165: | |
| 166: | |
| 167: | |
| 168: | |
| 169: | |
| 170: | |
| 171: | |
| 172: | public function getId() |
| 173: | { |
| 174: | return $this->id; |
| 175: | } |
| 176: | |
| 177: | |
| 178: | |
| 179: | |
| 180: | |
| 181: | |
| 182: | |
| 183: | |
| 184: | public function setTemplate($template) |
| 185: | { |
| 186: | $this->template = $template; |
| 187: | |
| 188: | return $this; |
| 189: | } |
| 190: | |
| 191: | |
| 192: | |
| 193: | |
| 194: | |
| 195: | |
| 196: | public function getTemplate() |
| 197: | { |
| 198: | return $this->template; |
| 199: | } |
| 200: | |
| 201: | |
| 202: | |
| 203: | |
| 204: | |
| 205: | |
| 206: | |
| 207: | |
| 208: | public function setLocale($locale) |
| 209: | { |
| 210: | $this->locale = $locale; |
| 211: | |
| 212: | return $this; |
| 213: | } |
| 214: | |
| 215: | |
| 216: | |
| 217: | |
| 218: | |
| 219: | |
| 220: | public function getLocale() |
| 221: | { |
| 222: | return $this->locale; |
| 223: | } |
| 224: | |
| 225: | |
| 226: | |
| 227: | |
| 228: | |
| 229: | |
| 230: | |
| 231: | |
| 232: | public function setReturnPath($returnPath) |
| 233: | { |
| 234: | $this->returnPath = $returnPath; |
| 235: | |
| 236: | return $this; |
| 237: | } |
| 238: | |
| 239: | |
| 240: | |
| 241: | |
| 242: | |
| 243: | |
| 244: | public function getReturnPath() |
| 245: | { |
| 246: | return $this->returnPath; |
| 247: | } |
| 248: | |
| 249: | |
| 250: | |
| 251: | |
| 252: | |
| 253: | |
| 254: | public function getMailFrom() |
| 255: | { |
| 256: | return $this->mailFrom; |
| 257: | } |
| 258: | |
| 259: | |
| 260: | |
| 261: | |
| 262: | |
| 263: | |
| 264: | public function getMailRcpt() |
| 265: | { |
| 266: | return $this->mailRcpt; |
| 267: | } |
| 268: | |
| 269: | |
| 270: | |
| 271: | |
| 272: | |
| 273: | |
| 274: | public function getMailBcc() |
| 275: | { |
| 276: | return $this->mailBcc; |
| 277: | } |
| 278: | |
| 279: | |
| 280: | |
| 281: | |
| 282: | |
| 283: | |
| 284: | |
| 285: | |
| 286: | public function setSubject($subject) |
| 287: | { |
| 288: | $this->subject = $subject; |
| 289: | |
| 290: | return $this; |
| 291: | } |
| 292: | |
| 293: | |
| 294: | |
| 295: | |
| 296: | |
| 297: | |
| 298: | public function getSubject() |
| 299: | { |
| 300: | return $this->subject; |
| 301: | } |
| 302: | |
| 303: | |
| 304: | |
| 305: | |
| 306: | |
| 307: | |
| 308: | |
| 309: | |
| 310: | public function setBody($body) |
| 311: | { |
| 312: | $this->body = $body; |
| 313: | |
| 314: | return $this; |
| 315: | } |
| 316: | |
| 317: | |
| 318: | |
| 319: | |
| 320: | |
| 321: | |
| 322: | public function getBody() |
| 323: | { |
| 324: | return $this->body; |
| 325: | } |
| 326: | |
| 327: | |
| 328: | |
| 329: | |
| 330: | |
| 331: | |
| 332: | |
| 333: | |
| 334: | public function setContentType($contentType) |
| 335: | { |
| 336: | $this->contentType = $contentType; |
| 337: | |
| 338: | return $this; |
| 339: | } |
| 340: | |
| 341: | |
| 342: | |
| 343: | |
| 344: | |
| 345: | |
| 346: | public function getContentType() |
| 347: | { |
| 348: | return $this->contentType; |
| 349: | } |
| 350: | |
| 351: | |
| 352: | |
| 353: | |
| 354: | |
| 355: | |
| 356: | |
| 357: | |
| 358: | public function setMessageId($messageId) |
| 359: | { |
| 360: | $this->messageId = $messageId; |
| 361: | |
| 362: | return $this; |
| 363: | } |
| 364: | |
| 365: | |
| 366: | |
| 367: | |
| 368: | |
| 369: | |
| 370: | public function getMessageId() |
| 371: | { |
| 372: | return $this->messageId; |
| 373: | } |
| 374: | |
| 375: | |
| 376: | |
| 377: | |
| 378: | |
| 379: | |
| 380: | |
| 381: | |
| 382: | public function setSendCode($sendCode) |
| 383: | { |
| 384: | $this->sendCode = $sendCode; |
| 385: | |
| 386: | return $this; |
| 387: | } |
| 388: | |
| 389: | |
| 390: | |
| 391: | |
| 392: | |
| 393: | |
| 394: | public function getSendCode() |
| 395: | { |
| 396: | return $this->sendCode; |
| 397: | } |
| 398: | |
| 399: | |
| 400: | |
| 401: | |
| 402: | |
| 403: | |
| 404: | |
| 405: | |
| 406: | public function setErrorMsg($errorMsg) |
| 407: | { |
| 408: | $this->errorMsg = $errorMsg; |
| 409: | |
| 410: | return $this; |
| 411: | } |
| 412: | |
| 413: | |
| 414: | |
| 415: | |
| 416: | |
| 417: | |
| 418: | public function getErrorMsg() |
| 419: | { |
| 420: | return $this->errorMsg; |
| 421: | } |
| 422: | |
| 423: | |
| 424: | |
| 425: | |
| 426: | |
| 427: | |
| 428: | |
| 429: | |
| 430: | public function setOrigin($origin) |
| 431: | { |
| 432: | $this->origin = $origin; |
| 433: | |
| 434: | return $this; |
| 435: | } |
| 436: | |
| 437: | |
| 438: | |
| 439: | |
| 440: | |
| 441: | |
| 442: | public function getOrigin() |
| 443: | { |
| 444: | return $this->origin; |
| 445: | } |
| 446: | |
| 447: | |
| 448: | |
| 449: | |
| 450: | |
| 451: | |
| 452: | |
| 453: | |
| 454: | public function setCreatedAt($createdAt) |
| 455: | { |
| 456: | $this->createdAt = $createdAt; |
| 457: | |
| 458: | return $this; |
| 459: | } |
| 460: | |
| 461: | |
| 462: | |
| 463: | |
| 464: | |
| 465: | |
| 466: | public function getCreatedAt() |
| 467: | { |
| 468: | return $this->createdAt; |
| 469: | } |
| 470: | } |
| 471: | |