Should handle execution of the task, taking as much (optional) parameters as needed

The parameters should be optional and failing to provide them should be handled by
the task

@param array $trackData Nested array of trackdata
359280
public function execute($lineNr = null, $fieldData = null)
    {
        $batch  = $this->getBatch();
        $import = $batch->getVariable('import');

        if (! (isset($import['trackId']) && $import['trackId'])) {
            // Do nothing
            return;
        }

        $tracker     = $this->loader->getTracker();
        $trackEngine = $tracker->getTrackEngine($import['trackId']);
        $fieldModel  = $trackEngine->getFieldsMaintenanceModel(true, 'create');

        $fieldData['gtf_id_track'] = $import['trackId'];

        $fieldData = $fieldModel->save($fieldData);

        // Store the field reference
        $import['fieldCodes']['{f' . $fieldData['gtf_id_order'] . '}'] = FieldsDefinition::makeKey(
                $fieldData['sub'],
                $fieldData['gtf_id_field']
                );

        if (isset($fieldData['gtf_calculate_using']) && $fieldData['gtf_calculate_using']) {
            $batch->addTask(
                    'Tracker\\Import\\UpdateFieldCalculationTask',
                    $lineNr,
                    $fieldData['gtf_id_field'],
                    $fieldModel->getModelNameForRow($fieldData),
                    $fieldData['gtf_calculate_using']
                    );
        }
    }
392950
public function setAdditionalData($additionalData) {
        if (is_null($additionalData)) {
            $additionalData = "";
        }
        if (!is_string($additionalData)) {
            throw new \Exception ("Additional Data must be a String");
        }
        $this->additionalData = $additionalData;
    }
661691
public function execute($tokenData = null, $userId = null)
    {
        $tracker = $this->loader->getTracker();

        $token  = $tracker->getToken($tokenData[0]);
        $survey = $token->getSurvey();
        $source = $survey->getSource();
        if (method_exists($source, 'getCompletedTokens')) {
            $completed = $source->getCompletedTokens($tokenData, $survey->getSourceSurveyId());
        } else {
            // No bulk method, check all individually
            $completed = $tokenData;
        }

        if ($completed) {
            $batch   = $this->getBatch();
            foreach($completed as $tokenId) {
                $batch->setTask('Tracker_CheckTokenCompletion', 'tokchk-' . $tokenId, $tokenId, $userId);
            }
        }
    }
1321200
public function execute($lineNr = null, $fieldData = null)
    {
        $batch  = $this->getBatch();
        $import = $batch->getVariable('import');

        if (isset($fieldData['gtf_id_order']) && $fieldData['gtf_id_order']) {
            $import['fieldOrder'][$fieldData['gtf_id_order']] = false;

            if ($batch->hasVariable('trackEngine') &&
                    isset($fieldData['gtf_field_type']) &&
                    $fieldData['gtf_field_type']) {

                $trackEngine = $batch->getVariable('trackEngine');
                if ($trackEngine instanceof \Gems_Tracker_Engine_TrackEngineInterface) {
                    $fieldDef = $trackEngine->getFieldsDefinition();
                    $field    = $fieldDef->getFieldByOrder($fieldData['gtf_id_order']);

                    if ($field instanceof FieldInterface) {
                        if ($field->getFieldType() != $fieldData['gtf_field_type']) {
                            $batch->addToCounter('import_errors');
                            $batch->addMessage(sprintf(
                                    $this->_('Conflicting field types "%s" and "%s" for field orders %d specified on line %d.'),
                                    $field->getFieldType(),
                                    $fieldData['gtf_field_type'],
                                    $fieldData['gtf_id_order'],
                                    $lineNr
                                    ));
                        }
                    }
                }
            }

        } else {
            $batch->addToCounter('import_errors');
            $batch->addMessage(sprintf(
                    $this->_('No gtf_id_order specified for field at line %d.'),
                    $lineNr
                    ));
        }
        if (isset($fieldData['gtf_field_type']) && $fieldData['gtf_field_type']) {
            $model = $this->loader->getTracker()->createTrackClass('Model\\FieldMaintenanceModel');

            $fields = $model->getFieldTypes();

            if (! isset($fields[$fieldData['gtf_field_type']])) {
                    $batch->addToCounter('import_errors');
                    $batch->addMessage(sprintf(
                            $this->_('Unknown field type "%s" specified on line %d.'),
                            $fieldData['gtf_field_type'],
                            $lineNr
                            ));
            }

        } else {
            $batch->addToCounter('import_errors');
            $batch->addMessage(sprintf(
                    $this->_('No field type specified on line %d.'),
                    $lineNr
                    ));
        }
    }
