public function mapToSubClass(string $classType)
    {
        if ($this->isEditForm() && $this->currentEditedObjectType) {
            if ($this->currentEditedObjectType !== $classType) {
                throw InvalidArgumentException::format(
                    'Invalid class type supplied to %s: cannot map to subclass %s, as the current object being edited is of type %s',
                    __METHOD__, $classType, $this->currentEditedObjectType
                );
            }
        }

        if (is_subclass_of($this->class->getClassName(), $classType, true)) {
            return;
        }

        /** @var string|TypedObject $classType */
        $this->class = $classType::definition();
        $this->createObjectType()->asClass($classType);
    }
public function mapToSubClass(string $classType)
    {
        if ($this->isEditForm() && $this->currentEditedObjectType) {
            if ($this->currentEditedObjectType !== $classType) {
                throw InvalidArgumentException::format(
                    'Invalid class type supplied to %s: cannot map to subclass %s, as the current object being edited is of type %s',
                    __METHOD__, $classType, $this->currentEditedObjectType
                );
            }
        }

        if (is_subclass_of($this->class->getClassName(), $classType, true)) {
            return;
        }

        /** @var string|TypedObject $classType */
        $this->class = $classType::definition();
        $this->createObjectType()->asClass($classType);
    }
public function mapToSubClass ( string $ classType ) { if ( $ this -> isEditForm ( ) && $ this -> currentEditedObjectType ) { if ( $ this -> currentEditedObjectType !== $ classType ) { throw InvalidArgumentException :: format ( 'Invalid class type supplied to %s: cannot map to subclass %s, as the current object being edited is of type %s' , __METHOD__ , $ classType , $ this -> currentEditedObjectType ) ; } } if ( is_subclass_of ( $ this -> class -> getClassName ( ) , $ classType , true ) ) { return ; } /** @var string|TypedObject $classType */ $ this -> class = $ classType :: definition ( ) ; $ this -> createObjectType ( ) -> asClass ( $ classType ) ; }
Defines that the form should map to an instance of the supplied type.

@param string $classType

@return void
@throws InvalidArgumentException
Defines that the form should map to an instance of the supplied type .