File tree Expand file tree Collapse file tree 2 files changed +10
-16
lines changed Expand file tree Collapse file tree 2 files changed +10
-16
lines changed Original file line number Diff line number Diff line change @@ -25,11 +25,8 @@ public function update(Entity $entity): RedirectResponse
25
25
26
26
$ entity = DB ::transaction (function () use ($ entity ) {
27
27
$ entity ->hfd = ! $ entity ->hfd ;
28
- $ xml_document = HfdTag::update ($ entity );
29
- if ($ xml_document ) {
30
- $ entity ->xml_file = $ xml_document ;
31
- $ entity ->update ();
32
- }
28
+ $ entity ->xml_file = HfdTag::update ($ entity );
29
+ $ entity ->update ();
33
30
34
31
return $ entity ;
35
32
});
Original file line number Diff line number Diff line change @@ -42,36 +42,33 @@ public function createFromXml(string $xml_document): false|string
42
42
return $ dom ->saveXML ();
43
43
}
44
44
45
- public function delete (Entity $ entity ): false | string
45
+ public function delete (Entity $ entity ): string
46
46
{
47
47
$ dom = $ this ->createDOM ($ entity ->xml_file );
48
48
$ xPath = $ this ->createXPath ($ dom );
49
- $ this ->deleteByXpath ($ xPath );
49
+ $ xpathQuery = $ this ->buildXPathQuery ($ this ->value );
50
+ $ this ->DeleteAllTags ($ xpathQuery , $ xPath );
50
51
$ dom ->normalize ();
51
52
52
53
return $ dom ->saveXML ();
53
54
}
54
55
55
- public function deleteByXpath (DOMXPath $ xPath ): void
56
- {
57
- $ xpathQuery = $ this ->buildXPathQuery ($ this ->value );
58
- $ this ->DeleteAllTags ($ xpathQuery , $ xPath );
59
- }
60
-
61
- public function update (Entity $ entity ): false |string
56
+ public function update (Entity $ entity ): string
62
57
{
63
58
try {
64
59
if ($ entity ->hfd ) {
65
60
if (! $ this ->hasTagInDocument ($ entity ->xml_file , $ this ->value )) {
66
61
return $ this ->create ($ entity );
67
62
}
63
+
64
+ return $ entity ->xml_file ;
68
65
} else {
69
66
if ($ this ->hasTagInDocument ($ entity ->xml_file , $ this ->value )) {
70
67
return $ this ->delete ($ entity );
71
68
}
72
- }
73
69
74
- return false ;
70
+ return $ entity ->xml_file ;
71
+ }
75
72
} catch (Exception $ e ) {
76
73
Log::critical ("Exception occurred in {$ entity ->id }}: {$ e ->getMessage ()}" );
77
74
throw $ e ;
You can’t perform that action at this time.
0 commit comments