TASK: PSR-2 and copyright notice
This commit is contained in:
parent
3bc6e09d9e
commit
9ea0c863dd
4 changed files with 109 additions and 70 deletions
|
@ -1,15 +1,26 @@
|
||||||
<?php
|
<?php
|
||||||
namespace DigiComp\Menu\MenuService;
|
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 for Menu-Configuration
|
||||||
*/
|
*/
|
||||||
interface ServiceInterface {
|
interface ServiceInterface
|
||||||
|
{
|
||||||
public function getItems();
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $forPath
|
||||||
|
*
|
||||||
|
* @return array|\Iterator
|
||||||
|
*/
|
||||||
|
public function getItems($forPath = null);
|
||||||
}
|
}
|
|
@ -1,53 +1,64 @@
|
||||||
<?php
|
<?php
|
||||||
namespace DigiComp\Menu\MenuService;
|
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\Annotations as Flow;
|
||||||
use TYPO3\Flow\Configuration\ConfigurationManager;
|
use TYPO3\Flow\Configuration\ConfigurationManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Menu
|
|
||||||
* @package DigiComp\Menu\Menu
|
* @package DigiComp\Menu\Menu
|
||||||
*
|
*
|
||||||
* @Flow\Scope("singleton")
|
* @Flow\Scope("singleton")
|
||||||
*/
|
*/
|
||||||
class SettingsService implements ServiceInterface {
|
class SettingsService implements ServiceInterface
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* @var \TYPO3\Flow\Configuration\ConfigurationManager
|
* @var \TYPO3\Flow\Configuration\ConfigurationManager
|
||||||
*/
|
*/
|
||||||
protected $configurationManager;
|
protected $configurationManager;
|
||||||
public function injectConfigurationManager(ConfigurationManager $configurationManager) {
|
public function injectConfigurationManager(ConfigurationManager $configurationManager)
|
||||||
|
{
|
||||||
$this->configurationManager = $configurationManager;
|
$this->configurationManager = $configurationManager;
|
||||||
$this->menu = $this->configurationManager->getConfiguration('Menu');
|
$this->menuConfiguration = $this->configurationManager->getConfiguration('Menu');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $menu;
|
protected $menuConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
protected $items = array();
|
protected $items = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $forMenu
|
* @param string $forMenu
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getItems($forMenu = NULL) {
|
public function getItems($forMenu = null)
|
||||||
|
{
|
||||||
if ($forMenu) {
|
if ($forMenu) {
|
||||||
$items = &$this->menu[$forMenu];
|
$items = &$this->menuConfiguration[$forMenu];
|
||||||
}else {
|
}else {
|
||||||
$items = &$this->menu;
|
$items = &$this->menuConfiguration;
|
||||||
}
|
}
|
||||||
if ($items) {
|
if ($items) {
|
||||||
uasort($items, function ($a, $b) {
|
uasort(
|
||||||
|
$items, function ($a, $b) {
|
||||||
return $a['sorting'] > $b['sorting'];
|
return $a['sorting'] > $b['sorting'];
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,25 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
namespace DigiComp\Menu;
|
||||||
* @author skoetzing
|
|
||||||
* @date 07.07.14
|
/*
|
||||||
|
* 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\Core\Bootstrap;
|
||||||
use TYPO3\Flow\Package\Package as BasePackage;
|
use TYPO3\Flow\Package\Package as BasePackage;
|
||||||
use TYPO3\Flow\Annotations as Flow;
|
|
||||||
use TYPO3\Flow\Configuration\ConfigurationManager;
|
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);
|
parent::boot($bootstrap);
|
||||||
|
|
||||||
$dispatcher = $bootstrap->getSignalSlotDispatcher();
|
$dispatcher = $bootstrap->getSignalSlotDispatcher();
|
||||||
$dispatcher->connect('TYPO3\Flow\Configuration\ConfigurationManager', 'configurationManagerReady',
|
$dispatcher->connect(
|
||||||
|
'TYPO3\Flow\Configuration\ConfigurationManager', 'configurationManagerReady',
|
||||||
function (ConfigurationManager $configurationManager) {
|
function (ConfigurationManager $configurationManager) {
|
||||||
$configurationManager->registerConfigurationType('Menu');
|
$configurationManager->registerConfigurationType('Menu');
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,22 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
namespace DigiComp\Menu\ViewHelpers;
|
namespace DigiComp\Menu\ViewHelpers;
|
||||||
/* *
|
|
||||||
* 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\Annotations as Flow;
|
||||||
/**
|
use TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||||
* Renders the sum of given collection and property name
|
|
||||||
*/
|
|
||||||
class MenuViewHelper extends \TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTE: This property has been introduced via code migration to ensure backwards-compatibility.
|
* Just adds the return of MenuService
|
||||||
* @see AbstractViewHelper::isOutputEscapingEnabled()
|
* TODO: Write example
|
||||||
* @var boolean
|
|
||||||
*/
|
*/
|
||||||
protected $escapeOutput = FALSE;
|
class MenuViewHelper extends AbstractViewHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $escapeOutput = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \DigiComp\Menu\MenuService\ServiceInterface
|
* @var \DigiComp\Menu\MenuService\ServiceInterface
|
||||||
|
@ -27,12 +32,11 @@ class MenuViewHelper extends \TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper {
|
||||||
/**
|
/**
|
||||||
* @param string $as
|
* @param string $as
|
||||||
* @param string $forPath
|
* @param string $forPath
|
||||||
* @return mixed
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function render($as = 'menuItems', $forPath = NULL) {
|
public function render($as = 'menuItems', $forPath = null)
|
||||||
|
{
|
||||||
$this->templateVariableContainer->add($as, $this->menuService->getItems($forPath));
|
$this->templateVariableContainer->add($as, $this->menuService->getItems($forPath));
|
||||||
return $this->renderChildren();
|
return $this->renderChildren();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
Loading…
Reference in a new issue