Creates Contact resource
@return Contact
195390
public function createContact() {
        $contact = new Contact($this->getContext());
        $this->addChild($contact);
        $qry = new CreateEntityQuery($contact);
        $this->getContext()->addQuery($qry, $contact);
        return $contact;
    }
1209594
public function createNew()
    {
        $resource = $this->traitCreateNew();

        if (!$resource instanceof TranslatableInterface) {
            throw new \InvalidArgumentException('Resource must implement TranslatableInterface.');
        }

        $resource->setCurrentLocale($this->localeProvider->getCurrentLocale());
        $resource->setFallbackLocale($this->localeProvider->getFallbackLocale());

        return $resource;
    }
1238196
public function setContact($contact)
    {
        if ($contact instanceof Contact) {
            $contact = $contact->getId();
        }

        $this->contact = $contact;

        return $this;
    }
960576
public function create( models\Call\ContactUrl $ContactUrl){
        $rest = $this->getService( self::API_URL);
        $rest->POST( $ContactUrl);

        return $rest->getResult( models\Call\ContactUrl::class);
    }
236299
public function setContactClient(ContactClient $contactClient)
    {
        $this->contactClient = $contactClient;
        $this->setPayload($this->contactClient->getFilePayload());

        return $this;
    }
24859
protected function createResourceCallable()
    {
        return function (array $data, array $values, ErrorBag $errorBag) {
            $model = $this->getDataModel()->newInstance();

            foreach ($values as $attribute => $value) {
                $model->setAttribute($attribute, $value);
            }

            if (!empty($data['id'])) {
                $model->setAttribute($model->getKeyName(), $data['id']);
            }

            try {
                $model->save();

                //We need to load the model from the DB in case the user is utilizing getRequiredFields() on the transformer.
                $model = $model->fresh();
            } catch (\Exception $e) {
                $errorBag[] = new Error('creation_error', 'Resource could not be created');
                throw $e;
            }

            return $model;
        };
    }
104068
public function addContextContact(Contact $contact = null)
    {
        if (!$contact) {
            return $this;
        }
        $context = [];
        $conType = [];

        // Append contact ID.
        $contactId     = (int) $contact->getId();
        $context['id'] = isset($contactId) ? $contactId : null;
        $conType['id'] = 'number';

        // Append contact owner data.
        $owner                         = $contact->getOwner();
        $context['owner']              = [];
        $context['owner']['id']        = $owner ? $owner->getId() : null;
        $conType['owner']['id']        = 'number';
        $context['owner']['username']  = $owner ? $owner->getUsername() : null;
        $context['owner']['firstName'] = $owner ? $owner->getFirstName() : null;
        $context['owner']['lastName']  = $owner ? $owner->getLastName() : null;
        $context['owner']['email']     = $owner ? $owner->getEmail() : null;

        // Append points value.
        $points            = $contact->getPoints();
        $context['points'] = isset($points) ? $points : null;
        $conType['points'] = 'number';

        // Append IP Addresses.
        $context['ipAddresses'] = [];
        $context['ip']          = null;
        foreach ($contact->getIpAddresses()->toArray() as $ip => $value) {
            $context['ipAddresses'][] = $ip;
            $context['ip']            = $ip;
        }

        // Add Identified date.
        /** @var \DateTime $dateIdentified */
        $dateIdentified            = $contact->getDateIdentified();
        $context['dateIdentified'] = $dateIdentified ? $this->dateFormatHelper->format($dateIdentified) : null;
        $conType['dateIdentified'] = 'datetime';

        // Add Modified date.
        /** @var \DateTime $dateModified */
        $dateModified            = $contact->getDateModified();
        $context['dateModified'] = $dateModified ? $this->dateFormatHelper->format($dateModified) : null;
        $conType['dateModified'] = 'datetime';

        // Add DNC data.
        $context['doNotContacts'] = [];
        $context['doNotContact']  = false;
        if ($contactId && $this->needsDncData) {
            /** @var \Mautic\LeadBundle\Model\DoNotContact $record */
            foreach ($contact->getDoNotContact() as $record) {
                $context['doNotContacts'][$record->getChannel()]           = [
                    'comments' => $record->getComments(),
                    'reason'   => $record->getReason(),
                    'exists'   => true,
                ];
                $conType['doNotContacts'][$record->getChannel()]['exists'] = 'boolean';
                $context['doNotContact']                                   = true;
            }
            $conType['doNotContact'] = 'boolean';
        }

        // Add UTM data.
        $context['utm'] = [
            'campaign'   => null,
            'content'    => null,
            'medium'     => null,
            'query'      => null,
            'referrer'   => null,
            'remoteHost' => null,
            'source'     => null,
            'term'       => null,
            'url'        => null,
            'userAgent'  => null,
        ];
        if ($contactId && $this->needsUtmData) {
            $utmTags            = $this->utmSourceHelper->getSortedUtmTags($contact);
            $context['utmTags'] = [];
            if ($utmTags) {
                foreach ($utmTags as $utmTag) {
                    $tags                 = [
                        'campaign'   => $utmTag->getUtmCampaign(),
                        'content'    => $utmTag->getUtmContent(),
                        'medium'     => $utmTag->getUtmMedium(),
                        'query'      => $utmTag->getQuery(),
                        'referrer'   => $utmTag->getReferer(),
                        'remoteHost' => $utmTag->getRemoteHost(),
                        'source'     => $utmTag->getUtmSource(),
                        'term'       => $utmTag->getUtmTerm(),
                        'url'        => $utmTag->getUrl(),
                        'userAgent'  => $utmTag->getUserAgent(),
                    ];
                    $context['utmTags'][] = $tags;
                    // Override the {{ utm.values }} to be the latest non-empty version of each found.
                    foreach ($tags as $key => $value) {
                        if (!empty($value)) {
                            $context['utm'][$key] = $value;
                        }
                    }
                }
            }
        }

        // Add Device data.
        $context['device'] = [
            'name'        => null,
            'brand'       => null,
            'model'       => null,
            'fingerprint' => null,
            'trackingId'  => null,
            'os'          => [
                'osName'      => null,
                'osShortName' => null,
                'osVersion'   => null,
                'osPlatform'  => null,
            ],
        ];
        if ($contactId && $this->needsDeviceData) {
            /** @var LeadDeviceRepository $deviceRepo */
            $deviceRepo = $this->contactModel->getDeviceRepository();
            $devices    = $deviceRepo->getEntities(
                [
                    'limit'            => 1,
                    'orderBy'          => $deviceRepo->getTableAlias().'.id',
                    'orderByDir'       => 'DESC',
                    'filter'           => [
                        'force' => [
                            [
                                'column' => 'IDENTITY('.$deviceRepo->getTableAlias().'.lead)',
                                'expr'   => 'eq',
                                'value'  => $contactId,
                            ],
                        ],
                    ],
                    'ignore_paginator' => true,
                ]
            );
            if ($devices && $device = reset($devices)) {
                $context['device'] = [
                    'name'        => $device->getDevice(),
                    'brand'       => $device->getDeviceBrand(),
                    'model'       => $device->getDeviceModel(),
                    'fingerprint' => $device->getDeviceFingerprint(),
                    'trackingId'  => $device->getTrackingId(),
                    'os'          => [
                        'osName'      => $device->getDeviceOsName(),
                        'osShortName' => $device->getDeviceOsShortName(),
                        'osVersion'   => $device->getDeviceOsVersion(),
                        'osPlatform'  => $device->getDeviceOsPlatform(),
                    ],
                ];
            }
        }

        $fieldGroups = $contact->getFields();
        if ($fieldGroups) {
            foreach ($fieldGroups as $fgKey => $fieldGroup) {
                foreach ($fieldGroup as $fkey => $field) {
                    $value = isset($field['value']) ? $field['value'] : '';
                    $type  = isset($field['type']) ? $field['type'] : '';
                    if ('' !== $value && in_array($type, ['datetime', 'date', 'time'])) {
                        // Soft support for labels/values as dates/times.
                        @$newValue = $this->dateFormatHelper->format($value);
                        if (null !== $newValue && '' !== $newValue) {
                            $value = $newValue;
                        }
                    }
                    $context[$fkey] = $value;
                    if ($type) {
                        $conType[$fkey] = $type;
                    }
                }
            }
        }

        // Support multiple contacts in the future if needed by uncommenting a bit here.
        // $contacts = !empty($this->context['contacts']) ? $this->context['contacts'] : [];

        // Set the context to this contact.
        $this->sanitizeContext($context);
        $this->context = array_merge($this->context, $context);
        $this->conType = array_merge($this->conType, $conType);

        // Support multiple contacts for future batch processing.
        // $this->context['contacts']                 = $contacts;
        // $this->context['contacts'][$context['id']] = $context;

        return $this;
    }
