Things that must happen before script execution.

@access public
@author Joel Bout, <joel.bout@tudor.lu>
@return void
510580
public function preRun()
    {
        
    	$this->options = array('verbose' => false,
        					   'action' => null,
    						   'extension' => null);
        
        $this->options = array_merge($this->options, $this->parameters);
        
        if ($this->options['verbose'] == true) {
        	$this->verbose = true;
        }
        
        // The 'action' parameter is always required.
        if ($this->options['action'] == null) {
        	$this->err("Please enter the 'action' parameter.", true);
        } else {
        	$this->options['action'] = strtolower($this->options['action']);
        	if (!in_array($this->options['action'], array_keys($this->getAllowedActions()))) {
        		$this->err("'" . $this->options['action'] . "' is not a valid action.", true);
        	} else {
        		// The 'action' parameter is ok.
        		// Let's check additional inputs depending on the value of the 'action' parameter.
        		$this->checkInput();	
        	}
        }
        
    }
1366634
public function onBeforeWrite()
    {
        $this->owner->StyleID = $this->owner->cleanStyleID($this->owner->StyleID);
        $this->owner->StyleClasses = $this->owner->cleanStyleClasses($this->owner->StyleClasses);
    }
275782
public function beforeDelete()
    {
        foreach ($this->attributes as $attr => $options) {
            $this->ensureAttributes($attr, $options);
            $this->deleteFiles($attr);
        }
    }
388572
public function onBeforeWrite()
    {
        $this->owner->GoogleVerificationCode    = $this->getVerificationCode($this->owner->GoogleVerificationCode);
        $this->owner->GoogleAnalyticsTrackingID = trim($this->owner->GoogleAnalyticsTrackingID);
    }
679574
public function exec() : void
    {
        $this -> actionLog('Script successfully entered');

        $sentence = $this -> storage['sentenced'];
        $response = NULL;
        if (method_exists($this, $sentence))
            $response = $this -> $sentence();
        else $this -> errorLog('Unknown method '.$sentence);

        if ($response)
            $this -> actionLog('Received data: '.$response);

        $this -> setMemory(memory_get_usage(TRUE));
        $this -> actionLog('Script successfully completed, action: '.$sentence);
    }
841340
public function preRun()
    {
        
        $this->options = array('verbose' => false,
        					   'user' => null,
        					   'password' => null,
        					   'model' => null,
        					   'input' => null);
        
        $this->options = array_merge($this->options, $this->parameters);
        
        // the 'file' param is checked by the parent implementation.
        
        if ($this->options['user'] == null){
        	$this->err("Please provide a TAO 'user'.", true);
        }
        else if ($this->options['password'] == null){
        	$this->err("Please provide a TAO 'password'.", true);
        }
        else if ($this->options['input'] == null){
        	$this->err("Please provide a RDF 'input' file.", true);
        }

        
    }
164083
public function beforeCompile(): void
	{
		// Skip if it's not CLI mode
		if (!$this->cliMode) return;

		$builder = $this->getContainerBuilder();

		// Lookup for Symfony Console Application
		$application = $builder->getDefinitionByType('Symfony\Component\Console\Application');

		// Register helpers
		$connectionHelper = $this->prefix('@connectionHelper');
		$application->addSetup(new Statement('$service->getHelperSet()->set(?, ?)', [$connectionHelper, 'db']));
	}
1284699
public function prepare(Script $script)
    {
        $script->addScriptFunction("uiDropdownFunctions", $this->getScriptDropdown());
        $script->addCustomScriptLabel(ScriptLabel::MouseClick, $this->getScriptMouseClick());
        $script->addCustomScriptLabel(ScriptLabel::OnInit, $this->getScriptInit());
    }
739132
public function beforeExport() {
		$this->overrideH5P();
		$this->overridePhet();
		$this->overrideIframes();
		$this->overrideEmbeds();
		$this->overrideVideo();
		$this->overrideAudio();
	}
931746
public function onBeforeWrite()
    {
        if ($this->owner instanceof Site) {
            if (!$this->owner->ID) {
                // Initialise a new Site to the top level
                $this->owner->SiteID   = 0;
                $this->owner->ParentID = 0;
            }
            return;
        }

        // Set the SiteID (and ParentID if required) for all new pages.
        if (!$this->owner->ID) {
            $parent = $this->owner->Parent();
            if ($parent && $parent->exists()) {
                // Page is beneath a Site
                if ($parent instanceof Site) {
                    $this->owner->SiteID = $parent->ID;
                } else {
                    $this->owner->SiteID = $parent->SiteID;
                }
            } else {
                // Create the page beneath the current Site
                $this->owner->SiteID   = Multisites::inst()->getDefaultSiteId();
                $this->owner->ParentID = $this->owner->SiteID;
            }
        }

        // Make sure SiteID is changed when site tree is reorganised.
        if ($this->owner->ID && $this->owner->isChanged('ParentID')) {
            // Get the new parent
            $parent = DataObject::get_by_id(SiteTree::class, $this->owner->ParentID);

            // Make sure the parent exists
            if ($parent) {
                // Recursively change SiteID for this and all child pages
                $siteId = ($parent instanceof Site) ? $parent->ID : $parent->SiteID;
                $this->owner->updateSiteID($siteId);
            }
        }
    }
