ttree/jobbutler

Neos CMS package to help Editors and Administrators to manage Jobs

Installs: 640

Dependents: 0

Suggesters: 0

Security: 0

Stars: 5

Watchers: 5

Forks: 1

Open Issues: 4

Type:typo3-flow-package

0.9.3 2017-02-10 22:00 UTC

This package is auto-updated.

Last update: 2024-04-26 03:44:13 UTC


README

StyleCI

Introduction

Neos CMS package to help Editors and Administrators to manage Jobs. Jobs can be anything:

  • Import data from external source
  • Export data (CSV, ...)
  • ETL
  • Analytics
  • ...

Works with Neos CMS 1.2-2.0+. This package is Composer ready, PSR-2 and PSR-4 compliant.

Currently this package is under development and version 1.0 is not out, breaking change can happen

Features

The package provide a backend module with a simple interface where Editors or Administrators can:

  • View all available Jobs
  • Manual Job execution
  • Pass options to a Job before manual execution
  • Filter job list by searching
  • Filter job list by tagging
  • Job can produce files (export), use the DocumentJobTrait
  • Create web hook to trigger job execution from external source
  • Schedule a Job (integrate with Ttree.Scheduler)
  • View the execution history for a given Job

Backend Module

Check the issue tracker to follow ongoing features.

Installation

composer require "ttree/jobbutler"

How to register a new Job

A Job is a PHP class based on JobConfigurationInterface. By default you can use the AbstractJobConfiguration abstract class that offer nice defaults and helpers for general usage.

You can create a simple class like this one:

<?php
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";
    }

}

The method DocumentJobTrait::writeDocument will automatically create a new AssetCollection name "Export" (check Settings.yaml to change the asset collection name). Generated document are stored outside of the public resource folder, check Settings.yaml to change the default path.

Now create a XLIFF file name Jobs.xlf in the same package, with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
    <file original="" product-name="Your.Package" source-language="en" datatype="plaintext">
        <body>
            <trans-unit id="your.package.jobconfiguration.exportdocumentjob.name" xml:space="preserve">
				<source>Export all Pages</source>
			</trans-unit>
			<trans-unit id="your.package.jobconfiguration.exportdocumentjob.description" xml:space="preserve">
				<source>Export a single CSV file with all Pages identifier and title.</source>
			</trans-unit>
        </body>
    </file>
</xliff>

You can extend this Job to get data from Google Analytics and you have a nice spreadsheet to work on Content Inventory ...

Now go to the backend module, you should see your Job, ready for execution.

How to configure a new Job

Ttree:
  JobButler:
    jobSettings:
      'Your\Package\JobConfiguration\ExportDocumentJob':
        'icon': 'circle-arrow-down'
        'wizardFactoryClass': 'Your\Package\JobConfiguration\Wizard\ExportProfileByReportWizard'

Currently the following settings are supported by AbstractJobConfiguration:

  • icon (string), default 'task'
  • tags (array), default emtpy array
  • wizardFactoryClass (string), default null
  • privilegeTarget (string), default null
  • asynchronous (boolean), default false

Adding a configuration Wizard before executing a Job

Your Job need to provide a Form factory to render the form:

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

Provide a simple Factor:

<?php
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;
    }
}

The ``RenderViewHelper``` take care for the finisher configuration and arguments processing.

Settings

  • maximumExecutionTime: Override the system maximum excution time from the php.ini (default: 300)

Acknowledgments

Development sponsored by ttree ltd - neos solution provider.

We try our best to craft this package with a lots of love, we are open to sponsoring, support request, ... just contact us.

License

The MIT License (MIT). Please see LICENSE for more information.