<?php

namespace Miruni\PageInfo;

use Miruni\Miruni_Post_ID_Placeholder;

class BreakdancePageInfo extends Miruni_Page_Info_Base
{
    /**
     * Get page information for Breakdance pages
     *
     * @return array{
     *  content: string|null,
     *  theme_mods: \stdClass,
     *  related_templates: array<int, mixed>,
     *  breakdance_data: mixed,
     *  is_home_page: bool,
     *  is_latest_posts: bool,
     *  options: array<string, mixed>
     * }|null Page information or null if no valid post
     */
    public function get_page_info(): ?array
    {
        // Check for either a regular post ID or the latest posts placeholder
        if (
            (!$this->post_id) ||
            !$this->post_title
        ) {
            return null;
        }

        $base_info = $this->get_base_page_info();

        // Include Breakdance-specific data
        $breakdance_data = null;

        // Only try to get Breakdance data for actual posts, not our placeholder
        if ($this->post_id !== Miruni_Post_ID_Placeholder::LATEST_POSTS) {
            // Assuming Breakdance data is stored in post meta with the key '_breakdance_data'
            $breakdance_data = get_post_meta($this->post_id, '_breakdance_data', true);
        }

        // Merge base info with Breakdance-specific context
        return array_merge(
            $base_info,
            [
                'breakdance_data' => $breakdance_data
            ]
        );
    }
}