Execute this action

@return ConfirmRecurring|Sell|Error
430085
protected function execute()
    {
        $response = $this->service->IPGApiAction($this);

        if ($response instanceof Error) {
            return $response;
        }

        if ($this->function === self::FUNCTION_INSTALL) {
            return new Sell($response);
        }

        return new ConfirmRecurring($response);
    }
1051221
public function execute() {
        $issuers = \core\oauth2\api::get_all_issuers();
        foreach ($issuers as $issuer) {
            if ($issuer->is_system_account_connected()) {
                try {
                    // Try to get an authenticated client; renew token if necessary.
                    // Returns false or throws a moodle_exception on error.
                    $success = \core\oauth2\api::get_system_oauth_client($issuer);
                } catch (moodle_exception $e) {
                    $success = false;
                }
                if ($success === false) {
                    $this->notify_admins($issuer);
                }
            }
        }
    }
239300
public function execute() {
        global $DB;

        $userid = $this->get_custom_data()->userid;

        // Get the user's preference.
        $hasbeenmigrated = get_user_preferences('core_message_migrate_data', false, $userid);

        if (!$hasbeenmigrated) {
            // To determine if we should update the preference.
            $updatepreference = true;

            // Get all the users the current user has received a message from.
            $sql = "SELECT DISTINCT(useridfrom)
                      FROM {message} m
                     WHERE useridto = ?
                     UNION
                    SELECT DISTINCT(useridfrom)
                      FROM {message_read} m
                     WHERE useridto = ?";
            $users = $DB->get_records_sql($sql, [$userid, $userid]);

            // Get all the users the current user has messaged.
            $sql = "SELECT DISTINCT(useridto)
                      FROM {message} m
                     WHERE useridfrom = ?
                     UNION
                    SELECT DISTINCT(useridto)
                      FROM {message_read} m
                     WHERE useridfrom = ?";
            $users = $users + $DB->get_records_sql($sql, [$userid, $userid]);
            if (!empty($users)) {
                // Loop through each user and migrate the data.
                foreach ($users as $otheruserid => $user) {
                    $ids = [$userid, $otheruserid];
                    sort($ids);
                    $key = implode('_', $ids);

                    // Set the lock data.
                    $timeout = 5; // In seconds.
                    $locktype = 'core_message_migrate_data';

                    // Get an instance of the currently configured lock factory.
                    $lockfactory = \core\lock\lock_config::get_lock_factory($locktype);

                    // See if we can grab this lock.
                    if ($lock = $lockfactory->get_lock($key, $timeout)) {
                        try {
                            $transaction = $DB->start_delegated_transaction();
                            $this->migrate_data($userid, $otheruserid);
                            $transaction->allow_commit();
                        } catch (\Throwable $e) {
                            throw $e;
                        } finally {
                            $lock->release();
                        }
                    } else {
                        // Couldn't get a lock, move on to next user but make sure we don't update user preference so
                        // we still try again.
                        $updatepreference = false;
                        continue;
                    }
                }
            }

            if ($updatepreference) {
                set_user_preference('core_message_migrate_data', true, $userid);
            } else {
                // Throwing an exception in the task will mean that it isn't removed from the queue and is tried again.
                throw new \moodle_exception('Task failed.');
            }
        }
    }
395410
public function execute() {
        global $DB, $CFG;

        require_once($CFG->dirroot . '/auth/mnet/auth.php');
        $mnetplugin = new \auth_plugin_mnet();
        $mnetplugin->keepalive_client();

        $random100 = rand(0,100);
        if ($random100 < 10) {
            $longtime = time() - DAYSECS;
            $DB->delete_records_select('mnet_session', "expires < ?", [$longtime]);
        }
    }
917520
protected function fire()
    {
        $container = $this->loadTaskContainer();

        $exitCode = 0;

        foreach ($this->getTasks($container) as $task) {
            $thisCode = $this->runTask($container, $task);

            if (0 !== $thisCode) {
                $exitCode = $thisCode;
            }

            if ($thisCode > 0 && ! $this->input->getOption('continue')) {
                $this->output->writeln('[<fg=red>✗</>] <fg=red>This task did not complete successfully on one of your servers.</>');

                break;
            }
        }

        foreach ($container->getFinishedCallbacks() as $callback) {
            call_user_func($callback);
        }

        return $exitCode;
    }
