<?php

/**
 * @package         Tassos Code Snippets
 * @version         1.0.1-RC2 Free
 *
 * @author          Tassos Marinos <info@tassos.gr>
 * @link            https://www.tassos.gr
 * @copyright       Copyright © 2026 Tassos Marinos All Rights Reserved
 * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
 */

namespace Tassos\CodeSnippets\Administrator\Location;

defined('_JEXEC') or die;

/**
 * Site Body Location
 * 
 * Injects snippets right after the opening <body> tag
 * on frontend pages via buffer manipulation.
 */
class SiteBody extends AbstractLocation
{
    /**
     * Get the Joomla event for injection
     *
     * @return string
     */
    public function getEvent(): ?string
    {
        return 'onAfterRender';
    }

    /**
     * Check if this location can run
     *
     * @return bool
     */
    public function canRun(): bool
    {
        return $this->isSite() && $this->isHtmlDocument();
    }

    /**
     * Inject snippets after <body> tag
     *
     * @return void
     */
    public function inject(): void
    {
        $content = $this->getBufferContent();
        $this->injectAfterBodyTag($content);
    }
}
