Weekly reporting view (#1892)
This commit is contained in:
@@ -10,6 +10,10 @@
|
||||
namespace App\Twig;
|
||||
|
||||
use App\Constants;
|
||||
use App\Entity\Activity;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\EntityWithMetaFields;
|
||||
use App\Entity\Project;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
use Twig\TwigFunction;
|
||||
@@ -27,6 +31,7 @@ class Extensions extends AbstractExtension
|
||||
return [
|
||||
new TwigFilter('docu_link', [$this, 'documentationLink']),
|
||||
new TwigFilter('multiline_indent', [$this, 'multilineIndent']),
|
||||
new TwigFilter('color', [$this, 'color']),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -40,6 +45,34 @@ class Extensions extends AbstractExtension
|
||||
];
|
||||
}
|
||||
|
||||
public function color(EntityWithMetaFields $entity): ?string
|
||||
{
|
||||
if ($entity instanceof Activity) {
|
||||
if (!empty($entity->getColor())) {
|
||||
return $entity->getColor();
|
||||
}
|
||||
|
||||
if (null !== $entity->getProject()) {
|
||||
$entity = $entity->getProject();
|
||||
}
|
||||
}
|
||||
|
||||
if ($entity instanceof Project) {
|
||||
if (!empty($entity->getColor())) {
|
||||
return $entity->getColor();
|
||||
}
|
||||
$entity = $entity->getCustomer();
|
||||
}
|
||||
|
||||
if ($entity instanceof Customer) {
|
||||
if (!empty($entity->getColor())) {
|
||||
return $entity->getColor();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $object
|
||||
* @return null|string
|
||||
|
||||
Reference in New Issue
Block a user