src/Sulu/Component/Content/Types/BlockContentType.php
private function doWrite(
        NodeInterface $node,
        PropertyInterface $property,
        $userId,
        $webspaceKey,
        $languageCode,
        $segmentKey,
        $isImport = false
    ) {
        if ($property->getIsBlock()) {
            /** @var BlockPropertyInterface $blockProperty */
            $blockProperty = $property;
            while (!($blockProperty instanceof BlockPropertyInterface)) {
                $blockProperty = $blockProperty->getProperty();
            }

            $data = $blockProperty->getValue();

            if (!$blockProperty->getIsMultiple()) {
                $data = [$data];
            }

            $data = array_filter($data);

            $len = count($data);

            // init properties
            $typeProperty = new Property('type', '', 'text_line');
            $lengthProperty = new Property('length', '', 'text_line');

            //save length
            $lengthProperty->setValue($len);
            $contentType = $this->contentTypeManager->get($lengthProperty->getContentTypeName());
            $contentType->write(
                $node,
                new BlockPropertyWrapper($lengthProperty, $property),
                $userId,
                $webspaceKey,
                $languageCode,
                $segmentKey
            );

            for ($i = 0; $i < $len; ++$i) {
                $blockPropertyType = $blockProperty->getProperties($i);

                // save type property
                $this->writeProperty(
                    $typeProperty,
                    $property,
                    $blockPropertyType->getName(),
                    $i,
                    $node,
                    $userId,
                    $webspaceKey,
                    $languageCode,
                    $segmentKey,
                    $isImport
                );

                foreach ($blockProperty->getProperties($i)->getChildProperties() as $subProperty) {
                    $this->writeProperty(
                        $subProperty,
                        $property,
                        $subProperty->getValue(),
                        $i,
                        $node,
                        $userId,
                        $webspaceKey,
                        $languageCode,
                        $segmentKey,
                        $isImport
                    );
                }
            }
        } else {
            throw new UnexpectedPropertyType($property, $this);
        }
    }
private function doWrite(
        NodeInterface $node,
        PropertyInterface $property,
        $userId,
        $webspaceKey,
        $languageCode,
        $segmentKey,
        $isImport = false
    ) {
        if ($property->getIsBlock()) {
            /** @var BlockPropertyInterface $blockProperty */
            $blockProperty = $property;
            while (!($blockProperty instanceof BlockPropertyInterface)) {
                $blockProperty = $blockProperty->getProperty();
            }

            $data = $blockProperty->getValue();

            if (!$blockProperty->getIsMultiple()) {
                $data = [$data];
            }

            $data = array_filter($data);

            $len = count($data);

            // init properties
            $typeProperty = new Property('type', '', 'text_line');
            $lengthProperty = new Property('length', '', 'text_line');

            //save length
            $lengthProperty->setValue($len);
            $contentType = $this->contentTypeManager->get($lengthProperty->getContentTypeName());
            $contentType->write(
                $node,
                new BlockPropertyWrapper($lengthProperty, $property),
                $userId,
                $webspaceKey,
                $languageCode,
                $segmentKey
            );

            for ($i = 0; $i < $len; ++$i) {
                $blockPropertyType = $blockProperty->getProperties($i);

                // save type property
                $this->writeProperty(
                    $typeProperty,
                    $property,
                    $blockPropertyType->getName(),
                    $i,
                    $node,
                    $userId,
                    $webspaceKey,
                    $languageCode,
                    $segmentKey,
                    $isImport
                );

                foreach ($blockProperty->getProperties($i)->getChildProperties() as $subProperty) {
                    $this->writeProperty(
                        $subProperty,
                        $property,
                        $subProperty->getValue(),
                        $i,
                        $node,
                        $userId,
                        $webspaceKey,
                        $languageCode,
                        $segmentKey,
                        $isImport
                    );
                }
            }
        } else {
            throw new UnexpectedPropertyType($property, $this);
        }
    }
private function doWrite ( NodeInterface $ node , PropertyInterface $ property , $ userId , $ webspaceKey , $ languageCode , $ segmentKey , $ isImport = false ) { if ( $ property -> getIsBlock ( ) ) { /** @var BlockPropertyInterface $blockProperty */ $ blockProperty = $ property ; while ( ! ( $ blockProperty instanceof BlockPropertyInterface ) ) { $ blockProperty = $ blockProperty -> getProperty ( ) ; } $ data = $ blockProperty -> getValue ( ) ; if ( ! $ blockProperty -> getIsMultiple ( ) ) { $ data = [ $ data ] ; } $ data = array_filter ( $ data ) ; $ len = count ( $ data ) ; // init properties $ typeProperty = new Property ( 'type' , '' , 'text_line' ) ; $ lengthProperty = new Property ( 'length' , '' , 'text_line' ) ; //save length $ lengthProperty -> setValue ( $ len ) ; $ contentType = $ this -> contentTypeManager -> get ( $ lengthProperty -> getContentTypeName ( ) ) ; $ contentType -> write ( $ node , new BlockPropertyWrapper ( $ lengthProperty , $ property ) , $ userId , $ webspaceKey , $ languageCode , $ segmentKey ) ; for ( $ i = 0 ; $ i < $ len ; ++ $ i ) { $ blockPropertyType = $ blockProperty -> getProperties ( $ i ) ; // save type property $ this -> writeProperty ( $ typeProperty , $ property , $ blockPropertyType -> getName ( ) , $ i , $ node , $ userId , $ webspaceKey , $ languageCode , $ segmentKey , $ isImport ) ; foreach ( $ blockProperty -> getProperties ( $ i ) -> getChildProperties ( ) as $ subProperty ) { $ this -> writeProperty ( $ subProperty , $ property , $ subProperty -> getValue ( ) , $ i , $ node , $ userId , $ webspaceKey , $ languageCode , $ segmentKey , $ isImport ) ; } } } else { throw new UnexpectedPropertyType ( $ property , $ this ) ; } }
Save the value from given property.

@param NodeInterface $node
@param PropertyInterface $property
@param $userId
@param $webspaceKey
@param $languageCode
@param $segmentKey
@param bool $isImport

@throws UnexpectedPropertyType
Save the value from given property .