From 91c8be2167021388e3658763e2f2520d2970aefd Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 13 Feb 2018 14:38:04 +0100 Subject: [PATCH] MOBILE-2333 core: Export lists of providers --- src/app/app.module.ts | 62 +++++++++++--------- src/core/contentlinks/contentlinks.module.ts | 11 ++-- src/core/course/course.module.ts | 20 ++++--- src/core/courses/courses.module.ts | 12 ++-- src/core/emulator/emulator.module.ts | 18 ++++++ src/core/fileuploader/fileuploader.module.ts | 14 +++-- src/core/grades/grades.module.ts | 12 ++-- src/core/login/login.module.ts | 9 ++- src/core/mainmenu/mainmenu.module.ts | 11 ++-- src/core/sharedfiles/sharedfiles.module.ts | 12 ++-- src/core/siteaddons/siteaddons.module.ts | 9 ++- src/core/sitehome/sitehome.module.ts | 10 +++- src/core/user/user.module.ts | 16 +++-- 13 files changed, 139 insertions(+), 77 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 376a2b963..893edcb9c 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -81,6 +81,36 @@ export function createTranslateLoader(http: HttpClient): TranslateHttpLoader { return new TranslateHttpLoader(http, './assets/lang/', '.json'); } +// List of providers. +export const CORE_PROVIDERS: any[] = [ + CoreLoggerProvider, + CoreDbProvider, + CoreAppProvider, + CoreConfigProvider, + CoreLangProvider, + CoreTextUtilsProvider, + CoreDomUtilsProvider, + CoreTimeUtilsProvider, + CoreUrlUtilsProvider, + CoreUtilsProvider, + CoreMimetypeUtilsProvider, + CoreInitDelegate, + CoreFileProvider, + CoreWSProvider, + CoreEventsProvider, + CoreSitesFactoryProvider, + CoreSitesProvider, + CoreLocalNotificationsProvider, + CoreGroupsProvider, + CoreCronDelegate, + CoreFileSessionProvider, + CoreFilepoolProvider, + CoreUpdateManagerProvider, + CorePluginFileDelegate, + CoreSyncProvider, + CoreAddonManagerProvider +]; + @NgModule({ declarations: [ MoodleMobileApp @@ -126,39 +156,13 @@ export function createTranslateLoader(http: HttpClient): TranslateHttpLoader { entryComponents: [ MoodleMobileApp ], - providers: [ + providers: CORE_PROVIDERS.concat([ { provide: HTTP_INTERCEPTORS, useClass: CoreInterceptor, multi: true, - }, - CoreLoggerProvider, - CoreDbProvider, - CoreAppProvider, - CoreConfigProvider, - CoreLangProvider, - CoreTextUtilsProvider, - CoreDomUtilsProvider, - CoreTimeUtilsProvider, - CoreUrlUtilsProvider, - CoreUtilsProvider, - CoreMimetypeUtilsProvider, - CoreInitDelegate, - CoreFileProvider, - CoreWSProvider, - CoreEventsProvider, - CoreSitesFactoryProvider, - CoreSitesProvider, - CoreLocalNotificationsProvider, - CoreGroupsProvider, - CoreCronDelegate, - CoreFileSessionProvider, - CoreFilepoolProvider, - CoreUpdateManagerProvider, - CorePluginFileDelegate, - CoreSyncProvider, - CoreAddonManagerProvider - ] + } + ]) }) export class AppModule { constructor(platform: Platform, initDelegate: CoreInitDelegate, updateManager: CoreUpdateManagerProvider, diff --git a/src/core/contentlinks/contentlinks.module.ts b/src/core/contentlinks/contentlinks.module.ts index 05c3ea838..0abe605db 100644 --- a/src/core/contentlinks/contentlinks.module.ts +++ b/src/core/contentlinks/contentlinks.module.ts @@ -16,14 +16,17 @@ import { NgModule } from '@angular/core'; import { CoreContentLinksDelegate } from './providers/delegate'; import { CoreContentLinksHelperProvider } from './providers/helper'; +// List of providers. +export const CORE_CONTENTLINKS_PROVIDERS = [ + CoreContentLinksDelegate, + CoreContentLinksHelperProvider +]; + @NgModule({ declarations: [], imports: [ ], - providers: [ - CoreContentLinksDelegate, - CoreContentLinksHelperProvider - ], + providers: CORE_CONTENTLINKS_PROVIDERS, exports: [] }) export class CoreContentLinksModule {} diff --git a/src/core/course/course.module.ts b/src/core/course/course.module.ts index 9154daaab..d26fbd730 100644 --- a/src/core/course/course.module.ts +++ b/src/core/course/course.module.ts @@ -25,6 +25,16 @@ import { CoreCourseFormatSocialModule } from './formats/social/social.module'; import { CoreCourseFormatTopicsModule } from './formats/topics/topics.module'; import { CoreCourseFormatWeeksModule } from './formats/weeks/weeks.module'; +// List of providers (without handlers). +export const CORE_COURSE_PROVIDERS: any[] = [ + CoreCourseProvider, + CoreCourseHelperProvider, + CoreCourseFormatDelegate, + CoreCourseModuleDelegate, + CoreCourseModulePrefetchDelegate, + CoreCourseOptionsDelegate +]; + @NgModule({ declarations: [], imports: [ @@ -33,15 +43,9 @@ import { CoreCourseFormatWeeksModule } from './formats/weeks/weeks.module'; CoreCourseFormatWeeksModule, CoreCourseFormatSocialModule ], - providers: [ - CoreCourseProvider, - CoreCourseHelperProvider, - CoreCourseFormatDelegate, - CoreCourseModuleDelegate, - CoreCourseModulePrefetchDelegate, - CoreCourseOptionsDelegate, + providers: CORE_COURSE_PROVIDERS.concat([ CoreCourseFormatDefaultHandler - ], + ]), exports: [] }) export class CoreCourseModule {} diff --git a/src/core/courses/courses.module.ts b/src/core/courses/courses.module.ts index 2fde4b912..d38dad816 100644 --- a/src/core/courses/courses.module.ts +++ b/src/core/courses/courses.module.ts @@ -22,18 +22,22 @@ import { CoreCoursesMyOverviewLinkHandler } from './providers/my-overview-link-h import { CoreMainMenuDelegate } from '../mainmenu/providers/delegate'; import { CoreContentLinksDelegate } from '../contentlinks/providers/delegate'; +// List of providers (without handlers). +export const CORE_COURSES_PROVIDERS: any[] = [ + CoreCoursesProvider, + CoreCoursesMyOverviewProvider +]; + @NgModule({ declarations: [], imports: [ ], - providers: [ - CoreCoursesProvider, + providers: CORE_COURSES_PROVIDERS.concat([ CoreCoursesMainMenuHandler, - CoreCoursesMyOverviewProvider, CoreCoursesCourseLinkHandler, CoreCoursesIndexLinkHandler, CoreCoursesMyOverviewLinkHandler - ], + ]), exports: [] }) export class CoreCoursesModule { diff --git a/src/core/emulator/emulator.module.ts b/src/core/emulator/emulator.module.ts index 353369710..8229d4bec 100644 --- a/src/core/emulator/emulator.module.ts +++ b/src/core/emulator/emulator.module.ts @@ -56,6 +56,24 @@ import { CoreUrlUtilsProvider } from '@providers/utils/url'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { CoreInitDelegate } from '@providers/init'; +// List of Ionic Native providers. +export const IONIC_NATIVE_PROVIDERS = [ + Camera, + Clipboard, + File, + FileTransfer, + Globalization, + InAppBrowser, + Keyboard, + LocalNotifications, + MediaCapture, + Network, + SplashScreen, + StatusBar, + SQLite, + Zip +]; + /** * This module handles the emulation of Cordova plugins in browser and desktop. * diff --git a/src/core/fileuploader/fileuploader.module.ts b/src/core/fileuploader/fileuploader.module.ts index 5d52372bb..d0545d32e 100644 --- a/src/core/fileuploader/fileuploader.module.ts +++ b/src/core/fileuploader/fileuploader.module.ts @@ -22,21 +22,25 @@ import { CoreFileUploaderCameraHandler } from './providers/camera-handler'; import { CoreFileUploaderFileHandler } from './providers/file-handler'; import { CoreFileUploaderVideoHandler } from './providers/video-handler'; +// List of providers (without handlers). +export const CORE_FILEUPLOADER_PROVIDERS: any[] = [ + CoreFileUploaderProvider, + CoreFileUploaderHelperProvider, + CoreFileUploaderDelegate +]; + @NgModule({ declarations: [ ], imports: [ ], - providers: [ - CoreFileUploaderProvider, - CoreFileUploaderHelperProvider, - CoreFileUploaderDelegate, + providers: CORE_FILEUPLOADER_PROVIDERS.concat([ CoreFileUploaderAlbumHandler, CoreFileUploaderAudioHandler, CoreFileUploaderCameraHandler, CoreFileUploaderFileHandler, CoreFileUploaderVideoHandler - ] + ]) }) export class CoreFileUploaderModule { constructor(delegate: CoreFileUploaderDelegate, albumHandler: CoreFileUploaderAlbumHandler, diff --git a/src/core/grades/grades.module.ts b/src/core/grades/grades.module.ts index d090f2e00..136715c3d 100644 --- a/src/core/grades/grades.module.ts +++ b/src/core/grades/grades.module.ts @@ -29,21 +29,25 @@ import { CoreEventsProvider } from '@providers/events'; import { CoreSitesProvider } from '@providers/sites'; import { CoreUserProvider } from '../user/providers/user'; +// List of providers (without handlers). +export const CORE_GRADES_PROVIDERS: any[] = [ + CoreGradesProvider, + CoreGradesHelperProvider +]; + @NgModule({ declarations: [ ], imports: [ CoreGradesComponentsModule ], - providers: [ - CoreGradesProvider, - CoreGradesHelperProvider, + providers: CORE_GRADES_PROVIDERS.concat([ CoreGradesMainMenuHandler, CoreGradesCourseOptionHandler, CoreGradesUserLinkHandler, CoreGradesOverviewLinkHandler, CoreGradesUserHandler - ] + ]) }) export class CoreGradesModule { constructor(mainMenuDelegate: CoreMainMenuDelegate, gradesMenuHandler: CoreGradesMainMenuHandler, diff --git a/src/core/login/login.module.ts b/src/core/login/login.module.ts index 8e4f9a3d8..55d40cff9 100644 --- a/src/core/login/login.module.ts +++ b/src/core/login/login.module.ts @@ -15,13 +15,16 @@ import { NgModule } from '@angular/core'; import { CoreLoginHelperProvider } from './providers/helper'; +// List of providers. +export const CORE_LOGIN_PROVIDERS = [ + CoreLoginHelperProvider +]; + @NgModule({ declarations: [ ], imports: [ ], - providers: [ - CoreLoginHelperProvider - ] + providers: CORE_LOGIN_PROVIDERS }) export class CoreLoginModule {} diff --git a/src/core/mainmenu/mainmenu.module.ts b/src/core/mainmenu/mainmenu.module.ts index 0a49f84b8..7873056cb 100644 --- a/src/core/mainmenu/mainmenu.module.ts +++ b/src/core/mainmenu/mainmenu.module.ts @@ -16,14 +16,17 @@ import { NgModule } from '@angular/core'; import { CoreMainMenuDelegate } from './providers/delegate'; import { CoreMainMenuProvider } from './providers/mainmenu'; +// List of providers. +export const CORE_MAINMENU_PROVIDERS = [ + CoreMainMenuDelegate, + CoreMainMenuProvider +]; + @NgModule({ declarations: [ ], imports: [ ], - providers: [ - CoreMainMenuDelegate, - CoreMainMenuProvider - ] + providers: CORE_MAINMENU_PROVIDERS }) export class CoreMainMenuModule {} diff --git a/src/core/sharedfiles/sharedfiles.module.ts b/src/core/sharedfiles/sharedfiles.module.ts index e58bbd904..fabe30c12 100644 --- a/src/core/sharedfiles/sharedfiles.module.ts +++ b/src/core/sharedfiles/sharedfiles.module.ts @@ -19,16 +19,20 @@ import { CoreSharedFilesHelperProvider } from './providers/helper'; import { CoreSharedFilesUploadHandler } from './providers/upload-handler'; import { CoreFileUploaderDelegate } from '../fileuploader/providers/delegate'; +// List of providers (without handlers). +export const CORE_SHAREDFILES_PROVIDERS: any[] = [ + CoreSharedFilesProvider, + CoreSharedFilesHelperProvider +]; + @NgModule({ declarations: [ ], imports: [ ], - providers: [ - CoreSharedFilesProvider, - CoreSharedFilesHelperProvider, + providers: CORE_SHAREDFILES_PROVIDERS.concat([ CoreSharedFilesUploadHandler - ] + ]) }) export class CoreSharedFilesModule { constructor(platform: Platform, delegate: CoreFileUploaderDelegate, handler: CoreSharedFilesUploadHandler, diff --git a/src/core/siteaddons/siteaddons.module.ts b/src/core/siteaddons/siteaddons.module.ts index 00275ba92..f7f7f9298 100644 --- a/src/core/siteaddons/siteaddons.module.ts +++ b/src/core/siteaddons/siteaddons.module.ts @@ -16,13 +16,16 @@ import { NgModule } from '@angular/core'; import { Platform } from 'ionic-angular'; import { CoreSiteAddonsProvider } from './providers/siteaddons'; +// List of providers. +export const CORE_SITEADDONS_PROVIDERS = [ + CoreSiteAddonsProvider +]; + @NgModule({ declarations: [ ], imports: [ ], - providers: [ - CoreSiteAddonsProvider - ] + providers: CORE_SITEADDONS_PROVIDERS }) export class CoreSiteAddonsModule { } diff --git a/src/core/sitehome/sitehome.module.ts b/src/core/sitehome/sitehome.module.ts index c498d2b12..d24f3c2df 100644 --- a/src/core/sitehome/sitehome.module.ts +++ b/src/core/sitehome/sitehome.module.ts @@ -19,15 +19,19 @@ import { CoreSiteHomeIndexLinkHandler } from './providers/index-link-handler'; import { CoreMainMenuDelegate } from '../mainmenu/providers/delegate'; import { CoreContentLinksDelegate } from '../contentlinks/providers/delegate'; +// List of providers (without handlers). +export const CORE_SITEHOME_PROVIDERS: any[] = [ + CoreSiteHomeProvider +]; + @NgModule({ declarations: [], imports: [ ], - providers: [ - CoreSiteHomeProvider, + providers: CORE_SITEHOME_PROVIDERS.concat([ CoreSiteHomeMainMenuHandler, CoreSiteHomeIndexLinkHandler - ], + ]), exports: [] }) export class CoreSiteHomeModule { diff --git a/src/core/user/user.module.ts b/src/core/user/user.module.ts index bfec54d89..12d3d78df 100644 --- a/src/core/user/user.module.ts +++ b/src/core/user/user.module.ts @@ -27,22 +27,26 @@ import { CoreUserParticipantsLinkHandler } from './providers/participants-link-h import { CoreCourseOptionsDelegate } from '@core/course/providers/options-delegate'; import { CoreUserComponentsModule } from './components/components.module'; +// List of providers (without handlers). +export const CORE_USER_PROVIDERS: any[] = [ + CoreUserDelegate, + CoreUserProfileFieldDelegate, + CoreUserProvider, + CoreUserHelperProvider, +]; + @NgModule({ declarations: [ ], imports: [ CoreUserComponentsModule ], - providers: [ - CoreUserDelegate, - CoreUserProfileFieldDelegate, + providers: CORE_USER_PROVIDERS.concat([ CoreUserProfileMailHandler, - CoreUserProvider, - CoreUserHelperProvider, CoreUserProfileLinkHandler, CoreUserParticipantsCourseOptionHandler, CoreUserParticipantsLinkHandler - ] + ]) }) export class CoreUserModule { constructor(userDelegate: CoreUserDelegate, userProfileMailHandler: CoreUserProfileMailHandler,