1353572
public function execute() {
        global $DB, $CFG;
        if (!empty($CFG->enablebadges)) {
            require_once($CFG->libdir . '/badgeslib.php');
            $total = 0;

            $courseparams = array();
            if (empty($CFG->badges_allowcoursebadges)) {
                $coursesql = '';
            } else {
                $coursesql = ' OR EXISTS (SELECT c.id FROM {course} c WHERE c.visible = :visible AND c.startdate < :current'
                        . '     AND c.id = b.courseid) ';
                $courseparams = array('visible' => true, 'current' => time());
            }

            $sql = 'SELECT b.id
                      FROM {badge} b
                     WHERE (b.status = :active OR b.status = :activelocked)
                       AND (b.type = :site ' . $coursesql . ')';
            $badgeparams = [
                'active' => BADGE_STATUS_ACTIVE,
                'activelocked' => BADGE_STATUS_ACTIVE_LOCKED,
                'site' => BADGE_TYPE_SITE
            ];
            $params = array_merge($badgeparams, $courseparams);
            $badges = $DB->get_fieldset_sql($sql, $params);

            mtrace('Started reviewing available badges.');
            foreach ($badges as $bid) {
                $badge = new \badge($bid);

                if ($badge->has_criteria()) {
                    if (debugging()) {
                        mtrace('Processing badge "' . $badge->name . '"...');
                    }

                    $issued = $badge->review_all_criteria();

                    if (debugging()) {
                        mtrace('...badge was issued to ' . $issued . ' users.');
                    }
                    $total += $issued;
                }
            }

            mtrace('Badges were issued ' . $total . ' time(s).');
        }
    }
1092440
public function execute()
    {
        $resultPage = $this->_resultPageFactory->create();
        $resultPage->getLayout()->getBlock('pagseguro.direct.payment')->setData('order', $this->_checkoutSession->getLastRealOrder()->getId());
        try {
            $this->_library->setEnvironment();
            $resultPage->getLayout()->getBlock('pagseguro.direct.payment')->setData(
                'sessionCode',
                $this->_library->getSession()
            );
            $resultPage->getLayout()->getBlock('pagseguro.direct.payment')->setData(
                'paymentUrl',
                $this->_library->getDirectPaymentUrl()
            );
        } catch (\Exception $exc) {
            /** @var \Magento\Sales\Model\Order $order */
            $order = $this->_objectManager->create('\Magento\Sales\Model\Order')->load(
                $this->_checkoutSession->getLastRealOrder()->getId()
            );
            /** change payment status in magento */
            $order->addStatusToHistory('pagseguro_cancelada', null, true);
            /** save order */
            $order->save();

            return $this->_redirect('pagseguro/payment/failure');
        }
        return $resultPage;
    }
1244052
protected function run()
    {
        $this->silentRunActionTrigger(Action::EVENT_START);
        try {
            $event = $this->action->execute($this->control, $this->context) ?: Action::EVENT_SUCCESS;
            $this->context->exitCode = 0;
        } catch (ErrorException $errorException) {
            $event = Action::EVENT_ERROR;
            $this->context->exception = $errorException;
            $this->context->exitCode = 2;
        } catch (Exception $exception) {
            $event = Action::EVENT_FAILURE;
            $this->context->exception = $exception;
            $this->context->exitCode = 1;
        }
        $this->context->finishTime = time();
        $this->silentRunActionTrigger($event);
        $this->silentRunActionTrigger(Action::EVENT_FINISH);
    }
1037430
public function execute(){
    
        if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime())
            $this->is_running = false;
    
        if(!$this->is_running){
            $this->last_result = false;
            $this->is_running = true;
            $this->save();
    
            Log::addDebugLog('Start execution of Admin task: '.$this->getTitle());
            $this->last_result = $this->executeSteps();
            if($this->last_result){
                $this->last_updated = new \DateTime();
                if($this->nb_occurrences > 0){
                    $this->nb_occurrences--;
                    if($this->nb_occurrences == 0) $this->is_enabled = false;
                }
            }
            $this->is_running = false;
            $this->save();
            Log::addDebugLog('Execution completed for Admin task: '.$this->getTitle().' - '.($this->last_result ? 'Success' : 'Failure'));
        }
    }
602012
public function execute($sale)
    {
        $url = $this->environment->getApiUrl() . '1/sales/';

        return $this->sendRequest('POST', $url, $sale);
    }
993568
public function execute() {
        // Get the validation URL from the request
        $url = $this->getRequest()->getParam('u');

        // Process the call after check
        if ("https" == parse_url($url, PHP_URL_SCHEME) && substr( parse_url($url, PHP_URL_HOST), -10 )  == ".apple.com" ) {
            // Prepare the configuration parameters
            $params = [];
            $params['merchantId']                = $this->gatewayConfig->getApplePayMerchantId();
            $params['domainName']                = $_SERVER["HTTP_HOST"];
            $params['displayName']               = $this->gatewayConfig->getStoreName();
            $params['processingCertificate']     = $this->gatewayConfig->getApplePayProcessingCertificate();
            $params['processingCertificatePass'] = $this->gatewayConfig->getApplePayProcessingCertificatePassword();
            $params['merchantCertificate']       = $this->gatewayConfig->getApplePayMerchantIdCertificate();
            $params['url']                       = $url;

            // create a new cURL resource
            $ch = curl_init();
            $data = '{"merchantIdentifier":"'. $params['merchantId'] .'", "domainName":"'. $params['domainName'] .'", "displayName":"'. $params['displayName'] .'"}';
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_SSLCERT, $params['merchantCertificate']);
            curl_setopt($ch, CURLOPT_SSLKEY, $params['processingCertificate']);
            curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $params['processingCertificatePass']);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
            if (curl_exec($ch) === false)
            {
                echo '{"curlError":"' . curl_error($ch) . '"}';
            }

            // close cURL resource, and free up system resources
            curl_close($ch);
        }
    }
