Skip to content

classes_system_objects

Daniel Spors edited this page Nov 14, 2024 · 4 revisions

Classes in file system_objects.php

class Wdf

WDF internal replacement for $GLOBALS usage.

Namespace: ScavixWDF

GetBuffer

Creates a buffer that can be used instead of $GLOBALS variable. Optionally, buffers can be mapped to a SESSION variable.

Definition: public static function GetBuffer($name, $initial_data)

Returns: \ScavixWDF\WdfBuffer

Parameters:

  • string $name Buffer identifier

  • array|callable $initial_data Array with initial data or callback returning this initial data

GetLock

Sets up a LOCK for a given name. On Linux system uses the /run/lock folder to create a lock file. If this succeeds returns true. If not and a timeout is given will try for that amount of seconds. If still fails trhows an exception if $exceptiononfailure is true or returns false. In all other OS see system_get_lock().

Definition: public static function GetLock($name, $timeout, $exceptiononfailure=true)

Returns: bool True on success, else false

Parameters:

  • string $name Lock name

  • int $timeout Seconds to wait/retry (default 10)

  • bool $exceptiononfailure If true will throw an exception if lock cannot be created (default: true)

HasBuffer

Checks if there's a buffer present.

Definition: public static function HasBuffer($name)

Returns: bool True if present, else false

Parameters:

  • string $name Buffer identifier

Once

Helper to easily check if something was already done.

Definition: public static function Once($id)

Returns: bool True, if has already been called with $id, else false

Parameters:

  • mixed $id An ID value

ReleaseLock

Releases a LOCK.

Definition: public static function ReleaseLock($name)

Returns: bool True if successful, else false

Parameters:

  • array|string $name The LOCK name as single string or array of lock names to release

class WdfBuffer

Implements buffering methods.

Namespace: ScavixWDF

Implements: <>

clear

Removes all data from the buffer.

Definition: public function clear()

Returns: void

current

IMPLEMENTS Iterator::current

del

Removes data from the buffer.

Definition: public function del($name)

Returns: mixed The removed value if present, else null

Parameters:

  • string $name The key for the data

dump

Returns all data as assiciative array.

Definition: public function dump()

Returns: array

get

Returns data from the buffer.

Definition: public function get($name, $default=null)

Returns: mixed The removed value if present, else null

Parameters:

  • string $name The key for the data

  • mixed $default A default value, can be a callable too that will get the name and must return the value;

has

Returns true, if there's data stored with the given name.

Definition: public function has($name)

Returns: bool

Parameters:

  • string $name The key for the data

hasChanged

Returns true if some data has been changed. This is true, if WdfBuffer::set or WdfBuffer::set have been used and if they effectively did something.

Definition: public function hasChanged()

Returns: bool

jsonSerialize

INTERNAL see JsonSerializable

key

IMPLEMENTS Iterator::key

keys

Returns an array of data keys.

Definition: public function keys()

Returns: array

mapToSession

Maps this buffer to a $_SESSION variable. Mapping to the session means that from now on all data will be stored into $_SESSION[$name] and that getting data will transparently use that variable too.

Definition: public function mapToSession($name=false)

Returns: \ScavixWDF\WdfBuffer

Parameters:

  • string $name Name of session variable

next

IMPLEMENTS Iterator::next

rewind

IMPLEMENTS Iterator::rewind

set

Stores data in the buffer.

Definition: public function set($name, $value)

Returns: mixed The value given

Parameters:

  • string $name The key for the data

  • mixed $value The data to store

valid

IMPLEMENTS Iterator::valid

interface ICallable

We use this to test access to controllers. All controllers must implement this interface

Namespace: ScavixWDF

interface ILogWritable

Defines an objects that handles log-string creation itself.

Namespace: ScavixWDF

class WdfException

Transparently wraps Exceptions thus providing a way to catch them easily while still having the original Exception information. Using static WdfException() method you can pass in multiple arguments. ScavixWDF will try to detect if there's an exception object given and use it (the first one detected) as inner exception object.

WdfException::Raise('My simple test');	
WdfException::Raise('My simple test2',$obj_to_debug_1,'and',$obj_to_debug_2);	
try{ $i=42/0; }catch(Exception $ex){ WdfException::Raise('That was stupid!',$ex); }	

Namespace: ScavixWDF

Extends: Exception

Subclasses: ToDoException, WdfDbException

class ToDoException

Thrown when something still needs investigation We use this like this: ToDoException::Raise('Not yet implemented')

Namespace: ScavixWDF

Extends: WdfException » Exception

class WdfDbException

Thrown from all database related system parts All code in the model essential (essentials/model.php + essentials/model/*) use this instead of WdfException. Just to have everyting nicely wrapped.

Namespace: ScavixWDF

Extends: WdfException » Exception

getArguments

Returns the arguments used

Definition: public function getArguments()

Returns: array The arguments

getErrorInfo

Returns an array with error information

Definition: public function getErrorInfo()

Returns: array

getMergedSql

Returns a string merged from the SQL statement and the arguments

Definition: public function getMergedSql()

Returns: string Merged SQL statement

getSql

Returns the SQL string used

Definition: public function getSql()

Returns: string SQL

isDuplicateKeyException

INTERNAL Helper method to detect if this represents an Exception indicating a duplicate key

isTableNotExistException

INTERNAL Helper method to detect if this represents an Exception indicating a missing table.

RaisePdoEx

INTERNAL Wraps a \PDOException, optionally with the triggering statement

RaiseStatement

INTERNAL Raises an Exception for a failed DB Statement.

class TerminationException

Thrown when some process reached a state where graceful but immidiate termination is required. We use this like this: TerminationException::WithCode('HTTP_500','Server responded with 500, cannot do that now')

Namespace: ScavixWDF

getReason

Returns the reason string.

Definition: public function getReason()

Returns: string The reason this exception was thrown of.

Silent

Raises a silent TerminationException.

Definition: public static function Silent(string $reason, $args)

Returns: void

Parameters:

  • string $reason The reason for the Exception

  • array $args Additional arguments to be logged.

Verbose

Raises a verbose TerminationException.

Definition: public static function Verbose(string $reason, $args)

Returns: void

Parameters:

  • string $reason The reason for the Exception

  • array $args Additional arguments to be logged.

writeLog

Writes the exception to the log if it is verbose.

Definition: public function writeLog()

Returns: void

Clone this wiki locally