_filename = $filename; $this->_delimiter = $delimiter; $this->_enclosure = $enclosure; } /** * Display profiling results */ public function display() { $fileHandle = fopen($this->_filename, 'w'); if (!$fileHandle) { throw new Varien_Exception(sprintf('Can not open a file "%s".', $this->_filename)); } $needLock = (strpos($this->_filename, 'php://') !== 0); $isLocked = false; while ($needLock && !$isLocked) { $isLocked = flock($fileHandle, LOCK_EX); } $this->_writeFileContent($fileHandle); if ($isLocked) { flock($fileHandle, LOCK_UN); } fclose($fileHandle); } /** * Write content into an opened file handle * * @param resource $fileHandle */ protected function _writeFileContent($fileHandle) { foreach ($this->_getTimers() as $timerId) { $row = array(); foreach ($this->_getColumns() as $columnId) { $row[] = $this->_renderColumnValue($timerId, $columnId); } fputcsv($fileHandle, $row, $this->_delimiter, $this->_enclosure); } } }