mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 07:33:50 +00:00
create contextmanager and refactor docgeneratorTemplateType
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocGeneratorBundle\Context;
|
||||
|
||||
class ContextManager
|
||||
{
|
||||
private iterable $contexts;
|
||||
|
||||
/**
|
||||
* @param iterable $contexts
|
||||
*/
|
||||
public function __construct(iterable $contexts)
|
||||
{
|
||||
$this->contexts = $contexts;
|
||||
}
|
||||
|
||||
public function getContext(): array
|
||||
{
|
||||
return iterator_to_array($this->contexts);
|
||||
}
|
||||
}
|
@@ -16,6 +16,11 @@ namespace Chill\DocGeneratorBundle\Context;
|
||||
*/
|
||||
interface DocGeneratorContextInterface
|
||||
{
|
||||
|
||||
public static function getKey(): string;
|
||||
|
||||
public function getName(): string;
|
||||
|
||||
/**
|
||||
* Get the data that will be injected to the generated document.
|
||||
*
|
||||
|
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocGeneratorBundle\Context\Exception;
|
||||
|
||||
class UnexpectedTypeException extends \LogicException
|
||||
{
|
||||
public function __construct($value, string $expectedType)
|
||||
{
|
||||
parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, \is_object($value) ? \get_class($value) : \gettype($value)));
|
||||
}
|
||||
}
|
@@ -23,6 +23,16 @@ use function get_class;
|
||||
*/
|
||||
class HouseholdMemberSelectionContext implements DocGeneratorContextInterface
|
||||
{
|
||||
public function getName(): string
|
||||
{
|
||||
return 'household member';
|
||||
}
|
||||
|
||||
public static function getKey(): string
|
||||
{
|
||||
return self::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data that will be injected to the generated document.
|
||||
*
|
||||
|
Reference in New Issue
Block a user