/** * Constructor * * @param array $config */ public function __construct(Bronto_Api_Rowset $rowset) { $this->_apiObject = $rowset->getApiObject(); if (!$this->_apiObject->canIterate()) { throw new Bronto_Api_Rowset_Exception(sprintf('Cannot iterate results for %s', $this->_apiObject->getName())); } $this->_type = $this->_apiObject->getIteratorType(); $this->_params = $this->_apiObject->getIteratorParams(); $this->_rowset = $rowset; $this->_count = $rowset->count(); // Set initial/next values $this->_setupParamValues(); }
/** * @param Bronto_Api_Object $object * @param int $attempts * @return string */ public function store(Bronto_Api_Object $object, $attempts = 0) { if (!@is_dir($this->_path) && !@mkdir($this->_path, 0777, true)) { throw new Bronto_Util_RetryerException(sprintf('The Retryer path is not a directory: %s', $this->_path)); } else { if (!@is_writable($this->_path)) { throw new Bronto_Util_RetryerException(sprintf('The Retryer path is not a writable: %s', $this->_path)); } } $filename = sprintf('%s_%s_%s_%d.php', strtolower($object->getName()), str_replace('.', '', microtime()), str_pad(rand(0, 1000), 4, ' ', STR_PAD_LEFT), (int) $attempts); $filename = str_replace(' ', '', $filename); $fh = @fopen($this->_path . DIRECTORY_SEPARATOR . $filename, 'w'); $serialized = serialize($object); $result = @fwrite($fh, sprintf("<?php return unserialize('%s'); ?>", $serialized)); @fclose($fh); return $result ? $filename : false; }