ttree/jobbutler

Neos CMS 包,帮助编辑和管理者管理任务。任务可以是任何东西

安装: 640

依赖项: 0

建议者: 0

安全: 0

星级: 5

关注者: 5

分支: 1

开放问题: 4

类型:typo3-flow-package

0.9.3 2017-02-10 22:00 UTC

This package is auto-updated.

Last update: 2024-08-26 04:20:22 UTC


README

StyleCI

简介

Neos CMS 包,帮助编辑和管理者管理任务。任务可以是任何东西

  • 从外部源导入数据
  • 导出数据(CSV、...)
  • ETL
  • 分析
  • ...

与 Neos CMS 1.2-2.0+ 兼容。此包已准备好使用 Composer,遵循 PSR-2PSR-4

目前此包处于开发中,版本 1.0 尚未发布,可能发生破坏性更改

特性

该包提供了一个具有简单界面的后端模块,编辑或管理员可以

  • 查看所有可用的任务
  • 手动执行任务
  • 在手动执行之前向任务传递选项
  • 通过搜索过滤任务列表
  • 通过标签过滤任务列表
  • 任务可以生成文件(导出),使用 DocumentJobTrait
  • 创建网络钩子以从外部源触发任务执行
  • 安排任务(集成 Ttree.Scheduler)
  • 查看特定任务的执行历史

Backend Module

检查问题跟踪器以关注正在进行的特性。

安装

composer require "ttree/jobbutler"

如何注册新任务

任务是基于 JobConfigurationInterface 的 PHP 类。默认情况下,您可以使用提供良好默认值和辅助工具的抽象类 AbstractJobConfiguration

您可以创建一个简单的类,如下所示

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

}

DocumentJobTrait::writeDocument 方法将自动创建一个名为 "Export" 的新资产集合(检查 Settings.yaml 以更改资产集合名称)。生成的文档存储在公共资源文件夹之外,检查 Settings.yaml 以更改默认路径。

现在在同一包中创建一个名为 Jobs.xlf 的 XLIFF 文件,内容如下

<?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>

您可以扩展此任务以从 Google Analytics 获取数据,您将有一个很棒的工作表来处理内容清单...

现在转到后端模块,您应该会看到您的任务,准备好执行。

如何配置新任务

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

目前 AbstractJobConfiguration 支持以下设置

  • icon(字符串),默认 'task'
  • tags(数组),默认空数组
  • wizardFactoryClass(字符串),默认 null
  • privilegeTarget(字符串),默认 null
  • asynchronous(布尔值),默认 false

在执行任务之前添加配置向导

您的任务需要提供一个表单工厂以渲染表单

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

提供一个简单的工厂

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

RenderViewHelper 负责完成器配置和参数处理。

设置

  • maximumExecutionTime:覆盖 php.ini 中的系统最大执行时间(默认:300)

致谢

ttree ltd - neos solution provider 赞助开发。

我们尽力用爱心制作此包,我们欢迎赞助、支持请求...请联系我们。

许可证

MIT 许可证(MIT)。有关更多信息,请参阅 LICENSE