PHP code example of ttree / jobbutler

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

    

ttree / jobbutler example snippets



namespace Your\Package\JobConfiguration;

use \Ttree\JobButler\Domain\Model\AbstractJobConfiguration;
use \Ttree\JobButler\Domain\Model\DocumentJobTrait;
use \Ttree\JobButler\Domain\Model\JobConfigurationOptions;

/**
 * Export Document Job
 */
class ExportDocumentJob extends AbstractJobConfiguration
{
    use DocumentJobTrait;
    
    public function getIcon()
    {
        return 'print';
    }

    public function execute(JobConfigurationOptions $options = null)
    {
        $context = $this->createContext('live');
        $sideNode = $context->getNode('/sites/yoursite');
        $flowQuery = new FlowQuery(array($sideNode));
        $flowQuery = $flowQuery->find('[instanceof TYPO3.Neos.NodeTypes:Page]');
        $writer = Writer::createFromFileObject(new \SplTempFileObject());
        $writer->insertOne([
            'identifier' => 'Identifier',
            'title' => 'Page Title'
        ]);

        foreach ($flowQuery as $node) {
            /** @var NodeInterface $node */
            $writer->insertOne([
                'identifier' => $node->getIdentifier(),
                'title' => $node->getProperty('title')
            ]);
        }

        $this->writeDocument($this->getOption('document', 'export.csv'), $writer);
        
        return true;
    }

    public function getPackageKey()
    {
        return "Vendor.PackageKey";
    }

}



namespace Your\Package\JobConfiguration;

/**
 * Export Profile Index Job
 */
class ExportDocumentWizard extends AbstractFormFactory {

    /**
     * @param array $factorySpecificConfiguration
     * @param string $presetName
     * @return \TYPO3\Form\Core\Model\FormDefinition
     */
    public function build(array $factorySpecificConfiguration, $presetName) {
        $formConfiguration = $this->getPresetConfiguration($presetName);
        $form = new FormDefinition('options', $formConfiguration);

        $page = $form->createPage('page');

        $reportIdentifier = $page->createElement('reportIdentifier', 'TYPO3.Form:SingleLineText');
        $reportIdentifier->setLabel('Report Identifier');
        $reportIdentifier->addValidator(new NotEmptyValidator());

        return $form;
    }
}

xml
    ...
    
    /**
     * {@inheritdoc}
     */
    public function getWizardFactoryClass()
    {
        return 'Your\Package\JobConfiguration\ExportDocumentWizard';
    }
    
    ...