【问题标题】:Typo3 - Extbase CommandController for scheduler taskTypo3 - 用于调度程序任务的 Extbase CommandController
【发布时间】:2015-07-09 09:06:24
【问题描述】:

我创建了一个空的 extbase/fluid 扩展,并为调度程序任务添加了一个 ImportCommandController。出于某种原因,我无法在我的调度程序中加载该任务。请注意,我想通过 CommandController (http://wiki.typo3.org/CommandController_In_Scheduler_Task) 和 NOT 通过 \TYPO3\CMS\Scheduler\Task\AbstractTask 来实现我的任务。

ext_localconf.php

<?php
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'VENDORx\\Sched\\Command\\ImportCommandController';

类/命令/ImportCommandController.php

<?php
    namespace VENDORx\Sched\Command;


    /**
     *
     *
     * @package Sched
     * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
     *
     */

    class ImportCommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandController {

        public function importCommand($commandIdentifier= NULL) {

        echo 'command run';

        }
      }
?>

知道缺少什么吗?

【问题讨论】:

  • 我不确定,但可能缺少importCommand()-method 的 phpdoc-comment。如果你运行php typo3/cli_dispatch.phpsh extbase help,至少会显示它的内容,所以它会被解释。
  • 我拿走了你的代码,添加了一个ext_emconf.php,安装了扩展 - 它工作正常(即新任务出现在下拉列表中)。我没有按照@Jost 和@Daniel 的建议向importCommand 添加注释。我使用的是 Windows 7,而且 - 与你不同 - Typo3 7.5.0。
  • ... 但是,实际运行您的任务需要提到的注释。没有它,我会收到以下错误消息:“任务“Extbase CommandController Task (extbase)”的执行失败,并显示以下消息:方法 [...]->importCommand() 的参数 $commandIdentifier 的参数类型不能是检测到。'

标签: typo3 extbase typo3-6.2.x


【解决方案1】:

正如 Jost 已经提到的,您需要正确的注释:

/**
 * @param integer $commandIdentifier 
 */
public function importCommand($commandIdentifier = NULL) {
    $this->outputLine('command run');
}

【讨论】:

  • 我已经修改了我的 CommadController 类,但我仍然不能“使用”它。我无法通过 T3 调度程序添加它。我已经制作了调度程序 BE 的屏幕截图。 i.imgur.com/j6VZ0rK.png
  • 黄色标记的下拉菜单不包含我的 importCommand。我一定是错过了什么。
  • 你的扩展安装了吗? ;)
  • 在我的例子中是自动加载。清除自动加载缓存或只是卸载/重新安装扩展有帮助。
【解决方案2】:

在下拉列表中选择“Extbase-CommandController-Task” 您将在底部获得另一个选择字段,您可以在其中找到“ImportCommand”选择并保存

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    • 2023-04-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多