AbstractConsumer.php
2 years ago
CurlConsumer.php
2 years ago
FileConsumer.php
2 years ago
SocketConsumer.php
2 years ago
index.php
2 years ago
FileConsumer.php
19 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | require_once(dirname(__FILE__) . "/AbstractConsumer.php"); |
| 4 | class ConsumerStrategies_FileConsumer extends ConsumerStrategies_AbstractConsumer { |
| 5 | private $_file; |
| 6 | function __construct($options) { |
| 7 | parent::__construct($options); |
| 8 | // what file to write to? |
| 9 | $this->_file = isset($options['file']) ? $options['file'] : dirname(__FILE__)."/../../messages.txt"; |
| 10 | } |
| 11 | public function persist($batch) { |
| 12 | if (count($batch) > 0) { |
| 13 | return file_put_contents($this->_file, json_encode($batch)."\n", FILE_APPEND | LOCK_EX) !== false; |
| 14 | } else { |
| 15 | return true; |
| 16 | } |
| 17 | } |
| 18 | } |
| 19 |