[TASK] Move ext:sys_action/x-sys_action.png to correct location
[Packages/TYPO3.CMS.git] / typo3 / sysext / taskcenter / Documentation / DevelopersGuide / CreatingANewTask / Index.rst
1 .. ==================================================
2 .. FOR YOUR INFORMATION
3 .. --------------------------------------------------
4 .. -*- coding: utf-8 -*- with BOM.
5
6 .. include:: ../../Includes.txt
7
8
9
10 .. _create-new-task:
11
12 Creating a new task
13 ^^^^^^^^^^^^^^^^^^^
14
15
16 .. _create-task-class:
17
18 Creating the task class
19 """""""""""""""""""""""
20
21 This is the heart of a task. It is the code that actually does what
22 the task is supposed to do. A task is represented by a PHP class that
23 implements the interface :code:`\TYPO3\CMS\Taskcenter\TaskInterface`:
24
25 ::
26
27 namespace Foo\Bar\Task;
28 class DoSomething implements \TYPO3\CMS\Taskcenter\TaskInterface {
29 public function getTask() {
30 ...
31 }
32 public function getOverview() {
33 ...
34 }
35 }
36
37 The 2 mentioned method **must** be implemented!
38
39 getTask()
40 The function :code:`getTask()` is expected to perform the task logic and
41 returns the content of the task.
42
43 getOverview()
44 The function :code:`getOverview()` creates an optional menu of items or
45 description which is rendered in the menu of tasks.
46
47
48 .. _autoloading:
49
50 Autoloading
51 """""""""""
52
53 The Taskcenter expects all task classes to be available with the TYPO3
54 autoloader. They thus must be declared in the
55 :file:`ext\_autoload.php` file of the extension that provides these
56 classes. Again the :file:`ext\_autoload.php` file of sys\_action can
57 be used as an example.
58
59
60 .. _declare-task-class:
61
62 Declaring the task class
63 """"""""""""""""""""""""
64
65 As a last step, the task class must be declared so the Taskcenter
66 knows of its existence. The declaration must be placed in the
67 :file:`ext_tables.php` file of the extension that provides the
68 task. Let's look at the declaration of sys\_action as an example:
69
70 ::
71
72 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['taskcenter']['sys_action']['tx_sysaction_task'] = array(
73 'title' => 'LLL:EXT:sys_action/locallang_tca.xlf:sys_action',
74 'description' => 'LLL:EXT:sys_action/locallang_csh_sysaction.xlf:.description',
75 'icon' => 'EXT:sys_action/Resources/Public/Images/x-sys_action.png'
76 );
77
78 The registration is made in the array
79 :code:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['taskcenter']`. A key is
80 then used that corresponds to the task class (in bold above). Then
81 come 3 parameters:
82
83 - **title** : the name of the task. May use localized labels.
84
85 - **description** : a text describing the task. It is displayed in the
86 information screen of the BE module. May use localized labels.
87
88 - **icon** : Path to an icon for the task.
89