public function beforeSave(Event $event, Entity $plugin, ArrayObject $options = null)
    {
        if ($plugin->isNew()) {
            $max = $this->find()
                ->order(['ordering' => 'DESC'])
                ->limit(1)
                ->first();
            $plugin->set('ordering', $max->ordering + 1);
        }
    }
public function beforeSave(Event $event, Entity $plugin, ArrayObject $options = null)
    {
        if ($plugin->isNew()) {
            $max = $this->find()
                ->order(['ordering' => 'DESC'])
                ->limit(1)
                ->first();
            $plugin->set('ordering', $max->ordering + 1);
        }
    }
public function beforeSave ( Event $ event , Entity $ plugin , ArrayObject $ options = null ) { if ( $ plugin -> isNew ( ) ) { $ max = $ this -> find ( ) -> order ( [ 'ordering' => 'DESC' ] ) -> limit ( 1 ) -> first ( ) ; $ plugin -> set ( 'ordering' , $ max -> ordering + 1 ) ; } }
Set plugin's load ordering to LAST if it's a new plugin being installed.

@param \Cake\Event\Event $event The event that was triggered
@param \Cake\ORM\Entity $plugin The Plugin entity being saved
@param \ArrayObject $options The options passed to the save method
@return void
Set plugin s load ordering to LAST if it s a new plugin being installed .