public function execute(Arguments $args, ConsoleIo $io)
    {
        $this->loadModel('MeCms.UsersGroups');

        if (!$this->UsersGroups->find()->isEmpty()) {
            $io->error(__d('me_cms', 'Some user groups already exist'));

            return null;
        }

        //Truncates the table (this resets IDs), then saves groups
        ConnectionManager::get('default')->execute(sprintf('TRUNCATE TABLE `%s`', $this->UsersGroups->getTable()));
        $this->UsersGroups->saveMany($this->UsersGroups->newEntities([
            ['id' => 1, 'name' => 'admin', 'label' => 'Admin'],
            ['id' => 2, 'name' => 'manager', 'label' => 'Manager'],
            ['id' => 3, 'name' => 'user', 'label' => 'User'],
        ]));
        $io->verbose(__d('me_cms', 'The user groups have been created'));

        return null;
    }
public function execute(Arguments $args, ConsoleIo $io)
    {
        $this->loadModel('MeCms.UsersGroups');

        if (!$this->UsersGroups->find()->isEmpty()) {
            $io->error(__d('me_cms', 'Some user groups already exist'));

            return null;
        }

        //Truncates the table (this resets IDs), then saves groups
        ConnectionManager::get('default')->execute(sprintf('TRUNCATE TABLE `%s`', $this->UsersGroups->getTable()));
        $this->UsersGroups->saveMany($this->UsersGroups->newEntities([
            ['id' => 1, 'name' => 'admin', 'label' => 'Admin'],
            ['id' => 2, 'name' => 'manager', 'label' => 'Manager'],
            ['id' => 3, 'name' => 'user', 'label' => 'User'],
        ]));
        $io->verbose(__d('me_cms', 'The user groups have been created'));

        return null;
    }
public function execute ( Arguments $ args , ConsoleIo $ io ) { $ this -> loadModel ( 'MeCms.UsersGroups' ) ; if ( ! $ this -> UsersGroups -> find ( ) -> isEmpty ( ) ) { $ io -> error ( __d ( 'me_cms' , 'Some user groups already exist' ) ) ; return null ; } //Truncates the table (this resets IDs), then saves groups ConnectionManager :: get ( 'default' ) -> execute ( sprintf ( 'TRUNCATE TABLE `%s`' , $ this -> UsersGroups -> getTable ( ) ) ) ; $ this -> UsersGroups -> saveMany ( $ this -> UsersGroups -> newEntities ( [ [ 'id' => 1 , 'name' => 'admin' , 'label' => 'Admin' ] , [ 'id' => 2 , 'name' => 'manager' , 'label' => 'Manager' ] , [ 'id' => 3 , 'name' => 'user' , 'label' => 'User' ] , ] ) ) ; $ io -> verbose ( __d ( 'me_cms' , 'The user groups have been created' ) ) ; return null ; }
Creates the user groups
@param Arguments $args The command arguments
@param ConsoleIo $io The console io
@return null|int The exit code or null for success
Creates the user groups