src/Controller/Component/MoveComponent.php
protected function _move(Table $table, $id, $step = 1, $type = self::TYPE_UP)
    {
        $behaviors = $table->behaviors();
        if (!Arr::in('Tree', $behaviors->loaded())) {
            $behaviors->load('Tree');
        }

        $entity = $table->get($id);

        /** @var TreeBehavior $treeBehavior */
        $treeBehavior = $behaviors->get('Tree');
        $treeBehavior->setConfig('scope', $entity->get('id'));

        if ($table->{$type}($entity, $step)) {
            $this->Flash->success($this->_configRead('messages.success'));
        } else {
            $this->Flash->error($this->_configRead('messages.error'));
        }

        return $this->_redirect();
    }
protected function _move(Table $table, $id, $step = 1, $type = self::TYPE_UP)
    {
        $behaviors = $table->behaviors();
        if (!Arr::in('Tree', $behaviors->loaded())) {
            $behaviors->load('Tree');
        }

        $entity = $table->get($id);

        /** @var TreeBehavior $treeBehavior */
        $treeBehavior = $behaviors->get('Tree');
        $treeBehavior->setConfig('scope', $entity->get('id'));

        if ($table->{$type}($entity, $step)) {
            $this->Flash->success($this->_configRead('messages.success'));
        } else {
            $this->Flash->error($this->_configRead('messages.error'));
        }

        return $this->_redirect();
    }
protected function _move ( Table $ table , $ id , $ step = 1 , $ type = self :: TYPE_UP ) { $ behaviors = $ table -> behaviors ( ) ; if ( ! Arr :: in ( 'Tree' , $ behaviors -> loaded ( ) ) ) { $ behaviors -> load ( 'Tree' ) ; } $ entity = $ table -> get ( $ id ) ; /** @var TreeBehavior $treeBehavior */ $ treeBehavior = $ behaviors -> get ( 'Tree' ) ; $ treeBehavior -> setConfig ( 'scope' , $ entity -> get ( 'id' ) ) ; if ( $ table -> { $ type } ( $ entity , $ step ) ) { $ this -> Flash -> success ( $ this -> _configRead ( 'messages.success' ) ) ; } else { $ this -> Flash -> error ( $ this -> _configRead ( 'messages.error' ) ) ; } return $ this -> _redirect ( ) ; }
Move object in tree table.

@param   Table $table
@param   string $type
@param   int $id
@param   int $step
@return  \Cake\Http\Response|null
Move object in tree table .