-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace old AdminApi::getLinks system with new service definition and…
… DI. refs #2500 and refs #2494 will require documentation. see companion commit in Pages module (FC-features branch) for implementation. /cc @cmfcmf
- Loading branch information
Showing
9 changed files
with
154 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/lib/Zikula/Bundle/CoreBundle/DependencyInjection/Compiler/LinkContainerPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Zikula\Bundle\CoreBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
class LinkContainerPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if (!$container->hasDefinition('zikula.link_container_collector')) { | ||
return; | ||
} | ||
|
||
$definition = $container->getDefinition('zikula.link_container_collector'); | ||
|
||
foreach ($container->findTaggedServiceIds('zikula.link_container') as $id => $linkContainer) { | ||
$definition->addMethodCall('addContainer', array(new Reference($id))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/lib/Zikula/Core/LinkContainer/LinkContainerCollector.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/** | ||
* Copyright Zikula Foundation 2015 - Zikula Application Framework | ||
* | ||
* This work is contributed to the Zikula Foundation under one or more | ||
* Contributor Agreements and licensed to You under the following license: | ||
* | ||
* @license GNU/LGPLv3 (or at your option, any later version). | ||
* @package Zikula | ||
* @subpackage Response | ||
* | ||
* Please see the NOTICE file distributed with this source code for further | ||
* information regarding copyright and licensing. | ||
*/ | ||
|
||
namespace Zikula\Core\LinkContainer; | ||
|
||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
use Zikula\Core\Event\GenericEvent; | ||
|
||
class LinkContainerCollector | ||
{ | ||
private $linkContainers; | ||
private $eventDispatcher; | ||
|
||
public function __construct(EventDispatcherInterface $dispatcher) | ||
{ | ||
$this->eventDispatcher = $dispatcher; | ||
$this->linkContainers = array(); | ||
} | ||
|
||
public function addContainer(LinkContainerInterface $linkContainer) | ||
{ | ||
$this->linkContainers[$linkContainer->getBundleName()] = $linkContainer; | ||
} | ||
|
||
public function getLinks($containerName, $type = LinkContainerInterface::TYPE_ADMIN) | ||
{ | ||
$links = array(); | ||
if ($this->hasContainer($containerName)) { | ||
$links = $this->linkContainers[$containerName]->getLinks($type); | ||
} | ||
// fire event here to add more links like hooks, moduleServices, etc | ||
$event = new GenericEvent($containerName, array('type' => $type), $links); | ||
$links = $this->eventDispatcher->dispatch(LinkContainerInterface::EVENT_NAME, $event)->getData(); | ||
|
||
return $links; | ||
} | ||
|
||
public function hasContainer($containerName) | ||
{ | ||
return isset($this->linkContainers[$containerName]); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/lib/Zikula/Core/LinkContainer/LinkContainerInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* Copyright Zikula Foundation 2015 - Zikula Application Framework | ||
* | ||
* This work is contributed to the Zikula Foundation under one or more | ||
* Contributor Agreements and licensed to You under the following license: | ||
* | ||
* @license GNU/LGPLv3 (or at your option, any later version). | ||
* @package Zikula | ||
* @subpackage Response | ||
* | ||
* Please see the NOTICE file distributed with this source code for further | ||
* information regarding copyright and licensing. | ||
*/ | ||
|
||
namespace Zikula\Core\LinkContainer; | ||
|
||
interface LinkContainerInterface | ||
{ | ||
const EVENT_NAME = 'zikula.link_collector'; | ||
const TYPE_ADMIN = 'admin'; | ||
const TYPE_USER = 'user'; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getBundleName(); | ||
|
||
/** | ||
* @param string $type | ||
* @return array | ||
*/ | ||
public function getLinks($type = self::TYPE_ADMIN); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters