In your controller you need to fetch your configuration options and pass it to your view as well as your data.
public function tableAction() {
$dangerousThreshold = $this->container->getParameter('dangerous_threshold');
$veryDangerousThreshold = $this->container->getParameter('very_dangerous_threshold');
// If required transform your threshold in a comparable value, eg. a date.
$data = $this->container->get('your_repository')->findAll();
return $this->render(
'YourBundle:Dashboard:table.html.twig',
array(
'data' => $data,
'dangerous_threshold' => $dangerousThreshold,
'very_dangerous_threshold' => $veryDangerousThreshold,
)
);
}
And in the view, compare the $data
date to both dangerous & very dangerous threshold and assign a css class which will allow you to set any style you want.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…