public static function newEntityType($class, array $choices = [], array $options = []) {

        // Check the options.
        if (false === array_key_exists("empty", $options)) {
            $options["empty"] = false;
        }
        if (false === array_key_exists("translator", $options)) {
            $options["translator"] = null;
        }

        // Initialize the output.
        $output = [
            "class"        => $class,
            "choices"      => [],
            "choice_label" => function($entity) use ($options) {
                return FormRenderer::renderOption($entity, $options["translator"]);
            },
        ];

        // Add an empty choice.
        if (true === $options["empty"]) {
            $output["choices"][] = null;
        }

        // Add all choices.
        $output["choices"] = array_merge($output["choices"], $choices);

        return $output;
    }
public static function newEntityType($class, array $choices = [], array $options = []) {

        // Check the options.
        if (false === array_key_exists("empty", $options)) {
            $options["empty"] = false;
        }
        if (false === array_key_exists("translator", $options)) {
            $options["translator"] = null;
        }

        // Initialize the output.
        $output = [
            "class"        => $class,
            "choices"      => [],
            "choice_label" => function($entity) use ($options) {
                return FormRenderer::renderOption($entity, $options["translator"]);
            },
        ];

        // Add an empty choice.
        if (true === $options["empty"]) {
            $output["choices"][] = null;
        }

        // Add all choices.
        $output["choices"] = array_merge($output["choices"], $choices);

        return $output;
    }
public static function newEntityType ( $ class , array $ choices = [ ] , array $ options = [ ] ) { // Check the options. if ( false === array_key_exists ( "empty" , $ options ) ) { $ options [ "empty" ] = false ; } if ( false === array_key_exists ( "translator" , $ options ) ) { $ options [ "translator" ] = null ; } // Initialize the output. $ output = [ "class" => $ class , "choices" => [ ] , "choice_label" => function ( $ entity ) use ( $ options ) { return FormRenderer :: renderOption ( $ entity , $ options [ "translator" ] ) ; } , ] ; // Add an empty choice. if ( true === $ options [ "empty" ] ) { $ output [ "choices" ] [ ] = null ; } // Add all choices. $ output [ "choices" ] = array_merge ( $ output [ "choices" ] , $ choices ) ; return $ output ; }
Create an entity type.

@param string $class The class.
@param array $choices The choices.
@param array $options The options.
@return array $choices Returns the entity type.
Create an entity type .