# hostinger/3.0.49/includes/Mcp/EventHandlerFactory.php

Hostinger Tools, version 3.0.49. 39 lines.

- Page: https://pluginprobe.com/plugins/hostinger/3.0.49/code/includes/Mcp/EventHandlerFactory.php
- Raw: https://pluginprobe.com/plugins/hostinger/3.0.49/raw/includes/Mcp/EventHandlerFactory.php
- Modified: 2025-07-22T10:37:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/hostinger/3.0.49/code/includes/Mcp/EventHandlerFactory.php#L10-L20`.

```php
<?php

namespace Hostinger\Mcp;

use Hostinger\Admin\Proxy;
use Hostinger\Mcp\Handlers\WebsiteMcpOptInToggled;
use Hostinger\Mcp\Handlers\WebsitePageUpdated;
use Hostinger\Mcp\Handlers\WebsiteUpdated;

defined( 'ABSPATH' ) || exit;

class EventHandlerFactory {

    public const MCP_EVENT_UPDATED       = 'wordpress.website.updated';
    public const MCP_EVENT_PAGE_UPDATED  = 'wordpress.website.page_updated';
    public const MCP_EVENT_OPTIN_TOGGLED = 'wordpress.website.mcp.opt_in_toggled';

    private array $handlers;
    private Proxy $proxy;

    public function __construct( Proxy $proxy ) {
        $this->proxy    = $proxy;
        $this->handlers = array(
            self::MCP_EVENT_UPDATED       => WebsiteUpdated::class,
            self::MCP_EVENT_PAGE_UPDATED  => WebsitePageUpdated::class,
            self::MCP_EVENT_OPTIN_TOGGLED => WebsiteMcpOptInToggled::class,
        );
    }

    public function get_handler( string $event ) {
        $handler = $this->handlers[ $event ] ?? false;
        if ( ! $handler ) {
            throw new \WP_Exception( 'Invalid event' );
        }

        return new $handler( $this->proxy );
    }
}

```
