protected function _checkPresence($field, $context)
    {
        $required = $field->isPresenceRequired();

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

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

        return !$required;
    }
protected function _checkPresence($field, $context)
    {
        $required = $field->isPresenceRequired();

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

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

        return !$required;
    }
protected function _checkPresence ( $ field , $ context ) { $ required = $ field -> isPresenceRequired ( ) ; if ( ! is_string ( $ required ) && is_callable ( $ required ) ) { return ! $ required ( $ context ) ; } $ newRecord = $ context [ 'newRecord' ] ; if ( in_array ( $ required , [ 'create' , 'update' ] , true ) ) { return ( ( $ required === 'create' && ! $ newRecord ) || ( $ required === 'update' && $ newRecord ) ) ; } return ! $ required ; }
Returns false if any validation for the passed rule set should be stopped
due to the field missing in the data array

@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 false if any validation for the passed rule set should be stopped due to the field missing in the data array