summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-02-10 17:45:04 +0100
committerJoas Schilling <coding@schilljs.com>2018-03-06 12:15:13 +0100
commit0911f3bde17f85ee04b3c2f18a1e63283a2163d7 (patch)
treee9dfe6f662b8c3988783dad51e1a80aa084a2d4d /apps
parent242f0c0b5a79d6f24a01989980a93f8b8bb09ad0 (diff)
downloadnextcloud-server-0911f3bde17f85ee04b3c2f18a1e63283a2163d7.tar.gz
nextcloud-server-0911f3bde17f85ee04b3c2f18a1e63283a2163d7.zip
Extract duplicated logic into a method
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/lib/Activity/Provider.php104
1 files changed, 24 insertions, 80 deletions
diff --git a/apps/files/lib/Activity/Provider.php b/apps/files/lib/Activity/Provider.php
index 3da1f3c1157..727dbddaeee 100644
--- a/apps/files/lib/Activity/Provider.php
+++ b/apps/files/lib/Activity/Provider.php
@@ -101,6 +101,14 @@ class Provider implements IProvider {
return $this->parseLongVersion($event, $previousEvent);
}
+ protected function setIcon(IEvent $event, $icon) {
+ if ($this->activityManager->getRequirePNG()) {
+ $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', $icon . '.png')));
+ } else {
+ $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', $icon . '.svg')));
+ }
+ }
+
/**
* @param IEvent $event
* @param IEvent|null $previousEvent
@@ -113,41 +121,21 @@ class Provider implements IProvider {
if ($event->getSubject() === 'created_by') {
$subject = $this->l->t('Created by {user}');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
- }
+ $this->setIcon($event, 'add-color');
} else if ($event->getSubject() === 'changed_by') {
$subject = $this->l->t('Changed by {user}');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
- }
+ $this->setIcon($event, 'change');
} else if ($event->getSubject() === 'deleted_by') {
$subject = $this->l->t('Deleted by {user}');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.svg')));
- }
+ $this->setIcon($event, 'delete-color');
} else if ($event->getSubject() === 'restored_by') {
$subject = $this->l->t('Restored by {user}');
} else if ($event->getSubject() === 'renamed_by') {
$subject = $this->l->t('Renamed by {user}');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
- }
+ $this->setIcon($event, 'change');
} else if ($event->getSubject() === 'moved_by') {
$subject = $this->l->t('Moved by {user}');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
- }
+ $this->setIcon($event, 'change');
} else {
throw new \InvalidArgumentException();
}
@@ -174,85 +162,41 @@ class Provider implements IProvider {
if ($event->getSubject() === 'created_self') {
$subject = $this->l->t('You created {file}');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
- }
+ $this->setIcon($event, 'add-color');
} else if ($event->getSubject() === 'created_by') {
$subject = $this->l->t('{user} created {file}');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
- }
+ $this->setIcon($event, 'add-color');
} else if ($event->getSubject() === 'created_public') {
$subject = $this->l->t('{file} was created in a public folder');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
- }
+ $this->setIcon($event, 'add-color');
} else if ($event->getSubject() === 'changed_self') {
$subject = $this->l->t('You changed {file}');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
- }
+ $this->setIcon($event, 'change');
} else if ($event->getSubject() === 'changed_by') {
$subject = $this->l->t('{user} changed {file}');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
- }
+ $this->setIcon($event, 'change');
} else if ($event->getSubject() === 'deleted_self') {
$subject = $this->l->t('You deleted {file}');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.svg')));
- }
+ $this->setIcon($event, 'delete-color');
} else if ($event->getSubject() === 'deleted_by') {
$subject = $this->l->t('{user} deleted {file}');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.svg')));
- }
+ $this->setIcon($event, 'delete-color');
} else if ($event->getSubject() === 'restored_self') {
$subject = $this->l->t('You restored {file}');
} else if ($event->getSubject() === 'restored_by') {
$subject = $this->l->t('{user} restored {file}');
} else if ($event->getSubject() === 'renamed_self') {
$subject = $this->l->t('You renamed {oldfile} to {newfile}');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
- }
+ $this->setIcon($event, 'change');
} else if ($event->getSubject() === 'renamed_by') {
$subject = $this->l->t('{user} renamed {oldfile} to {newfile}');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
- }
+ $this->setIcon($event, 'change');
} else if ($event->getSubject() === 'moved_self') {
$subject = $this->l->t('You moved {oldfile} to {newfile}');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
- }
+ $this->setIcon($event, 'change');
} else if ($event->getSubject() === 'moved_by') {
$subject = $this->l->t('{user} moved {oldfile} to {newfile}');
- if ($this->activityManager->getRequirePNG()) {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
- } else {
- $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
- }
+ $this->setIcon($event, 'change');
} else {
throw new \InvalidArgumentException();
}