protected function _canBeEmpty($field, $context)
    {
        $allowed = $field->isEmptyAllowed();

        if (!is_string($allowed) && is_callable($allowed)) {
            return $allowed($context);
        }

        $newRecord = $context['newRecord'];
        if (in_array($allowed, ['create', 'update'], true)) {
            $allowed = (
                ($allowed === 'create' && $newRecord) ||
                ($allowed === 'update' && !$newRecord)
            );
        }

        return $allowed;
    }
protected function _canBeEmpty($field, $context)
    {
        $allowed = $field->isEmptyAllowed();

        if (!is_string($allowed) && is_callable($allowed)) {
            return $allowed($context);
        }

        $newRecord = $context['newRecord'];
        if (in_array($allowed, ['create', 'update'], true)) {
            $allowed = (
                ($allowed === 'create' && $newRecord) ||
                ($allowed === 'update' && !$newRecord)
            );
        }

        return $allowed;
    }
protected function _canBeEmpty ( $ field , $ context ) { $ allowed = $ field -> isEmptyAllowed ( ) ; if ( ! is_string ( $ allowed ) && is_callable ( $ allowed ) ) { return $ allowed ( $ context ) ; } $ newRecord = $ context [ 'newRecord' ] ; if ( in_array ( $ allowed , [ 'create' , 'update' ] , true ) ) { $ allowed = ( ( $ allowed === 'create' && $ newRecord ) || ( $ allowed === 'update' && ! $ newRecord ) ) ; } return $ allowed ; }
Returns whether the field can be left blank according to `allowEmpty`

@param \Cake\Validation\ValidationSet $field the set of rules for a field
@param array $context a key value list of data containing the validation context.
@return bool
Returns whether the field can be left blank according to allowEmpty