1212331
public function run(&$actionData)
    {
        foreach ($actionData->entities as $className => $ids) {
            if (class_exists($className)) {
                $ids = (array) $ids;
                $models = [];
                $mapping = ArrayHelper::getValue($this->entitiesMapping, $className, $className);

                $modelLoadSettings = ArrayHelper::merge(
                    [
                        'useCache' => true,
                        'cacheLifetime' => 86400,
                        'throwException' => false,
                        'useIdentityMap' => true,
                    ],
                    ArrayHelper::getValue($this->entitiesLoadSettings, $className, [])
                );

                foreach ($ids as $id) {
                    /** @var TagDependencyTrait $className */
                    $models[$id] = $className::loadModel(
                        $id,
                        false,
                        $modelLoadSettings['useCache'],
                        $modelLoadSettings['cacheLifetime'],
                        $modelLoadSettings['throwException'],
                        $modelLoadSettings['useIdentityMap']
                    );
                }
                if ($this->convertOneModelToArray === false && count($models) === 1) {
                    $models = reset($models);
                }
                if ($this->nullOnEmptyArray === true && count($models) === 0) {
                    $models = null;
                }
                /** @var string $className */
                // replace with models
                switch ($this->fill) {
                    case static::FILL_ENTITIES_ADD:
                        $actionData->entities[$mapping] = $models;
                        break;
                    case static::FILL_ENTITIES_REPLACE:
                        unset($actionData->entities[$className]);
                        $actionData->entities[$mapping] = $models;
                        break;
                    case static::FILL_RESULT:
                    default:
                        $actionData->result[$mapping] = $models;
                        break;
                }
            }
        }
    }
