public function updateSection(Section $section, SectionUpdateStruct $sectionUpdateStruct)
    {
        if ($sectionUpdateStruct->name !== null && !is_string($sectionUpdateStruct->name)) {
            throw new InvalidArgumentValue('name', $section->name, 'Section');
        }

        if ($sectionUpdateStruct->identifier !== null && !is_string($sectionUpdateStruct->identifier)) {
            throw new InvalidArgumentValue('identifier', $section->identifier, 'Section');
        }

        if (!$this->permissionResolver->canUser('section', 'edit', $section)) {
            throw new UnauthorizedException('section', 'edit');
        }

        if ($sectionUpdateStruct->identifier !== null) {
            try {
                $existingSection = $this->loadSectionByIdentifier($sectionUpdateStruct->identifier);

                // Allowing identifier update only for the same section
                if ($existingSection->id != $section->id) {
                    throw new InvalidArgumentException('sectionUpdateStruct', 'section with specified identifier already exists');
                }
            } catch (APINotFoundException $e) {
                // Do nothing
            }
        }

        $loadedSection = $this->loadSection($section->id);

        $this->repository->beginTransaction();
        try {
            $spiSection = $this->sectionHandler->update(
                $loadedSection->id,
                $sectionUpdateStruct->name ?: $loadedSection->name,
                $sectionUpdateStruct->identifier ?: $loadedSection->identifier
            );
            $this->repository->commit();
        } catch (Exception $e) {
            $this->repository->rollback();
            throw $e;
        }

        return $this->buildDomainSectionObject($spiSection);
    }
public function updateSection(Section $section, SectionUpdateStruct $sectionUpdateStruct)
    {
        if ($sectionUpdateStruct->name !== null && !is_string($sectionUpdateStruct->name)) {
            throw new InvalidArgumentValue('name', $section->name, 'Section');
        }

        if ($sectionUpdateStruct->identifier !== null && !is_string($sectionUpdateStruct->identifier)) {
            throw new InvalidArgumentValue('identifier', $section->identifier, 'Section');
        }

        if (!$this->permissionResolver->canUser('section', 'edit', $section)) {
            throw new UnauthorizedException('section', 'edit');
        }

        if ($sectionUpdateStruct->identifier !== null) {
            try {
                $existingSection = $this->loadSectionByIdentifier($sectionUpdateStruct->identifier);

                // Allowing identifier update only for the same section
                if ($existingSection->id != $section->id) {
                    throw new InvalidArgumentException('sectionUpdateStruct', 'section with specified identifier already exists');
                }
            } catch (APINotFoundException $e) {
                // Do nothing
            }
        }

        $loadedSection = $this->loadSection($section->id);

        $this->repository->beginTransaction();
        try {
            $spiSection = $this->sectionHandler->update(
                $loadedSection->id,
                $sectionUpdateStruct->name ?: $loadedSection->name,
                $sectionUpdateStruct->identifier ?: $loadedSection->identifier
            );
            $this->repository->commit();
        } catch (Exception $e) {
            $this->repository->rollback();
            throw $e;
        }

        return $this->buildDomainSectionObject($spiSection);
    }
public function updateSection ( Section $ section , SectionUpdateStruct $ sectionUpdateStruct ) { if ( $ sectionUpdateStruct -> name !== null && ! is_string ( $ sectionUpdateStruct -> name ) ) { throw new InvalidArgumentValue ( 'name' , $ section -> name , 'Section' ) ; } if ( $ sectionUpdateStruct -> identifier !== null && ! is_string ( $ sectionUpdateStruct -> identifier ) ) { throw new InvalidArgumentValue ( 'identifier' , $ section -> identifier , 'Section' ) ; } if ( ! $ this -> permissionResolver -> canUser ( 'section' , 'edit' , $ section ) ) { throw new UnauthorizedException ( 'section' , 'edit' ) ; } if ( $ sectionUpdateStruct -> identifier !== null ) { try { $ existingSection = $ this -> loadSectionByIdentifier ( $ sectionUpdateStruct -> identifier ) ; // Allowing identifier update only for the same section if ( $ existingSection -> id != $ section -> id ) { throw new InvalidArgumentException ( 'sectionUpdateStruct' , 'section with specified identifier already exists' ) ; } } catch ( APINotFoundException $ e ) { // Do nothing } } $ loadedSection = $ this -> loadSection ( $ section -> id ) ; $ this -> repository -> beginTransaction ( ) ; try { $ spiSection = $ this -> sectionHandler -> update ( $ loadedSection -> id , $ sectionUpdateStruct -> name ? : $ loadedSection -> name , $ sectionUpdateStruct -> identifier ? : $ loadedSection -> identifier ) ; $ this -> repository -> commit ( ) ; } catch ( Exception $ e ) { $ this -> repository -> rollback ( ) ; throw $ e ; } return $ this -> buildDomainSectionObject ( $ spiSection ) ; }
Updates the given section in the content repository.

@throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user user is not allowed to create a section
@throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the new identifier already exists (if set in the update struct)

@param \eZ\Publish\API\Repository\Values\Content\Section $section
@param \eZ\Publish\API\Repository\Values\Content\SectionUpdateStruct $sectionUpdateStruct

@return \eZ\Publish\API\Repository\Values\Content\Section
Updates the given section in the content repository .