snicco/better-wp-hooks-bundle

v2.0.0-beta.9 2024-09-07 14:27 UTC

README

codecov Psalm Type-Coverage Psalm level PhpMetrics - Static Analysis PHP-Versions

This WordPress bundle configures the standalone snicco/better-wp-hooks library for usage in applications based on snicco/kernel.

Installation

composer install snicco/better-wp-hooks-bundle

Configuration

This bundle currently has no configuration options.

Usage

Add the BetterWPHooksBundle to your bundles.php configuration file.

<?php
// /path/to/configuration/bundles.php

use Snicco\Bundle\BetterWPHooks\BetterWPHooksBundle;
use Snicco\Component\Kernel\ValueObject\Environment;

return [
    
    'bundles' => [
        Environment::ALL => [
            BetterWPHooksBundle::class
        ]   
    ]   
];

You can now lazily resolve the following services after booting the kernel:

use Psr\EventDispatcher\EventDispatcherInterface;
use Snicco\Component\BetterWPHooks\EventMapping\EventMapper;
use Snicco\Component\EventDispatcher\EventDispatcher;


/**
* @var Kernel $kernel
*/
$kernel->boot();

$event_dispatcher = $kernel->container()->make(EventDispatcher::class);

$psr_event_dispatcher = $kernel->container()->make(EventDispatcherInterface::class);

var_dump($event_dispatcher === $psr_event_dispatcher); // true

$event_mapper = $kernel->container()->make(EventMapper::class);

If the snicco/event-dispatcher-testing package is installed a TestableEventDispatcher will automatically be used in the testing environment.

Contributing

This repository is a read-only split of the development repo of the Snicco project.

This is how you can contribute.

Reporting issues and sending pull requests

Please report issues in the Snicco monorepo.

Security

If you discover a security vulnerability within BetterWPCache, please follow our disclosure procedure.