mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 17:28:23 +00:00 
			
		
		
		
	Handle DateTime type for activity while DateTimeImmutable is expected
This commit is contained in:
		| @@ -274,7 +274,7 @@ class User implements UserInterface, \Stringable | ||||
|         return $this->mainLocation; | ||||
|     } | ||||
|  | ||||
|     public function getMainScope(\DateTime $atDate = null): ?Scope | ||||
|     public function getMainScope(\DateTimeImmutable $atDate = null): ?Scope | ||||
|     { | ||||
|         $atDate ??= new \DateTimeImmutable('now'); | ||||
|  | ||||
| @@ -326,7 +326,7 @@ class User implements UserInterface, \Stringable | ||||
|         return $this->salt; | ||||
|     } | ||||
|  | ||||
|     public function getUserJob(\DateTime $atDate = null): ?UserJob | ||||
|     public function getUserJob(\DateTimeImmutable $atDate = null): ?UserJob | ||||
|     { | ||||
|         $atDate ??= new \DateTimeImmutable('now'); | ||||
|  | ||||
|   | ||||
| @@ -13,6 +13,7 @@ namespace Chill\MainBundle\Templating\Entity; | ||||
|  | ||||
| use Chill\MainBundle\Entity\User; | ||||
| use Chill\MainBundle\Templating\TranslatableStringHelper; | ||||
| use Monolog\DateTimeImmutable; | ||||
| use Symfony\Contracts\Translation\TranslatorInterface; | ||||
|  | ||||
| /** | ||||
| @@ -35,6 +36,8 @@ class UserRender implements ChillEntityRenderInterface | ||||
|     { | ||||
|         $opts = \array_merge(self::DEFAULT_OPTIONS, $options); | ||||
|  | ||||
|         $opts['at_date'] = $opts['at_date'] instanceOf \DateTime ? DateTimeImmutable::createFromMutable($opts['at_date']) : $opts['at_date']; | ||||
|  | ||||
|         return $this->engine->render('@ChillMain/Entity/user.html.twig', [ | ||||
|             'user' => $entity, | ||||
|             'opts' => $opts, | ||||
| @@ -45,16 +48,18 @@ class UserRender implements ChillEntityRenderInterface | ||||
|     { | ||||
|         $opts = \array_merge(self::DEFAULT_OPTIONS, $options); | ||||
|  | ||||
|         $immutableAtDate = $opts['at_date'] instanceOf \DateTime ? DateTimeImmutable::createFromMutable($opts['at_date']) : $opts['at_date']; | ||||
|  | ||||
|         $str = $entity->getLabel(); | ||||
|  | ||||
|         if (null !== $entity->getUserJob($opts['at_date']) && $opts['user_job']) { | ||||
|         if (null !== $entity->getUserJob($immutableAtDate) && $opts['user_job']) { | ||||
|             $str .= ' ('.$this->translatableStringHelper | ||||
|                 ->localize($entity->getUserJob($opts['at_date'])->getLabel()).')'; | ||||
|                 ->localize($entity->getUserJob($immutableAtDate)->getLabel()).')'; | ||||
|         } | ||||
|  | ||||
|         if (null !== $entity->getMainScope($opts['at_date']) && $opts['main_scope']) { | ||||
|         if (null !== $entity->getMainScope($immutableAtDate) && $opts['main_scope']) { | ||||
|             $str .= ' ('.$this->translatableStringHelper | ||||
|                 ->localize($entity->getMainScope($opts['at_date'])->getName()).')'; | ||||
|                 ->localize($entity->getMainScope($immutableAtDate)->getName()).')'; | ||||
|         } | ||||
|  | ||||
|         if ($entity->isAbsent() && $opts['absence']) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user