Buffalo Eats Online API Documentation

ThemeService
in package

Theme service for generating CSS variable blocks and managing theme data.

Coordinates base theme CSS variables with per-business customizations to produce the final theme output for storefront rendering.

Tags
author

J.J. Johnson visionquest716@gmail.com

copyright

2026 VisionQuestServices LLC

Table of Contents

Properties

$allowedFonts  : array<string|int, mixed>
$businessThemeModel  : BusinessTheme
$cache  : array<string|int, mixed>
$defaults  : array<string|int, mixed>
$themeModel  : Theme

Methods

__construct()  : mixed
Initialize the theme service.
clearCache()  : void
Clear the request-level cache (for testing).
generateCssVariablesBlock()  : string
Generate a CSS variables style block for the storefront.
generateGoogleFontsLink()  : string
Generate a Google Fonts link tag for the theme fonts.
getAllowedFonts()  : array<string|int, mixed>
Get the list of allowed Google Fonts.
getCached()  : array<string|int, mixed>
Get cached theme data for a business (request-level cache).
getDefaults()  : array<string|int, mixed>
Get the default CSS variables.
getDefaultThemeData()  : array<string|int, mixed>
Get default theme data matching current hardcoded appearance.
getPreviewThemeData()  : array<string|int, mixed>
Get preview theme data without saving (for live preview).
getThemeDataForBusiness()  : array<string|int, mixed>
Get merged theme data for a business (base CSS vars + business overrides).
hexToRgb()  : string
Convert a hex color to RGB string.
sanitizeCustomCss()  : string
Sanitize custom CSS to strip XSS vectors.
extractFontName()  : string|null
Extract font name from a CSS font-family value.

Properties

$allowedFonts

private static array<string|int, mixed> $allowedFonts = ['Arial, sans-serif', 'Verdana, sans-serif', 'Tahoma, sans-serif', 'Trebuchet MS, sans-serif', 'Times New Roman, serif', 'Georgia, serif', 'Garamond, serif', 'Courier New, monospace', 'Brush Script MT, cursive']

Allowed web-safe fonts

$cache

private static array<string|int, mixed> $cache = []

Request-level cache keyed by business ID

$defaults

private static array<string|int, mixed> $defaults = ['--beo-primary' => '#2c3e50', '--beo-primary-rgb' => '44, 62, 80', '--beo-accent' => '#e67e22', '--beo-accent-rgb' => '230, 126, 34', '--beo-hero-bg' => '#2c3e50', '--beo-hero-text' => '#ffffff', '--beo-navbar-bg' => '#212529', '--beo-navbar-text' => '#ffffff', '--beo-body-bg' => '#ffffff', '--beo-body-text' => '#212529', '--beo-card-bg' => '#ffffff', '--beo-card-border' => '#dee2e6', '--beo-footer-bg' => '#212529', '--beo-footer-text' => '#f8f9fa', '--beo-link-color' => '#0d6efd', '--beo-btn-primary-bg' => '#0d6efd', '--beo-btn-primary-text' => '#ffffff', '--beo-font-heading' => 'inherit', '--beo-font-body' => 'inherit', '--beo-border-radius' => '0.375rem']

Default CSS variable values matching current hardcoded appearance

Methods

__construct()

Initialize the theme service.

public __construct() : mixed

clearCache()

Clear the request-level cache (for testing).

public static clearCache() : void

generateCssVariablesBlock()

Generate a CSS variables style block for the storefront.

public generateCssVariablesBlock(array<string|int, mixed> $themeData) : string
Parameters
$themeData : array<string|int, mixed>

Theme data from getThemeDataForBusiness()

Return values
string

HTML style element with :root CSS variables

Generate a Google Fonts link tag for the theme fonts.

public generateGoogleFontsLink(array<string|int, mixed> $themeData) : string

All allowed fonts are web-safe system fonts, so no external stylesheet is needed. Returns empty string.

Parameters
$themeData : array<string|int, mixed>

Theme data from getThemeDataForBusiness()

Return values
string

HTML link element or empty string

getAllowedFonts()

Get the list of allowed Google Fonts.

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

getCached()

Get cached theme data for a business (request-level cache).

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

Business ID

Return values
array<string|int, mixed>

Theme data

getDefaults()

Get the default CSS variables.

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

getDefaultThemeData()

Get default theme data matching current hardcoded appearance.

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

Theme data with default values

getPreviewThemeData()

Get preview theme data without saving (for live preview).

public getPreviewThemeData(int $themeId[, array<string|int, mixed> $customizations = [] ]) : array<string|int, mixed>
Parameters
$themeId : int

Theme ID to preview

$customizations : array<string|int, mixed> = []

Optional customizations to overlay

Return values
array<string|int, mixed>

Theme data array

getThemeDataForBusiness()

Get merged theme data for a business (base CSS vars + business overrides).

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

Business ID

Return values
array<string|int, mixed>

Theme data with keys: variables, layout_style, header_style, custom_footer_text, custom_css

hexToRgb()

Convert a hex color to RGB string.

public static hexToRgb(string $hex) : string
Parameters
$hex : string

Hex color (e.g., #2c3e50)

Return values
string

RGB values (e.g., "44, 62, 80")

sanitizeCustomCss()

Sanitize custom CSS to strip XSS vectors.

public sanitizeCustomCss(string $css) : string

Removes script tags, javascript: URIs, expression(), @import, and data: URIs.

Parameters
$css : string

Raw custom CSS

Return values
string

Sanitized CSS

extractFontName()

Extract font name from a CSS font-family value.

private extractFontName(string $fontFamily) : string|null
Parameters
$fontFamily : string

CSS font-family value

Return values
string|null

Font name or null if inherit/system


        
On this page

Search results