Created
August 4, 2017 07:40
-
-
Save adsc-cloudtec/294805ac0a0d11515a1381adb901f769 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
/* | |
* This file is part of Sulu. | |
* | |
* (c) MASSIVE ART WebServices GmbH | |
* | |
* This source file is subject to the MIT license that is bundled | |
* with this source code in the file LICENSE. | |
*/ | |
namespace WebsiteBundle\DependencyInjection; | |
use Symfony\Component\Config\FileLocator; | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | |
use Symfony\Component\DependencyInjection\Loader; | |
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | |
/** | |
* This is the class that loads and manages your bundle configuration. | |
* | |
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} | |
*/ | |
class ClientWebsiteExtension extends Extension | |
{ | |
/** | |
* {@inheritdoc} | |
*/ | |
public function load(array $configs, ContainerBuilder $container) | |
{ | |
$configuration = new Configuration(); | |
$config = $this->processConfiguration($configuration, $configs); | |
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); | |
$loader->load('services.xml'); | |
$ymlLoader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); | |
$ymlLoader->load('services.yml'); | |
} | |
} |
This file contains hidden or 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
<?php | |
namespace WebsiteBundle\Subscriber; | |
use Massive\Bundle\SearchBundle\Search\Event\DeindexEvent; | |
use Massive\Bundle\SearchBundle\Search\Event\IndexEvent; | |
use Massive\Bundle\SearchBundle\Search\SearchEvents; | |
use Psr\Log\LoggerInterface; | |
use Sulu\Bundle\MediaBundle\Entity\Media; | |
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |
class SearchIndexSubscriber implements EventSubscriberInterface { | |
/** | |
* @var LoggerInterface | |
*/ | |
protected $logger; | |
/** | |
* @param LoggerInterface $logger | |
*/ | |
public function __construct(LoggerInterface $logger) { | |
$this->logger = $logger; | |
} | |
/** | |
* @return array | |
*/ | |
public static function getSubscribedEvents() { | |
return [ | |
SearchEvents::INDEX => 'handleIndex', | |
SearchEvents::DEINDEX => 'handleDeindex', | |
]; | |
} | |
/** | |
* @param IndexEvent $event | |
*/ | |
public function handleIndex(IndexEvent $event) { | |
$this->logger->info('SEARCHINDEX'); | |
$subject = $event->getSubject(); | |
if ($subject instanceof Media) { | |
$this->logger->info('Indexing a media element'); | |
} | |
} | |
/** | |
* @param DeindexEvent $event | |
*/ | |
public function handleDeindex(DeindexEvent $event) { | |
$this->logger->info('SEARCHINDEX'); | |
$subject = $event->getSubject(); | |
if ($subject instanceof Media) { | |
$this->logger->info('Deindexing a media element'); | |
} | |
} | |
} |
This file contains hidden or 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
services: | |
cloudtec.searchindexer: | |
class: WebsiteBundle\Subscriber\SearchIndexSubscriber | |
arguments: [ '@logger' ] | |
tags: | |
- { name: kernel.event_subscriber } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment