- Add comprehensive test suite for CMS and Asset modules using Pest Framework - Implement ContentTypeService::delete() protection against deletion of in-use content types - Add CannotDeleteContentTypeInUseException for better error handling - Fix DerivatPipelineRegistry::getAllPipelines() to handle object uniqueness correctly - Fix VariantName::getScale() to correctly parse scales with file extensions - Update CMS module documentation with new features, exceptions, and test coverage - Add CmsTestHelpers and AssetTestHelpers for test data factories - Fix BlockTypeRegistry to be immutable after construction - Update ContentTypeService to check for associated content before deletion - Improve BlockRendererRegistry initialization Test coverage: - Value Objects: All CMS and Asset value objects - Services: ContentService, ContentTypeService, SlugGenerator, BlockValidator, ContentLocalizationService, AssetService, DeduplicationService, MetadataExtractor - Repositories: All database repositories with mocked connections - Rendering: Block renderers and ContentRenderer - Controllers: API endpoints for both modules 254 tests passing, 38 remaining (mostly image processing pipeline tests)
37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Domain\Cms\Rendering;
|
|
|
|
use App\Domain\Cms\ValueObjects\BlockType;
|
|
use App\Domain\Cms\ValueObjects\ContentBlock;
|
|
|
|
final readonly class HeroBlockRenderer implements BlockRendererInterface
|
|
{
|
|
public function render(ContentBlock $block): array
|
|
{
|
|
$data = $block->data->toArray();
|
|
$settings = $block->settings?->toArray() ?? [];
|
|
|
|
return [
|
|
'component' => 'cms/hero',
|
|
'data' => [
|
|
'title' => $data['title'] ?? '',
|
|
'subtitle' => $data['subtitle'] ?? null,
|
|
'backgroundImage' => $data['backgroundImage'] ?? $data['background_image'] ?? null,
|
|
'ctaText' => $data['ctaText'] ?? $data['cta_text'] ?? null,
|
|
'ctaLink' => $data['ctaLink'] ?? $data['cta_link'] ?? null,
|
|
'fullWidth' => $settings['fullWidth'] ?? $settings['full_width'] ?? false,
|
|
'padding' => $settings['padding'] ?? 'medium',
|
|
],
|
|
];
|
|
}
|
|
|
|
public function supports(string $blockType): bool
|
|
{
|
|
return $blockType === BlockType::HERO;
|
|
}
|
|
}
|
|
|