import * as React from "react" ; import * as PropTypes from "prop-types" ; import { ClientAemContext , AemContext } from "../AemContext" ; import RootComponentRegistry from "../RootComponentRegistry" ; import { Container } from "../di/Container" ; /**
 * Provides base functionality for components that are
 */ export default class AemComponent < P , S > extends React . PureComponent < P , S > { public static contextTypes : any = { wcmmode : PropTypes . string , path : PropTypes . string , rootPath : PropTypes . string , aemContext : PropTypes . any } ; public context : { wcmmode : string ; path : string ; aemContext : ClientAemContext ; } ; public getWcmmode ( ) { return this . context . wcmmode ; } public getPath ( ) { return this . context . path ; } public isWcmEnabled ( ) { return ! this . getWcmmode ( ) || this . getWcmmode ( ) !== "disabled" ; } protected getAemContext ( ) { return this . context . aemContext ; } public getRegistry ( ) { return this . context . aemContext . registry ; } public getComponent ( name ) { return this . getContainer ( ) . get ( name ) ; } public getOsgiService ( name ) { return this . getContainer ( ) . getOsgiService ( name ) ; } public getResourceModel ( name ) { return this . getContainer ( ) . getResourceModel ( this . getPath ( ) , name ) ; } public getRequestModel ( name ) { return this . getContainer ( ) . getRequestModel ( this . getPath ( ) , name ) ; } protected getContainer ( ) { return this . context . aemContext . container ; } }