@@ -32,12 +32,14 @@ abstract class AutoPurge implements ObserverInterface {
3232 * @var ManagerInterface _messageManager Instance of the ManagerInterface
3333 * @var Purger _purger Instance of the Purger helper class
3434 * @var StoreManager _storeManager Instance of the StoreManager
35+ * @var Array _messages Saved messages for dumping together
3536 */
3637 protected $ _data ;
3738 protected $ _logger ;
3839 protected $ _messageManager ;
3940 protected $ _purger ;
4041 protected $ _storeManager ;
42+ protected $ _messages ;
4143
4244 /**
4345 * This constructor is overloaded from the parent class in order to use dependency injection
@@ -61,6 +63,7 @@ public function __construct (
6163 $ this ->_messageManager = $ messageManager ;
6264 $ this ->_purger = $ purger ;
6365 $ this ->_storeManager = $ storeManager ;
66+ $ this ->_messages = [];
6467 }
6568
6669 /**
@@ -98,7 +101,6 @@ protected function _purgeOnAllServers ( $target, $purgeChildren = false ) {
98101 return $ noErrors ;
99102 }
100103
101-
102104 /**
103105 * This method takes in a route and it looks through the rewrites table for all urls that lead
104106 * to said url. It uses a passed store object to determine the base url to use.
@@ -121,14 +123,26 @@ protected function _purgeUsingStoreObject ( $route, $store ) {
121123 $ success &= $ this ->_purgeOnAllServers ( rtrim ( $ target , "/ " ) . "? " , true );
122124 if ( $ success ) {
123125 // Add success response message
124- $ targetHtml = "<font color='#79A22E' ><b> $ target</b></font> " ;
125- $ serverHtml = "<font color='#79A22E' ><b>all varnish servers</b></font> " ;
126- $ message = "Successfully purged varnish cache for $ targetHtml on $ serverHtml " ;
127- $ this ->_messageManager ->addSuccess ( $ message );
126+ array_push ( $ this ->_messages , $ target );
128127 }
129128 }
130129 }
131130
131+ /**
132+ * This method takes in some header text and appends all the saved messages to it. It then
133+ * uses the message manager to send the message together.
134+ * @param String header The header to append to the message\
135+ * @return void
136+ */
137+ protected function _dumpCombinedMessages ( $ header ) {
138+ if ( count ( $ this ->_messages ) > 0 ) {
139+ $ header = "<font color='#79A22E' ><b> $ header</b></font> " ;
140+ array_unshift ( $ this ->_messages , $ header );
141+ $ this ->_messageManager ->addSuccess ( implode ( "</br> " , $ this ->_messages ) );
142+ $ this ->_messages = [];
143+ }
144+ }
145+
132146 /**
133147 * This method takes in a route and determines if the current scope is the "All Stores Scope".
134148 * If it is, then all store views are purged, otherwise just the current one is purged.
0 commit comments