Extract duplicated logic into a method
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
533e8351ad
commit
03a25410f1
1 changed files with 24 additions and 80 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue