final public static function objectField(
        FieldNameBuilder $fieldBuilder,
        IIdentifiableObjectSet $dataSource,
        callable $objectValidationCallback = null
    ) : FieldBuilderBase
    {
        $field = $fieldBuilder
            ->name(IObjectAction::OBJECT_FIELD_NAME)
            ->label('Object');

        if ($dataSource instanceof IEntitySet) {
            $field = $field->entityFrom($dataSource);
        } elseif ($dataSource instanceof IObjectSetWithIdentityByIndex) {
            $field = $field->objectFromIndex($dataSource);
        } else {
            throw InvalidArgumentException::format(
                'Unknown object data source type: %s', get_class($dataSource)
            );
        }

        $field = $field->required();

        if ($objectValidationCallback) {
            $field->assert($objectValidationCallback, self::INVALID_OBJECT_MESSAGE);
        }

        return $field;
    }
final public static function objectField(
        FieldNameBuilder $fieldBuilder,
        IIdentifiableObjectSet $dataSource,
        callable $objectValidationCallback = null
    ) : FieldBuilderBase
    {
        $field = $fieldBuilder
            ->name(IObjectAction::OBJECT_FIELD_NAME)
            ->label('Object');

        if ($dataSource instanceof IEntitySet) {
            $field = $field->entityFrom($dataSource);
        } elseif ($dataSource instanceof IObjectSetWithIdentityByIndex) {
            $field = $field->objectFromIndex($dataSource);
        } else {
            throw InvalidArgumentException::format(
                'Unknown object data source type: %s', get_class($dataSource)
            );
        }

        $field = $field->required();

        if ($objectValidationCallback) {
            $field->assert($objectValidationCallback, self::INVALID_OBJECT_MESSAGE);
        }

        return $field;
    }
final public static function objectField ( FieldNameBuilder $ fieldBuilder , IIdentifiableObjectSet $ dataSource , callable $ objectValidationCallback = null ) : FieldBuilderBase { $ field = $ fieldBuilder -> name ( IObjectAction :: OBJECT_FIELD_NAME ) -> label ( 'Object' ) ; if ( $ dataSource instanceof IEntitySet ) { $ field = $ field -> entityFrom ( $ dataSource ) ; } elseif ( $ dataSource instanceof IObjectSetWithIdentityByIndex ) { $ field = $ field -> objectFromIndex ( $ dataSource ) ; } else { throw InvalidArgumentException :: format ( 'Unknown object data source type: %s' , get_class ( $ dataSource ) ) ; } $ field = $ field -> required ( ) ; if ( $ objectValidationCallback ) { $ field -> assert ( $ objectValidationCallback , self :: INVALID_OBJECT_MESSAGE ) ; } return $ field ; }
Builds the field to load an entity from the supplied source.

@param FieldNameBuilder       $fieldBuilder
@param IIdentifiableObjectSet $dataSource
@param callable|null          $objectValidationCallback

@return FieldBuilderBase
@throws InvalidArgumentException
Builds the field to load an entity from the supplied source .