upskill-event-manager/wordpress-dev/vendor/brain/monkey/src/Container.php
bengizmo cdef12ee80 feat(events): Implement fallback logic and UI for Create/Modify Event page
- Refactored fallback submission logic in `class-event-handler.php` to remove `wp_die`/`exit` calls and use redirects for error handling, enabling proper unit testing.
- Implemented meta-data saving (dates, venue, organizer) in the fallback logic using `update_post_meta`.
- Updated unit tests (`test-event-management.php`) to remove `markTestIncomplete` calls related to handler errors and uncommented meta assertions. Unit tests for fallback logic now pass.
- Added Instructions section and Return to Dashboard button to the event form shortcode (`display_event_form_shortcode`).
- Applied basic theme styling classes (`ast-container`, `notice`, `ast-button`) to the event form.
- Updated `docs/implementation_plan.md` to reflect completion of tasks 4.1-4.5 and set focus to Task 5.

Refs: Task 4.1, 4.2, 4.3, 4.4, 4.5
2025-04-01 11:46:24 -03:00

113 lines
2.5 KiB
PHP

<?php # -*- coding: utf-8 -*-
/*
* This file is part of the BrainMonkey package.
*
* (c) Giuseppe Mazzapica
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Brain\Monkey;
/**
* @author Giuseppe Mazzapica <giuseppe.mazzapica@gmail.com>
* @package BrainMonkey
* @license http://opensource.org/licenses/MIT MIT
*/
final class Container
{
/**
* @var Container|null
*/
private static $instance;
/**
* @var array
*/
private $services = [];
/**
* Static instance lookup.
*
* @return Container
*/
public static function instance()
{
if ( ! self::$instance) {
require_once dirname(__DIR__).'/inc/patchwork-loader.php';
self::$instance = new static();
}
return self::$instance;
}
/**
* @return \Brain\Monkey\Expectation\ExpectationFactory
*/
public function expectationFactory()
{
return $this->service(__FUNCTION__, new Expectation\ExpectationFactory());
}
/**
* @return \Brain\Monkey\Hook\HookRunningStack
*/
public function hookRunningStack()
{
return $this->service(__FUNCTION__, new Hook\HookRunningStack());
}
/**
* @return \Brain\Monkey\Hook\HookStorage
*/
public function hookStorage()
{
return $this->service(__FUNCTION__, new Hook\HookStorage());
}
/**
* @return \Brain\Monkey\Hook\HookExpectationExecutor
*/
public function hookExpectationExecutor()
{
return $this->service(__FUNCTION__, new Hook\HookExpectationExecutor(
$this->hookRunningStack(),
$this->expectationFactory()
));
}
/**
* @return \Brain\Monkey\Expectation\FunctionStubFactory
*/
public function functionStubFactory()
{
return $this->service(__FUNCTION__, new Expectation\FunctionStubFactory());
}
/**
* @return void
*/
public function reset()
{
$this->expectationFactory()->reset();
$this->hookRunningStack()->reset();
$this->hookStorage()->reset();
$this->functionStubFactory()->reset();
}
/**
* @param string $id
* @param mixed $service
* @return mixed
*/
private function service($id, $service)
{
if ( ! array_key_exists($id, $this->services)) {
$this->services[$id] = $service;
}
return $this->services[$id];
}
}