You are here

private function PushNotificationsBroadcasterApns::determineCertificatePath in Push Notifications 8

Determine the realpath to the APNS certificate.

Throws

\Exception Certificate file needs to be set

See also

http://stackoverflow.com/questions/809682

1 call to PushNotificationsBroadcasterApns::determineCertificatePath()
PushNotificationsBroadcasterApns::__construct in src/PushNotificationsBroadcasterApns.php
Constructor.

File

src/PushNotificationsBroadcasterApns.php, line 166
Contains \Drupal\push_notifications\PushNotificationsBroadcasterApns.

Class

PushNotificationsBroadcasterApns
Broadcasts Android messages.

Namespace

Drupal\push_notifications

Code

private function determineCertificatePath() {

  // Determine if custom path is set.
  $path = $this->config
    ->get('certificate_folder');

  // If no custom path is set, get module directory.
  if (empty($path)) {
    $path = drupal_realpath(drupal_get_path('module', 'push_notifications'));
    $path .= DIRECTORY_SEPARATOR . 'certificates' . DIRECTORY_SEPARATOR;
  }

  // Append name of certificate.
  $path .= push_notifications_get_certificate_name($this->config
    ->get('environment'));
  if (!file_exists($path)) {
    throw new \Exception(t("Cannot find apns certificate file at @path", array(
      '@path' => $path,
    )));
  }
  $this->certificate_path = $path;
}