mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 22:04:23 +00:00
generate context for evaluations
This commit is contained in:
parent
29134f0f11
commit
6c1a946608
@ -29,4 +29,6 @@ interface DocGeneratorContextWithPublicFormInterface extends DocGeneratorContext
|
|||||||
* @param mixed $entity
|
* @param mixed $entity
|
||||||
*/
|
*/
|
||||||
public function hasPublicForm(DocGeneratorTemplate $template, $entity): bool;
|
public function hasPublicForm(DocGeneratorTemplate $template, $entity): bool;
|
||||||
|
|
||||||
|
public function getFormData(DocGeneratorTemplate $template, $entity): array;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ final class DocGeneratorTemplateController extends AbstractController
|
|||||||
|
|
||||||
if ($context instanceof DocGeneratorContextWithPublicFormInterface
|
if ($context instanceof DocGeneratorContextWithPublicFormInterface
|
||||||
&& $context->hasPublicForm($template, $entity)) {
|
&& $context->hasPublicForm($template, $entity)) {
|
||||||
$builder = $this->createFormBuilder();
|
$builder = $this->createFormBuilder($context->getFormData($template, $entity));
|
||||||
$context->buildPublicForm($builder, $template, $entity);
|
$context->buildPublicForm($builder, $template, $entity);
|
||||||
$form = $builder->getForm()->handleRequest($request);
|
$form = $builder->getForm()->handleRequest($request);
|
||||||
|
|
||||||
|
@ -99,6 +99,24 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
|||||||
}
|
}
|
||||||
|
|
||||||
$type = $reflection->getProperty($attribute->getName())->getType();
|
$type = $reflection->getProperty($attribute->getName())->getType();
|
||||||
|
} elseif ($reflection->hasMethod($method = 'get'.ucfirst($attribute->getName()))) {
|
||||||
|
if (!$reflection->getMethod($method)->hasReturnType()) {
|
||||||
|
throw new \LogicException(sprintf(
|
||||||
|
'Could not determine how the content is determined for the attribute %s. Add a return type on the method',
|
||||||
|
$attribute->getName()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = $reflection->getMethod($method)->getReturnType();
|
||||||
|
} elseif ($reflection->hasMethod($method = 'is'.ucfirst($attribute->getName()))) {
|
||||||
|
if (!$reflection->getMethod($method)->hasReturnType()) {
|
||||||
|
throw new \LogicException(sprintf(
|
||||||
|
'Could not determine how the content is determined for the attribute %s. Add a return type on the method',
|
||||||
|
$attribute->getName()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = $reflection->getMethod($method)->getReturnType();
|
||||||
} elseif ($reflection->hasMethod($attribute->getName())) {
|
} elseif ($reflection->hasMethod($attribute->getName())) {
|
||||||
if (!$reflection->getMethod($attribute->getName())->hasReturnType()) {
|
if (!$reflection->getMethod($attribute->getName())->hasReturnType()) {
|
||||||
throw new \LogicException(sprintf(
|
throw new \LogicException(sprintf(
|
||||||
@ -149,11 +167,13 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
|||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'array':
|
case 'array':
|
||||||
|
return [];
|
||||||
case 'bool':
|
case 'bool':
|
||||||
case 'double':
|
case 'double':
|
||||||
case 'float':
|
case 'float':
|
||||||
case 'int':
|
case 'int':
|
||||||
case 'resource':
|
case 'resource':
|
||||||
|
return null;
|
||||||
case 'string':
|
case 'string':
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
@ -197,7 +217,7 @@ class DocGenObjectNormalizer implements NormalizerAwareInterface, NormalizerInte
|
|||||||
} elseif (null === $value) {
|
} elseif (null === $value) {
|
||||||
$data[$key] = $this->normalizeNullOutputValue($format, $context, $attribute, $reflection);
|
$data[$key] = $this->normalizeNullOutputValue($format, $context, $attribute, $reflection);
|
||||||
} else {
|
} else {
|
||||||
$data[$key] = (string) $value;
|
$data[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,11 +249,11 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
|
|||||||
*/
|
*/
|
||||||
public function getWarningDate(): ?DateTimeImmutable
|
public function getWarningDate(): ?DateTimeImmutable
|
||||||
{
|
{
|
||||||
if (null === $this->getWarningDate() || null === $this->getWarningInterval()) {
|
if (null === $this->getEndDate() || null === $this->getWarningInterval()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getWarningDate()->sub($this->getWarningInterval());
|
return $this->getEndDate()->sub($this->getWarningInterval());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeDocument(AccompanyingPeriodWorkEvaluationDocument $document): self
|
public function removeDocument(AccompanyingPeriodWorkEvaluationDocument $document): self
|
||||||
|
@ -34,7 +34,6 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|||||||
use function array_key_exists;
|
use function array_key_exists;
|
||||||
|
|
||||||
class AccompanyingPeriodContext implements
|
class AccompanyingPeriodContext implements
|
||||||
DocGeneratorContextInterface,
|
|
||||||
DocGeneratorContextWithAdminFormInterface,
|
DocGeneratorContextWithAdminFormInterface,
|
||||||
DocGeneratorContextWithPublicFormInterface
|
DocGeneratorContextWithPublicFormInterface
|
||||||
{
|
{
|
||||||
@ -173,6 +172,13 @@ class AccompanyingPeriodContext implements
|
|||||||
return AccompanyingPeriod::class;
|
return AccompanyingPeriod::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFormData(DocGeneratorTemplate $template, $entity): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'course' => $entity
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public static function getKey(): string
|
public static function getKey(): string
|
||||||
{
|
{
|
||||||
return self::class;
|
return self::class;
|
||||||
|
@ -53,9 +53,12 @@ class AccompanyingPeriodWorkContext implements
|
|||||||
$this->periodContext->buildAdminForm($builder);
|
$this->periodContext->buildAdminForm($builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AccompanyingPeriodWork $entity
|
||||||
|
*/
|
||||||
public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void
|
public function buildPublicForm(FormBuilderInterface $builder, DocGeneratorTemplate $template, $entity): void
|
||||||
{
|
{
|
||||||
$this->periodContext->buildPublicForm($builder, $template, $entity);
|
$this->periodContext->buildPublicForm($builder, $template, $entity->getAccompanyingPeriod());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,6 +85,14 @@ class AccompanyingPeriodWorkContext implements
|
|||||||
return AccompanyingPeriodWork::class;
|
return AccompanyingPeriodWork::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AccompanyingPeriodWork $entity
|
||||||
|
*/
|
||||||
|
public function getFormData(DocGeneratorTemplate $template, $entity): array
|
||||||
|
{
|
||||||
|
return $this->periodContext->getFormData($template, $entity->getAccompanyingPeriod());
|
||||||
|
}
|
||||||
|
|
||||||
public static function getKey(): string
|
public static function getKey(): string
|
||||||
{
|
{
|
||||||
return 'accompanying_period_work_regular';
|
return 'accompanying_period_work_regular';
|
||||||
|
@ -136,6 +136,15 @@ class AccompanyingPeriodWorkEvaluationContext implements
|
|||||||
return AccompanyingPeriodWorkEvaluation::class;
|
return AccompanyingPeriodWorkEvaluation::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AccompanyingPeriodWorkEvaluation $entity
|
||||||
|
*/
|
||||||
|
public function getFormData(DocGeneratorTemplate $template, $entity): array
|
||||||
|
{
|
||||||
|
return $this->accompanyingPeriodWorkContext->getFormData($template,
|
||||||
|
$entity->getAccompanyingPeriodWork());
|
||||||
|
}
|
||||||
|
|
||||||
public static function getKey(): string
|
public static function getKey(): string
|
||||||
{
|
{
|
||||||
return 'accompanying_period_work_evaluation_regular';
|
return 'accompanying_period_work_evaluation_regular';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user