519914
public function createResponse()
    {
        // Cannot continue if a resource has not been set
        if (!$this->resource instanceof ResourceInterface) {
            return $this->response;
        }

        return $this->response
            ->setResource($this->resource)
            ->create();
    }
474450
public static function createFromEnvironment()
    {
        $request = new static($_GET, $_POST, $_FILES, $_SERVER);
        $request->setContent(null);
        return $request;
    }
538286
def create
      @contact_form = Cmtool::ContactForm.new(contact_form_params)

      respond_to do |format|
        if @contact_form.save
          format.html { redirect_to([cmtool, @contact_form], notice: I18n.t('cmtool.action.create.successful', model: Cmtool::ContactForm.model_name.human)) }
          format.xml  { render xml: @contact_form, status: :created, location: @contact_form }
        else
          format.html { render action: "new" }
          format.xml  { render xml: @contact_form.errors, status: :unprocessable_entity }
        end
      end
    end
167282
public function getContactEmail()
    {
        if (false !== $this->contactEmail && !$this->contactEmail) {
            $user = $this->getUser();
            $email = false;
            if (isset($user)) {
                $email = $user->getInfo()->getEmail();
            }
            $this->setContactEmail($email);
        }
        return $this->contactEmail;
    }
688998
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $mapper = new ContactMapper();
        $mapper->setDbAdapter($serviceLocator->get('Zend\Db\Adapter\Adapter'));
        $mapper->setEntityPrototype(new ContactEntity());
        $mapper->setHydrator(new ContactHydrator());
        return $mapper;

    }
347264
public function create()
    {
        $instance = self::createAddress($this);
        $this->setId($instance->getId());
        return $instance;
    }
436991
public function create()
    {
        $params = array(
            'slug' => $this->ensureParameter('slug'),
            'name' => $this->ensureParameter('name'),
            'i18n_type' => $this->ensureParameter('i18nType'),
            'content' => $this->ensureParameter('content'),
        );

        $this->post(
            sprintf('project/%s/resources/', $this->ensureParameter('project')),
            $params
        );

        return $this;
    }
459493
public function setContactSource(ContactSource $contactSource)
    {
        $this->contactSource = $contactSource;
        $campaignSettings    = null == $this->contactSource->getCampaignSettings() ? '{}' : $this->contactSource->getCampaignSettings();
        $this->setCampaignSettings($campaignSettings);

        return $this;
    }
276806
function makeResource()
    {
        $resource = $this->resource;
        if ($this->id) $resource .= '/' . $this->id;
        return $resource;
    }
29776
public function create()
    {
        $instance = self::createRefundTransaction($this);
        $this->setId($instance->getId());
        return $instance;
    }