-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from thomasblass/ObjectIdentifierTransformer
[Task] Add ObjectIdentifierTransformer
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
Classes/Flowpack/ElasticSearch/Indexer/Object/Transform/ObjectIdentifierTransformer.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,49 @@ | ||
<?php | ||
namespace Flowpack\ElasticSearch\Indexer\Object\Transform; | ||
|
||
/* * | ||
* This script belongs to the TYPO3 Flow package "Flowpack.ElasticSearch".* | ||
* * | ||
* It is free software; you can redistribute it and/or modify it under * | ||
* the terms of the GNU Lesser General Public License, either version 3 * | ||
* of the License, or (at your option) any later version. * | ||
* * | ||
* The TYPO3 project - inspiring people to share! * | ||
* */ | ||
|
||
use TYPO3\Flow\Annotations as Flow; | ||
use TYPO3\Flow\Persistence\PersistenceManagerInterface; | ||
|
||
/** | ||
* @Flow\Scope("singleton") | ||
*/ | ||
class ObjectIdentifierTransformer implements TransformerInterface { | ||
|
||
/** | ||
* @Flow\Inject | ||
* @var PersistenceManagerInterface | ||
*/ | ||
protected $persistenceManager; | ||
|
||
/** | ||
* Returns the Elasticsearch type this transform() method returns | ||
* | ||
* @return string | ||
*/ | ||
public function getTargetMappingType() { | ||
return 'string'; | ||
} | ||
|
||
/** | ||
* @param mixed $source | ||
* @param \Flowpack\ElasticSearch\Annotations\Transform $annotation | ||
* @return string | ||
*/ | ||
public function transformByAnnotation($source, \Flowpack\ElasticSearch\Annotations\Transform $annotation) { | ||
if($source != null) { | ||
return $this->persistenceManager->getIdentifierByObject($source); | ||
} | ||
return ''; | ||
} | ||
} | ||
|