From 0840938dff3a2bdc8db836662fea2bbccff05e03 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Sun, 26 Jan 2020 20:30:24 +0100 Subject: [PATCH] Rename classes - Repository/Model Notification => Notify - Factory/Object Notification => Notification --- include/api.php | 8 ++++---- include/enotify.php | 8 ++++---- mod/ping.php | 2 +- .../{Notifications.php => Notifies.php} | 4 ++-- src/DI.php | 18 +++++++++--------- ...ntroductionFactory.php => Introduction.php} | 6 +++--- ...otificationFactory.php => Notification.php} | 8 ++++---- src/Model/{Notification.php => Notify.php} | 6 +++--- src/Module/Notifications/Introductions.php | 2 +- src/Module/Notifications/Notification.php | 4 ++-- src/Module/Notifications/Notifications.php | 8 ++++---- .../{Notification.php => Notify.php} | 16 ++++++++-------- 12 files changed, 45 insertions(+), 45 deletions(-) rename src/Collection/{Notifications.php => Notifies.php} (69%) rename src/Factory/Notification/{IntroductionFactory.php => Introduction.php} (98%) rename src/Factory/Notification/{NotificationFactory.php => Notification.php} (98%) rename src/Model/{Notification.php => Notify.php} (96%) rename src/Repository/{Notification.php => Notify.php} (81%) diff --git a/include/api.php b/include/api.php index 0729c2a0f..f43ee2d1b 100644 --- a/include/api.php +++ b/include/api.php @@ -23,7 +23,7 @@ use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Item; use Friendica\Model\Mail; -use Friendica\Model\Notification; +use Friendica\Model\Notify; use Friendica\Model\Photo; use Friendica\Model\Profile; use Friendica\Model\User; @@ -5907,7 +5907,7 @@ function api_friendica_notification($type) throw new BadRequestException("Invalid argument count"); } - $notifications = DI::notification()->select(['uid' => api_user()], ['order' => ['seen' => 'ASC', 'date' => 'DESC'], 'limit' => 50]); + $notifications = DI::notify()->select(['uid' => api_user()], ['order' => ['seen' => 'ASC', 'date' => 'DESC'], 'limit' => 50]); if ($type == "xml") { $xmlnotes = false; @@ -5955,10 +5955,10 @@ function api_friendica_notification_seen($type) $id = (!empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0); try { - $notification = DI::notification()->getByID($id); + $notification = DI::notify()->getByID($id); $notification->setSeen(); - if ($notification->otype === Notification::OTYPE_ITEM) { + if ($notification->otype === Notify::OTYPE_ITEM) { $item = Item::selectFirstForUser(api_user(), [], ['id' => $notification->iid, 'uid' => api_user()]); if (DBA::isResult($item)) { // we found the item, return it to the user diff --git a/include/enotify.php b/include/enotify.php index f509367ef..144460693 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -12,7 +12,7 @@ use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; use Friendica\Model\ItemContent; -use Friendica\Model\Notification; +use Friendica\Model\Notify; use Friendica\Model\User; use Friendica\Model\UserItem; use Friendica\Protocol\Activity; @@ -161,7 +161,7 @@ function notification($params) // if it's a post figure out who's post it is. $item = null; - if ($params['otype'] === Notification::OTYPE_ITEM && $parent_id) { + if ($params['otype'] === Notify::OTYPE_ITEM && $parent_id) { $item = Item::selectFirstForUser($params['uid'], Item::ITEM_FIELDLIST, ['id' => $parent_id, 'deleted' => false]); } @@ -483,7 +483,7 @@ function notification($params) $notify_id = 0; if ($show_in_notification_page) { - $notification = DI::notification()->insert([ + $notification = DI::notify()->insert([ 'name' => $params['source_name'], 'url' => $params['source_link'], 'photo' => $params['source_photo'], @@ -498,7 +498,7 @@ function notification($params) $notification->link = DI::baseUrl() . '/notification/view/' . $notification->id; $notification->msg = Renderer::replaceMacros($epreamble, ['$itemlink' => $notification->link]); - DI::notification()->update($notification); + DI::notify()->update($notification); $itemlink = $notification->link; $notify_id = $notification->id; diff --git a/mod/ping.php b/mod/ping.php index a786d379f..dd57ba34d 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -433,7 +433,7 @@ function ping_get_notifications($uid) $notification["message"] = $notification["msg_cache"]; } else { $notification["name"] = strip_tags(BBCode::convert($notification["name"])); - $notification["message"] = Friendica\Model\Notification::formatMessage($notification["name"], strip_tags(BBCode::convert($notification["msg"]))); + $notification["message"] = Friendica\Model\Notify::formatMessage($notification["name"], strip_tags(BBCode::convert($notification["msg"]))); q( "UPDATE `notify` SET `name_cache` = '%s', `msg_cache` = '%s' WHERE `id` = %d", diff --git a/src/Collection/Notifications.php b/src/Collection/Notifies.php similarity index 69% rename from src/Collection/Notifications.php rename to src/Collection/Notifies.php index 1c04bdf4d..0d64ee7e6 100644 --- a/src/Collection/Notifications.php +++ b/src/Collection/Notifies.php @@ -5,10 +5,10 @@ namespace Friendica\Collection; use Friendica\BaseCollection; use Friendica\Model; -class Notifications extends BaseCollection +class Notifies extends BaseCollection { /** - * @return Model\Notification + * @return Model\Notify */ public function current() { diff --git a/src/DI.php b/src/DI.php index 8f80bf68d..3034bd971 100644 --- a/src/DI.php +++ b/src/DI.php @@ -245,19 +245,19 @@ abstract class DI } /** - * @return \Friendica\Factory\Notification\NotificationFactory + * @return \Friendica\Factory\Notification\Notification */ - public static function factNotification() + public static function notification() { - return self::$dice->create(Factory\Notification\NotificationFactory::class); + return self::$dice->create(Factory\Notification\Notification::class); } /** - * @return \Friendica\Factory\Notification\IntroductionFactory + * @return \Friendica\Factory\Notification\Introduction */ - public static function factNotIntro() + public static function notificationIntro() { - return self::$dice->create(Factory\Notification\IntroductionFactory::class); + return self::$dice->create(Factory\Notification\Introduction::class); } // @@ -273,11 +273,11 @@ abstract class DI } /** - * @return Repository\Notification + * @return Repository\Notify */ - public static function notification() + public static function notify() { - return self::$dice->create(Repository\Notification::class); + return self::$dice->create(Repository\Notify::class); } /** diff --git a/src/Factory/Notification/IntroductionFactory.php b/src/Factory/Notification/Introduction.php similarity index 98% rename from src/Factory/Notification/IntroductionFactory.php rename to src/Factory/Notification/Introduction.php index 098882115..6b192ec1d 100644 --- a/src/Factory/Notification/IntroductionFactory.php +++ b/src/Factory/Notification/Introduction.php @@ -15,7 +15,7 @@ use Friendica\Database\Database; use Friendica\Model\Contact; use Friendica\Module\BaseNotifications; use Friendica\Network\HTTPException\InternalServerErrorException; -use Friendica\Object\Notification\Introduction; +use Friendica\Object; use Friendica\Util\Proxy; use Psr\Log\LoggerInterface; @@ -25,7 +25,7 @@ use Psr\Log\LoggerInterface; * - Friend suggestion * - Friend/Follower request */ -class IntroductionFactory extends BaseFactory +class Introduction extends BaseFactory { /** @var Database */ private $dba; @@ -61,7 +61,7 @@ class IntroductionFactory extends BaseFactory * @param int $limit Maximum number of query results * @param int $id When set, only the introduction with this id is displayed * - * @return Introduction[] + * @return Object\Notification\Introduction[] */ public function getList(bool $all = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT, int $id = 0) { diff --git a/src/Factory/Notification/NotificationFactory.php b/src/Factory/Notification/Notification.php similarity index 98% rename from src/Factory/Notification/NotificationFactory.php rename to src/Factory/Notification/Notification.php index 05dd200ad..5f2c2231b 100644 --- a/src/Factory/Notification/NotificationFactory.php +++ b/src/Factory/Notification/Notification.php @@ -16,7 +16,7 @@ use Friendica\Model\Item; use Friendica\Module\BaseNotifications; use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Protocol\Activity; -use Friendica\Repository\Notification; +use Friendica\Repository; use Friendica\Util\DateTimeFormat; use Friendica\Util\Proxy; use Friendica\Util\Temporal; @@ -31,11 +31,11 @@ use Psr\Log\LoggerInterface; * - home * - personal */ -class NotificationFactory extends BaseFactory +class Notification extends BaseFactory { /** @var Database */ private $dba; - /** @var Notification */ + /** @var Repository\Notify */ private $notification; /** @var BaseURL */ private $baseUrl; @@ -44,7 +44,7 @@ class NotificationFactory extends BaseFactory /** @var string */ private $nurl; - public function __construct(LoggerInterface $logger, Database $dba, Notification $notification, BaseURL $baseUrl, L10n $l10n, App $app, IPConfig $pConfig, ISession $session) + public function __construct(LoggerInterface $logger, Database $dba, Repository\Notify $notification, BaseURL $baseUrl, L10n $l10n, App $app, IPConfig $pConfig, ISession $session) { parent::__construct($logger); diff --git a/src/Model/Notification.php b/src/Model/Notify.php similarity index 96% rename from src/Model/Notification.php rename to src/Model/Notify.php index 75fb95829..1bb9f2904 100644 --- a/src/Model/Notification.php +++ b/src/Model/Notify.php @@ -42,17 +42,17 @@ use Psr\Log\LoggerInterface; * @property-read string $msg_html * @property-read string $msg_plain */ -class Notification extends BaseModel +class Notify extends BaseModel { const OTYPE_ITEM = 'item'; const OTYPE_INTRO = 'intro'; const OTYPE_MAIL = 'mail'; const OTYPE_PERSON = 'person'; - /** @var \Friendica\Repository\Notification */ + /** @var \Friendica\Repository\Notify */ private $repo; - public function __construct(Database $dba, LoggerInterface $logger, \Friendica\Repository\Notification $repo, array $data = []) + public function __construct(Database $dba, LoggerInterface $logger, \Friendica\Repository\Notify $repo, array $data = []) { parent::__construct($dba, $logger, $data); diff --git a/src/Module/Notifications/Introductions.php b/src/Module/Notifications/Introductions.php index 69c776382..10919a13a 100644 --- a/src/Module/Notifications/Introductions.php +++ b/src/Module/Notifications/Introductions.php @@ -26,7 +26,7 @@ class Introductions extends BaseNotifications $notifications = [ 'ident' => 'introductions', - 'notifications' => DI::factNotIntro()->getList($all, self::$firstItemNum, self::ITEMS_PER_PAGE, $id), + 'notifications' => DI::notificationIntro()->getList($all, self::$firstItemNum, self::ITEMS_PER_PAGE, $id), ]; return [ diff --git a/src/Module/Notifications/Notification.php b/src/Module/Notifications/Notification.php index f7fe6f190..9b252562c 100644 --- a/src/Module/Notifications/Notification.php +++ b/src/Module/Notifications/Notification.php @@ -24,7 +24,7 @@ class Notification extends BaseModule // @TODO: Replace with parameter from router if (DI::args()->get(1) === 'mark' && DI::args()->get(2) === 'all') { try { - $success = DI::notification()->setAllSeen(); + $success = DI::notify()->setAllSeen(); }catch (\Exception $e) { $success = false; } @@ -48,7 +48,7 @@ class Notification extends BaseModule // @TODO: Replace with parameter from router if (DI::args()->getArgc() > 2 && DI::args()->get(1) === 'view' && intval(DI::args()->get(2))) { try { - $notification = DI::notification()->getByID(DI::args()->get(2)); + $notification = DI::notify()->getByID(DI::args()->get(2)); $notification->setSeen(); if (!empty($notification->link)) { diff --git a/src/Module/Notifications/Notifications.php b/src/Module/Notifications/Notifications.php index bff5026df..37b234666 100644 --- a/src/Module/Notifications/Notifications.php +++ b/src/Module/Notifications/Notifications.php @@ -31,7 +31,7 @@ class Notifications extends BaseNotifications $notificationHeader = DI::l10n()->t('Network Notifications'); $notifications = [ 'ident' => Notification::NETWORK, - 'notifications' => DI::factNotification()->getNetworkList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE), + 'notifications' => DI::notification()->getNetworkList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE), ]; // Get the system notifications @@ -39,7 +39,7 @@ class Notifications extends BaseNotifications $notificationHeader = DI::l10n()->t('System Notifications'); $notifications = [ 'ident' => Notification::SYSTEM, - 'notifications' => DI::factNotification()->getSystemList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE), + 'notifications' => DI::notification()->getSystemList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE), ]; // Get the personal notifications @@ -47,7 +47,7 @@ class Notifications extends BaseNotifications $notificationHeader = DI::l10n()->t('Personal Notifications'); $notifications = [ 'ident' => Notification::PERSONAL, - 'notifications' => DI::factNotification()->getPersonalList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE), + 'notifications' => DI::notification()->getPersonalList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE), ]; // Get the home notifications @@ -55,7 +55,7 @@ class Notifications extends BaseNotifications $notificationHeader = DI::l10n()->t('Home Notifications'); $notifications = [ 'ident' => Notification::HOME, - 'notifications' => DI::factNotification()->getHomeList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE), + 'notifications' => DI::notification()->getHomeList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE), ]; // fallback - redirect to main page } else { diff --git a/src/Repository/Notification.php b/src/Repository/Notify.php similarity index 81% rename from src/Repository/Notification.php rename to src/Repository/Notify.php index a17d1223a..2ac14858f 100644 --- a/src/Repository/Notification.php +++ b/src/Repository/Notify.php @@ -10,28 +10,28 @@ use Friendica\Collection; use Friendica\Network\HTTPException\NotFoundException; use Friendica\Util\DateTimeFormat; -class Notification extends BaseRepository +class Notify extends BaseRepository { protected static $table_name = 'notify'; - protected static $model_class = Model\Notification::class; + protected static $model_class = Model\Notify::class; - protected static $collection_class = Collection\Notifications::class; + protected static $collection_class = Collection\Notifies::class; /** * {@inheritDoc} * - * @return Model\Notification + * @return Model\Notify */ protected function create(array $data) { - return new Model\Notification($this->dba, $this->logger, $this, $data); + return new Model\Notify($this->dba, $this->logger, $this, $data); } /** * {@inheritDoc} * - * @return Collection\Notifications + * @return Collection\Notifies */ public function select(array $condition = [], array $params = []) { @@ -45,7 +45,7 @@ class Notification extends BaseRepository /** * {@inheritDoc} * - * @return Model\Notification + * @return Model\Notify * @throws NotFoundException */ public function getByID(int $id) @@ -67,7 +67,7 @@ class Notification extends BaseRepository /** * @param array $fields * - * @return Model\Notification + * @return Model\Notify * * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws Exception