mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 21:13:57 +00:00
adapting classes to new interfaces
This commit is contained in:
@@ -23,6 +23,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -86,9 +87,28 @@ class ReasonAggregator implements AggregatorInterface
|
||||
return "Aggregate by activity reason";
|
||||
}
|
||||
|
||||
public function requiredRole()
|
||||
public function addRole()
|
||||
{
|
||||
return new Role('dummy');
|
||||
return new Role(ActivityVoter::SEE);
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return array_combine($values, $values);
|
||||
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
// add select element
|
||||
if ($data['level'] === 'reason') {
|
||||
return array('activity_reason_id');
|
||||
} elseif ($data['level'] === 'category') {
|
||||
return array ('activity_category_id');
|
||||
} else {
|
||||
throw new \RuntimeException('the data provided are not recognised');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -20,9 +20,10 @@
|
||||
namespace Chill\ActivityBundle\Export\Export;
|
||||
|
||||
use Chill\MainBundle\Export\ExportInterface;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Doctrine\ORM\Query;
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -77,7 +78,34 @@ class CountActivity implements ExportInterface
|
||||
|
||||
public function requiredRole()
|
||||
{
|
||||
return new Role('dummy');
|
||||
return new Role(ActivityStatsVoter::STATS);
|
||||
}
|
||||
|
||||
public function getAllowedFormattersTypes()
|
||||
{
|
||||
return array(\Chill\MainBundle\Export\FormatterInterface::TYPE_TABULAR);
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
if ($key !== 'export_count_activity') {
|
||||
throw new \LogicException("the key $key is not used by this export");
|
||||
}
|
||||
|
||||
$labels = array_combine($values, $values);
|
||||
$labels['_header'] = 'Number of activities';
|
||||
|
||||
return $labels;
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
return array('export_count_activity');
|
||||
}
|
||||
|
||||
public function getResult(QueryBuilder $qb, $data)
|
||||
{
|
||||
return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ use Chill\ActivityBundle\Entity\ActivityReason;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Doctrine\ORM\Query\Expr;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -90,8 +91,8 @@ class ActivityReasonFilter implements FilterInterface
|
||||
return 'Filter by reason';
|
||||
}
|
||||
|
||||
public function requiredRole()
|
||||
public function addRole()
|
||||
{
|
||||
return new Role('dummy');
|
||||
return new Role(ActivityVoter::SEE);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user