Completed
Push — master ( 112f6f...d692f3 )
by
unknown
20:22 queued 14s
created
apps/files/lib/Activity/FavoriteProvider.php 2 patches
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -15,135 +15,135 @@
 block discarded – undo
15 15
 use OCP\L10N\IFactory;
16 16
 
17 17
 class FavoriteProvider implements IProvider {
18
-	public const SUBJECT_ADDED = 'added_favorite';
19
-	public const SUBJECT_REMOVED = 'removed_favorite';
18
+    public const SUBJECT_ADDED = 'added_favorite';
19
+    public const SUBJECT_REMOVED = 'removed_favorite';
20 20
 
21
-	/** @var IL10N */
22
-	protected $l;
21
+    /** @var IL10N */
22
+    protected $l;
23 23
 
24
-	/**
25
-	 * @param IFactory $languageFactory
26
-	 * @param IURLGenerator $url
27
-	 * @param IManager $activityManager
28
-	 * @param IEventMerger $eventMerger
29
-	 */
30
-	public function __construct(
31
-		protected IFactory $languageFactory,
32
-		protected IURLGenerator $url,
33
-		protected IManager $activityManager,
34
-		protected IEventMerger $eventMerger,
35
-	) {
36
-	}
24
+    /**
25
+     * @param IFactory $languageFactory
26
+     * @param IURLGenerator $url
27
+     * @param IManager $activityManager
28
+     * @param IEventMerger $eventMerger
29
+     */
30
+    public function __construct(
31
+        protected IFactory $languageFactory,
32
+        protected IURLGenerator $url,
33
+        protected IManager $activityManager,
34
+        protected IEventMerger $eventMerger,
35
+    ) {
36
+    }
37 37
 
38
-	/**
39
-	 * @param string $language
40
-	 * @param IEvent $event
41
-	 * @param IEvent|null $previousEvent
42
-	 * @return IEvent
43
-	 * @throws UnknownActivityException
44
-	 * @since 11.0.0
45
-	 */
46
-	public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
47
-		if ($event->getApp() !== 'files' || $event->getType() !== 'favorite') {
48
-			throw new UnknownActivityException();
49
-		}
38
+    /**
39
+     * @param string $language
40
+     * @param IEvent $event
41
+     * @param IEvent|null $previousEvent
42
+     * @return IEvent
43
+     * @throws UnknownActivityException
44
+     * @since 11.0.0
45
+     */
46
+    public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
47
+        if ($event->getApp() !== 'files' || $event->getType() !== 'favorite') {
48
+            throw new UnknownActivityException();
49
+        }
50 50
 
51
-		$this->l = $this->languageFactory->get('files', $language);
51
+        $this->l = $this->languageFactory->get('files', $language);
52 52
 
53
-		if ($this->activityManager->isFormattingFilteredObject()) {
54
-			try {
55
-				return $this->parseShortVersion($event);
56
-			} catch (UnknownActivityException) {
57
-				// Ignore and simply use the long version...
58
-			}
59
-		}
53
+        if ($this->activityManager->isFormattingFilteredObject()) {
54
+            try {
55
+                return $this->parseShortVersion($event);
56
+            } catch (UnknownActivityException) {
57
+                // Ignore and simply use the long version...
58
+            }
59
+        }
60 60
 
61
-		return $this->parseLongVersion($event, $previousEvent);
62
-	}
61
+        return $this->parseLongVersion($event, $previousEvent);
62
+    }
63 63
 
64
-	/**
65
-	 * @param IEvent $event
66
-	 * @return IEvent
67
-	 * @throws UnknownActivityException
68
-	 * @since 11.0.0
69
-	 */
70
-	public function parseShortVersion(IEvent $event): IEvent {
71
-		if ($event->getSubject() === self::SUBJECT_ADDED) {
72
-			$event->setParsedSubject($this->l->t('Added to favorites'));
73
-			if ($this->activityManager->getRequirePNG()) {
74
-				$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.png')));
75
-			} else {
76
-				$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg')));
77
-			}
78
-		} elseif ($event->getSubject() === self::SUBJECT_REMOVED) {
79
-			$event->setType('unfavorite');
80
-			$event->setParsedSubject($this->l->t('Removed from favorites'));
81
-			if ($this->activityManager->getRequirePNG()) {
82
-				$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.png')));
83
-			} else {
84
-				$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.svg')));
85
-			}
86
-		} else {
87
-			throw new UnknownActivityException();
88
-		}
64
+    /**
65
+     * @param IEvent $event
66
+     * @return IEvent
67
+     * @throws UnknownActivityException
68
+     * @since 11.0.0
69
+     */
70
+    public function parseShortVersion(IEvent $event): IEvent {
71
+        if ($event->getSubject() === self::SUBJECT_ADDED) {
72
+            $event->setParsedSubject($this->l->t('Added to favorites'));
73
+            if ($this->activityManager->getRequirePNG()) {
74
+                $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.png')));
75
+            } else {
76
+                $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg')));
77
+            }
78
+        } elseif ($event->getSubject() === self::SUBJECT_REMOVED) {
79
+            $event->setType('unfavorite');
80
+            $event->setParsedSubject($this->l->t('Removed from favorites'));
81
+            if ($this->activityManager->getRequirePNG()) {
82
+                $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.png')));
83
+            } else {
84
+                $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.svg')));
85
+            }
86
+        } else {
87
+            throw new UnknownActivityException();
88
+        }
89 89
 
90
-		return $event;
91
-	}
90
+        return $event;
91
+    }
92 92
 
