TASK: Remove example plugin

* In order to not waste time.
* In order to not irritate participants with two plugins.
This commit is contained in:
Daniel Siepmann 2019-03-01 10:06:54 +01:00
parent a99c42257c
commit 58030d7b69
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
9 changed files with 34 additions and 85 deletions

View file

@ -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!';
}
}

View file

@ -1,12 +1,6 @@
<?php
(function () {
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Workshop.ExampleExtension',
'pluginkey',
'Example Plugin'
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Workshop.ExampleExtension',
'Address',

View file

@ -1,14 +1,6 @@
<?php
(function () {
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Workshop.ExampleExtension',
'pluginkey',
[
'Example' => 'example'
]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Workshop.ExampleExtension',
'Address',
@ -27,13 +19,13 @@
wizardItems {
plugins {
elements {
exampleElement {
iconIdentifier = content-coffee
title = Example title
description = Example Description
address {
iconIdentifier = content-marker
title = Addresses
description = Allows to List and edit addresses
tt_content_defValues {
CType = list
list_type = exampleextension_pluginkey
list_type = exampleextension_address
}
}
}

View file

@ -37,8 +37,8 @@ This is done with the following code in file
(function () {
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Workshop.ExampleExtension',
'pluginkey',
'Example Plugin'
'Address',
'Address Plugin'
);
})();
@ -57,9 +57,9 @@ configure the plugin in :file:`ext_localconf.php`:
(function () {
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'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:
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
*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
:file:`Classes/Controller/ExampleController.php`:
:file:`Classes/Controller/AddressController.php`:
.. literalinclude:: ../../CodeExamples/localPackages/example_extension/Classes/Controller/ExampleController.php
:language: php
:lines: 1-27,36
.. code-block:: php
namespace Workshop\ExampleExtension\Controller;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class AddressController extends ActionController
{
}
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
configured default action does not exist yet, so let's create it.
.. literalinclude:: ../../CodeExamples/localPackages/example_extension/Classes/Controller/ExampleController.php
:language: php
:lines: 26-29,34-
.. code-block:: php
public function indexAction()
{
return 'Hello world!';
}
We now should see "Hello world!" in our frontend.

View file

@ -70,7 +70,7 @@ The configuration via TypoScript has to be located at a specific path:
// For a specific frontend plugin of the extension
plugin {
tx_exampleextension_pluginkey {
tx_exampleextension_addresspluginkey {
settings {
// The configuration goes here
}

View file

@ -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
:language: html
:linenos:
:lines: 1-7,10
:lines: 2-8,11
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
----------------

View file

@ -39,8 +39,8 @@ Also the configuration of callable controller actions and caching is stored in
The controller
--------------
TypoScript will call Extbase, which will figure out to call the ``exampleAction``
method of our ``ExampleController``, thanks to our frontend rendering configuration.
TypoScript will call Extbase, which will figure out to call the ``indexAction``
method of our ``AddressController``, thanks to our frontend rendering configuration.
The default action is always the first action of the first controller in the
configuration. Multiple actions will be shown later.

View file

@ -37,7 +37,7 @@ edit a record, you could use the following:
:language: html
:linenos:
:dedent: 4
:lines: 9
:lines: 10
The ViewHelper generates a link, thanks to the current plugin context, all arguments
are prefixed with the plugin namespace.

View file

@ -32,7 +32,7 @@ Paths
The path to the template of an controller action is
: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