/**
  * @param string $entityClass
  * @return array
  */
 public function getContactInformationFieldsInfo($entityClass)
 {
     if (!$entityClass) {
         return array();
     }
     return $this->helper->getEntityContactInformationColumnsInfo($entityClass);
 }
 /**
  * @param AbstractQueryDesigner $abstractQueryDesigner
  * @param object $entity
  * @param string $type
  *
  * @return string[]
  */
 public function getQueryContactInformationFields(AbstractQueryDesigner $abstractQueryDesigner, $entity, $type)
 {
     $contactInformationFields = $this->contactInformationFieldHelper->getEntityContactInformationColumns(ClassUtils::getRealClass($entity));
     if (empty($contactInformationFields)) {
         return [];
     }
     $definitionColumns = [];
     $definition = $abstractQueryDesigner->getDefinition();
     if ($definition) {
         $definition = json_decode($definition, JSON_OBJECT_AS_ARRAY);
         if (!empty($definition['columns'])) {
             $definitionColumns = array_map(function (array $columnDefinition) {
                 return $columnDefinition['name'];
             }, $definition['columns']);
         }
     }
     $typedFields = array_keys(array_filter($contactInformationFields, function ($contactInformationField) use($type) {
         return $contactInformationField === $type;
     }));
     if (!empty($definitionColumns)) {
         $typedFields = array_intersect($typedFields, $definitionColumns);
     }
     $propertyAccessor = PropertyAccess::createPropertyAccessor();
     return array_map(function ($typedField) use($propertyAccessor, $entity) {
         return (string) $propertyAccessor->getValue($entity, $typedField);
     }, $typedFields);
 }
 /**
  * Assert that value has contact information column in it's definition.
  *
  * @param AbstractQueryDesigner $value
  * @param string $type
  * @return bool
  */
 protected function assertContactInformationFields(AbstractQueryDesigner $value, $type)
 {
     $contactInformationFields = $this->contactInformationFieldHelper->getQueryContactInformationColumns($value);
     if ($type) {
         return array_key_exists($type, $contactInformationFields) && (bool) count($contactInformationFields[$type]);
     }
     return (bool) count($contactInformationFields);
 }
 /**
  * @param string|object $entityOrClass
  * @param string|null $type
  * @return array
  */
 public function getEntityTypedFields($entityOrClass, $type = null)
 {
     $entityOrClass = ClassUtils::getRealClass($entityOrClass);
     $contactInformationFields = $this->contactInformationFieldHelper->getEntityContactInformationColumns($entityOrClass);
     if (empty($contactInformationFields)) {
         return [];
     }
     if ($type) {
         $contactInformationFields = $this->filterByType($contactInformationFields, $type);
     }
     return $contactInformationFields;
 }
 public function testGetEntityContactInformationColumnsInfo()
 {
     $entity = '\\stdClass';
     $columns = array($this->fields['one'], $this->fields['two'], $this->fields['three'], $this->fields['four']);
     $this->assertEntityMetadataCall($entity, $columns);
     $this->assertContactInformationConfig($entity);
     $fields = array(array('name' => $this->fields['one'], 'label' => 'One label'), array('name' => $this->fields['two'], 'label' => 'Two label'), array('name' => $this->fields['three'], 'label' => 'Three label'), array('name' => $this->fields['four'], 'label' => 'Four label'));
     $this->fieldProvider->expects($this->once())->method('getFields')->with($entity, false, true)->will($this->returnValue($fields));
     $this->assertEquals(array(array('name' => $this->fields['one'], 'label' => 'One label', 'contact_information_type' => 'email'), array('name' => $this->fields['two'], 'label' => 'Two label', 'contact_information_type' => 'phone')), $this->helper->getEntityContactInformationColumnsInfo($entity));
 }
 /**
  * Assert that value has contact information column in it's definition.
  *
  * @param AbstractQueryDesigner $value
  * @return bool
  */
 protected function assertContactInformationFields(AbstractQueryDesigner $value)
 {
     return count($this->contactInformationFieldHelper->getQueryContactInformationColumns($value)) > 0;
 }