diff --git a/Classes/Command/ExampleCommandController.php b/Classes/Command/ExampleCommandController.php index 6ea89a4..03e0bca 100644 --- a/Classes/Command/ExampleCommandController.php +++ b/Classes/Command/ExampleCommandController.php @@ -2,17 +2,18 @@ namespace EHAERER\EhBootstrap\Command; /** - * This file is part of the "news" Extension for TYPO3 CMS. + * This file is part of the "eh_bootstrap" Extension for TYPO3 CMS. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. */ -use TYPO3\CMS\Extbase\Mvc\Controller\CommandController; +use \TYPO3\CMS\Extbase\Mvc\Controller\CommandController; use \TYPO3\CMS\Core\Utility\GeneralUtility; use \TYPO3\CMS\Core\Messaging\FlashMessage; /** * Example controller + * [Example-11] * */ class ExampleCommandController extends CommandController @@ -28,10 +29,12 @@ class ExampleCommandController extends CommandController public function runCommand($required, $optional = false, $string = '') { $message = 'Required: ' . $required . ' | optional:' . $optional . ' | string:' . $string; + /* @var $messageOut \TYPO3\CMS\Core\Messaging\FlashMessage */ $messageOut = GeneralUtility::makeInstance( \TYPO3\CMS\Core\Messaging\FlashMessage::class, $message, 'Field content', FlashMessage::OK, FALSE ); // get backend message queue + /* @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */ $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); // add message diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index b85bc2c..43c765c 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -26,15 +26,9 @@ * This copyright notice MUST APPEAR in all copies of the script! * ************************************************************* */ -use \TYPO3\CMS\Core\Messaging\FlashMessage; -use \TYPO3\CMS\Core\Utility\GeneralUtility; -use \TYPO3\CMS\Core\Utility\DebugUtility; -use \TYPO3\CMS\Extbase\Utility\LocalizationUtility; -use \TYPO3\CMS\Extbase\Utility\DebuggerUtility; -use \TYPO3\CMS\Core\Utility\ExtensionManagementUtility; - /** * AbstractController + * [Example-5] */ class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController { @@ -67,11 +61,13 @@ public function __construct() parent::__construct(); /* [Example-1] */ + /* visit at the file ext_conf_template.txt to see all options */ $this->emSettings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]); } /** * action plugin + * Output of the extbase plugin in backend * * @return \string The rendered view. */ @@ -86,6 +82,9 @@ public function pluginAction() /** * action render + * loaded via AJAX to demonstrate the rendering via AJAX + * [Example-6] + * [Example-7] * * @return \string The rendered view. */ @@ -109,6 +108,8 @@ public function renderAction() /** * action module + * used for the backend module + * [Example-9] * * @return \string The rendered view. For the backend module */ diff --git a/Classes/Eid/ExtbaseDispatcher.php b/Classes/Eid/ExtbaseDispatcher.php index e9a43d9..f7a7d74 100644 --- a/Classes/Eid/ExtbaseDispatcher.php +++ b/Classes/Eid/ExtbaseDispatcher.php @@ -24,6 +24,7 @@ * This copyright notice MUST APPEAR in all copies of the script! * * + * [Example-6] * Usage of this script: * * - Copy this script in your Extension Dir in the Folder Classes @@ -31,9 +32,10 @@ * - Include the next line in the ext_localconf.php, change the ext name! * - $TYPO3_CONF_VARS['FE']['eID_include']['myExtAjaxDispatcher'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('myExtension').'Classes/Eid/EidDispatcher.php'; * - * tested with TYPO3 7.6 + * tested with TYPO3 7.6 and 8.7 * - * Use for Ajax Calls in your jQuery Code: + * Usage for AJAX calls in your jQuery Code: + * see example file Resources/Public/JavaScript/main.js * * $('.jqAjax').click(function(e) { * var uid = $(this).find('.uid').html(); @@ -64,9 +66,9 @@ * } * }); * ************************************************************* */ -/** - * Gets the Ajax Call Parameters - */ +/* * ********************************** + * Gets the AJAX Call Parameters + * ********************************* */ $ajax = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('request'); /** * Set Vendor and Extension Name @@ -92,56 +94,62 @@ global $TYPO3_CONF_VARS; -$GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class, $TYPO3_CONF_VARS, $pid, 0); +/* @var $GLOBALS['TSFE'] \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController */ +$GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class, $TYPO3_CONF_VARS, $pid, 0); \TYPO3\CMS\Frontend\Utility\EidUtility::initLanguage(); -//init TCA to load content elements -//\TYPO3\CMS\Frontend\Utility\EidUtility::initTCA(); // Get FE User Information $GLOBALS['TSFE']->initFEuser(); // get backend user information $GLOBALS['TSFE']->initializeBackendUser(); -//init TCA to load content elements +// init TCA to load content elements \TYPO3\CMS\Frontend\Utility\EidUtility::initTCA(); -// Important: no Cache for Ajax stuff +// disable Cache for AJAX calls $GLOBALS['TSFE']->set_no_cache(); -//$GLOBALS['TSFE']->checkAlternativCoreMethods(); +// Provides ways to bypass the '?id=[xxx]&type=[xx]' format $GLOBALS['TSFE']->checkAlternativeIdMethods(); +// Determines the id and evaluates any preview settings $GLOBALS['TSFE']->determineId(); +// Initialize the TypoScript template parser $GLOBALS['TSFE']->initTemplate(); +// Checks if config-array exists already but if not, gets it $GLOBALS['TSFE']->getConfigArray(); -//\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($GLOBALS['TSFE']); die(); -//\TYPO3\CMS\Core\Core\Bootstrap::getInstance(); -//\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->loadConfigurationAndInitialize(); -$GLOBALS['TSFE']->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer'); +/* @var $GLOBALS['TSFE']->cObj \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer */ +$GLOBALS['TSFE']->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class); +// Setting the language key that will be used by the current page $GLOBALS['TSFE']->settingLanguage(); +// Setting locale for frontend rendering $GLOBALS['TSFE']->settingLocale(); -/** - * @var $objectManager \TYPO3\CMS\Extbase\Object\ObjectManager - */ -$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager'); -/** - * Initialize Extbase bootstap - */ -$bootstrapConf['extensionName'] = $ajax['extensionName']; -$bootstrapConf['pluginName'] = $ajax['pluginName']; -$bootstrap = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Core\Bootstrap'); +/* @var $objectManager \TYPO3\CMS\Extbase\Object\ObjectManager */ +$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); +/* * ********************************* + * Initialize the Extbase bootstap + * ******************************** */ +$bootstrapConf = [ + 'extensionName' => $ajax['extensionName'], + 'pluginName' => $ajax['pluginName'], +]; +/* @var $bootstrap \TYPO3\CMS\Extbase\Core\Bootstrap */ +$bootstrap = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Core\Bootstrap::class); $bootstrap->initialize($bootstrapConf); -$bootstrap->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer'); -//\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; -/** +/* @var $bootstrap->cObj \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer */ +$bootstrap->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class); +/* * *****$bootstrap************* * Build the request - */ -$request = $objectManager->get('TYPO3\CMS\Extbase\Mvc\Request'); + * ***************** */ +/* @var $request \TYPO3\CMS\Extbase\Mvc\Request */ +$request = $objectManager->get(\TYPO3\CMS\Extbase\Mvc\Request::class); $request->setControllerVendorName($ajax['vendor']); $request->setcontrollerExtensionName($ajax['extensionName']); $request->setPluginName($ajax['pluginName']); $request->setControllerName($ajax['controller']); $request->setControllerActionName($ajax['action']); $request->setArguments($ajax['arguments']); -$request->setFormat("html"); // set to use html file as template -> default is txt -$response = $objectManager->get('TYPO3\CMS\Extbase\Mvc\ResponseInterface'); -$dispatcher = $objectManager->get('TYPO3\CMS\Extbase\Mvc\Dispatcher'); +// set to use html file as template -> default is txt file +$request->setFormat("html"); +/* @var $response \TYPO3\CMS\Extbase\Mvc\ResponseInterface */ +$response = $objectManager->get(\TYPO3\CMS\Extbase\Mvc\ResponseInterface::class); +/* @var $dispatcher \TYPO3\CMS\Extbase\Mvc\Dispatcher */ +$dispatcher = $objectManager->get(\TYPO3\CMS\Extbase\Mvc\Dispatcher::class); $dispatcher->dispatch($request, $response); echo $response->getContent(); -//die(); \ No newline at end of file diff --git a/Classes/Hooks/PageLayoutView/NewContentElementPreviewRenderer.php b/Classes/Hooks/PageLayoutView/NewContentElementPreviewRenderer.php index 9b60f1d..4c366a3 100644 --- a/Classes/Hooks/PageLayoutView/NewContentElementPreviewRenderer.php +++ b/Classes/Hooks/PageLayoutView/NewContentElementPreviewRenderer.php @@ -21,6 +21,7 @@ /** * Contains a preview rendering for the page module of CType="eh_bs_01" + * [Example-4] */ class NewContentElementPreviewRenderer implements PageLayoutViewDrawItemHookInterface { @@ -66,6 +67,7 @@ public function preProcess( */ protected function renderFluidStandAlone($templatePath = 'Abstract/PluginPreview.html') { + /* @var $view \TYPO3\CMS\Fluid\View\StandaloneView */ $view = GeneralUtility::makeInstance(\TYPO3\CMS\Fluid\View\StandaloneView::class); $view->getRequest()->setControllerExtensionName($this->extKey); // path the extension name to get translation work $view->setPartialRootPaths(array(100 => ExtensionManagementUtility::extPath($this->extKey) . 'Resources/Private/Partials/')); diff --git a/Classes/Task/Example.php b/Classes/Task/Example.php index 01e92fa..c6ed3e4 100644 --- a/Classes/Task/Example.php +++ b/Classes/Task/Example.php @@ -29,19 +29,20 @@ use \TYPO3\CMS\Core\Utility\GeneralUtility; /** + * [Example-10] * task class which executes only another class * see: http://docs.typo3.org/typo3cms/extensions/scheduler/latest/DevelopersGuide/CreatingTasks/Index.html */ class Example extends \TYPO3\CMS\Scheduler\Task\AbstractTask { - /* + + /** * executed by scheduler */ - public function execute() { - - // initialize task class + // initialize task class via make instance because it's easier to add/update the fields later + /* @var $exampleTask \EHAERER\EhBootstrap\Task\ExampleTask */ $exampleTask = GeneralUtility::makeInstance(\EHAERER\EhBootstrap\Task\ExampleTask::class); return $exampleTask->run($this->link, $this->translang); } diff --git a/Classes/Task/ExampleTask.php b/Classes/Task/ExampleTask.php index a51bc25..69d54ba 100644 --- a/Classes/Task/ExampleTask.php +++ b/Classes/Task/ExampleTask.php @@ -29,6 +29,11 @@ use \TYPO3\CMS\Core\Utility\GeneralUtility; use \TYPO3\CMS\Core\Messaging\FlashMessage; +/** + * [Example-10] + * task class which will be instantiated by the default scheduler class + * see: http://docs.typo3.org/typo3cms/extensions/scheduler/latest/DevelopersGuide/CreatingTasks/Index.html + */ class ExampleTask { @@ -47,12 +52,14 @@ class ExampleTask */ public function run($link, $transLang) { + /* @var $messageOut \TYPO3\CMS\Core\Messaging\FlashMessage */ $messageOut = GeneralUtility::makeInstance( \TYPO3\CMS\Core\Messaging\FlashMessage::class, 'Configured link: ' . $link . ' | Configured language: ' . $transLang, 'Field content', FlashMessage::OK, FALSE ); // get backend message queue + /* @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */ $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); - $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); + $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier('ehBoostrap.task.default'); // add message $flashMessageQueue->enqueue($messageOut); diff --git a/Classes/Task/ExampleTaskFields.php b/Classes/Task/ExampleTaskFields.php index 62aa7ec..b6d291f 100644 --- a/Classes/Task/ExampleTaskFields.php +++ b/Classes/Task/ExampleTaskFields.php @@ -31,6 +31,11 @@ use \TYPO3\CMS\Core\Utility\GeneralUtility; use \TYPO3\CMS\Core\Utility\DebugUtility; +/** + * [Example-10] + * additional task class to add custom fields in the scheduler + * @see https://docs.typo3.org/typo3cms/extensions/scheduler/DevelopersGuide/CreatingTasks/Index.html + */ class ExampleTaskFields implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface { @@ -120,12 +125,14 @@ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Sched if (!empty($errors)) { foreach ($message as $m) { + /* @var $messageOut \TYPO3\CMS\Core\Messaging\FlashMessage */ $messageOut = GeneralUtility::makeInstance( \TYPO3\CMS\Core\Messaging\FlashMessage::class, $m['body'], $m['head'], FlashMessage::ERROR, FALSE ); // get backend message queue + /* @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */ $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); - $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); + $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier('ehBoostrap.task.default'); // add message $flashMessageQueue->enqueue($messageOut); } diff --git a/Classes/ViewHelpers/FlashMessagesViewHelper.php b/Classes/ViewHelpers/FlashMessagesViewHelper.php index cc82b55..55320b4 100644 --- a/Classes/ViewHelpers/FlashMessagesViewHelper.php +++ b/Classes/ViewHelpers/FlashMessagesViewHelper.php @@ -5,6 +5,7 @@ /** * Display core flash messages + * [Example-13] * * @package EHAERER\EhBootstrap\ViewHelpers */ diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php index 607feb8..bbb61e5 100644 --- a/Configuration/TCA/Overrides/sys_template.php +++ b/Configuration/TCA/Overrides/sys_template.php @@ -1,5 +1,5 @@ + + * updated coding with more annotations and links for documentation + * release of version 1.0.4 + + 2017-09-10 Ephraim Härer * improved compatibility with TYPO3 8 diff --git a/Documentation/Developer/Index.rst b/Documentation/Developer/Index.rst index d5c852a..d9b9537 100644 --- a/Documentation/Developer/Index.rst +++ b/Documentation/Developer/Index.rst @@ -51,14 +51,5 @@ could be accessed inside of the class. $this->emSettings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]); } -or some other language: - -.. code-block:: javascript - :linenos: - :emphasize-lines: 2-4 - - $(document).ready( - function () { - doStuff(); - } - ); +You should also read the documentation on https://docs.typo3.org/typo3cms/CoreApiReference/ExtensionArchitecture/ConfigurationOptions/Index.html +and the information on https://docs.typo3.org/typo3cms/TyposcriptSyntaxReference/TypoScriptTemplates/TheConstantEditor/Index.html#constant-editor. \ No newline at end of file diff --git a/Documentation/Introduction/Index.rst b/Documentation/Introduction/Index.rst index b53b4a4..647adc9 100644 --- a/Documentation/Introduction/Index.rst +++ b/Documentation/Introduction/Index.rst @@ -12,19 +12,26 @@ Introduction What does it do? ---------------- -This extension is an example for building a TYPO3 CMS extension with the use of basic features of TYPO3. +This extension is an example for building a TYPO3 CMS extension with the use +of basic features/functions of TYPO3. +I collected some of often used functions/features that I'm using in my own extensions. It's built for developers to use it as an example for using the following functions of the TYPO3 CMS Core: - * Example for Extension Manager configuration - * Example for an update script which could be executed in Extension Manager - * A basic composer.json which will be updated from time to time - * A custom content element which uses default fields and shows a backend preview (button) - * An Extbase plugin which shows a basic backend preview and renders two buttons for demonstration of Ajax requests - * An example Extbase dispatcher for rendering Ajax requests via eID - * An example for Ajax requests with typoscript_rendering extension - * Automatically includes the constants and setup for the extension - * A backend module to show the basic functionality - * A scheduler task with custom fields - * A scheduler task as command controller task (could be executed via command line) - -Please read the developers part in the documentation to get more information on how to use this extension. \ No newline at end of file + * [Example-1]: Extension Manager configuration file reading (ext_conf_template.txt) + * [Example-2]: an update script which could be executed in Extension Manager + * [Example-3]: a basic composer.json which will be updated from time to time + * [Example-4]: a custom content element which uses default fields and shows a backend preview (button) + * [Example-5]: an Extbase plugin which shows a basic backend preview and renders two buttons for demonstration of AJAX requests + * [Example-6]: an example Extbase dispatcher for rendering AJAX requests via eID + * [Example-7]: an example for AJAX requests with typoscript_rendering extension + * [Example-8]: automatically include the constants and setup for the extension + * [Example-9]: a backend module to show the basic functionality + * [Example-10]: a default scheduler task with custom fields + * [Example-11]: a scheduler task as command controller task (could be executed via command line) + * [Example-12]: register extension icons with the icon registry + * [Example-13]: custom flash messages ViewHelper to get all flash messages + +Please read the developers part in the documentation to get more information on how to use this extension. + +You could search the extension for example with the keys e.g. '[Example-7]' to find all +files which are needed to get this feature/function to work. \ No newline at end of file diff --git a/Documentation/Settings.cfg b/Documentation/Settings.cfg index c7a7ff5..4c19d59 100644 --- a/Documentation/Settings.cfg +++ b/Documentation/Settings.cfg @@ -20,7 +20,7 @@ project = TYPO3 CMS example extension version = 1.0 -release = 1.0.3 +release = 1.0.4 t3author = Ephraim Härer copyright = since 2017 by Ephraim Härer diff --git a/Readme.md b/Readme.md index 46f76a4..96839d2 100644 --- a/Readme.md +++ b/Readme.md @@ -5,17 +5,20 @@ It could be used as example in the TYPO3 Bootstrap package. ## Features - - Example for Extension Manager configuration - - Example for an update script which could be executed in Extension Manager - - A basic composer.json which will be updated from time to time - - A custom content element which uses default fields and shows a backend preview (button) - - An Extbase plugin which shows a basic backend preview and renders two buttons for demonstration of Ajax requests - - An example Extbase dispatcher for rendering Ajax requests via eID - - An example for Ajax requests with typoscript_rendering extension - - Automatically includes the constants and setup for the extension - - A backend module to show the basic functionality - - A scheduler task with custom fields - - A scheduler task as command controller task (could be executed via command line) + - [Example-1]: Extension Manager configuration file reading (ext_conf_template.txt) + - [Example-2]: an update script which could be executed in Extension Manager + - [Example-3]: a basic composer.json which will be updated from time to time + - [Example-4]: a custom content element which uses default fields and shows a backend preview (button) + - [Example-5]: an Extbase plugin which shows a basic backend preview and renders two buttons for demonstration of AJAX requests + - [Example-6]: an example Extbase dispatcher for rendering AJAX requests via eID + - [Example-7]: an example for AJAX requests with typoscript_rendering extension + - [Example-8]: automatically include the constants and setup for the extension + - [Example-9]: a backend module to show the basic functionality + - [Example-10]: a default scheduler task with custom fields + - [Example-11]: a scheduler task as command controller task (could be executed via command line) + - [Example-12]: register extension icons with the icon registry + - [Example-13]: custom flash messages ViewHelper to get all flash messages used in [Example-2] + ## Usage diff --git a/Resources/Private/Layouts/Backend.html b/Resources/Private/Layouts/Backend.html index 4232282..5fe9e27 100644 --- a/Resources/Private/Layouts/Backend.html +++ b/Resources/Private/Layouts/Backend.html @@ -1,4 +1,4 @@
- - + +
\ No newline at end of file diff --git a/Resources/Private/Partials/FlashMessages.html b/Resources/Private/Partials/FlashMessages.html index 262f4f6..4648098 100644 --- a/Resources/Private/Partials/FlashMessages.html +++ b/Resources/Private/Partials/FlashMessages.html @@ -1,5 +1,5 @@ {namespace e = EHAERER\EhBootstrap\ViewHelpers} - +[Example-13]
diff --git a/Resources/Private/Templates/Abstract/Module.html b/Resources/Private/Templates/Abstract/Module.html index d9d69f1..ca82bfc 100644 --- a/Resources/Private/Templates/Abstract/Module.html +++ b/Resources/Private/Templates/Abstract/Module.html @@ -1,7 +1,7 @@ -
- +
+ diff --git a/Resources/Private/Templates/Abstract/PluginPreview.html b/Resources/Private/Templates/Abstract/PluginPreview.html index aaf4df1..c86fc47 100644 --- a/Resources/Private/Templates/Abstract/PluginPreview.html +++ b/Resources/Private/Templates/Abstract/PluginPreview.html @@ -1,4 +1,5 @@ +[Example-4]

Load extension manager configuration via eID diff --git a/Resources/Private/Templates/EhBs01.html b/Resources/Private/Templates/EhBs01.html index 205e287..505541f 100644 --- a/Resources/Private/Templates/EhBs01.html +++ b/Resources/Private/Templates/EhBs01.html @@ -1,4 +1,5 @@ +[Example-4]