PHP code example of godbout / alfred-workflow-scriptfilter

1. Go to this page and download the library: Download godbout/alfred-workflow-scriptfilter 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/ */

    

godbout / alfred-workflow-scriptfilter example snippets


composer 



use Godbout\Alfred\Workflow\ScriptFilter;

echo ScriptFilter::output();

ScriptFilter::add(
    Item::create()
        ->uid('uidd')
        ->title('titlee')
        ->subtitle('subtitlee')
        ->arg('argg')
        ->icon(
            Icon::create('icon path')
        )
        ->valid()
        ->match('matchh')
        ->autocomplete('autocompletee')
        ->mod(
            Ctrl::create()
                ->arg('ctrl arg')
                ->subtitle('ctrl subtitle')
                ->valid()
        )
        ->copy('copyy')
        ->largetype('largetypee')
        ->quicklookurl('quicklookurll')
);

ScriptFilter::add(
    Variable::create('food', 'chocolate'),
    Variable::create('dessert', 'red beans')
);

ScriptFilter::rerun(4.5);

$anotherItem = Item::create()
    ->icon(
        Icon::createFileicon('icon pathh')
    )
    ->mods(
        Shift::create()
            ->subtitle('shift subtitle'),
        Fnn::create()
            ->arg('fn arg')
            ->valid(true)
    );

$thirdItem = Item::create()
    ->variables(
        Variable::create('guitar', 'fender'),
        Variable::create('amplifier', 'orange')
    )
    ->mod(
        Alt::create()
            ->icon(
                Icon::createFileicon('alt icon path')
            )
            ->variables(
                Variable::create('grade', 'colonel'),
                Variable::create('drug', 'power')
            )
    );

ScriptFilter::add($anotherItem, $thirdItem);

echo ScriptFilter::output();


/**
 * Will sort the items ascendingly
 * based on titles.
 */
ScriptFilter::add(...);
ScriptFilter::sortItems();
ScriptFilter::output();

/**
 * Will sort the items descendingly
 * based on subtitles.
 */
ScriptFilter::add(...);
ScriptFilter::sortItems('desc', 'subtitle');
ScriptFilter::output();


/**
 * Only items with a title that contains
 * 'start' will show up in the output.
 */
ScriptFilter::add(...);
ScriptFilter::filterItems('start');
ScriptFilter::output();

/**
 * Only items with a subtitle that contains
 * 'end' will show up in the output.
 */
ScriptFilter::add(...);
ScriptFilter::filterItems('end', 'subtitle');
ScriptFilter::output();

ScriptFilter::create()
    ->item($item)
    ->variable(Variable::create('gender', 'undefined'))
    ->items($anotherItem, $oneMoreItem)
    ->variables($aVariable, $anotherVariable)
    ->rerun(4)
    ->item(Item::create());

Item::createDefault();
// same same
Item::create()->default();
// same same
Item::create()->type('default');


Item::createFile();
// same same
Item::create()->file();
// same same
Item::create()->type('file');


Item::createSkipcheck();
// same same
Item::create()->skipcheck();
// same same
Item::create()->type('file:skipcheck');


Item::create()->copy('text to copy');
// same same
Item::create()->text('copy', 'text to copy');


Item::create()->largetype('show large');
// same same
Item::create()->text('largetype', 'show large');

Icon::create('~/Desktop');
// same same
Icon::create()->path('~/Desktop');


Icon::createFileicon('~/Desktop');
// same same
Icon::create('~/Desktop')->fileicon();


Icon::createFiletype('~/Desktop');
// same same
Icon::create()->path('~/Desktop')->filetype();

Variable::create('guitar', 'fender');
// same same
Variable::create()->name('guitar')->value('fender');


/**
 * Anywhere you use the ->variable(...) fluent interface
 * you can pass the name and value arguments directly
 * if this is your thing.
 */
...->variable(Variable::create('gender', 'unknown'));
// same same
...->variable('gender', 'unknown');