Skip to content

Commit

Permalink
solve #5
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Semm committed Mar 31, 2012
1 parent 5572f01 commit ca1ce40
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 94 deletions.
4 changes: 4 additions & 0 deletions Doctrine/Annotation/Field.php
Expand Up @@ -25,4 +25,8 @@ public function getNameWithAlias() {

throw new \RuntimeException('unsupported type'. $this->type);
}

public function __toString() {
return $this->name;
}
}
4 changes: 3 additions & 1 deletion Doctrine/Mapper/MetaInformation.php
@@ -1,6 +1,8 @@
<?php
namespace FS\SolrBundle\Doctrine\Mapper;

use FS\SolrBundle\Doctrine\Annotation\Field;

class MetaInformation {
private $identifier = '';

Expand Down Expand Up @@ -46,7 +48,7 @@ public function getDocumentName() {
}

/**
* @return the $fields
* @return array With instances of FS\SolrBundle\Doctrine\Annotation\Field
*/
public function getFields() {
return $this->fields;
Expand Down
30 changes: 0 additions & 30 deletions Event/DeleteLogListener.php

This file was deleted.

30 changes: 0 additions & 30 deletions Event/InsertLogListener.php

This file was deleted.

26 changes: 26 additions & 0 deletions Event/Listener/AbstractLogListener.php
@@ -0,0 +1,26 @@
<?php
namespace FS\SolrBundle\Event\Listener;

use FS\SolrBundle\Event\EventListenerInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use FS\SolrBundle\Doctrine\Mapper\MetaInformation;

abstract class AbstractLogListener implements EventListenerInterface {
/**
*
* @var LoggerInterface
*/
protected $logger = null;

public function __construct(LoggerInterface $logger) {
$this->logger = $logger;
}

protected function createDocumentNameWithId(MetaInformation $metaInformation) {
return $metaInformation->getDocumentName().':'.$metaInformation->getEntityId();
}

protected function createFieldList(MetaInformation $metaInformation) {
return implode(', ', $metaInformation->getFields());
}
}
19 changes: 19 additions & 0 deletions Event/Listener/DeleteLogListener.php
@@ -0,0 +1,19 @@
<?php
namespace FS\SolrBundle\Event\Listener;

use FS\SolrBundle\Doctrine\Mapper\MetaInformation;

class DeleteLogListener extends AbstractLogListener {

/* (non-PHPdoc)
* @see FS\SolrBundle\Event.EventListenerInterface::notify()
*/
public function notify(MetaInformation $metaInformation) {
$nameWithId = $this->createDocumentNameWithId($metaInformation);
$fieldList = $this->createFieldList($metaInformation);

$this->logger->info(sprintf('%s with fields %s was deleted', $nameWithId, $fieldList));
}
}

?>
19 changes: 19 additions & 0 deletions Event/Listener/InsertLogListener.php
@@ -0,0 +1,19 @@
<?php
namespace FS\SolrBundle\Event\Listener;

use FS\SolrBundle\Doctrine\Mapper\MetaInformation;

class InsertLogListener extends AbstractLogListener {

/* (non-PHPdoc)
* @see FS\SolrBundle\Event.EventListenerInterface::notify()
*/
public function notify(MetaInformation $metaInformation) {
$nameWithId = $this->createDocumentNameWithId($metaInformation);
$fieldList = $this->createFieldList($metaInformation);

$this->logger->info(sprintf('%s with fields %s was added', $nameWithId, $fieldList));
}
}

?>
20 changes: 20 additions & 0 deletions Event/Listener/UpdateLogListener.php
@@ -0,0 +1,20 @@
<?php
namespace FS\SolrBundle\Event\Listener;

use FS\SolrBundle\Doctrine\Mapper\MetaInformation;
use FS\SolrBundle\Event\Listener\AbstractLogListener;

class UpdateLogListener extends AbstractLogListener {

/* (non-PHPdoc)
* @see FS\SolrBundle\Event.EventListenerInterface::notify()
*/
public function notify(MetaInformation $metaInformation) {
$nameWithId = $this->createDocumentNameWithId($metaInformation);
$fieldList = $this->createFieldList($metaInformation);

$this->logger->info(sprintf('%s with fields %s was updated', $nameWithId, $fieldList));
}
}

?>
30 changes: 0 additions & 30 deletions Event/UpdateLogListener.php

This file was deleted.

6 changes: 3 additions & 3 deletions Resources/config/services.xml
Expand Up @@ -15,9 +15,9 @@
<parameter key="solr.mapping.all.class">FS\SolrBundle\Doctrine\Mapper\Mapping\MapAllFieldsCommand</parameter>
<parameter key="solr.mapping.identifier.class">FS\SolrBundle\Doctrine\Mapper\Mapping\MapIdentifierCommand</parameter>
<parameter key="solr.event_manager.class">FS\SolrBundle\Event\EventManager</parameter>
<parameter key="solr.log_listener.insert.class">FS\SolrBundle\Event\InsertLogListener</parameter>
<parameter key="solr.log_listener.update.class">FS\SolrBundle\Event\UpdateLogListener</parameter>
<parameter key="solr.log_listener.delete.class">FS\SolrBundle\Event\DeleteLogListener</parameter>
<parameter key="solr.log_listener.insert.class">FS\SolrBundle\Event\Listener\InsertLogListener</parameter>
<parameter key="solr.log_listener.update.class">FS\SolrBundle\Event\Listener\UpdateLogListener</parameter>
<parameter key="solr.log_listener.delete.class">FS\SolrBundle\Event\Listener\DeleteLogListener</parameter>
</parameters>

<services>
Expand Down

0 comments on commit ca1ce40

Please sign in to comment.