public function sync()
    {
        $actionMap = $this->Guardian->getActionMap();

        // check existance of all permission entries for each individual group
        /** @var Query $groups */
        $groups = $this->GroupPermissions->Groups->find('all')
            ->where(['Groups.id <>' => 1]);// ignore Administrator group

        /** @var Connection $connection */
        $connection = $this->GroupPermissions->connection();
        $connection->begin();

        // delete guest actions
        $this->GroupPermissions->deleteAll([
            'path IN' => $this->Guardian->getGuestActions()
        ]);

        foreach ($groups as $group) {
            try {
                $this->GroupPermissions->createMissingPermissions($group->id, $actionMap);
                $this->GroupPermissions->deleteOrphans($group->id, $actionMap);
            } catch (Exception $e) {
                $connection->rollback();
            }
        }

        if ($connection->inTransaction()) {
            $connection->commit();
        }
        // delete guardian path cache
        $this->eventManager()->dispatch(new Event('Guardian.GroupPermissions.afterSync'));

        $this->Flash->success(__d('wasabi_core', 'All permissions have been synchronized.'));
        $this->redirect(['action' => 'index']);
        //@codingStandardIgnoreStart
        return;
        //@codingStandardIgnoreEnd
    }