Create a People Contact

@return Google_Service_PeopleService_Person
165378
public static function createContact()
    {
        $person = self::getPerson();

        // New person check
        if (isset($person->resourceName)) {
            throw new Exception("You should use newPeron() before create", 500);
        }
        
        return self::getService()->people->createContact($person);
    }
1144156
public function create()
    {
        return $this->makeResponse('create', [
            'file' => [],
            'articles' => Article::when('owner' != user('role'), function ($query) {
                    $query->where('user_id', user('id'));
                })
                ->latest()
                ->get() ?? [],
        ]);
    }
195390
public function createContact() {
        $contact = new Contact($this->getContext());
        $this->addChild($contact);
        $qry = new CreateEntityQuery($contact);
        $this->getContext()->addQuery($qry, $contact);
        return $contact;
    }
1096046
public static function create_contact_request(int $userid, int $requesteduserid) : \stdClass {
        global $DB, $PAGE;

        $request = new \stdClass();
        $request->userid = $userid;
        $request->requesteduserid = $requesteduserid;
        $request->timecreated = time();

        $request->id = $DB->insert_record('message_contact_requests', $request);

        // Send a notification.
        $userfrom = \core_user::get_user($userid);
        $userfromfullname = fullname($userfrom);
        $userto = \core_user::get_user($requesteduserid);
        $url = new \moodle_url('/message/pendingcontactrequests.php');

        $subject = get_string('messagecontactrequestsnotificationsubject', 'core_message', $userfromfullname);
        $fullmessage = get_string('messagecontactrequestsnotification', 'core_message', $userfromfullname);

        $message = new \core\message\message();
        $message->courseid = SITEID;
        $message->component = 'moodle';
        $message->name = 'messagecontactrequests';
        $message->notification = 1;
        $message->userfrom = $userfrom;
        $message->userto = $userto;
        $message->subject = $subject;
        $message->fullmessage = text_to_html($fullmessage);
        $message->fullmessageformat = FORMAT_HTML;
        $message->fullmessagehtml = $fullmessage;
        $message->smallmessage = '';
        $message->contexturl = $url->out(false);
        $userpicture = new \user_picture($userfrom);
        $userpicture->includetoken = $userto->id; // Generate an out-of-session token for the user receiving the message.
        $message->customdata = [
            'notificationiconurl' => $userpicture->get_url($PAGE)->out(false),
            'actionbuttons' => [
                'accept' => get_string_manager()->get_string('accept', 'moodle', null, $userto->lang),
                'reject' => get_string_manager()->get_string('reject', 'moodle', null, $userto->lang),
            ],
        ];

        message_send($message);

        return $request;
    }
399716
public function create()
    {
        if ($this->validate()) {

            $auth = Yii::$app->authManager;
            $role = $auth->getRole($this->roleName);
            if(!$role) {
                return null;
            }

            $user = new User();
            $user->username = $this->username;
            $user->email = $this->email;
            $user->setPassword($this->password);
            $user->generateAuthKey();
            if ($user->save()) {
                $auth->assign($role, $user->getId());
                return $user;
            }
        }
        return null;
    }
1148906
private function setupGoogleClient()
    {
        $client = new Google_Client();

        $client->setClientId($this->getConfig('oauth2_client_id'));
        $client->setClientSecret($this->getConfig('oauth2_client_secret'));
        $client->setRedirectUri($this->getConfig('oauth2_redirect_uri'));
        $client->setScopes($this->getConfig('services'));
        $client->setAccessType($this->getConfig('access_type'));
        $client->setApprovalPrompt($this->getConfig('approval_prompt'));

        return $client;
    }
1131029
def create_customer(name, email, phone):
    
    Party = client.model('party.party')
    ContactMechanism = client.model('party.contact_mechanism')

    party, = Party.create([{'name': name}])

    # Bulk create the email and phone
    ContactMechanism.create([
        {'type': 'email', 'value': email, 'party': party},
        {'type': 'phone', 'value': phone, 'party': party},
    ])

    return party
331142
private function createHealthService()
    {
        $resourceChecker = call_user_func($this->resourceCheckerClosure);

        $cache = call_user_func($this->cacheClosure);

        $this->healthServiceClosure = function () use (
            $resourceChecker,
            $cache
        ) {
            return $this->instantiateService($resourceChecker, $cache);
        };

        $this->healthService = call_user_func($this->healthServiceClosure);
    }
53048
public function getContact()
    {
        if (empty($this->contact)) {
            throw new LogicException(
                sprintf(self::ERROR_MISSING_ATTRIBUTE_FORMAT, 'contact')
            );
        }
        return $this->contact;
    }
930320
public function createContacts(User $currentUser, array $users)
    {
        $this->om->startFlushSuite();
        $createdContacts = [];

        foreach ($users as $user) {
            $contact = $this->contactRepo->findOneBy(['user' => $currentUser, 'contact' => $user]);

            if (is_null($contact)) {
                $contact = new Contact();
                $contact->setUser($currentUser);
                $contact->setContact($user);
                $this->om->persist($contact);
                $createdContacts[] = $contact;
            }
        }
        $this->om->endFlushSuite();

        return $createdContacts;
    }