466430
public function onBeforeWrite()
    {
        parent::onBeforeWrite();
        if (empty($this->Title)) {
            $type = $this->Type;
            switch ($type) {
                case 'URL':
                case 'Email':
                case 'Phone':
                    $this->Title = $this->getField($type);
                    break;
                case 'SiteTree':
                    $this->Title = $this->SiteTree()->MenuTitle;
                    break;
                default:
                    if ($this->getRelationType($type) == 'has_one' && $component = $this->getComponent($type)) {
                        $this->Title = $component->Title;
                    } else {
                        $this->Title = 'Link-' . $this->ID;
                    }
                    break;
            }
        }
    }
1190481
public function beforeCreate()
    {
        $this->timestamp_create = time();
        $this->timestamp_update = 0;
        $this->create_user_id = Module::getAuthorUserId();
        $this->update_user_id = Module::getAuthorUserId();
        $this->slugifyAlias();
    }
1050547
public function onBeforeWrite()
    {
        parent::onBeforeWrite();
        $siteConfig = SiteConfig::current_site_config();
        if ($siteConfig->MustApprove) {
            $this->Visible = false;
        }
        if (substr($this->URL, 0, 4) != 'http' && $this->URL != '') {
            $this->URL = 'http://' . $this->URL;
        }
        /** setup the MD5 for Gravatar usage */
        $this->MD5Email = md5($this->Email);
        if ($siteConfig->AkismetKey) {
            $this->checkAkismet($siteConfig);
        }
        /** PHP and HTML do not like each other I guess. */
        $this->Comment = nl2br($this->Comment);
    }
849734
function before_process() {
    global $messageStack;
    $this->authorize = $_POST;
    unset($this->authorize['btn_submit_x'], $this->authorize['btn_submit_y']);
    $this->authorize['HashValidationValue'] = $this->calc_md5_response($this->authorize['x_trans_id'], $this->authorize['x_amount']);
    $this->authorize['HashMatchStatus'] = ($this->authorize['x_MD5_Hash'] == $this->authorize['HashValidationValue']) ? 'PASS' : 'FAIL';

    $this->_debugActions($this->authorize, 'Response-Data', '', zen_session_id());

    // if in 'echo' mode, dump the returned data to the browser and stop execution
    if (AUTHORIZENET_DEVELOPER_MODE == 'echo' || MODULE_PAYMENT_AUTHORIZENET_DEBUGGING == 'echo') {
      echo 'Returned Response Codes:<br /><pre>' . print_r($_POST, true) . '</pre><br />';
      die('Press the BACK button in your browser to return to the previous page.');
    }

    if ($this->authorize['x_response_code'] == '1'
//       && $this->authorize['x_type'] == $this->submit_data['x_type']
//       && $this->authorize['x_method'] == $this->submit_data['x_method']
//       && $this->authorize['x_amount'] == $this->submit_data['x_amount']
//       && $this->authorize['x_invoice_num'] == $this->submit_data['x_invoice_num']
//       && $this->authorize['x_description'] == $this->submit_data['x_description']
       && (/*MODULE_PAYMENT_AUTHORIZENET_MD5HASH == 'DANGEROUSLY-BYPASSED' || */ $this->authorize['x_MD5_Hash'] == $this->authorize['HashValidationValue'])
     ){
      $this->auth_code = $this->authorize['x_auth_code'];
      $this->transaction_id = $this->authorize['x_trans_id'];
      return;
    }
    if ($this->authorize['x_response_code'] == '2') {
      $messageStack->add_session('checkout_payment', $this->authorize['x_response_reason_text'] . MODULE_PAYMENT_AUTHORIZENET_TEXT_DECLINED_MESSAGE, 'error');
      zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
    }
    // Code 3 or anything else is an error
    $messageStack->add_session('checkout_payment', MODULE_PAYMENT_AUTHORIZENET_TEXT_ERROR_MESSAGE, 'error');
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
  }
1232366
def before_run(self):
        """"""
        # Actions and checks counters
        self.nb_checks = 0
        self.nb_internal_checks = 0
        self.nb_checks_launched = 0
        self.nb_actions_launched = 0

        self.nb_checks_results = 0
        self.nb_checks_results_timeout = 0
        self.nb_checks_results_passive = 0
        self.nb_checks_results_active = 0

        self.nb_actions_results = 0
        self.nb_actions_results_timeout = 0
        self.nb_actions_results_passive = 0

        self.nb_broks_dropped = 0
        self.nb_checks_dropped = 0
        self.nb_actions_dropped = 0

        # Broks, notifications, ... counters
        self.nb_broks = 0
        self.nb_notifications = 0
        self.nb_event_handlers = 0
        self.nb_external_commands = 0

        self.ticks = 0
792872
public function triggerBeforeFind()
    {
        if (!$this->_beforeFindFired && $this->_type === 'select') {
            $this->_beforeFindFired = true;

            /** @var \Cake\Event\EventDispatcherInterface $repository */
            $repository = $this->getRepository();
            $repository->dispatchEvent('Model.beforeFind', [
                $this,
                new ArrayObject($this->_options),
                !$this->isEagerLoaded()
            ]);
        }
    }
926831
public function beforeNodeCreate()
    {
        if (!$this->eventEmittingService->isEnabled()) {
            return;
        }

        /* @var $nodeEvent NodeEvent */
        $nodeEvent = $this->eventEmittingService->generate(self::NODE_ADDED, [], NodeEvent::class);
        $this->currentNodeAddEvents[] = $nodeEvent;
        $this->eventEmittingService->pushContext($nodeEvent);
    }