Create a new cache entity with the existing Contact and contactClient.
Normalize the fields as much as possible to aid in exclusive/duplicate/limit correlation.

@return CacheEntity

@throws \Exception
192057
private function createEntity()
    {
        $entity = new CacheEntity();
        $entity->setAddress1(trim(ucwords($this->contact->getAddress1())));
        $entity->setAddress2(trim(ucwords($this->contact->getAddress2())));
        $category = $this->contactClient->getCategory();
        if ($category) {
            $entity->setCategory($category->getId());
        }
        $entity->setCity(trim(ucwords($this->contact->getCity())));
        $entity->setContact($this->contact->getId());
        $entity->setContactClient($this->contactClient->getId());
        $entity->setState(trim(ucwords($this->contact->getStage())));
        $entity->setCountry(trim(ucwords($this->contact->getCountry())));
        $entity->setZipcode(trim($this->contact->getZipcode()));
        $entity->setEmail(trim($this->contact->getEmail()));
        $phone = $this->phoneValidate($this->contact->getPhone());
        if (!empty($phone)) {
            $entity->setPhone($phone);
        }
        $mobile = $this->phoneValidate($this->contact->getMobile());
        if (!empty($mobile)) {
            $entity->setMobile($mobile);
        }
        $utmSource = $this->getUtmSource();
        if (!empty($utmSource)) {
            $entity->setUtmSource($utmSource);
        }
        if ($this->dateSend) {
            $entity->setDateAdded($this->dateSend);
        }

        return $entity;
    }
407408
public function createMetaEntityFactory(): MetaEntityFactory {
		if (null === $this->metaEntityFactory) {
			$this->metaEntityFactory = new SqliteMetaEntityFactory($this);
		}
		
		return $this->metaEntityFactory;
	}
748825
public function create()
    {
        $entityClass = $this->getEntityName();

        $reflection = new \ReflectionClass($entityClass);

        if ($reflection->isAbstract()) {
            throw RuntimeException::createAbstract($entityClass);
        }

        return new $entityClass();
    }
801531
public function getCustomerContact()
    {
        $contact = $this->entity->getCustomerContact();
        if ($contact) {
            return array(
                'id' => $contact->getId(),
                'fullName' => $contact->getFullName()
            );
        }

        return null;
    }
468452
protected function loadEntity()
    {
        $params = array_merge($this->params()->fromPost(), $this->params()->fromRoute());
        if (empty($params['id'])) {
            throw new EntityNotFoundException('Bad Request');
        }

        $objectManager = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');

        if (!$model = $objectManager->getRepository(get_class($this->getEntity()))->find($params['id'])) {
            throw new EntityNotFoundException('Entity not found');
        }
        return $model;
    }
863654
public function create()
    {
        /**
         * @var Comment $comment
         */
        $classNamespace = $this->getEntityNamespace();
        $comment = new $classNamespace();
        $comment
            ->setParent(null)
            ->setChildren(new ArrayCollection())
            ->setEnabled(true)
            ->setCreatedAt($this->now());

        return $comment;
    }
228094
public function contactsCreateAction(User $currentUser, Request $request)
    {
        $serializedContacts = [];
        $users = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\User');
        $contacts = $this->contactManager->createContacts($currentUser, $users);

        foreach ($contacts as $contact) {
            $serializedContacts[] = $this->contactSerializer->serialize($contact);
        }

        return new JsonResponse($serializedContacts);
    }
894657
private function createEntity($campaignId = 0)
    {
        $entity = new CacheEntity();
        $entity->setAddress1(trim(ucwords($this->contact->getAddress1())));
        $entity->setAddress2(trim(ucwords($this->contact->getAddress2())));
        $category = $this->contactSource->getCategory();
        if ($category) {
            $entity->setCategory($category->getId());
        }
        if ($campaignId) {
            $entity->setCampaign($campaignId);
        }
        $entity->setCity(trim(ucwords($this->contact->getCity())));
        $entity->setContact($this->contact->getId());
        $entity->setContactSource($this->contactSource->getId());
        $entity->setState(trim(ucwords($this->contact->getStage())));
        $entity->setCountry(trim(ucwords($this->contact->getCountry())));
        $entity->setZipcode(trim($this->contact->getZipcode()));
        $entity->setEmail(trim($this->contact->getEmail()));
        $phone = $this->contact->getPhone();
        if (!empty($phone)) {
            $entity->setPhone($phone);
        }
        $mobile = $this->contact->getMobile();
        if (!empty($mobile)) {
            $entity->setMobile($mobile);
        }
        // get the original / first utm source code for contact
        $utmSource = $this->utmSourceHelper->getFirstUtmSource($this->contact);
        if (!empty($utmSource)) {
            $entity->setUtmSource(trim($utmSource));
        }

        return $entity;
    }
1097546
function getById($contactId){
        return new Contact(
            $this->getContext(),
            new ResourcePathEntity($this->getContext(),$this->getResourcePath(),$contactId)
        );
    }
1215043
public function create()
    {
        $instance = self::createStoreCreditTransaction($this);
        $this->setId($instance->getId());
        return $instance;
    }
995996
public function create()
    {
        /**
         * @var Tax $tax
         */
        $classNamespace = $this->getEntityNamespace();
        $tax = new $classNamespace();
        $tax
            ->setName('')
            ->setDescription('')
            ->setValue(0)
            ->setEnabled(false);

        return $tax;
    }
1243113
public function create( models\Call\ContactEntry $ContactEntry){
        $rest = $this->getService( self::API_CONTACT);
        $rest->POST( $ContactEntry);

        return $rest->getResult( models\Call\ContactEntry::class);
    }
672064
public function newInstance()
    {
        $class = $this->entityMap->getClass();

        if ($this->entityMap->useDependencyInjection()) {
            return $this->newInstanceUsingDependencyInjection($class);
        }

        return $this->newInstanceUsingInstantiator($class);
    }
1044679
public static function getGeneral()
	{
		$user = new User();
		$entity = self::createGeneral();
		$user->setEntity($entity);
		return $user;
	}
1000365
public function create()
    {
        // Validate form
        $form = $this->getForm('Create' . $this->getEntityName());
        if (!$form->isValid()) {
            return false;
        }

        // Insert new entity
        $now    = new \DateTime();
        $entity = $form->getData();
        $entity->setLastModified($now);
        $entity->setCreated($now);

        // Trigger oncreate
        $this->onCreate($entity);

        // Save
        $this->getEntityManager()->persist($entity);
        return $this->save($this->getEntityName() . ' created.', 'Unable to create ' . strtolower($this->getEntityName()) . '.');
    }
805902
public function build(): RequestEntriesRequest
	{
		$instance = new RequestEntriesRequest();
		if ($this->cacheId === null) {
			throw new BuilderException('Property [cacheId] is required.');
		}
		$instance->cacheId = $this->cacheId;
		if ($this->skipCount === null) {
			throw new BuilderException('Property [skipCount] is required.');
		}
		$instance->skipCount = $this->skipCount;
		if ($this->pageSize === null) {
			throw new BuilderException('Property [pageSize] is required.');
		}
		$instance->pageSize = $this->pageSize;
		$instance->pathFilter = $this->pathFilter;
		return $instance;
	}
1091436
public function create()
    {
        /**
         * @var Location $location
         */
        $classNamespace = $this->getEntityNamespace();
        $location = new $classNamespace();
        $location
            ->setChildren(new ArrayCollection())
            ->setParents(new ArrayCollection());

        return $location;
    }