93
-	/**
94
-	 * @param IEvent $event
95
-	 * @param IEvent|null $previousEvent
96
-	 * @return IEvent
97
-	 * @throws UnknownActivityException
98
-	 * @since 11.0.0
99
-	 */
100
-	public function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null): IEvent {
101
-		if ($event->getSubject() === self::SUBJECT_ADDED) {
102
-			$subject = $this->l->t('You added {file} to your favorites');
103
-			if ($this->activityManager->getRequirePNG()) {
104
-				$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.png')));
105
-			} else {
106
-				$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg')));
107
-			}
108
-		} elseif ($event->getSubject() === self::SUBJECT_REMOVED) {
109
-			$event->setType('unfavorite');
110
-			$subject = $this->l->t('You removed {file} from your favorites');
111
-			if ($this->activityManager->getRequirePNG()) {
112
-				$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.png')));
113
-			} else {
114
-				$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.svg')));
115
-			}
116
-		} else {
117
-			throw new UnknownActivityException();
118
-		}
93
+    /**
94
+     * @param IEvent $event
95
+     * @param IEvent|null $previousEvent
96
+     * @return IEvent
97
+     * @throws UnknownActivityException
98
+     * @since 11.0.0
99
+     */
100
+    public function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null): IEvent {
101
+        if ($event->getSubject() === self::SUBJECT_ADDED) {
102
+            $subject = $this->l->t('You added {file} to your favorites');
103
+            if ($this->activityManager->getRequirePNG()) {
104
+                $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.png')));
105
+            } else {
106
+                $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg')));
107
+            }
108
+        } elseif ($event->getSubject() === self::SUBJECT_REMOVED) {
109
+            $event->setType('unfavorite');
110
+            $subject = $this->l->t('You removed {file} from your favorites');
111
+            if ($this->activityManager->getRequirePNG()) {
112
+                $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.png')));
113
+            } else {
114
+                $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.svg')));
115
+            }
116
+        } else {
117
+            throw new UnknownActivityException();
118
+        }
119 119
 
120
-		$this->setSubjects($event, $subject);
121
-		$event = $this->eventMerger->mergeEvents('file', $event, $previousEvent);
122
-		return $event;
123
-	}
120
+        $this->setSubjects($event, $subject);
121
+        $event = $this->eventMerger->mergeEvents('file', $event, $previousEvent);
122
+        return $event;
123
+    }
124 124
 
125
-	/**
126
-	 * @param IEvent $event
127
-	 * @param string $subject
128
-	 */
129
-	protected function setSubjects(IEvent $event, $subject) {
130
-		$subjectParams = $event->getSubjectParameters();
131
-		if (empty($subjectParams)) {
132
-			// Try to fall back to the old way, but this does not work for emails.
133
-			// But at least old activities still work.
134
-			$subjectParams = [
135
-				'id' => $event->getObjectId(),
136
-				'path' => $event->getObjectName(),
137
-			];
138
-		}
139
-		$parameter = [
140
-			'type' => 'file',
141
-			'id' => (string)$subjectParams['id'],
142
-			'name' => basename($subjectParams['path']),
143
-			'path' => trim($subjectParams['path'], '/'),
144
-			'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $subjectParams['id']]),
145
-		];
125
+    /**
126
+     * @param IEvent $event
127
+     * @param string $subject
128
+     */
129
+    protected function setSubjects(IEvent $event, $subject) {
130
+        $subjectParams = $event->getSubjectParameters();
131
+        if (empty($subjectParams)) {
132
+            // Try to fall back to the old way, but this does not work for emails.
133
+            // But at least old activities still work.
134
+            $subjectParams = [
135
+                'id' => $event->getObjectId(),
136
+                'path' => $event->getObjectName(),
137
+            ];
138
+        }
139
+        $parameter = [
140
+            'type' => 'file',
141
+            'id' => (string)$subjectParams['id'],
142
+            'name' => basename($subjectParams['path']),
143
+            'path' => trim($subjectParams['path'], '/'),
144
+            'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $subjectParams['id']]),
145
+        ];
146 146
 
147
-		$event->setRichSubject($subject, ['file' => $parameter]);
148
-	}
147
+        $event->setRichSubject($subject, ['file' => $parameter]);
148
+    }
149 149
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@
 block discarded – undo
138 138
 		}
139 139
 		$parameter = [
140 140
 			'type' => 'file',
141
-			'id' => (string)$subjectParams['id'],
141
+			'id' => (string) $subjectParams['id'],
142 142
 			'name' => basename($subjectParams['path']),
143 143
 			'path' => trim($subjectParams['path'], '/'),
144 144
 			'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $subjectParams['id']]),
Please login to merge, or discard this patch.