PHP code example of arillo / silverstripe-utils

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

    

arillo / silverstripe-utils example snippets



use SilverStripe\CMS\Model\SiteTree;
use Arillo\Utils\FluentHelper;

class Page extends SiteTree
{
    public function onBeforeDelete()
    {
        parent::onBeforeDelete();
        FluentHelper::force_delete($this); // insert this
    }
}


use SilverStripe\CMS\Model\SiteTree;
use Arillo\Utils\CMS;

class Page extends SiteTree
{
    public function getCMSActions()
    {
        return CMS::remove_campaign_actions(parent::getCMSActions());
    }
}


use SilverStripe\CMS\Model\SiteTree;
use Arillo\Utils\AlertField;

class Page extends SiteTree
{
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->addFieldToTab(
            'Root.Main',
            AlertField::create('PageInfo', "Page type: {$this->ClassName}", 'dark')
        , 'Title');
        return $fields;
    }
}