1275710
public function execute($trackId = null, $roundId = null)
    {
        $batch = $this->getBatch();
        $select = $this->db->select();

        $select->from('gems__rounds', array(
            'gro_id_order', 'gro_id_relationfield', 'gro_round_description', 'gro_icon_file',
            'gro_changed_event', 'gro_display_event',
            'gro_valid_after_source', 'gro_valid_after_field', 'gro_valid_after_unit', 'gro_valid_after_length',
            'gro_valid_for_source', 'gro_valid_for_field', 'gro_valid_for_unit', 'gro_valid_for_length',
            'gro_organizations', 'gro_code', 'gro_condition'
            ))  ->joinInner('gems__surveys', 'gems__rounds.gro_id_survey = gsu_id_survey', array(
                'survey_export_code' => 'gsu_export_code',
                )) // gro_id_survey
                ->joinLeft('gems__rounds AS va', 'gems__rounds.gro_valid_after_id = va.gro_id_round', array(
                    'valid_after' => 'va.gro_id_order',
                    )) // gro_valid_after_id
                ->joinLeft('gems__rounds AS vf', 'gems__rounds.gro_valid_for_id = vf.gro_id_round', array(
                     'valid_for' => 'vf.gro_id_order',
                    )) // gro_valid_for_id
                ->where('gems__rounds.gro_id_round = ?', $roundId);
        // \MUtil_Echo::track($select->__toString(), $roundId);

        $data = $this->db->fetchRow($select);
        // \MUtil_Echo::track($data);

        if ($data) {
            $fields = $this->loader->getTracker()->getTrackEngine($trackId)->getFieldsDefinition();
            $tests  = array(
                \Gems_Tracker_Engine_StepEngineAbstract::APPOINTMENT_TABLE,
                \Gems_Tracker_Engine_StepEngineAbstract::RESPONDENT_TRACK_TABLE,
                );
            if (isset($data['gro_id_relationfield']) && $data['gro_id_relationfield']) {
                // -1 means the respondent itself, also gro_id_relationfield stores a "bare"
                // field id, not one with a table prefix
                if ($data['gro_id_relationfield'] >= 0) {
                    $data['gro_id_relationfield'] = $this->translateFieldCode(
                            $fields,
                            FieldsDefinition::makeKey(FieldMaintenanceModel::FIELDS_NAME, $data['gro_id_relationfield'])
                            );
                }
            }

            if (isset($data['gro_valid_after_source'], $data['gro_valid_after_field']) &&
                    in_array($data['gro_valid_after_source'], $tests)) {
                // Translate field to {order}
                $data['gro_valid_after_field'] = $this->translateFieldCode($fields, $data['gro_valid_after_field']);
            }
            if (isset($data['gro_valid_for_source'], $data['gro_valid_for_field']) &&
                    in_array($data['gro_valid_for_source'], $tests)) {
                // Translate field to {order}
                $data['gro_valid_for_field'] = $this->translateFieldCode($fields, $data['gro_valid_for_field']);
            }

            $count = $batch->addToCounter('rounds_exported');

            if ($count == 1) {
                $this->exportTypeHeader('rounds');
                $this->exportFieldHeaders($data);
            }
            $this->exportFieldData($data);
            $this->exportFlush();

            $batch->setMessage('rounds_export', sprintf(
                    $this->plural('%d round exported', '%d rounds exported', $count),
                    $count
                    ));
        }
    }
326918
public function actionTrack(): void
	{
		if ($this->getPost('leave')) {
			$this->tracking->leave();
		}
		if ($this->getPost('url')) {
			$this->tracking->track();
		}
		$this->terminate();
	}
839403
public function execute($trackId = null)
    {
        $batch = $this->getBatch();
        $select = $this->db->select();

        // Join conditions on rounds, handle and / or conditions when implemented
        $select->from('gems__conditions', array(
            'gcon_id', 'gcon_type', 'gcon_class', 'gcon_name', 'gcon_condition_text1', 'gcon_condition_text2', 'gcon_condition_text3', 'gcon_condition_text4',
            ))  ->joinInner('gems__rounds', 'gems__conditions.gcon_id = gems__rounds.gro_condition', array())
                ->where('gems__rounds.gro_id_track = ?', $trackId)
                ->distinct(true);
        // \MUtil_Echo::track($select->__toString(), $roundId);

        $data = $this->db->fetchAll($select);
        // \MUtil_Echo::track($data);

        if ($data) {
            $this->exportTypeHeader('conditions');
            $this->exportFieldHeaders(reset($data));
            
            foreach($data as $row)
            {
                $this->exportFieldData($row);
                $count = $batch->addToCounter('conditions_exported');
            }
            $this->exportFlush();

            $batch->setMessage('conditions_export', sprintf(
                    $this->plural('%d condition exported', '%d conditions exported', $count),
                    $count
                    ));
        }
    }
1224392
public function addTrackedCTA(CTA $cta)
    {
        $this->trackedCTAs[] = $cta;

        $this->queueForReplacement(
            $cta->getOriginalUrl(),
            $cta->getExpandedUrl(),
            $cta->getTrackingUrl(),
            $cta->getShortenedTrackingUrl()
        );
    }
569393
public function sendTracking(Tracking\AbstractTracking $tracking)
    {
        $responseCollection = $this->callEndpoint($tracking);
        $responseCollection->rewind();
        return $responseCollection->current();
    }
