Tiger_Model_Code
@api· extendsTiger_Model_Table
Tiger_Model_Code — the Tiger Code store (executable PHP + client CSS/JS/HTML).
The DB row is the source of truth; Tiger_Code_Runtime compiles active rows into a cached bundle and executes/ships that (never this table per request). This model owns the table: transactional save() with a version snapshot, the compiler's load query, PHP syntax linting, and error-marking for the auto-deactivate rail.
SECURITY: php rows are server-executed — the service restricts them to the platform
scope (org_id = '') and the code.execute ACL. css/js/html are client-injected.
Methods
save()
save(array $data, $id = null)
Save (insert/update) + snapshot to code_version, transactionally.
$dataarray— the code row fields$idstring|null— the code_id to update, or null to insert
Returns string — the code_id
Throws Throwable — on any failure (the transaction is rolled back and the error rethrown)
activeForLoad()
activeForLoad($language, $location, $orgId = '')
The compiler's rebuild query: active rows for a language + run location + org scope, in load order. Hits ix_code_load. Only ever called during a (rare) bundle rebuild.
$languagestring— the code language (php/phtml/js/css/html)$locationstring— the run location$orgIdstring— the org scope ('' = platform/global)
Returns Zend_Db_Table_Rowset_Abstract — the matching active rows, in load order
activeClient()
activeClient($runLocation, $orgId = '')
Active client-injected rows (css/js/html/phtml) for a run location + org scope, in load order — the source for the injection manifest + asset bundles (Tiger_Code_Runtime). PHP (the bootstrap bundle) is handled separately by activeForLoad().
$runLocationstring— the run location$orgIdstring— the org scope ('' = platform/global)
Returns Zend_Db_Table_Rowset_Abstract — the matching active client rows, in load order
lint()
lint($code)
Lint PHP source with php -l (out-of-process, never executed). Returns {ok:bool, error:?string}. The safety gate before any PHP row can go active.
$codestring— the PHP source to lint (a code body, no opening tag needed)
Returns array{ok:bool,error:?string} — lint result
normalize()
normalize($code)
Strip a leading <?php/<?/BOM and a trailing ?> so stored code is a clean body.
$codestring— the raw code
Returns string — the normalized code body
markError()
markError($id, $msg)
Flag a row inactive with the error that killed it (the auto-deactivate rail).
$idstring— the code_id$msgstring— the error message (truncated to 2000 chars)
setActive()
setActive($id, $active)
Toggle active state (service lints PHP before activating). Clears last_error on activate.
$idstring— the code_id$activebool— whether the row should be active
restoreVersion()
restoreVersion($id, $version)
Restore a prior version (does NOT auto-reactivate — safer for executable code).
$idstring— the code_id$versionint— the version number to restore
Returns string — the code_id
Throws RuntimeException — when the requested version doesn't exist