<?php

namespace CCDN;

use CCDN\Controllers\BtnController;
use CCDN\Controllers\CalendarController;
use CCDN\Controllers\CollectionsController;
use CCDN\Controllers\DeletePluginController;
use CCDN\Controllers\FranchisePartsController;
use CCDN\Controllers\FutureFranchisesController;
use CCDN\Controllers\LogsController;
use CCDN\Controllers\MainController;
use CCDN\Controllers\ModuleController;
use CCDN\Controllers\NewFranchiseController;
use CCDN\Controllers\ParseDataBaseController;
use CCDN\Controllers\SettingsController;
use CCDN\Controllers\UpdatePostController;
use CCDN\Helpers\Exception\CCDNException;
use CCDN\Helpers\Http\Router;
use CCDN\Helpers\Facade\Http\Url;


class Init extends Router
{

    /**
     * @throws CCDNException
     */
    public function run()
    {
        /**
         * MainController
         */
        $this->get('main', MainController::class, 'main');
        $this->get('main-clear-cache', MainController::class, 'clearCache', 'main');
        $this->get('main-update-plugin', MainController::class, 'update', 'main');
        /**
         * BtnController
         */
        $this->get('btn-settings', BtnController::class, 'main');
        $this->post('btn-save-config', BtnController::class, 'saveSettings', 'btn-settings');
        $this->post('btn-get-franchise-details', BtnController::class, 'getFranchiseDetails', 'btn-settings');
        $this->get('btn-search', BtnController::class, 'search', 'btn-settings');
        /**
         * ParseDataBaseController
         */
        $this->get('parse-database', ParseDataBaseController::class, 'main');
        $this->post('parse-database-do', ParseDataBaseController::class, 'parse', 'parse-database');
        $this->get('collaps-database-data', ParseDataBaseController::class, 'getCollapsList', 'parse-database');
        /**
         * FranchisePartsController
         */
        $this->get('franchise-parts', FranchisePartsController::class, 'main');
        /**
         * UpdatePostController
         */
        $this->get('update-post', UpdatePostController::class, 'updateFilms');
        $this->get('update-post-get-chunk-count', UpdatePostController::class, 'chunksCount');
        /**
         * CalendarController
         */
        $this->get('calendar', CalendarController::class, 'main');
        $this->post('calendar-save-config', CalendarController::class, 'saveSettings', 'calendar');
        /**
         * CollectionsController
         */
        $this->get('collections', CollectionsController::class, 'main');
        $this->get('collections-chunk-count', CollectionsController::class, 'chunksCount', 'collections');
        $this->get('collections-update', CollectionsController::class, 'update', 'collections');
        $this->post('collections-save-config', CollectionsController::class, 'saveSettings', 'collections');
        /**
         * SettingsController
         */
        $this->get('settings', SettingsController::class, 'settings');
        $this->post('settings-save-config', SettingsController::class, 'saveConfig', 'settings');
        /**
         * ModuleController
         */
        $this->get('module', ModuleController::class, 'main');
        $this->post('module-save-settings', ModuleController::class, 'saveSettings', 'module');
        /**
         * NewFranchiseController
         */
        $this->get('new-franchise', NewFranchiseController::class, 'main');
        $this->post('new-franchise-save-config', NewFranchiseController::class, 'saveConfig', 'new-franchise');
        $this->get('new-franchise-list', NewFranchiseController::class, 'getNewFranchise', 'new-franchise');
        $this->get('new-franchise-get-franchise-details', NewFranchiseController::class, 'getFranchiseDetails', 'new-franchise');
        $this->post('new-franchise-create-new-post-by-franchise', NewFranchiseController::class, 'createPost', 'new-franchise');
        /**
         * FutureFranchises
         */
        $this->get('future-franchises', FutureFranchisesController::class, 'main');
        $this->get('future-franchises-get', FutureFranchisesController::class, 'getFutureFranchises', 'future-franchises');
        $this->post('future-franchises-save-config', FutureFranchisesController::class, 'saveSettings', 'future-franchises');
        $this->post('future-franchises-new-post', FutureFranchisesController::class, 'createPost', 'future-franchises');
        /**
         * LogsController
         */
        $this->get('logs', LogsController::class, 'main');
        $this->get('logs-print', LogsController::class, 'printLog', 'logs');
        $this->get('logs-download', LogsController::class, 'download', 'logs');
        $this->get('logs-delete', LogsController::class, 'delete', 'logs');
        $this->get('logs-delete-all', LogsController::class, 'deleteAll', 'logs');
        /**
         * DeletePluginController
         */
        $this->get('delete-plugin', DeletePluginController::class, 'delete');


        return $this->touch(Url::getAction());
    }

}
