feat(marketing-pages): add bindProductionMarketingPages(config) DI helper
This commit is contained in:
@@ -6,7 +6,8 @@
|
|||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts",
|
".": "./src/index.ts",
|
||||||
"./cms": "./src/integrations/cms/index.ts",
|
"./cms": "./src/integrations/cms/index.ts",
|
||||||
"./api": "./src/integrations/api/router.ts"
|
"./api": "./src/integrations/api/router.ts",
|
||||||
|
"./di/bind-production": "./src/di/bind-production.ts"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc --noEmit",
|
"build": "tsc --noEmit",
|
||||||
|
|||||||
29
packages/marketing-pages/src/di/bind-production.ts
Normal file
29
packages/marketing-pages/src/di/bind-production.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import type { SanitizedConfig } from "payload";
|
||||||
|
import { marketingPagesContainer } from "./container";
|
||||||
|
import { MARKETING_PAGES_SYMBOLS } from "./symbols";
|
||||||
|
import { PayloadPagesRepository } from "../infrastructure/repositories/payload-pages.repository";
|
||||||
|
import { PayloadSiteSettingsRepository } from "../infrastructure/repositories/payload-site-settings.repository";
|
||||||
|
|
||||||
|
export function bindProductionMarketingPages(config: SanitizedConfig): void {
|
||||||
|
if (
|
||||||
|
marketingPagesContainer.isBound(MARKETING_PAGES_SYMBOLS.IPagesRepository)
|
||||||
|
) {
|
||||||
|
marketingPagesContainer.unbind(MARKETING_PAGES_SYMBOLS.IPagesRepository);
|
||||||
|
}
|
||||||
|
marketingPagesContainer
|
||||||
|
.bind(MARKETING_PAGES_SYMBOLS.IPagesRepository)
|
||||||
|
.toConstantValue(new PayloadPagesRepository(config));
|
||||||
|
|
||||||
|
if (
|
||||||
|
marketingPagesContainer.isBound(
|
||||||
|
MARKETING_PAGES_SYMBOLS.ISiteSettingsRepository,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
marketingPagesContainer.unbind(
|
||||||
|
MARKETING_PAGES_SYMBOLS.ISiteSettingsRepository,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
marketingPagesContainer
|
||||||
|
.bind(MARKETING_PAGES_SYMBOLS.ISiteSettingsRepository)
|
||||||
|
.toConstantValue(new PayloadSiteSettingsRepository(config));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user