import { ControllerClass , Type } from "./deps.ts" ; export interface ViewConfig { name ? : string ; path ? : string ; template ? : string ; layout ? : string | false ; } export class ViewCatalog { private static readonly viewCatalog = new Map < Type , { controller ? : ViewConfig ; actions : { [ action ] : ViewConfig ; } ; } > ( ) ; static registerControllerView ( type , registration ) { this . getControllerRegistration ( type ) . controller = { ... this . getControllerRegistration ( type ) . controller , ... registration } ; } static registerActionView ( type , action , registration ) { this . getControllerRegistration ( type ) . actions [ action ] = { ... this . getControllerRegistration ( type ) . actions [ action ] , ... registration } ; } static getView ( type , action ) { return { ... this . viewCatalog . get ( type ) ?. controller , ... this . viewCatalog . get ( type ) ?. actions [ action ] } ; } private static getControllerRegistration ( type ) { let registration = this . viewCatalog . get ( type ) ; if ( ! registration ) { registration = { actions : { } } ; this . viewCatalog . set ( type , registration ) ; } return registration ; } }