TASK: PSR-2 and copyright notice

This commit is contained in:
Ferdinand Kuhl 2017-06-03 11:39:59 +02:00
parent 3bc6e09d9e
commit 9ea0c863dd
4 changed files with 109 additions and 70 deletions

View file

@ -1,15 +1,26 @@
<?php
namespace DigiComp\Menu\MenuService;
/* *
* This script belongs to the FLOW3 package "DigiComp.Controls". *
* *
* */
/*
* This file is part of the DigiComp.Menu package.
*
* (c) digital competence
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
/**
* Interface for Menu-Configuration
*/
interface ServiceInterface {
public function getItems();
interface ServiceInterface
{
/**
* @param mixed $forPath
*
* @return array|\Iterator
*/
public function getItems($forPath = null);
}

View file

@ -1,53 +1,64 @@
<?php
namespace DigiComp\Menu\MenuService;
/* *
* This script belongs to the FLOW3 package "DigiComp.Controls". *
* *
* */
/*
* This file is part of the DigiComp.Menu package.
*
* (c) digital competence
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Configuration\ConfigurationManager;
/**
* Class Menu
* @package DigiComp\Menu\Menu
*
* @Flow\Scope("singleton")
*/
class SettingsService implements ServiceInterface {
class SettingsService implements ServiceInterface
{
/**
* @var \TYPO3\Flow\Configuration\ConfigurationManager
*/
protected $configurationManager;
public function injectConfigurationManager(ConfigurationManager $configurationManager) {
public function injectConfigurationManager(ConfigurationManager $configurationManager)
{
$this->configurationManager = $configurationManager;
$this->menu = $this->configurationManager->getConfiguration('Menu');
$this->menuConfiguration = $this->configurationManager->getConfiguration('Menu');
}
/**
* @var array
*/
protected $menu;
protected $menuConfiguration;
/**
* @var array
*/
protected $items = array();
/**
* @param string $forMenu
* @return array
*/
public function getItems($forMenu = NULL) {
if ($forMenu){
$items = &$this->menu[$forMenu];
}else {
$items = &$this->menu;
}
if ($items) {
uasort($items, function ($a, $b) {
return $a['sorting'] > $b['sorting'];
});
}
/**
* @param string $forMenu
* @return array
*/
public function getItems($forMenu = null)
{
if ($forMenu) {
$items = &$this->menuConfiguration[$forMenu];
}else {
$items = &$this->menuConfiguration;
}
if ($items) {
uasort(
$items, function ($a, $b) {
return $a['sorting'] > $b['sorting'];
}
);
}
return $items;
}
}

View file

@ -1,25 +1,38 @@
<?php
/**
* @author skoetzing
* @date 07.07.14
namespace DigiComp\Menu;
/*
* This file is part of the DigiComp.Menu package.
*
* (c) digital competence
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
namespace DigiComp\Menu;
use TYPO3\Flow\Core\Bootstrap;
use TYPO3\Flow\Package\Package as BasePackage;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Configuration\ConfigurationManager;
class Package extends BasePackage{
/**
* Package base class of the DigiComp.Menu package.
*
* @Flow\Scope("singleton")
*/
class Package extends BasePackage
{
public function boot(Bootstrap $bootstrap){
public function boot(Bootstrap $bootstrap)
{
parent::boot($bootstrap);
$dispatcher = $bootstrap->getSignalSlotDispatcher();
$dispatcher->connect('TYPO3\Flow\Configuration\ConfigurationManager', 'configurationManagerReady',
function(ConfigurationManager $configurationManager){
$configurationManager->registerConfigurationType('Menu');
});
$dispatcher->connect(
'TYPO3\Flow\Configuration\ConfigurationManager', 'configurationManagerReady',
function (ConfigurationManager $configurationManager) {
$configurationManager->registerConfigurationType('Menu');
}
);
}
}

View file

@ -1,22 +1,27 @@
<?php
namespace DigiComp\Menu\ViewHelpers;
/* *
* This script belongs to the FLOW3 package "DigiComp.Controls". *
* *
* */
use TYPO3\Flow\Annotations as Flow;
/**
* Renders the sum of given collection and property name
/*
* This file is part of the DigiComp.Menu package.
*
* (c) digital competence
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
class MenuViewHelper extends \TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper {
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* NOTE: This property has been introduced via code migration to ensure backwards-compatibility.
* @see AbstractViewHelper::isOutputEscapingEnabled()
* @var boolean
*/
protected $escapeOutput = FALSE;
/**
* Just adds the return of MenuService
* TODO: Write example
*/
class MenuViewHelper extends AbstractViewHelper
{
protected $escapeOutput = false;
/**
* @var \DigiComp\Menu\MenuService\ServiceInterface
@ -24,15 +29,14 @@ class MenuViewHelper extends \TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper {
*/
protected $menuService;
/**
* @param string $as
* @param string $forPath
* @return mixed
*/
public function render($as = 'menuItems', $forPath = NULL) {
/**
* @param string $as
* @param string $forPath
* @return string
*/
public function render($as = 'menuItems', $forPath = null)
{
$this->templateVariableContainer->add($as, $this->menuService->getItems($forPath));
return $this->renderChildren();
}
}
?>