src/Entity/BlockManager.php
public function updatePosition($id, $position, $parentId = null, $pageId = null, $partial = true)
    {
        if ($partial) {
            $meta = $this->getEntityManager()->getClassMetadata($this->getClass());

            // retrieve object references
            $block = $this->getEntityManager()->getReference($this->getClass(), $id);
            $pageRelation = $meta->getAssociationMapping('page');
            $page = $this->getEntityManager()->getPartialReference($pageRelation['targetEntity'], $pageId);

            $parentRelation = $meta->getAssociationMapping('parent');
            $parent = $this->getEntityManager()->getPartialReference($parentRelation['targetEntity'], $parentId);

            $block->setPage($page);
            $block->setParent($parent);
        } else {
            $block = $this->find($id);
        }

        // set new values
        $block->setPosition($position);
        $this->getEntityManager()->persist($block);

        return $block;
    }
public function updatePosition($id, $position, $parentId = null, $pageId = null, $partial = true)
    {
        if ($partial) {
            $meta = $this->getEntityManager()->getClassMetadata($this->getClass());

            // retrieve object references
            $block = $this->getEntityManager()->getReference($this->getClass(), $id);
            $pageRelation = $meta->getAssociationMapping('page');
            $page = $this->getEntityManager()->getPartialReference($pageRelation['targetEntity'], $pageId);

            $parentRelation = $meta->getAssociationMapping('parent');
            $parent = $this->getEntityManager()->getPartialReference($parentRelation['targetEntity'], $parentId);

            $block->setPage($page);
            $block->setParent($parent);
        } else {
            $block = $this->find($id);
        }

        // set new values
        $block->setPosition($position);
        $this->getEntityManager()->persist($block);

        return $block;
    }
public function updatePosition ( $ id , $ position , $ parentId = null , $ pageId = null , $ partial = true ) { if ( $ partial ) { $ meta = $ this -> getEntityManager ( ) -> getClassMetadata ( $ this -> getClass ( ) ) ; // retrieve object references $ block = $ this -> getEntityManager ( ) -> getReference ( $ this -> getClass ( ) , $ id ) ; $ pageRelation = $ meta -> getAssociationMapping ( 'page' ) ; $ page = $ this -> getEntityManager ( ) -> getPartialReference ( $ pageRelation [ 'targetEntity' ] , $ pageId ) ; $ parentRelation = $ meta -> getAssociationMapping ( 'parent' ) ; $ parent = $ this -> getEntityManager ( ) -> getPartialReference ( $ parentRelation [ 'targetEntity' ] , $ parentId ) ; $ block -> setPage ( $ page ) ; $ block -> setParent ( $ parent ) ; } else { $ block = $ this -> find ( $ id ) ; } // set new values $ block -> setPosition ( $ position ) ; $ this -> getEntityManager ( ) -> persist ( $ block ) ; return $ block ; }
Updates position for given block.

@param int  $id       Block Id
@param int  $position New Position
@param int  $parentId Parent block Id (needed when partial = true)
@param int  $pageId   Page Id (needed when partial = true)
@param bool $partial  Should we use partial references? (Better for performance, but can lead to query issues.)

@return mixed
Updates position for given block .