856010
public function execute()
    {
        try {
            $adminUser = $this->_auth->getUser();

            if ($adminUser->getRefreshToken()) {
                $adminUser->setRefreshToken('')
                    ->save();
            }
            $this->messageManager->addSuccessMessage('Successfully disconnected');
        } catch (\Exception $e) {
            $this->messageManager->addErrorMessage($e->getMessage());
        }

        $this->_redirect('adminhtml/system_config/edit', ['section' => 'connector_developer_settings']);
    }
128835
public function run ()
    {
        // Calculate payment amount based on buyer selected shipping address
        $paymentTotal = $this->_calculatePaymentAmountBasedOnBuyerDestinationAddress();
        
        // Added custom information and seller note to the billing agreement
        $this->_addSellerInformationToBillingAgreement();
        
        /*
         * Confirm billing agreement. The billing agreement has to be consented 
         * by buyer before you confirm the billing agreement.
         */
        $this->_confirmBillingAgreement();
        
        // Validate billing agreement (optional)
        $this->_validateBillingAgreement();
        
        // First payment
        $amazonAuthorizationId1 = $this->_authorizePaymentAmount($paymentTotal, 
                $this->queryStringParams['billingAgreementId'] . "-A01");
        $this->_waitUntilAuthorizationProcessingIsCompleted($amazonAuthorizationId1);
        $this->_capturePaymentAmount($paymentTotal, $amazonAuthorizationId1);
        
        // Second payment with capture now
        $this->_authorizePaymentAmountWithCaptureNow($paymentTotal, 
                $this->queryStringParams['billingAgreementId'] . "-A02");
        
        // Third payment with capture now
        $this->_authorizePaymentAmountWithCaptureNow($paymentTotal, 
                $this->queryStringParams['billingAgreementId'] . "-A03");
        
        // Close the billing agreement when this automatic payment is no longer
        // needed
        $this->_closeBillingAgreement();
        
        print HTML_LB . HTML_LB . "Automatic payment simple checkout sample is complete";
    }
467834
public function execute()
    {
        $curdir = getcwd();
        chdir($this->phpci->buildPath);

        $behat = $this->executable;

        if (!$behat) {
            $this->phpci->logFailure(Lang::get('could_not_find', 'behat'));

            return false;
        }

        $success = $this->phpci->executeCommand($behat . ' %s', $this->features);
        chdir($curdir);

        list($errorCount, $data) = $this->parseBehatOutput();

        $this->build->storeMeta('behat-warnings', $errorCount);
        $this->build->storeMeta('behat-data', $data);

        return $success;
    }
978566
public function execute() {

        // Get the payment token from response
        $paymentToken = $this->extractPaymentToken();

        // Process the gateway response
        $this->response = $this->verifyPaymentService->verifyPayment($paymentToken);

        // Debug info
        $this->watchdog->bark($this->response);

        // If this is a 3D Secure fail
        if ($this->is3DSFailure()) {

            // Try to rebuild the customer cart
            $this->rebuildFailedOrderCart();
        }

        // Add the response message
        $this->messageManager->addErrorMessage( __("The transaction couldn't be processed or has been cancelled."));                

        // Redirect to cart
        return $this->redirect->setPath('checkout/cart', ['_secure' => true]);
    }
656303
public function execute()
    {
        // Init the retry times
        if ($this->retries && is_null($this->leftRetries)) {
            $this->leftRetries = $this->retries;
        }

        // Prepare request
        $ch = $this->ch = curl_init();
        curl_setopt_array($ch, $this->prepareCurlOptions());
        $this->beforeSend && call_user_func($this->beforeSend, $this, $ch);

        // Execute request
        $response = curl_exec($ch);

        // Handle response
        $this->handleResponse($response);
        $this->complete && call_user_func($this->complete, $this, $ch);

        // Retry if response error
        if ($this->result === false && $this->leftRetries > 0) {
            $this->leftRetries--;
            $this->execute();
            return;
        }

        if ($this->throwException && $this->errorException) {
            throw $this->errorException;
        }
    }
41855
public function execute()
    {
        set_error_handler([$this, 'processErrors'], E_WARNING);

        $stream = fopen($this->requestData['url'], 'r', false, $this->streamContext);

        $this->responseBody = stream_get_contents($stream);

        $this->responseHeaders = $http_response_header;

        $this->response = implode("\r\n", $http_response_header) . "\r\n\r\n" . $this->responseBody;

        restore_error_handler();
    }