Weekly reporting view (#1892)

This commit is contained in:
Kevin Papst
2020-08-16 12:20:33 +02:00
committed by GitHub
parent 2449a1e8bf
commit 2d4cfbe821
39 changed files with 1130 additions and 248 deletions

View File

@@ -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