<?php

namespace Hubleto\App\Community\EventFeedback;

class Loader extends \Hubleto\Erp\App
{

  /**
   * Inits the app: adds routes, settings, calendars, event listeners, menu items, ...
   *
   * @return void
   * 
   */
  public function init(): void
  {
    parent::init();

    $this->router()->get([
      '/^events-feedback\/?$/' => Controllers\Dashboard::class,
      '/^events-feedback\/contacts\/?$/' => Controllers\Contacts::class,
      '/^settings\/events-feedback\/?$/' => Controllers\Settings::class,
    ]);

    $settingsApp = $this->appManager()->getApp(\Hubleto\App\Community\Settings\Loader::class);
    $settingsApp->addSetting($this, [
      'title' => $this->translate('EventFeedback'),
      'icon' => 'fas fa-table',
      'url' => 'settings/events-feedback',
    ]);

    /** @var \Hubleto\App\Community\Calendar\Manager $calendarManager */
    $calendarManager = $this->getService(\Hubleto\App\Community\Calendar\Manager::class);
    $calendarManager->addCalendar(
      $this, 
      'EventFeedback-calendar', // UID of your app's calendar. Will be referenced as "source" when fetching app's events.
      Calendar::class // your app's Calendar class
    );

  }

  // upgradeSchema
  public function installApp(int $round): void
  {
    if ($round == 1) {
      $this->getModel(Models\Contact::class)->upgradeSchema();
    }
  }

  // generateDemoData
  public function generateDemoData(): void
  {
    // Create any demo data to promote your app.
  }

}
