1
0
Fork 0

Rename classes

- Repository/Model Notification => Notify
- Factory/Object Notification => Notification
This commit is contained in:
Philipp Holzer 2020-01-26 20:30:24 +01:00
parent b85511b00d
commit 0840938dff
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
12 changed files with 45 additions and 45 deletions

View file

@ -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

View file

@ -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;

View file

@ -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",

View file

@ -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()
{

View file

@ -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);
}
/**

View file

@ -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)
{

View file

@ -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);

View file

@ -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);

View file

@ -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 [

View file

@ -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)) {

View file

@ -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 {

View file

@ -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