$class_name::getName(), 'required' => $class_name::getRequiredConfig(), 'optional' => $class_name::getOptionalConfig(), ); } } foreach (self::$_drivers as $driver_name => $driver) { if ($driver->isSupported()) { $result[$driver_name] = array( 'name' => $driver->getName(), 'required' => $driver->getRequiredConfig(), 'optional' => $driver->getOptionalConfig(), ); } } ksort($result); return $result; } /** * The constructor. */ public function __construct() { } /** * Set the sender's member_srl. * * @param int $member_srl * @return bool */ public function setFrom(int $member_srl): bool { $this->from = $member_srl; return true; } /** * Get the sender's phone number. * * @return int|null */ public function getFrom(): ?int { return $this->from; } /** * Add a recipient. * * @param int $member_srl * @return bool */ public function addTo(int $member_srl): bool { $this->to[] = $member_srl; return true; } /** * Get the list of recipients without country codes. * * @return array */ public function getRecipients(): array { return $this->to; } /** * Set the subject. * * @param string $subject * @return bool */ public function setSubject(string $subject): bool { $this->subject = utf8_trim(utf8_clean($subject)); return true; } /** * Get the subject. * * @return string */ public function getSubject(): string { return $this->subject; } /** * Set the content. * * @param string $content * @return bool */ public function setContent(string $content): bool { $this->content = utf8_trim(utf8_clean($content)); $this->content = strtr($this->content, array("\r\n" => "\n")); return true; } /** * Get the content. * * @return string */ public function getContent(): string { return $this->content; } /** * Set an image to associate with this push notification. * * @param string $image * @return bool */ public function setImage(string $image): bool { $this->image = utf8_trim(utf8_clean($image)); return true; } /** * Get the image associated with this push notification. * * @return string */ public function getImage(): string { return $this->image; } /** * Set a URL to associate with this push notification. * * @param string $url * @return bool */ public function setURL(string $url): bool { $this->url = $url; return true; } /** * Get the URL associated with this push notification. * * @return string */ public function getURL(): string { return $this->url; } /** * Send the message. * * @return bool */ public function send(): bool { // Get caller information. $backtrace = debug_backtrace(0); if(count($backtrace) && isset($backtrace[0]['file'])) { $this->caller = $backtrace[0]['file'] . ($backtrace[0]['line'] ? (' line ' . $backtrace[0]['line']) : ''); } $output = \ModuleHandler::triggerCall('push.send', 'before', $this); if(!$output->toBool()) { $this->errors[] = $output->getMessage(); return false; } try { //$this->getDriver('fcm'); //$this->getDriver('apns'); } catch(\Exception $e) { $this->errors[] = class_basename($e) . ': ' . $e->getMessage(); $this->sent = false; } $output = \ModuleHandler::triggerCall('push.send', 'after', $this); if(!$output->toBool()) { $this->errors[] = $output->getMessage(); } return $this->sent; } /** * Check if the message was sent. * * @return bool */ public function isSent(): bool { return $this->sent; } /** * Get caller information. * * @return string */ public function getCaller(): string { return $this->caller; } /** * Get errors. * * @return array */ public function getErrors(): array { return $this->errors; } /** * Add an error message. * * @param string $message * @return void */ public function addError(string $message): void { $this->errors[] = $message; } }