Skip to content

Commit

Permalink
Merge pull request #38 from the-coding-owl/bugfix_optionalWidget
Browse files Browse the repository at this point in the history
Bugfix optional widget
  • Loading branch information
the-coding-owl committed Nov 6, 2021
2 parents a282a70 + f85178d commit ff022a1
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 27 deletions.
1 change: 1 addition & 0 deletions Classes/Toolbar/Clock.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function __construct()
$this->view = GeneralUtility::makeInstance(StandaloneView::class);
/** @var ExtensionConfiguration $extensionConfiguration */
$extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class);
/** @var array{dashboard:string[],additionalTemplateRootPath:string,additionalPartialRootPath:string,additionalLayoutRootPath:string} $extConf */
$extConf = $extensionConfiguration->get('oclock');
$rootPaths = [
'template' => [
Expand Down
8 changes: 6 additions & 2 deletions Classes/Widgets/ClockWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,18 @@ class ClockWidget implements WidgetInterface, RequireJsModuleInterface, Addition
/**
* Constructor of the ClockWidget
*
* @var StandaloneView $view
* @param StandaloneView $view
*/
public function __construct(StandaloneView $view)
{
$this->view = $view;
/** @var ExtensionConfiguration $extensionConfiguration */
$extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class);
$this->extConf = $extensionConfiguration->get('oclock');
/** @var array{dashboard:string[],additionalTemplateRootPath:string,additionalPartialRootPath:string,additionalLayoutRootPath:string} $extConf */
$extConf = $extensionConfiguration->get('oclock');
if (is_array($extConf)) {
$this->extConf = $extConf;
}
}

/**
Expand Down
7 changes: 7 additions & 0 deletions Configuration/Icons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
return [
'the-coding-owl-clock' => [
'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
'source' => 'EXT:oclock/Resources/Public/Icons/clock.svg'
]
];
28 changes: 28 additions & 0 deletions Configuration/Services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);
namespace Vendor\ExtName;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Reference;
use TYPO3\CMS\Dashboard\Widgets\WidgetInterface;

return function (ContainerConfigurator $configurator, ContainerBuilder $containerBuilder) {
$services = $configurator->services();

if ($containerBuilder->hasDefinition(WidgetInterface::class)) {
$services->set('widgets.dashboard.widget.clockWidget')
->class(TheCodingOwl\Oclock\Widgets\ClockWidget::class)
->arg('$view', new Reference('dashboard.views.widget'))
->tag('dashboard.widget', [
'identifier' => 'theCodingOwlClock',
'groupNames' => 'systemInfo',
'title' => 'Clock Widget',
'description' => 'Displays a clock',
'iconIdentifier' => 'the-coding-owl-clock',
'height' => 'medium',
'width' => 'medium'
]);
}
};
16 changes: 3 additions & 13 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@ services:
autowire: true
autoconfigure: true
public: false
dashboard.widget.custom:
class: 'TheCodingOwl\Oclock\Widgets\ClockWidget'
arguments:
$view: '@dashboard.views.widget'
tags:
- name: dashboard.widget
identifier: theCodingOwlClock
groupNames: 'systemInfo'
title: 'Clock Widget'
description: 'Displays a clock'
iconIdentifier: 'the-coding-owl-clock'
height: 'medium'
width: 'medium'

TheCodingOwl\Oclock\:
resource: '../Classes/*'
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
"typo3-ter/oclock": "self.version"
},
"require-dev": {
"phpstan/phpstan": "^0.12.18",
"saschaegerer/phpstan-typo3": "^0.13.1",
"phpstan/extension-installer": "^1.0",
"squizlabs/php_codesniffer": "^3.5"
"phpstan/phpstan": "^1.0.1",
"saschaegerer/phpstan-typo3": "^1.0.0",
"phpstan/extension-installer": "^1.1.0",
"squizlabs/php_codesniffer": "^3.6.1",
"roave/security-advisories": "dev-master",
"friendsofphp/php-cs-fixer": "^3.2"
},
"extra": {
"typo3/cms": {
Expand Down
22 changes: 14 additions & 8 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<?php

use TYPO3\CMS\Core\Utility\VersionNumberUtility;

call_user_func(function($extKey) {
$GLOBALS['TYPO3_CONF_VARS']['BE']['toolbarItems'][] = \TheCodingOwl\Oclock\Toolbar\Clock::class;
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
$iconRegistry->registerIcon(
'the-coding-owl-clock',
\TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
[
'source' => 'EXT:oclock/Resources/Public/Icons/clock.svg'
]
);
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '11.4.0', '<')) {
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Imaging\IconRegistry::class
);
$iconRegistry->registerIcon(
'the-coding-owl-clock',
\TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
[
'source' => 'EXT:oclock/Resources/Public/Icons/clock.svg'
]
);
}
}, 'oclock');

0 comments on commit ff022a1

Please sign in to comment.