src/Behaviour/PositionInterface/Implementation.php
public function ActiveCollabDatabaseStructureBehaviourPositionInterfaceImplementation()
    {
        $this->registerEventHandler('on_before_save', function () {
            if (!$this->getPosition()) {
                $table_name = $this->connection->escapeTableName($this->getTableName());
                $conditions = $this->getPositionContextConditions();

                if ($this->getPositionMode() == PositionInterface::POSITION_MODE_HEAD) {
                    $this->setPosition(1);

                    if ($ids = $this->connection->executeFirstColumn("SELECT `id` FROM $table_name $conditions")) {
                        $this->connection->execute("UPDATE $table_name SET `position` = `position` + 1 $conditions");
                    }
                } else {
                    $this->setPosition($this->connection->executeFirstCell("SELECT MAX(`position`) FROM $table_name $conditions") + 1);
                }
            }
        });
    }
public function ActiveCollabDatabaseStructureBehaviourPositionInterfaceImplementation()
    {
        $this->registerEventHandler('on_before_save', function () {
            if (!$this->getPosition()) {
                $table_name = $this->connection->escapeTableName($this->getTableName());
                $conditions = $this->getPositionContextConditions();

                if ($this->getPositionMode() == PositionInterface::POSITION_MODE_HEAD) {
                    $this->setPosition(1);

                    if ($ids = $this->connection->executeFirstColumn("SELECT `id` FROM $table_name $conditions")) {
                        $this->connection->execute("UPDATE $table_name SET `position` = `position` + 1 $conditions");
                    }
                } else {
                    $this->setPosition($this->connection->executeFirstCell("SELECT MAX(`position`) FROM $table_name $conditions") + 1);
                }
            }
        });
    }
public function ActiveCollabDatabaseStructureBehaviourPositionInterfaceImplementation ( ) { $ this -> registerEventHandler ( 'on_before_save' , function ( ) { if ( ! $ this -> getPosition ( ) ) { $ table_name = $ this -> connection -> escapeTableName ( $ this -> getTableName ( ) ) ; $ conditions = $ this -> getPositionContextConditions ( ) ; if ( $ this -> getPositionMode ( ) == PositionInterface :: POSITION_MODE_HEAD ) { $ this -> setPosition ( 1 ) ; if ( $ ids = $ this -> connection -> executeFirstColumn ( "SELECT `id` FROM $table_name $conditions" ) ) { $ this -> connection -> execute ( "UPDATE $table_name SET `position` = `position` + 1 $conditions" ) ; } } else { $ this -> setPosition ( $ this -> connection -> executeFirstCell ( "SELECT MAX(`position`) FROM $table_name $conditions" ) + 1 ) ; } } } ) ; }
Say hello to the parent class.
Say hello to the parent class .