public function convertTypeDefinition(array $data = null)
    {
        if (empty($data)) {
            return null;
        }

        if (empty($data[JSONConstants::JSON_TYPE_ID])) {
            throw new CmisInvalidArgumentException('Id of type definition is empty but must not be empty!');
        }
        $typeDefinition = $this->getBindingsObjectFactory()->getTypeDefinitionByBaseTypeId(
            $data[JSONConstants::JSON_TYPE_BASE_ID] ?? '',
            $data[JSONConstants::JSON_TYPE_ID] ?? ''
        );

        $data = $this->convertTypeDefinitionSpecificData($data, $typeDefinition);

        $data[JSONConstants::JSON_TYPE_TYPE_MUTABILITY] = $this->convertTypeMutability(
            $data[JSONConstants::JSON_TYPE_TYPE_MUTABILITY] ?? null
        );

        foreach ($data[JSONConstants::JSON_TYPE_PROPERTY_DEFINITIONS] ?? [] as $propertyDefinitionData) {
            if (is_array($propertyDefinitionData)) {
                $propertyDefinition = $this->convertPropertyDefinition($propertyDefinitionData);
                if ($propertyDefinition !== null) {
                    $typeDefinition->addPropertyDefinition($propertyDefinition);
                }
            }
        }

        unset(
            $data[JSONConstants::JSON_TYPE_BASE_ID],
            $data[JSONConstants::JSON_TYPE_ID],
            $data[JSONConstants::JSON_TYPE_PROPERTY_DEFINITIONS]
        );

        $typeDefinition->populate(
            array_filter($data, function ($item) { return !empty($item); }),
            array_merge(
                array_combine(JSONConstants::getTypeKeys(), JSONConstants::getTypeKeys()),
                [
                    JSONConstants::JSON_TYPE_PARENT_ID => 'parentTypeId',
                    JSONConstants::JSON_TYPE_ALLOWED_TARGET_TYPES => 'allowedTargetTypeIds',
                    JSONConstants::JSON_TYPE_ALLOWED_SOURCE_TYPES => 'allowedSourceTypeIds',
                ]
            ),
            true
        );

        $typeDefinition->setExtensions($this->convertExtension($data, JSONConstants::getTypeKeys()));

        return $typeDefinition;
    }
public function convertTypeDefinition(array $data = null)
    {
        if (empty($data)) {
            return null;
        }

        if (empty($data[JSONConstants::JSON_TYPE_ID])) {
            throw new CmisInvalidArgumentException('Id of type definition is empty but must not be empty!');
        }
        $typeDefinition = $this->getBindingsObjectFactory()->getTypeDefinitionByBaseTypeId(
            $data[JSONConstants::JSON_TYPE_BASE_ID] ?? '',
            $data[JSONConstants::JSON_TYPE_ID] ?? ''
        );

        $data = $this->convertTypeDefinitionSpecificData($data, $typeDefinition);

        $data[JSONConstants::JSON_TYPE_TYPE_MUTABILITY] = $this->convertTypeMutability(
            $data[JSONConstants::JSON_TYPE_TYPE_MUTABILITY] ?? null
        );

        foreach ($data[JSONConstants::JSON_TYPE_PROPERTY_DEFINITIONS] ?? [] as $propertyDefinitionData) {
            if (is_array($propertyDefinitionData)) {
                $propertyDefinition = $this->convertPropertyDefinition($propertyDefinitionData);
                if ($propertyDefinition !== null) {
                    $typeDefinition->addPropertyDefinition($propertyDefinition);
                }
            }
        }

        unset(
            $data[JSONConstants::JSON_TYPE_BASE_ID],
            $data[JSONConstants::JSON_TYPE_ID],
            $data[JSONConstants::JSON_TYPE_PROPERTY_DEFINITIONS]
        );

        $typeDefinition->populate(
            array_filter($data, function ($item) { return !empty($item); }),
            array_merge(
                array_combine(JSONConstants::getTypeKeys(), JSONConstants::getTypeKeys()),
                [
                    JSONConstants::JSON_TYPE_PARENT_ID => 'parentTypeId',
                    JSONConstants::JSON_TYPE_ALLOWED_TARGET_TYPES => 'allowedTargetTypeIds',
                    JSONConstants::JSON_TYPE_ALLOWED_SOURCE_TYPES => 'allowedSourceTypeIds',
                ]
            ),
            true
        );

        $typeDefinition->setExtensions($this->convertExtension($data, JSONConstants::getTypeKeys()));

        return $typeDefinition;
    }
public function convertTypeDefinition ( array $ data = null ) { if ( empty ( $ data ) ) { return null ; } if ( empty ( $ data [ JSONConstants :: JSON_TYPE_ID ] ) ) { throw new CmisInvalidArgumentException ( 'Id of type definition is empty but must not be empty!' ) ; } $ typeDefinition = $ this -> getBindingsObjectFactory ( ) -> getTypeDefinitionByBaseTypeId ( $ data [ JSONConstants :: JSON_TYPE_BASE_ID ] ?? '' , $ data [ JSONConstants :: JSON_TYPE_ID ] ?? '' ) ; $ data = $ this -> convertTypeDefinitionSpecificData ( $ data , $ typeDefinition ) ; $ data [ JSONConstants :: JSON_TYPE_TYPE_MUTABILITY ] = $ this -> convertTypeMutability ( $ data [ JSONConstants :: JSON_TYPE_TYPE_MUTABILITY ] ?? null ) ; foreach ( $ data [ JSONConstants :: JSON_TYPE_PROPERTY_DEFINITIONS ] ?? [ ] as $ propertyDefinitionData ) { if ( is_array ( $ propertyDefinitionData ) ) { $ propertyDefinition = $ this -> convertPropertyDefinition ( $ propertyDefinitionData ) ; if ( $ propertyDefinition !== null ) { $ typeDefinition -> addPropertyDefinition ( $ propertyDefinition ) ; } } } unset ( $ data [ JSONConstants :: JSON_TYPE_BASE_ID ] , $ data [ JSONConstants :: JSON_TYPE_ID ] , $ data [ JSONConstants :: JSON_TYPE_PROPERTY_DEFINITIONS ] ) ; $ typeDefinition -> populate ( array_filter ( $ data , function ( $ item ) { return ! empty ( $ item ) ; } ) , array_merge ( array_combine ( JSONConstants :: getTypeKeys ( ) , JSONConstants :: getTypeKeys ( ) ) , [ JSONConstants :: JSON_TYPE_PARENT_ID => 'parentTypeId' , JSONConstants :: JSON_TYPE_ALLOWED_TARGET_TYPES => 'allowedTargetTypeIds' , JSONConstants :: JSON_TYPE_ALLOWED_SOURCE_TYPES => 'allowedSourceTypeIds' , ] ) , true ) ; $ typeDefinition -> setExtensions ( $ this -> convertExtension ( $ data , JSONConstants :: getTypeKeys ( ) ) ) ; return $ typeDefinition ; }
Convert an array to a type definition object

@param array|null $data
@return AbstractTypeDefinition|null
@throws CmisInvalidArgumentException
Convert an array to a type definition object