/**
  * @param string $relatedEntityClass
  * @param mixed $relatedEntityId
  *
  * @return QueryBuilder
  */
 protected function createActivityListQb($relatedEntityClass, $relatedEntityId)
 {
     $activityListQb = $this->getActivityListRepository()->getBaseActivityListQueryBuilder($relatedEntityClass, $relatedEntityId);
     $activityListQb->andWhere('activity.relatedActivityId = e.id')->andWhere('activity.relatedActivityClass = :related_activity_class');
     $this->activityListAclHelper->applyAclCriteria($activityListQb, $this->activityListProvider->getProviders());
     return $activityListQb;
 }
Esempio n. 2
0
 /**
  * @param string $entityClass
  * @param int $entityId
  * @param array $filter
  *
  * @return QueryBuilder
  */
 protected function prepareQB($entityClass, $entityId, $filter)
 {
     $qb = $this->getBaseQB($entityClass, $entityId);
     $this->activityInheritanceTargetsHelper->applyInheritanceActivity($qb, $entityClass, $entityId);
     if ($this->config->get('oro_activity_list.grouping')) {
         $qb->andWhere($qb->expr()->andX('activity.head = true'));
     }
     $this->activityListFilterHelper->addFiltersToQuery($qb, $filter);
     $this->activityListAclHelper->applyAclCriteria($qb, $this->chainProvider->getProviders());
     return $qb;
 }
 /**
  * @param string  $entityClass
  * @param integer $entityId
  * @param array   $filter
  *
  * @return ActivityList[]
  */
 public function getListCount($entityClass, $entityId, $filter)
 {
     $qb = $this->getBaseQB($entityClass, $entityId);
     $this->activityListFilterHelper->addFiltersToQuery($qb, $filter);
     $this->activityListAclHelper->applyAclCriteria($qb, $this->chainProvider->getProviders());
     $qb->resetDQLPart('orderBy');
     $query = $qb->getQuery();
     $parserResult = QueryUtils::parseQuery($query);
     $parameterMappings = $parserResult->getParameterMappings();
     list($params, $types) = QueryUtils::processParameterMappings($query, $parameterMappings);
     $statement = $query->getEntityManager()->getConnection()->executeQuery('SELECT COUNT(*) FROM (' . $query->getSQL() . ') AS e', $params, $types);
     $result = $statement->fetchColumn();
     return $result;
 }