PHP code example of lumturo-net / contao-globals-wrapper

1. Go to this page and download the library: Download lumturo-net/contao-globals-wrapper 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/ */

    

lumturo-net / contao-globals-wrapper example snippets


use LumturoNet\Globals\Dca;

$dca = Dca::new(string $namespace);

$dca->config()
    ->dataContainer('Table')
    ->cTable(['tl_tabelle'])
    ->enableVersioning()
    ->custom([
        // Eigene Konfigurationsfelder
    ])
    ->sql([
        'keys' => ['id' => 'primary']
    ]);

$dca->list()
    ->sorting()
        ->fields(['title'])
        ->mode(1)
        ->flag(11)
        ->panelLayout('search;filter')
        ->compile()
    ->label()
        ->fields(['title'])
        ->compile()
    ->globalOperations('all')
        ->label($label)
        ->href()
        ->class()
        ->attributes()
        ->compile()
    ->operations('edit')
        ->href()
        ->icon()
        ->compile()

$dca->fields('mein_feld')
    ->text()
    ->label(string|array $label)
    ->exclude()
    ->eval()
        ->mandatory()
        ->maxlength(255)
        ->compile()
    ->relation([
        'hasOne' => 'lazy'    
    ])
    ->sql()

$dca->palettes(string $palette)
    ->group('title_legend' [string $translations, boolean $hidden])
    ->fields([
        'mein_feld',
        'anderes_feld',
        'nochein_feld'
    ])
    ->compile()

$dca->subpalette('mein_feld')
    ->fields([
        'unterfeld_1',
        'unterfeld_2'
    ])
    ->compile();

use LumturoNet\Globals\Cte;
use Namespace\Elements\MyCustomElement1;
use Namespace\Elements\MyCustomElement2;
use Namespace\Elements\MyCustomElement3;

Cte::new(string $namespace)->push([
    'MyCustomElement1' => MyCustomElement1::class,
    'MyCustomElement2' => MyCustomElement2::class,
    'MyCustomElement3' => MyCustomElement3::class,
]);

use LumturoNet\Globals\Lang;

$lang = Lang::set($namespace);
$lang->trans('MyCustomElement1', 'Ein cooles Inhaltselement')
     ->trans('MyCustomElement2', 'Und noch eins')
     ->trans('MyCustomElement3', 'Elemente gründen Gewerkschaft');
     ->trans('sharkday', ['Haitag', 'Es ist Haitag']);

use LumturoNet\Globals\Lang;

Lang::set($namespace);

$dca->field('text')
    ->label(__('sharkday'));

use LumturoNet\Globals\Lang;

$dca->field('text')
    ->label(__('deleteConfirm', 'MSC'));

use LumturoNet\Globals\Models;

use Namespace\Models\MyModel;
use Namespace\Models\MySecondModel;

Models::bind([
    'tl_tabelle'   => MyModel:class,
    'tl_tabelle_2' => MySecondModel::class,
    ...
]);

use LumturoNet\Globals\Backend;

Backend::new(string $namespace, string $module, [int $position = 1])->tables([
    'tl_tabelle_1',
    'tl_tabelle_2',
    ...
]);

use LumturoNet\Globals\Hooks;
use Namespace\Hooks\AddCommentHook;

$hooks = Hooks::get()
$hooks->activateAccount(array $myCallback)
      ->addComment([AddCommentHook::class, 'addCommentHook']);
 
use LumturoNet\Globals\Css;

Css::push([
    'path/to/file1.css',
    'path/to/file2.css',
    ...
]);