File tree Expand file tree Collapse file tree 4 files changed +15
-15
lines changed Expand file tree Collapse file tree 4 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ public function update(Request $request): Response
107107
108108 if (!auth \LinksAccess::canUpdate ($ user , $ link )) {
109109 $ link = $ user ->obtainLink ($ link );
110- utils \SourceHelper:: setLinkSource ( $ link, $ from );
110+ $ link-> setSourceFrom ( $ from );
111111 }
112112
113113 $ form = new forms \links \EditLinkCollections (model: $ link );
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ public function create(Request $request): Response
5555
5656 $ link = $ user ->obtainLink ($ link );
5757 if (!$ link ->isPersisted ()) {
58- utils \SourceHelper:: setLinkSource ( $ link, $ from );
58+ $ link-> setSourceFrom ( $ from );
5959 $ link ->save ();
6060 }
6161
@@ -103,7 +103,7 @@ public function later(Request $request): Response
103103
104104 $ link = $ user ->obtainLink ($ link );
105105 if (!$ link ->isPersisted ()) {
106- utils \SourceHelper:: setLinkSource ( $ link, $ from );
106+ $ link-> setSourceFrom ( $ from );
107107 $ link ->save ();
108108 }
109109
Original file line number Diff line number Diff line change @@ -353,6 +353,18 @@ public function source(): User|Collection|null
353353 }
354354 }
355355
356+ /**
357+ * Set the source properties of the link if "from" is a supported internal path.
358+ */
359+ public function setSourceFrom (string $ from ): void
360+ {
361+ list ($ source_type , $ source_resource_id ) = utils \SourceHelper::extractFromPath ($ from );
362+ if ($ source_type ) {
363+ $ this ->source_type = $ source_type ;
364+ $ this ->source_resource_id = $ source_resource_id ;
365+ }
366+ }
367+
356368 /**
357369 * Return whether or not the given user has the link URL in its bookmarks.
358370 */
Original file line number Diff line number Diff line change 1010 */
1111class SourceHelper
1212{
13- /**
14- * Set the source_* properties of a link if possible.
15- */
16- public static function setLinkSource (models \Link $ link , string $ from ): void
17- {
18- list ($ source_type , $ source_resource_id ) = self ::extractFromPath ($ from );
19- if ($ source_type ) {
20- $ link ->source_type = $ source_type ;
21- $ link ->source_resource_id = $ source_resource_id ;
22- }
23- }
24-
2513 /**
2614 * Return the source type and resource id from a path.
2715 *
You can’t perform that action at this time.
0 commit comments