diff --git a/Doctrine/Annotation/Field.php b/Doctrine/Annotation/Field.php index 3727f972..8fc0efa7 100644 --- a/Doctrine/Annotation/Field.php +++ b/Doctrine/Annotation/Field.php @@ -25,4 +25,8 @@ public function getNameWithAlias() { throw new \RuntimeException('unsupported type'. $this->type); } + + public function __toString() { + return $this->name; + } } diff --git a/Doctrine/Mapper/MetaInformation.php b/Doctrine/Mapper/MetaInformation.php index d7acd518..3313fcc7 100644 --- a/Doctrine/Mapper/MetaInformation.php +++ b/Doctrine/Mapper/MetaInformation.php @@ -1,6 +1,8 @@ fields; diff --git a/Event/DeleteLogListener.php b/Event/DeleteLogListener.php deleted file mode 100644 index 4279ccda..00000000 --- a/Event/DeleteLogListener.php +++ /dev/null @@ -1,30 +0,0 @@ -logger = $logger; - } - - /* (non-PHPdoc) - * @see FS\SolrBundle\Event.EventListenerInterface::notify() - */ - public function notify(MetaInformation $metaInformation) { - $this->logger->info('document was deleted'); - - } - - -} - -?> \ No newline at end of file diff --git a/Event/InsertLogListener.php b/Event/InsertLogListener.php deleted file mode 100644 index 894ee7ef..00000000 --- a/Event/InsertLogListener.php +++ /dev/null @@ -1,30 +0,0 @@ -logger = $logger; - } - - /* (non-PHPdoc) - * @see FS\SolrBundle\Event.EventListenerInterface::notify() - */ - public function notify(MetaInformation $metaInformation) { - $this->logger->info('document was add to the index'); - - } - - -} - -?> \ No newline at end of file diff --git a/Event/Listener/AbstractLogListener.php b/Event/Listener/AbstractLogListener.php new file mode 100644 index 00000000..e49567bd --- /dev/null +++ b/Event/Listener/AbstractLogListener.php @@ -0,0 +1,26 @@ +logger = $logger; + } + + protected function createDocumentNameWithId(MetaInformation $metaInformation) { + return $metaInformation->getDocumentName().':'.$metaInformation->getEntityId(); + } + + protected function createFieldList(MetaInformation $metaInformation) { + return implode(', ', $metaInformation->getFields()); + } +} diff --git a/Event/Listener/DeleteLogListener.php b/Event/Listener/DeleteLogListener.php new file mode 100644 index 00000000..6b4d75e1 --- /dev/null +++ b/Event/Listener/DeleteLogListener.php @@ -0,0 +1,19 @@ +createDocumentNameWithId($metaInformation); + $fieldList = $this->createFieldList($metaInformation); + + $this->logger->info(sprintf('%s with fields %s was deleted', $nameWithId, $fieldList)); + } +} + +?> \ No newline at end of file diff --git a/Event/Listener/InsertLogListener.php b/Event/Listener/InsertLogListener.php new file mode 100644 index 00000000..b9fc9d81 --- /dev/null +++ b/Event/Listener/InsertLogListener.php @@ -0,0 +1,19 @@ +createDocumentNameWithId($metaInformation); + $fieldList = $this->createFieldList($metaInformation); + + $this->logger->info(sprintf('%s with fields %s was added', $nameWithId, $fieldList)); + } +} + +?> \ No newline at end of file diff --git a/Event/Listener/UpdateLogListener.php b/Event/Listener/UpdateLogListener.php new file mode 100644 index 00000000..c2e85cfc --- /dev/null +++ b/Event/Listener/UpdateLogListener.php @@ -0,0 +1,20 @@ +createDocumentNameWithId($metaInformation); + $fieldList = $this->createFieldList($metaInformation); + + $this->logger->info(sprintf('%s with fields %s was updated', $nameWithId, $fieldList)); + } +} + +?> \ No newline at end of file diff --git a/Event/UpdateLogListener.php b/Event/UpdateLogListener.php deleted file mode 100644 index ac61687a..00000000 --- a/Event/UpdateLogListener.php +++ /dev/null @@ -1,30 +0,0 @@ -logger = $logger; - } - - /* (non-PHPdoc) - * @see FS\SolrBundle\Event.EventListenerInterface::notify() - */ - public function notify(MetaInformation $metaInformation) { - $this->logger->info('document was updated'); - - } - - -} - -?> \ No newline at end of file diff --git a/Resources/config/services.xml b/Resources/config/services.xml index 442551ea..cc51ef29 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -15,9 +15,9 @@ FS\SolrBundle\Doctrine\Mapper\Mapping\MapAllFieldsCommand FS\SolrBundle\Doctrine\Mapper\Mapping\MapIdentifierCommand FS\SolrBundle\Event\EventManager - FS\SolrBundle\Event\InsertLogListener - FS\SolrBundle\Event\UpdateLogListener - FS\SolrBundle\Event\DeleteLogListener + FS\SolrBundle\Event\Listener\InsertLogListener + FS\SolrBundle\Event\Listener\UpdateLogListener + FS\SolrBundle\Event\Listener\DeleteLogListener