/**
  * Searches entities associated with the specified type of activity.
  *
  * @param string $activity The type of the activity entity.
  *
  * @Get("/activities/{activity}/relations/search", name="")
  *
  * @QueryParam(
  *      name="page",
  *      requirements="\d+",
  *      nullable=true,
  *      description="Page number, starting from 1. Defaults to 1."
  * )
  * @QueryParam(
  *      name="limit",
  *      requirements="\d+",
  *      nullable=true,
  *      description="Number of items per page. Defaults to 10."
  * )
  * @QueryParam(
  *     name="search",
  *     requirements=".+",
  *     nullable=true,
  *     description="The search string."
  * )
  * @QueryParam(
  *      name="from",
  *      requirements=".+",
  *      nullable=true,
  *      description="The entity alias. One or several aliases separated by comma. Defaults to all entities"
  * )
  *
  * @ApiDoc(
  *      description="Searches entities associated with the specified type of activity",
  *      resource=true
  * )
  *
  * @return Response
  */
 public function cgetAction($activity)
 {
     $manager = $this->getManager();
     $manager->setClass($manager->resolveEntityClass($activity, true));
     $page = (int) $this->getRequest()->get('page', 1);
     $limit = (int) $this->getRequest()->get('limit', self::ITEMS_PER_PAGE);
     $filters = ['search' => $this->getRequest()->get('search')];
     $from = $this->getRequest()->get('from', null);
     if ($from) {
         $filter = new ChainParameterFilter([new StringToArrayParameterFilter(), new EntityClassParameterFilter($this->get('oro_entity.entity_class_name_helper'))]);
         $filters['from'] = $filter->filter($from, null);
     }
     return $this->handleGetListRequest($page, $limit, $filters);
 }
 /**
  * Searches entities associated with the email activity.
  *
  * @Get("/activities/emails/relations/search", name="")
  *
  * @QueryParam(
  *      name="page",
  *      requirements="\d+",
  *      nullable=true,
  *      description="Page number, starting from 1. Defaults to 1."
  * )
  * @QueryParam(
  *      name="limit",
  *      requirements="\d+",
  *      nullable=true,
  *      description="Number of items per page. Defaults to 10."
  * )
  * @QueryParam(
  *     name="search",
  *     requirements=".+",
  *     nullable=true,
  *     description="The search string."
  * )
  * @QueryParam(
  *      name="from",
  *      requirements=".+",
  *      nullable=true,
  *      description="The entity alias. One or several aliases separated by comma. Defaults to all entities."
  * )
  * @QueryParam(
  *      name="email",
  *      requirements=".+",
  *      nullable=true,
  *      description="An email address. One or several addresses separated by comma."
  * )
  *
  * @ApiDoc(
  *      description="Searches entities associated with the email activity.",
  *      resource=true
  * )
  *
  * @return Response
  */
 public function cgetAction()
 {
     $page = (int) $this->getRequest()->get('page', 1);
     $limit = (int) $this->getRequest()->get('limit', self::ITEMS_PER_PAGE);
     $filters = ['search' => $this->getRequest()->get('search')];
     $from = $this->getRequest()->get('from', null);
     if ($from) {
         $filter = new ChainParameterFilter([new StringToArrayParameterFilter(), new EntityClassParameterFilter($this->get('oro_entity.entity_class_name_helper'))]);
         $filters['from'] = $filter->filter($from, null);
     }
     $email = $this->getRequest()->get('email', null);
     if ($email) {
         $filter = new ChainParameterFilter([new StringToArrayParameterFilter(), new EmailAddressParameterFilter($this->container->get('oro_email.email.address.helper'))]);
         $filters['emails'] = $filter->filter($email, null);
     }
     $data = $this->getManager()->getSearchResult($limit, $page, $filters);
     return $this->buildResponse($data['result'], self::ACTION_LIST, $data);
 }