Example #1
0
 /**
  * @param  Entity\Contact  $contact
  * @param  Entity\Facebook $facebook
  * @return bool
  */
 public function isContactInFacebook(Entity\Contact $contact, Entity\Facebook $facebook)
 {
     $resultSetMap = new ResultSetMapping();
     $resultSetMap->addEntityResult('Contact\\Entity\\Contact', 'c');
     /**
      * Don't map the contact_id because that will overwrite the existing contact object leaving an emtpy one
      */
     $resultSetMap->addFieldResult('c', 'email', 'email');
     $queryInString = sprintf("SELECT %s FROM %s WHERE %s", $facebook->getContactKey(), $facebook->getFromClause(), $facebook->getWhereClause());
     $query = $this->getEntityManager()->createNativeQuery(sprintf("SELECT email FROM contact WHERE contact_id = %s AND contact_id IN (%s) AND date_end IS NULL", $contact->getId(), $queryInString), $resultSetMap);
     return sizeof($query->getResult()) > 0;
 }
Example #2
0
 /**
  * Return Contact entities based on a query generated by the Facebook functionality
  *
  * @param Entity\Facebook $facebook
  *
  * @return Entity\Contact[]
  */
 public function findContactsInFacebook(Entity\Facebook $facebook)
 {
     $resultSetMap = new ResultSetMapping();
     $resultSetMap->addEntityResult('Contact\\Entity\\Contact', 'c');
     $resultSetMap->addFieldResult('c', 'contact_id', 'id');
     $resultSetMap->addFieldResult('c', 'email', 'email');
     $resultSetMap->addFieldResult('c', 'firstname', 'firstName');
     $resultSetMap->addFieldResult('c', 'middlename', 'middleName');
     $resultSetMap->addFieldResult('c', 'lastname', 'lastName');
     $resultSetMap->addFieldResult('c', 'position', 'position');
     $queryInString = sprintf("SELECT %s FROM %s WHERE %s", $facebook->getContactKey(), $facebook->getFromClause(), $facebook->getWhereClause());
     $orderBy = null;
     if (null !== $facebook->getOrderbyClause()) {
         $orderBy = sprintf(" ORDER BY %s", $facebook->getOrderbyClause());
     }
     $query = $this->getEntityManager()->createNativeQuery(sprintf("SELECT contact_id, email, firstname, middlename, lastname, position FROM contact WHERE contact_id IN (%s) AND date_end IS NULL %s ", $queryInString, $orderBy), $resultSetMap);
     return $query->getResult();
 }