PHP code example of wilr / silverstripe-tasker

1. Go to this page and download the library: Download wilr/silverstripe-tasker 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/ */

    

wilr / silverstripe-tasker example snippets




use Wilr\SilverStripe\Tasker\Traits\TaskHelpers;
use Wilr\SilverStripe\Tasker\Traits\TaskerFormatter;
use SilverStripe\Dev\BuildTask;

class MyAppUpgradeTask extends BuildTask
{
    use TaskerFormatter;
    use TaskHelpers;

    public function run()
    {
        $this->echoHeading('My Heading');
        
        $this->archivePage(10);
        
        // any other tasks as below.
        
        if ($wrong) {
            $this->echoWarning('Shows a warning message');
        } else {
            $this->echoSuccess('Outputs a tick');
        }

        while (true) {
            // displays progress dots
            $this->echoProgress();
        }
    }
}

SilverStripe\CMS\Model\SiteTree:
  migration_on_build: true
  latest_schema_version: 2
  migration_class: 'MyAppUpgradeTask'