public function recreateDefaults()
    {
        // Administrator group
        /** @var AdminUserGroup $group */
        $group = AdminUserGroupRepository::findOneEntityById(1);

        // If no any Admin group - create new empty group
        if (!$group || !$group->getUndeletable() || !$group->getCanSetPermissions() || !$group->getFullAccess()) {
            if ($group) {
                $group->is_super_admin = true;
                $group
                    ->setField('undeletable', 1)
                    ->setField('can_set_permissions', 1)
                    ->setField('structure_permissions', 1)
                    ->setFullAccess(1)
                    ->save();
            } else {

                // Delete all groups
                $group_collection = new AdminUserGroupRepository();
                $group_collection->deleteObjectCollection();

                // Drop auto-increment value
                $group_collection->alterTableResetAutoIncrement();

                // Create new Group for Admins
                $group = new AdminUserGroup();
                $group->is_super_admin = true;
                $group->loadDataFromArray(
                    [
                        'undeletable'           => 1,
                        'can_set_permissions'   => 1,
                        'structure_permissions' => 1,
                        'full_access'           => 1,
                        'title'                 => 'Developers',
                    ]
                );
                $group->save();

                // Create new Group for Managers
                $group = new AdminUserGroup();
                $group->is_super_admin = true;
                $group->loadDataFromArray(
                    [
                        'undeletable'           => 0,
                        'can_set_permissions'   => 1,
                        'structure_permissions' => 1,
                        'full_access'           => 1,
                        'title'                 => 'Managers',
                        'default'               => 1,
                    ]
                );
                $group->save();

                echo '<br>Default User Group is created.<br>';
            }
        }

        unset($data);

        // Check we have any active Admin
        $users_collection = new AdminUserRepository();
        $users_collection->setWhereActive(1);
        $have_any_user = $users_collection->hasAnyObjectInCollection();

        // Check we have admin as first User
        $users_collection = new AdminUserRepository();
        $users_collection->setWhereActive(1);
        $users_collection->setWhereId(1);
        $users_collection->setWhereGroupId(1);
        $users_collection->setWhereLogin('neTpyceB'); // Name of vendor repo owner
        $have_default_user = $users_collection->hasAnyObjectInCollection();

        // Recreate default User
        if (!$have_any_user || !$have_default_user) {
            //Remove all Users
            $users_collection = new AdminUserRepository;
            $users_collection->deleteObjectCollection();

            // Reset auto-increment
            $users_collection->alterTableResetAutoIncrement();

            // Create new default Developer
            $user = new AdminUser;
            $user->loadDataFromArray(
                [
                    'group_id' => 1, // Developer
                    'login'    => 'neTpyceB', // Name of vendor repo owner
                    'password' => $this->generateHash(Configuration::getInstance()->get('cms')['unique_key']), // Password is the same as unique key
                    'active'   => 1,
                ]
            );
            $user->save();

            // Create new default Manager
            $user = new AdminUser;
            $user->loadDataFromArray(
                [
                    'group_id' => 2, // Manager
                    'login'    => 'manager',
                    'password' => $this->generateHash(''), // Empty password
                    'active'   => 1,
                ]
            );
            $user->save();

            echo '<br>Default User "manager" and empty password is created.
			<br>
			Please log in and change password.
			<br>';
        }
    }
public function recreateDefaults()
    {
        // Administrator group
        /** @var AdminUserGroup $group */
        $group = AdminUserGroupRepository::findOneEntityById(1);

        // If no any Admin group - create new empty group
        if (!$group || !$group->getUndeletable() || !$group->getCanSetPermissions() || !$group->getFullAccess()) {
            if ($group) {
                $group->is_super_admin = true;
                $group
                    ->setField('undeletable', 1)
                    ->setField('can_set_permissions', 1)
                    ->setField('structure_permissions', 1)
                    ->setFullAccess(1)
                    ->save();
            } else {

                // Delete all groups
                $group_collection = new AdminUserGroupRepository();
                $group_collection->deleteObjectCollection();

                // Drop auto-increment value
                $group_collection->alterTableResetAutoIncrement();

                // Create new Group for Admins
                $group = new AdminUserGroup();
                $group->is_super_admin = true;
                $group->loadDataFromArray(
                    [
                        'undeletable'           => 1,
                        'can_set_permissions'   => 1,
                        'structure_permissions' => 1,
                        'full_access'           => 1,
                        'title'                 => 'Developers',
                    ]
                );
                $group->save();

                // Create new Group for Managers
                $group = new AdminUserGroup();
                $group->is_super_admin = true;
                $group->loadDataFromArray(
                    [
                        'undeletable'           => 0,
                        'can_set_permissions'   => 1,
                        'structure_permissions' => 1,
                        'full_access'           => 1,
                        'title'                 => 'Managers',
                        'default'               => 1,
                    ]
                );
                $group->save();

                echo '<br>Default User Group is created.<br>';
            }
        }

        unset($data);

        // Check we have any active Admin
        $users_collection = new AdminUserRepository();
        $users_collection->setWhereActive(1);
        $have_any_user = $users_collection->hasAnyObjectInCollection();

        // Check we have admin as first User
        $users_collection = new AdminUserRepository();
        $users_collection->setWhereActive(1);
        $users_collection->setWhereId(1);
        $users_collection->setWhereGroupId(1);
        $users_collection->setWhereLogin('neTpyceB'); // Name of vendor repo owner
        $have_default_user = $users_collection->hasAnyObjectInCollection();

        // Recreate default User
        if (!$have_any_user || !$have_default_user) {
            //Remove all Users
            $users_collection = new AdminUserRepository;
            $users_collection->deleteObjectCollection();

            // Reset auto-increment
            $users_collection->alterTableResetAutoIncrement();

            // Create new default Developer
            $user = new AdminUser;
            $user->loadDataFromArray(
                [
                    'group_id' => 1, // Developer
                    'login'    => 'neTpyceB', // Name of vendor repo owner
                    'password' => $this->generateHash(Configuration::getInstance()->get('cms')['unique_key']), // Password is the same as unique key
                    'active'   => 1,
                ]
            );
            $user->save();

            // Create new default Manager
            $user = new AdminUser;
            $user->loadDataFromArray(
                [
                    'group_id' => 2, // Manager
                    'login'    => 'manager',
                    'password' => $this->generateHash(''), // Empty password
                    'active'   => 1,
                ]
            );
            $user->save();

            echo '<br>Default User "manager" and empty password is created.
			<br>
			Please log in and change password.
			<br>';
        }
    }