547319
public function contactUs()
    {
        //Checks if the "contact us" form is enabled
        if (!getConfig('default.contact_us')) {
            $this->Flash->error(I18N_DISABLED);

            return $this->redirect(['_name' => 'homepage']);
        }

        $contact = new ContactUsForm;

        if ($this->request->is('post')) {
            //Checks for reCAPTCHA, if requested
            if (!getConfig('security.recaptcha') || $this->Recaptcha->verify()) {
                //Sends the email
                if ($contact->execute($this->request->getData())) {
                    $this->Flash->success(I18N_OPERATION_OK);

                    return $this->redirect(['_name' => 'homepage']);
                }

                $this->Flash->error(I18N_OPERATION_NOT_OK);
            } else {
                $this->Flash->error(__d('me_cms', 'You must fill in the {0} control correctly', 'reCAPTCHA'));
            }
        }

        $this->set(compact('contact'));
    }
386603
public function createAction()
    {
        // Load form
        $entityClass = $this->getModuleNamespace() . '\Entity\\' . $this->getEntityName();
        $entity      = new $entityClass();
        $form        = $this->getForm('Create' . $this->getEntityName());
        $form->bind($entity);

        // Implement Post/Redirect/Get pattern
        $prg = $this->prg();
        if ($prg instanceof Response) {
            return $prg;
        } else if (false !== $prg) {

            // Set form data
            $form->setData($prg);

            // Create account
            $result = $this->getService()->create();
            if ($result) {
                return $this->redirect()->toRoute($this->indexRoute);
            }
        }

        // Set up view model
        $viewModel = new ViewModel(array(
            'entityName' => $this->getEntityName(),
            'form'       => $form,
        ));
        $viewModel->setTemplate('infinity-base/crud/create');

        return $viewModel;
    }
595325
public function createConnection()
    {
        $pdoCheck = $this->application->make(PdoMysqlExtension::class)->performCheck();
        if ($pdoCheck->getState() !== PreconditionResult::STATE_PASSED) {
            throw new UserMessageException($pdoCheck->getMessage());
        }
        $databaseConfiguration = $this->getDefaultConnectionConfiguration();
        if ($databaseConfiguration === null) {
            throw new UserMessageException(t('The configuration is missing the required database connection parameters.'));
        }
        $databaseManager = $this->application->make(DatabaseManager::class);
        try {
            $connection = $databaseManager->getFactory()->createConnection($databaseConfiguration);
        } catch (Exception $x) {
            throw new UserMessageException($x->getMessage(), $x->getCode(), $x);
        } catch (Throwable $x) {
            throw new UserMessageException($x->getMessage(), $x->getCode());
        }

        $connection = $this->setPreferredCharsetCollation($connection);

        return $connection;
    }
1085020
private function addContactToQueue()
    {
        if (
            !$this->queue
            && $this->file
            && $this->contactClient
            && $this->contact
        ) {
            // Check for a pre-existing instance of this contact queued for this file.
            $queue = $this->getQueueRepository()->findOneBy(
                [
                    'contactClient' => $this->contactClient,
                    'file'          => $this->file,
                    'contact'       => (int) $this->contact->getId(),
                ]
            );
            if ($queue) {
                throw new ContactClientException(
                    'Skipping duplicate Contact. Already queued for file delivery.',
                    Codes::HTTP_CONFLICT,
                    null,
                    Stat::TYPE_DUPLICATE,
                    false,
                    $queue
                );
            } else {
                /** @var Queue $queue */
                $queue = new Queue();
                $queue->setContactClient($this->contactClient);
                $queue->setContact($this->contact);
                $queue->setFile($this->file);

                if (!empty($this->event['id'])) {
                    $queue->setCampaignEvent($this->event['id']);
                }
                if ($this->campaign) {
                    $queue->setCampaign($this->campaign);
                }
                if ($queue) {
                    $this->queue = $queue;
                    $this->getQueueRepository()->saveEntity($this->queue);
                    $this->valid = true;
                    $this->setLogs($this->queue->getId(), 'queueId');
                }
            }
        }

        if (!$this->queue) {
            throw new ContactClientException(
                'Could not append this contact to the queue.',
                Codes::HTTP_INTERNAL_SERVER_ERROR,
                isset($e) ? $e : null,
                Stat::TYPE_ERROR,
                false
            );
        }

        return $this->queue;
    }
1177472
public function getContactService()
    {
        if (!array_key_exists('contact', $this->services)) {
            $this->services['contact'] = new Contact($this->httpClient, $this->key);
        }

        return $this->services['contact'];
    }
199279
public function create()
	{
		// create a new session
		$this->keys['session_id']	= $this->_new_session_id();
		$this->keys['previous_id']	= $this->keys['session_id'];	// prevents errors if previous_id has a unique index
		$this->keys['ip_hash']		= md5(\Input::ip().\Input::real_ip());
		$this->keys['user_agent']	= \Input::user_agent();
		$this->keys['created'] 		= $this->time->get_timestamp();
		$this->keys['updated'] 		= $this->keys['created'];

		return $this;
	}
831447
public function actionCreate()
    {
        $model = new User();

        if ($model->loadAll(request()->post())) {
            $model->setPassword($model->password_hash);
            $model->generateAuthKey();
            if ($model->saveAll()) {
                set_flash('success_create_new_user', $array = [
                    'type'     => 'success',
                    'duration' => 3000,
                    'icon'     => 'glyphicon glyphicon-ok-sign',
                    'title'    => \t('app', 'Congratulations!'),
                    'message'  => \t('app','Your content has been saved'),
                ]);
                return $this->redirect(['update', 'id' => $model->id]);
            } else {
                set_flash('error_user_has_not_been_saved', $array = [
                    'type'     => 'danger',
                    'duration' => 3000,
                    'icon'     => 'glyphicon glyphicon-remove-sign',
                    'title'    => \t('app', 'An error has occurred!'),
                    'message'  => \t('app','Your content has not been saved'),
                ]);
            }
        }

        return $this->render('create', [
            'model' => $model,
        ]);

    }