TASK: Remove example plugin
* In order to not waste time. * In order to not irritate participants with two plugins.
This commit is contained in:
parent
a99c42257c
commit
58030d7b69
9 changed files with 34 additions and 85 deletions
|
@ -1,36 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Workshop\ExampleExtension\Controller;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2018 Daniel Siepmann <coding@daniel-siepmann.de>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
||||||
* 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
|
||||||
|
|
||||||
class ExampleController extends ActionController
|
|
||||||
{
|
|
||||||
public function exampleAction()
|
|
||||||
{
|
|
||||||
// Use the code below, to output the string.
|
|
||||||
// Comment the code out, to use fluid template from
|
|
||||||
// "Resources/Private/Templates/Example/Example.html"
|
|
||||||
|
|
||||||
return 'Hello world!';
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
|
|
||||||
'Workshop.ExampleExtension',
|
|
||||||
'pluginkey',
|
|
||||||
'Example Plugin'
|
|
||||||
);
|
|
||||||
|
|
||||||
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
|
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
|
||||||
'Workshop.ExampleExtension',
|
'Workshop.ExampleExtension',
|
||||||
'Address',
|
'Address',
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
|
|
||||||
'Workshop.ExampleExtension',
|
|
||||||
'pluginkey',
|
|
||||||
[
|
|
||||||
'Example' => 'example'
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
|
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
|
||||||
'Workshop.ExampleExtension',
|
'Workshop.ExampleExtension',
|
||||||
'Address',
|
'Address',
|
||||||
|
@ -27,13 +19,13 @@
|
||||||
wizardItems {
|
wizardItems {
|
||||||
plugins {
|
plugins {
|
||||||
elements {
|
elements {
|
||||||
exampleElement {
|
address {
|
||||||
iconIdentifier = content-coffee
|
iconIdentifier = content-marker
|
||||||
title = Example title
|
title = Addresses
|
||||||
description = Example Description
|
description = Allows to List and edit addresses
|
||||||
tt_content_defValues {
|
tt_content_defValues {
|
||||||
CType = list
|
CType = list
|
||||||
list_type = exampleextension_pluginkey
|
list_type = exampleextension_address
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,8 @@ This is done with the following code in file
|
||||||
(function () {
|
(function () {
|
||||||
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
|
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
|
||||||
'Workshop.ExampleExtension',
|
'Workshop.ExampleExtension',
|
||||||
'pluginkey',
|
'Address',
|
||||||
'Example Plugin'
|
'Address Plugin'
|
||||||
);
|
);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@ -57,9 +57,9 @@ configure the plugin in :file:`ext_localconf.php`:
|
||||||
(function () {
|
(function () {
|
||||||
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
|
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
|
||||||
'Workshop.ExampleExtension',
|
'Workshop.ExampleExtension',
|
||||||
'pluginkey',
|
'Address',
|
||||||
[
|
[
|
||||||
'Example' => 'example'
|
'Address' => 'index'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
})();
|
})();
|
||||||
|
@ -83,28 +83,37 @@ for our local development instance:
|
||||||
|
|
||||||
Afterwards we should see the following error message:
|
Afterwards we should see the following error message:
|
||||||
|
|
||||||
Could not analyse class: "Workshop\\ExampleExtension\\Controller\\ExampleController" maybe not loaded or no autoloader? Class Workshop\\ExampleExtension\\Controller\\ExampleController does not exist
|
Could not analyse class: "Workshop\\ExampleExtension\\Controller\\AddressController" maybe not loaded or no autoloader? Class Workshop\\ExampleExtension\\Controller\\AddressController does not exist
|
||||||
|
|
||||||
This tells us that everything so far has worked as expected. TYPO3 tries to call our
|
This tells us that everything so far has worked as expected. TYPO3 tries to call our
|
||||||
*ExampleController*, which just does not exist yet.
|
*AddressController*, which just does not exist yet.
|
||||||
|
|
||||||
So let's create the controller with the following code in
|
So let's create the controller with the following code in
|
||||||
:file:`Classes/Controller/ExampleController.php`:
|
:file:`Classes/Controller/AddressController.php`:
|
||||||
|
|
||||||
.. literalinclude:: ../../CodeExamples/localPackages/example_extension/Classes/Controller/ExampleController.php
|
.. code-block:: php
|
||||||
:language: php
|
|
||||||
:lines: 1-27,36
|
namespace Workshop\ExampleExtension\Controller;
|
||||||
|
|
||||||
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||||
|
|
||||||
|
class AddressController extends ActionController
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
The error message should change to:
|
The error message should change to:
|
||||||
|
|
||||||
An action "exampleAction" does not exist in controller "Workshop\\ExampleExtension\\Controller\\ExampleController".
|
An action "indexAction" does not exist in controller "Workshop\\ExampleExtension\\Controller\\AddressController".
|
||||||
|
|
||||||
Yeah, we fixed the error to get the next one. Even if our class exists, the
|
Yeah, we fixed the error to get the next one. Even if our class exists, the
|
||||||
configured default action does not exist yet, so let's create it.
|
configured default action does not exist yet, so let's create it.
|
||||||
|
|
||||||
.. literalinclude:: ../../CodeExamples/localPackages/example_extension/Classes/Controller/ExampleController.php
|
.. code-block:: php
|
||||||
:language: php
|
|
||||||
:lines: 26-29,34-
|
public function indexAction()
|
||||||
|
{
|
||||||
|
return 'Hello world!';
|
||||||
|
}
|
||||||
|
|
||||||
We now should see "Hello world!" in our frontend.
|
We now should see "Hello world!" in our frontend.
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ The configuration via TypoScript has to be located at a specific path:
|
||||||
|
|
||||||
// For a specific frontend plugin of the extension
|
// For a specific frontend plugin of the extension
|
||||||
plugin {
|
plugin {
|
||||||
tx_exampleextension_pluginkey {
|
tx_exampleextension_addresspluginkey {
|
||||||
settings {
|
settings {
|
||||||
// The configuration goes here
|
// The configuration goes here
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ With our records in our template, we can iterate over them to display them.
|
||||||
.. literalinclude:: ../../CodeExamples/localPackages/example_extension/Resources/Private/Templates/Address/Index.html
|
.. literalinclude:: ../../CodeExamples/localPackages/example_extension/Resources/Private/Templates/Address/Index.html
|
||||||
:language: html
|
:language: html
|
||||||
:linenos:
|
:linenos:
|
||||||
:lines: 1-7,10
|
:lines: 2-8,11
|
||||||
|
|
||||||
Configure storage pid
|
Configure storage pid
|
||||||
---------------------
|
---------------------
|
||||||
|
@ -223,16 +223,6 @@ We could also configure the pid via TypoScript:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Add new plugin
|
|
||||||
--------------
|
|
||||||
|
|
||||||
You might have noticed that the above controller is not the same as in our first
|
|
||||||
example. We therefore can add the controller to the existing plugin or add a new
|
|
||||||
plugin for this controller.
|
|
||||||
|
|
||||||
I would recommend to create a new plugin, to separate things. The process is not
|
|
||||||
explained again. If you struggle, take a look at :ref:`add-first-plugin` again.
|
|
||||||
|
|
||||||
Check everything
|
Check everything
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@ Also the configuration of callable controller actions and caching is stored in
|
||||||
The controller
|
The controller
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
TypoScript will call Extbase, which will figure out to call the ``exampleAction``
|
TypoScript will call Extbase, which will figure out to call the ``indexAction``
|
||||||
method of our ``ExampleController``, thanks to our frontend rendering configuration.
|
method of our ``AddressController``, thanks to our frontend rendering configuration.
|
||||||
|
|
||||||
The default action is always the first action of the first controller in the
|
The default action is always the first action of the first controller in the
|
||||||
configuration. Multiple actions will be shown later.
|
configuration. Multiple actions will be shown later.
|
||||||
|
|
|
@ -37,7 +37,7 @@ edit a record, you could use the following:
|
||||||
:language: html
|
:language: html
|
||||||
:linenos:
|
:linenos:
|
||||||
:dedent: 4
|
:dedent: 4
|
||||||
:lines: 9
|
:lines: 10
|
||||||
|
|
||||||
The ViewHelper generates a link, thanks to the current plugin context, all arguments
|
The ViewHelper generates a link, thanks to the current plugin context, all arguments
|
||||||
are prefixed with the plugin namespace.
|
are prefixed with the plugin namespace.
|
||||||
|
|
|
@ -32,7 +32,7 @@ Paths
|
||||||
|
|
||||||
The path to the template of an controller action is
|
The path to the template of an controller action is
|
||||||
:file:`example_extension/Resources/Private/Templates/ControllerName/ActionName.html`,
|
:file:`example_extension/Resources/Private/Templates/ControllerName/ActionName.html`,
|
||||||
which in our example would be: :file:`example_extension/Resources/Private/Templates/Example/Example.html`,
|
which in our example would be: :file:`example_extension/Resources/Private/Templates/Address/Index.html`,
|
||||||
|
|
||||||
.. admonition:: Task
|
.. admonition:: Task
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue