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