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){
|
{
|
||||||
$items = &$this->menu[$forMenu];
|
if ($forMenu) {
|
||||||
}else {
|
$items = &$this->menuConfiguration[$forMenu];
|
||||||
$items = &$this->menu;
|
}else {
|
||||||
}
|
$items = &$this->menuConfiguration;
|
||||||
if ($items) {
|
}
|
||||||
uasort($items, function ($a, $b) {
|
if ($items) {
|
||||||
return $a['sorting'] > $b['sorting'];
|
uasort(
|
||||||
});
|
$items, function ($a, $b) {
|
||||||
}
|
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(
|
||||||
function(ConfigurationManager $configurationManager){
|
'TYPO3\Flow\Configuration\ConfigurationManager', 'configurationManagerReady',
|
||||||
$configurationManager->registerConfigurationType('Menu');
|
function (ConfigurationManager $configurationManager) {
|
||||||
});
|
$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.
|
||||||
* */
|
*
|
||||||
use TYPO3\Flow\Annotations as Flow;
|
* (c) digital competence
|
||||||
/**
|
*
|
||||||
* Renders the sum of given collection and property name
|
* 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.
|
* Just adds the return of MenuService
|
||||||
* @see AbstractViewHelper::isOutputEscapingEnabled()
|
* TODO: Write example
|
||||||
* @var boolean
|
*/
|
||||||
*/
|
class MenuViewHelper extends AbstractViewHelper
|
||||||
protected $escapeOutput = FALSE;
|
{
|
||||||
|
|
||||||
|
protected $escapeOutput = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \DigiComp\Menu\MenuService\ServiceInterface
|
* @var \DigiComp\Menu\MenuService\ServiceInterface
|
||||||
|
@ -24,15 +29,14 @@ class MenuViewHelper extends \TYPO3\Fluid\Core\ViewHelper\AbstractViewHelper {
|
||||||
*/
|
*/
|
||||||
protected $menuService;
|
protected $menuService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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