@@ -22,6 +22,8 @@ class ThothBookService
2222{
2323 public $ factory ;
2424 public $ repository ;
25+
26+ private $ originalThothBook ;
2527 private $ registeredEntryId ;
2628
2729 public function __construct ($ factory , $ repository )
@@ -30,6 +32,16 @@ public function __construct($factory, $repository)
3032 $ this ->repository = $ repository ;
3133 }
3234
35+ public function getOriginalThothBook ()
36+ {
37+ return $ this ->originalThothBook ;
38+ }
39+
40+ public function setOriginalThothBook ($ originalThothBook )
41+ {
42+ $ this ->originalThothBook = $ originalThothBook ;
43+ }
44+
3345 public function getRegisteredEntryId ()
3446 {
3547 return $ this ->registeredEntryId ;
@@ -45,6 +57,11 @@ public function register($publication, $thothImprintId)
4557 $ thothBook = $ this ->factory ->createFromPublication ($ publication );
4658 $ thothBook ->setImprintId ($ thothImprintId );
4759
60+ if ($ thothBook ->getWorkStatus () === ThothWork::WORK_STATUS_ACTIVE ) {
61+ $ this ->setOriginalThothBook ($ thothBook );
62+ $ thothBook ->setWorkStatus (ThothWork::WORK_STATUS_FORTHCOMING );
63+ }
64+
4865 $ thothBookId = $ this ->repository ->add ($ thothBook );
4966 $ publication ->setData ('thothBookId ' , $ thothBookId );
5067 $ this ->setRegisteredEntryId ($ thothBookId );
@@ -122,4 +139,15 @@ public function deleteRegisteredEntry()
122139 $ this ->repository ->delete ($ this ->getRegisteredEntryId ());
123140 $ this ->setRegisteredEntryId (null );
124141 }
142+
143+ public function setActive ()
144+ {
145+ if ($ this ->getOriginalThothBook () === null ) {
146+ return ;
147+ }
148+
149+ $ originalThothBook = $ this ->getOriginalThothBook ();
150+ $ originalThothBook ->setWorkStatus (ThothWork::WORK_STATUS_ACTIVE );
151+ $ this ->repository ->edit ($ originalThothBook );
152+ }
125153}
0 commit comments