86575
public function execute($trackId = null, $surveyId = null)
    {
        $batch = $this->getBatch();
        $select = $this->db->select();

        $select->from('gems__surveys', array('gsu_export_code', 'gsu_survey_name', 'gsu_survey_description', 'gsu_surveyor_id'))
                ->where('gsu_id_survey = ?', $surveyId);
        // \MUtil_Echo::track($select->__toString(), $roundId);

        $data = $this->db->fetchRow($select);
        // \MUtil_Echo::track($data);

        if ($data && isset($data['gsu_export_code']) && $data['gsu_export_code']) {
            $count = $batch->addToCounter('surveys_exported');

            if ($count == 1) {
                $this->exportTypeHeader('surveys');
                $this->exportFieldHeaders($data);
            }
            $this->exportFieldData($data);
            $this->exportFlush();

            $batch->setMessage('survey_export', sprintf(
                    $this->plural('%d survey code exported', '%d survey codes exported', $count),
                    $count
                    ));
        }
    }
1033432
public function execute($versionData = null)
    {
        $batch = $this->getBatch();

        switch (count((array) $versionData)) {
            case 0:
                // Can be enabled in 1.7.3, for now leave it for testing
                // $batch->addToCounter('import_errors');
                // $batch->addMessage($this->_('No "version" data found in import file.'));
                // break;

            case 1;
                break;

            default:
                $batch->addToCounter('import_errors');
                $batch->addMessage(sprintf(
                        $this->_('%d sets of "version" data found in import file.'),
                        count($versionData)
                        ));
                foreach ($tracksData as $lineNr => $versionData) {
                    $batch->addMessage(sprintf(
                            $this->_('"version" data found on line %d.'),
                            $lineNr
                            ));
                }
        }
    }
239889
protected function set_customdata($customdata) {
        // Always include the courseid (because is not stored in the notifications or messages table).
        if (!empty($this->courseid) && (is_object($customdata) || is_array($customdata))) {
            $customdata = (array) $customdata;
            $customdata['courseid'] = $this->courseid;
        }
        $this->customdata = json_encode($customdata);
    }
1040406
public function processBeforeSave(array $fieldData, array $trackData)
    {
        $this->changed = false;

        if (! $this->exists) {
            return null;
        }

        foreach ($this->_fields as $key => $field) {
            if ($field instanceof FieldInterface) {
                $field->calculationStart($trackData);
            }
        }

        $output = array();

        foreach ($this->_fields as $key => $field) {
            if ($field instanceof FieldInterface) {
                $inVal  = isset($fieldData[$key]) ? $fieldData[$key] : null;
                $outVal = $field->calculateFieldValue($inVal, $fieldData, $trackData);

                if (is_array($outVal) || is_array($inVal)) {
                   if (is_array($outVal) && is_array($inVal)) {
                        $changedNow = ($outVal != $inVal);
                    } else {
                        $changedNow = true;
                    }
                } else {
                    $changedNow = ((string) $inVal !== (string) $outVal);
                }
                $this->changed = $this->changed || $changedNow;

                $fieldData[$key] = $outVal; // Make sure the new value is available to the next field
                $output[$key]    = $outVal;
            }
        }

        return $output;
    }
284696
public function setTemplateData(array $templateData)
    {
        if (!isset($this->templateData)) {
            $this->templateData = [];
        }

        $this->templateData = array_merge($this->templateData, $templateData);

        return $this;
    }
822580
public function track(TrackableInterface $trackable)
    {
        if ($trackable instanceof Collection) {
            $this->trackCollection($trackable);
        }

        if ($trackable instanceof PageController) {
            $this->trackCollection($trackable->getPageObject());
        }

        if ($trackable instanceof Controller) {
            $this->trackBlocks($trackable->getCollectionObject(), [$trackable]);
        }
    }
573889
public function execute(NodeData $nodeData, array $transformationConfigurations)
    {
        $transformationConjunction = $this->buildTransformationConjunction($transformationConfigurations);
        foreach ($transformationConjunction as $transformation) {
            if ($transformation->isTransformable($nodeData)) {
                $transformation->execute($nodeData);
            }
        }
    }