PHP code example of revstrat / silverstripe-agegate

1. Go to this page and download the library: Download revstrat/silverstripe-agegate library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

revstrat / silverstripe-agegate example snippets

/dev/build?flush=all

public function updateGetShowAgeGate(&$ageGateActive, &$sufficientAge) {
        
    }

    public function updateAgeGateForm(&$fields, &$actions, $minimumAge) {
    	$fields->removeByName('OfAge');
    	$actions = new FieldList(
    		FormAction::create('passAgeGate')->setTitle("Yes I'm over $minimumAge"),
    		FormAction::create('failAgeGate')->setTitle("I'm not $minimumAge yet")
    	);
    }

    public function passAgeGate($data, Form $form) {
    	$data['OfAge'] = true;
    	return $this->doAgeGate($data, $form);
    }

    public function failAgeGate($data, Form $form) {
    	$data["OfAge"] = false;
    	return $this->doAgeGate($data, $form);
    }