protected function adjustPosition($op, array $managers)
    {
        if (count($managers) == 0) {
            return null;
        }

        $this->checkValidOperation($op);

        try {
            $result = null;
            $this->blockRepository->startTransaction();
            foreach ($managers as $blockManager) {
                $block = $blockManager->get();
                $contentPosition = $block->getContentPosition();
                $position = ($op == 'add') ? $contentPosition + 1 : $contentPosition - 1;
                $result = $this->blockRepository
                                ->setRepositoryObject($block)
                                ->save(array("ContentPosition" => $position));

                if (false === $result) {
                    break;
                }
            }

            if (false !== $result) {
                $this->blockRepository->commit();

                return $result;
            }

            $this->blockRepository->rollBack();

            return $result;
        } catch (\Exception $e) {
            $this->blockRepository->rollBack();

            throw $e;
        }
    }
protected function adjustPosition($op, array $managers)
    {
        if (count($managers) == 0) {
            return null;
        }

        $this->checkValidOperation($op);

        try {
            $result = null;
            $this->blockRepository->startTransaction();
            foreach ($managers as $blockManager) {
                $block = $blockManager->get();
                $contentPosition = $block->getContentPosition();
                $position = ($op == 'add') ? $contentPosition + 1 : $contentPosition - 1;
                $result = $this->blockRepository
                                ->setRepositoryObject($block)
                                ->save(array("ContentPosition" => $position));

                if (false === $result) {
                    break;
                }
            }

            if (false !== $result) {
                $this->blockRepository->commit();

                return $result;
            }

            $this->blockRepository->rollBack();

            return $result;
        } catch (\Exception $e) {
            $this->blockRepository->rollBack();

            throw $e;
        }
    }
protected function adjustPosition ( $ op , array $ managers ) { if ( count ( $ managers ) == 0 ) { return null ; } $ this -> checkValidOperation ( $ op ) ; try { $ result = null ; $ this -> blockRepository -> startTransaction ( ) ; foreach ( $ managers as $ blockManager ) { $ block = $ blockManager -> get ( ) ; $ contentPosition = $ block -> getContentPosition ( ) ; $ position = ( $ op == 'add' ) ? $ contentPosition + 1 : $ contentPosition - 1 ; $ result = $ this -> blockRepository -> setRepositoryObject ( $ block ) -> save ( array ( "ContentPosition" => $ position ) ) ; if ( false === $ result ) { break ; } } if ( false !== $ result ) { $ this -> blockRepository -> commit ( ) ; return $ result ; } $ this -> blockRepository -> rollBack ( ) ; return $ result ; } catch ( \ Exception $ e ) { $ this -> blockRepository -> rollBack ( ) ; throw $ e ; } }
Adjusts the blocks position on the slot, when a new block is added or a block is deleted.

When in *add* mode, it creates a space between the adding block's position and
the blocks below, incrementing their position by one

When in *del* mode, decrements by 1 the position of the blocks placed below the
removing block

@param  string     $op       The operation to do. It accepts add or del as valid values
@param  array      $managers An array of block managers
@throws \Exception
@return boolean
Adjusts the blocks position on the slot when a new block is added or a block is deleted .