Empty

Empty class

Empty -class is returned, if you try to load a Table, Page or Field that does not exists.

The main idea is to prevent code from braking if tables or fields are removed or names are modified. So you can ask $Page->field->field->getValue() without worrying if you should check the every return value.

Loop through join field that does not exists:

foreach ( $Order->missing_field->getPages() as $Row ){
    // This is not executed, because Empty::getPages() will return empty array
}

Check if field that does not exists has a value:

if ( $Order->missing_field->isGiven() ){
    // This is not executed, since Empty::isGiven() always returns false.
}

Setting value to field that does not exists:

$Order->missing_field->setValue(123);
// Value is set to Empty object, which is not handled in save.

Method list

Method Return value Description
isField() false
isPage() false
isTable() false
getId() 0
isGiven() false
isChanged() false
hasValue() false
getValue() '' Empty string
getNumber() 0
__get() Empty Allow chaining in non-existing path
__call() Empty Allow chaining in non-existing path