public function testHasActivityAssociationForNonConfigurableEntity() { $activityEntityClass = 'Test\\Activity'; $targetEntityClass = 'Test\\Entity'; $this->activityConfigProvider->expects($this->once())->method('hasConfig')->with($targetEntityClass)->will($this->returnValue(false)); $this->assertFalse($this->manager->hasActivityAssociation($targetEntityClass, $activityEntityClass)); }
/** * @param EntityManager $em * @param object $target * @param integer $skipId * @param string $direction * * @return Call */ protected function getLastActivity(EntityManager $em, $target, $skipId, $direction = null) { if (!$this->activityManager->hasActivityAssociation(ClassUtils::getClass($target), $this->getSupportedClass())) { return null; } $qb = $em->getRepository('OroCRM\\Bundle\\CallBundle\\Entity\\Call')->createQueryBuilder('call')->select('call')->innerJoin(sprintf('call.%s', ExtendHelper::buildAssociationName(ClassUtils::getClass($target), ActivityScope::ASSOCIATION_KIND)), 'target')->andWhere('target = :target')->orderBy('call.callDateTime', 'DESC')->setMaxResults(1)->setParameter('target', $target->getId()); if ($skipId) { $qb->andWhere('call.id <> :skipId')->setParameter('skipId', $skipId); } if ($direction) { $qb->join('call.direction', 'direction')->andWhere('direction.name = :direction')->setParameter('direction', $direction); } return $qb->getQuery()->getOneOrNullResult(); }
/** * Check if call log action is applicable to entity as activity * * @param object|null $entity * @return bool */ public function isApplicable($entity = null) { return is_object($entity) && $this->call->supportActivityTarget(ClassUtils::getClass($entity)) && $this->activityManager->hasActivityAssociation(ClassUtils::getClass($entity), ClassUtils::getClass($this->call)); }