コード例 #1
0
ファイル: notificationtest.php プロジェクト: farukuzun/core-1
 /**
  * @dataProvider dataSetObject
  * @param string $type
  * @param int|string $id
  * @param string $exptectedId
  */
 public function testSetObject($type, $id, $exptectedId)
 {
     $this->assertSame('', $this->notification->getObjectType());
     $this->assertSame('', $this->notification->getObjectId());
     $this->assertSame($this->notification, $this->notification->setObject($type, $id));
     $this->assertSame($type, $this->notification->getObjectType());
     $this->assertSame($exptectedId, $this->notification->getObjectId());
 }
コード例 #2
0
ファイル: Notifier.php プロジェクト: rchicoli/owncloud-core
 /**
  * @param INotification $notification
  * @param string $languageCode The code of the language that should be used to prepare the notification
  * @return INotification
  * @throws \InvalidArgumentException When the notification was not prepared by a notifier
  * @since 9.0.0
  */
 public function prepare(INotification $notification, $languageCode)
 {
     if ($notification->getApp() !== 'updatenotification') {
         throw new \InvalidArgumentException();
     }
     $l = $this->l10NFactory->get('updatenotification', $languageCode);
     if ($notification->getObjectType() === 'core') {
         $appName = $l->t('ownCloud core');
         $this->updateAlreadyInstalledCheck($notification, $this->getCoreVersions());
     } else {
         $appInfo = $this->getAppInfo($notification->getObjectType());
         $appName = $appInfo === null ? $notification->getObjectType() : $appInfo['name'];
         if (isset($this->appVersions[$notification->getObjectType()])) {
             $this->updateAlreadyInstalledCheck($notification, $this->appVersions[$notification->getObjectType()]);
         }
     }
     $notification->setParsedSubject($l->t('Update for %1$s to version %2$s is available.', [$appName, $notification->getObjectId()]));
     return $notification;
 }
コード例 #3
0
ファイル: Handler.php プロジェクト: drognisep/Portfolio-Site
 /**
  * Turn a notification into an input statement
  *
  * @param IQueryBuilder $sql
  * @param INotification $notification
  */
 protected function sqlInsert(IQueryBuilder $sql, INotification $notification)
 {
     $sql->setValue('app', $sql->createParameter('app'))->setParameter('app', $notification->getApp());
     $sql->setValue('user', $sql->createParameter('user'))->setParameter('user', $notification->getUser());
     $sql->setValue('timestamp', $sql->createParameter('timestamp'))->setParameter('timestamp', $notification->getDateTime()->getTimestamp());
     $sql->setValue('object_type', $sql->createParameter('objectType'))->setParameter('objectType', $notification->getObjectType());
     $sql->setValue('object_id', $sql->createParameter('objectId'))->setParameter('objectId', $notification->getObjectId());
     $sql->setValue('subject', $sql->createParameter('subject'))->setParameter('subject', $notification->getSubject());
     $sql->setValue('subject_parameters', $sql->createParameter('subject_parameters'))->setParameter('subject_parameters', json_encode($notification->getSubjectParameters()));
     $sql->setValue('message', $sql->createParameter('message'))->setParameter('message', $notification->getMessage());
     $sql->setValue('message_parameters', $sql->createParameter('message_parameters'))->setParameter('message_parameters', json_encode($notification->getMessageParameters()));
     $sql->setValue('link', $sql->createParameter('link'))->setParameter('link', $notification->getLink());
     $actions = [];
     foreach ($notification->getActions() as $action) {
         /** @var IAction $action */
         $actions[] = ['label' => $action->getLabel(), 'link' => $action->getLink(), 'type' => $action->getRequestType(), 'primary' => $action->isPrimary()];
     }
     $sql->setValue('actions', $sql->createParameter('actions'))->setParameter('actions', json_encode($actions));
 }
コード例 #4
0
 /**
  * @param int $notificationId
  * @param INotification $notification
  * @return array
  */
 protected function notificationToArray($notificationId, INotification $notification)
 {
     $data = ['notification_id' => $notificationId, 'app' => $notification->getApp(), 'user' => $notification->getUser(), 'datetime' => $notification->getDateTime()->format('c'), 'object_type' => $notification->getObjectType(), 'object_id' => $notification->getObjectId(), 'subject' => $notification->getParsedSubject(), 'message' => $notification->getParsedMessage(), 'link' => $notification->getLink(), 'actions' => []];
     foreach ($notification->getParsedActions() as $action) {
         $data['actions'][] = $this->actionToArray($action);
     }
     return $data;
 }