render = $render; $this->instructions = new InstructionsPolicy( $render ); $this->banned_phrases = new BannedPhrasesPolicy( $render ); $this->custom_fields = new CustomFieldsPolicy( $render ); $this->taxonomy = new TaxonomyPolicy( $render ); $this->title = new TitlePolicy( $render ); $this->faq = new FaqPolicy( $render ); $this->seo_meta = new SeoMetaPolicy( $render ); $this->image_alt = new ImageAltPolicy( $render ); $this->voice = new VoicePolicy( $render ); $this->sources = new SourcesPolicy( $render ); $this->extra_slots = new ExtraSlotsPolicy( $render ); $this->store_sections = new StoreSectionsPolicy( $render ); } /** * The policy for display data an admin page renders (the content * template block of its localized data): every answer reads the * `_cache_only` twin of its bridge ({@see RenderMode}), so the page never * waits on a licence check. A run, and anything that enforces a plan, * keeps `new EntitlementPolicy()`, whose bridges decide authoritatively. * This policy refuses the run-only methods ({@see apply()}, * {@see clampBrandProfile()} and the `*FreeDefault()` notices) with a * LogicException, so display data can never decide a run. * * @return self */ public static function forRender(): self { return new self( true ); } /** * Clamp a resolved definition to this site's entitlements. * * @param string $generator Generator key. * @param array $definition Normalized BlueprintDefinition (the already-resolved runtime copy). * @param array $automation_context Optional array{reviewGuaranteed?:bool}, set only for an Automation run: {@see \AIPT\Api\AutomationJobs\JobExecutor} threads its job-uniform `reviewGuaranteed` boolean down through {@see \AIPT\Api\ContentStructure\Integration\BlueprintIntegration} and {@see \AIPT\Api\ContentStructure\Engine\ExecutionRequest}. Every non-Automation call site omits it and keeps today's behavior. * @return array{definition:array,appliedFreeDefaults:array} */ public function apply( string $generator, array $definition, array $automation_context = array() ): array { $this->refuseInRenderMode( __METHOD__ ); $clamped = $definition; $applied = array(); $this->instructions->clamp( $generator, $clamped, $applied ); $this->banned_phrases->clamp( $clamped, $applied ); $this->custom_fields->clamp( $clamped, $applied ); $this->sources->clamp( $clamped, $applied ); if ( Generators::TAXONOMY === $generator ) { $this->taxonomy->clamp( $clamped, $applied ); } if ( Generators::DESCRIPTION === $generator ) { $this->store_sections->clamp( $clamped, $applied, $automation_context ); } if ( Generators::TITLE === $generator ) { $this->title->clamp( $clamped, $applied ); } if ( Generators::FAQ === $generator ) { $this->faq->clamp( $clamped, $applied ); } if ( Generators::SEO_META === $generator ) { $this->seo_meta->clamp( $clamped, $applied ); } if ( Generators::IMAGE_ALT === $generator ) { $this->image_alt->clamp( $clamped, $applied ); } return array( 'definition' => $clamped, 'appliedFreeDefaults' => $applied ); } /** * The source fields this site's plan withholds from a run, per * generator, from the same lists and plan answers the clamps use, so * the editor locks exactly the fields a run leaves out. A list that * holds 'core:attributes' also withholds every `attr:*` field. * * @return array Generator key => withheld FieldRefs. */ public function lockedSourceRefs(): array { return array( Generators::TITLE => $this->title->lockedSourceRefs(), Generators::FAQ => $this->faq->lockedSourceRefs(), Generators::IMAGE_ALT => $this->image_alt->lockedSourceRefs(), Generators::TAXONOMY => $this->taxonomy->withheldTermRefs(), ); } /** * @see TaxonomyPolicy::taxonomyCustomPurposeAllowed() * @return bool */ public function taxonomyCustomPurposeAllowed(): bool { return $this->taxonomy->taxonomyCustomPurposeAllowed(); } /** * @see TaxonomyPolicy::taxonomyAllowedSources() * @return string[] */ public function taxonomyAllowedSources(): array { return $this->taxonomy->taxonomyAllowedSources(); } /** * @see TaxonomyPolicy::taxonomyMaxSamples() * @return int */ public function taxonomyMaxSamples(): int { return $this->taxonomy->taxonomyMaxSamples(); } /** * @see TaxonomyPolicy::taxonomyCommonAttributesAllowed() * @return bool */ public function taxonomyCommonAttributesAllowed(): bool { return $this->taxonomy->taxonomyCommonAttributesAllowed(); } /** * @see TaxonomyPolicy::taxonomyProductDescriptionsAllowed() * @return bool */ public function taxonomyProductDescriptionsAllowed(): bool { return $this->taxonomy->taxonomyProductDescriptionsAllowed(); } /** * @see BannedPhrasesPolicy::bannedPhrasesAllowed() * @return bool */ public function bannedPhrasesAllowed(): bool { return $this->banned_phrases->bannedPhrasesAllowed(); } /** * @see InstructionsPolicy::instructionsAllowed() * @param string $generator Generator key. * @return bool */ public function instructionsAllowed( string $generator ): bool { return $this->instructions->instructionsAllowed( $generator ); } /** * @see InstructionsPolicy::noteAllowed() * @param string $generator Generator key. * @return bool */ public function noteAllowed( string $generator ): bool { return $this->instructions->noteAllowed( $generator ); } /** * @see InstructionsPolicy::aiNoteFreeDefault() * @param string $generator Generator key whose note was withheld. * @return array{key:string,reason:string} */ public function aiNoteFreeDefault( string $generator ): array { $this->refuseInRenderMode( __METHOD__ ); return $this->instructions->aiNoteFreeDefault( $generator ); } /** * @see FaqPolicy::faqAdvancedModeAllowed() * @return bool */ public function faqAdvancedModeAllowed(): bool { return $this->faq->faqAdvancedModeAllowed(); } /** * @see FaqPolicy::faqAdvancedSourcesAllowed() * @return bool */ public function faqAdvancedSourcesAllowed(): bool { return $this->faq->faqAdvancedSourcesAllowed(); } /** * @see TitlePolicy::titleAdvancedSourcesAllowed() * @return bool */ public function titleAdvancedSourcesAllowed(): bool { return $this->title->titleAdvancedSourcesAllowed(); } /** * @see TitlePolicy::titleKeywordsAllowed() * @return bool */ public function titleKeywordsAllowed(): bool { return $this->title->titleKeywordsAllowed(); } /** * @see TitlePolicy::titleImproveExistingAllowed() * @return bool */ public function titleImproveExistingAllowed(): bool { return $this->title->titleImproveExistingAllowed(); } /** * @see TitlePolicy::titleImproveExistingFreeDefault() * @return array{key:string,reason:string} */ public function titleImproveExistingFreeDefault(): array { $this->refuseInRenderMode( __METHOD__ ); return $this->title->titleImproveExistingFreeDefault(); } /** * @see SeoMetaPolicy::seoMetaLengthCeilings() * @return array{title:int,description:int} */ public function seoMetaLengthCeilings(): array { return $this->seo_meta->seoMetaLengthCeilings(); } /** * @see SeoMetaPolicy::seoMetaKeywordAiAllowed() * @return bool */ public function seoMetaKeywordAiAllowed(): bool { return $this->seo_meta->seoMetaKeywordAiAllowed(); } /** * @see SeoMetaPolicy::seoMetaMaxVariants() * @return int */ public function seoMetaMaxVariants(): int { return $this->seo_meta->seoMetaMaxVariants(); } /** * @see SeoMetaPolicy::seoMetaVariantsFreeDefault() * @return array{key:string,reason:string} */ public function seoMetaVariantsFreeDefault(): array { $this->refuseInRenderMode( __METHOD__ ); return $this->seo_meta->seoMetaVariantsFreeDefault(); } /** * @see ImageAltPolicy::imageAltGalleryAllowed() * @return bool */ public function imageAltGalleryAllowed(): bool { return $this->image_alt->imageAltGalleryAllowed(); } /** * @see ImageAltPolicy::imageAltAttributesAllowed() * @return bool */ public function imageAltAttributesAllowed(): bool { return $this->image_alt->imageAltAttributesAllowed(); } /** * @see ImageAltPolicy::imageAltGalleryFreeDefault() * @return array{key:string,reason:string} */ public function imageAltGalleryFreeDefault(): array { $this->refuseInRenderMode( __METHOD__ ); return $this->image_alt->imageAltGalleryFreeDefault(); } /** * @see VoicePolicy::voiceSamplesAllowed() * @return bool */ public function voiceSamplesAllowed(): bool { return $this->voice->voiceSamplesAllowed(); } /** * @see VoicePolicy::clampBrandProfile() * @param array|null $profile BrandProfileData, or null. * @return array{profile:array|null,dropped:bool} */ public function clampBrandProfile( ?array $profile ): array { $this->refuseInRenderMode( __METHOD__ ); return $this->voice->clampBrandProfile( $profile ); } /** * @see VoicePolicy::voiceSamplesFreeDefault() * @return array{key:string,reason:string} */ public function voiceSamplesFreeDefault(): array { $this->refuseInRenderMode( __METHOD__ ); return $this->voice->voiceSamplesFreeDefault(); } /** * @see VoicePolicy::voiceLimit() * @return int Most voices this plan may hold; non-positive means no cap. */ public function voiceLimit(): int { return $this->voice->voiceLimit(); } /** * @see ExtraSlotsPolicy::extraSlotsAllowed() * @return bool */ public function extraSlotsAllowed(): bool { return $this->extra_slots->extraSlotsAllowed(); } /** * @see ExtraSlotsPolicy::extraSlotsFreeDefault() * @return array{key:string,reason:string} */ public function extraSlotsFreeDefault(): array { $this->refuseInRenderMode( __METHOD__ ); return $this->extra_slots->extraSlotsFreeDefault(); } /** * @see SourcesPolicy::webPageSourcesAllowed() * @return bool */ public function webSourcesAllowed(): bool { return $this->sources->webPageSourcesAllowed(); } /** * @see StoreSectionsPolicy::storeSectionsAllowed() * @return bool */ public function storeSectionsAllowed(): bool { return $this->store_sections->storeSectionsAllowed(); } }