public function recreateDefaults ( ) { // Administrator group /** @var AdminUserGroup $group */ $ group = AdminUserGroupRepository :: findOneEntityById ( 1 ) ; // If no any Admin group - create new empty group if ( ! $ group || ! $ group -> getUndeletable ( ) || ! $ group -> getCanSetPermissions ( ) || ! $ group -> getFullAccess ( ) ) { if ( $ group ) { $ group -> is_super_admin = true ; $ group -> setField ( 'undeletable' , 1 ) -> setField ( 'can_set_permissions' , 1 ) -> setField ( 'structure_permissions' , 1 ) -> setFullAccess ( 1 ) -> save ( ) ; } else { // Delete all groups $ group_collection = new AdminUserGroupRepository ( ) ; $ group_collection -> deleteObjectCollection ( ) ; // Drop auto-increment value $ group_collection -> alterTableResetAutoIncrement ( ) ; // Create new Group for Admins $ group = new AdminUserGroup ( ) ; $ group -> is_super_admin = true ; $ group -> loadDataFromArray ( [ 'undeletable' => 1 , 'can_set_permissions' => 1 , 'structure_permissions' => 1 , 'full_access' => 1 , 'title' => 'Developers' , ] ) ; $ group -> save ( ) ; // Create new Group for Managers $ group = new AdminUserGroup ( ) ; $ group -> is_super_admin = true ; $ group -> loadDataFromArray ( [ 'undeletable' => 0 , 'can_set_permissions' => 1 , 'structure_permissions' => 1 , 'full_access' => 1 , 'title' => 'Managers' , 'default' => 1 , ] ) ; $ group -> save ( ) ; echo '<br>Default User Group is created.<br>' ; } } unset ( $ data ) ; // Check we have any active Admin $ users_collection = new AdminUserRepository ( ) ; $ users_collection -> setWhereActive ( 1 ) ; $ have_any_user = $ users_collection -> hasAnyObjectInCollection ( ) ; // Check we have admin as first User $ users_collection = new AdminUserRepository ( ) ; $ users_collection -> setWhereActive ( 1 ) ; $ users_collection -> setWhereId ( 1 ) ; $ users_collection -> setWhereGroupId ( 1 ) ; $ users_collection -> setWhereLogin ( 'neTpyceB' ) ; // Name of vendor repo owner $ have_default_user = $ users_collection -> hasAnyObjectInCollection ( ) ; // Recreate default User if ( ! $ have_any_user || ! $ have_default_user ) { //Remove all Users $ users_collection = new AdminUserRepository ; $ users_collection -> deleteObjectCollection ( ) ; // Reset auto-increment $ users_collection -> alterTableResetAutoIncrement ( ) ; // Create new default Developer $ user = new AdminUser ; $ user -> loadDataFromArray ( [ 'group_id' => 1 , // Developer 'login' => 'neTpyceB' , // Name of vendor repo owner 'password' => $ this -> generateHash ( Configuration :: getInstance ( ) -> get ( 'cms' ) [ 'unique_key' ] ) , // Password is the same as unique key 'active' => 1 , ] ) ; $ user -> save ( ) ; // Create new default Manager $ user = new AdminUser ; $ user -> loadDataFromArray ( [ 'group_id' => 2 , // Manager 'login' => 'manager' , 'password' => $ this -> generateHash ( '' ) , // Empty password 'active' => 1 , ] ) ; $ user -> save ( ) ; echo '<br>Default User "manager" and empty password is created.
			<br>
			Please log in and change password.
			<br>' ; } }
Installing new database. Use only when auto-creating new site
Installing new database . Use only when auto - creating new site