Buffalo Eats Online API Documentation

ArchiveService
in package

Service for archiving all data associated with a business.

Exports all business-related records to JSON files organized in a timestamped directory under storage/archives/. Copies associated file assets (logos, photos). Supports ZIP download and deletion.

Tags
author

J.J. Johnson visionquest716@gmail.com

copyright

2026 VisionQuestServices LLC

Table of Contents

Properties

$db  : PDO

Methods

__construct()  : mixed
archiveBusiness()  : array<string|int, mixed>
Archive all data for a business to JSON files and copy associated assets.
createZip()  : string|null
Create a ZIP archive from an existing archive directory.
deleteArchive()  : bool
Delete an archive directory and its ZIP file if present.
getArchive()  : array<string|int, mixed>|null
Get a single archive by its directory name.
listArchives()  : array<string|int, mixed>
List all archives on disk.
addDirectoryToZip()  : void
Recursively add a directory to a ZipArchive.
copyAssets()  : int
Copy file assets (logo, photos) into the archive directory.
deleteDirectory()  : bool
Recursively delete a directory and its contents.
exportQuery()  : int
Export query results to a JSON file.
exportTable()  : int
Export a table's rows matching a WHERE clause to a JSON file.
getDirectorySize()  : int
Get total size of a directory in bytes.

Properties

Methods

archiveBusiness()

Archive all data for a business to JSON files and copy associated assets.

public archiveBusiness(int $businessId) : array<string|int, mixed>
Parameters
$businessId : int

Business ID

Return values
array<string|int, mixed>

Result with keys: success, path, error, stats

createZip()

Create a ZIP archive from an existing archive directory.

public createZip(string $archiveDir) : string|null
Parameters
$archiveDir : string

Path to archive directory

Return values
string|null

Path to ZIP file, or null on failure

deleteArchive()

Delete an archive directory and its ZIP file if present.

public deleteArchive(string $archiveDir) : bool
Parameters
$archiveDir : string

Path to archive directory

Return values
bool

True if deleted successfully

getArchive()

Get a single archive by its directory name.

public getArchive(string $dirName) : array<string|int, mixed>|null
Parameters
$dirName : string

Directory basename (e.g. "my-biz_2026-02-24_120000")

Return values
array<string|int, mixed>|null

Archive manifest data or null

listArchives()

List all archives on disk.

public listArchives() : array<string|int, mixed>
Return values
array<string|int, mixed>

List of archive metadata from manifest files

addDirectoryToZip()

Recursively add a directory to a ZipArchive.

private addDirectoryToZip(ZipArchive $zip, string $dir, string $zipPrefix) : void
Parameters
$zip : ZipArchive

ZipArchive instance

$dir : string

Directory path

$zipPrefix : string

Prefix inside ZIP

copyAssets()

Copy file assets (logo, photos) into the archive directory.

private copyAssets(string $archiveDir, array<string|int, mixed> $business, int $businessId) : int
Parameters
$archiveDir : string

Target archive directory

$business : array<string|int, mixed>

Business record

$businessId : int

Business ID

Return values
int

Number of files copied

deleteDirectory()

Recursively delete a directory and its contents.

private deleteDirectory(string $dir) : bool
Parameters
$dir : string

Directory path

Return values
bool

True if deleted successfully

exportQuery()

Export query results to a JSON file.

private exportQuery(string $dir, string $filename, string $sql, array<string|int, mixed> $params) : int
Parameters
$dir : string

Archive directory

$filename : string

Output filename (without .json)

$sql : string

SQL query

$params : array<string|int, mixed>

Bind parameters

Return values
int

Number of records exported

exportTable()

Export a table's rows matching a WHERE clause to a JSON file.

private exportTable(string $dir, string $filename, string $table, string $where, array<string|int, mixed> $params) : int
Parameters
$dir : string

Archive directory

$filename : string

Output filename (without .json)

$table : string

Table name

$where : string

WHERE clause

$params : array<string|int, mixed>

Bind parameters

Return values
int

Number of records exported

getDirectorySize()

Get total size of a directory in bytes.

private getDirectorySize(string $dir) : int
Parameters
$dir : string

Directory path

Return values
int

Size in bytes


        
On this page

Search results