Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/upstream/1.2' into 5.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	Service/ExportService.php
#	Test/AbstractElasticsearchTestCase.php
#	Tests/Functional/Command/IndexImportCommandTest.php
  • Loading branch information
Simonas Šerlinskas committed Jan 30, 2017
2 parents 58fa62d + 61188a7 commit d03398d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Annotation/Version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <info@nfq.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace ONGR\ElasticsearchBundle\Annotation;

/**
* Associates document property with _version meta-field.
*
* @Annotation
* @Target("PROPERTY")
*/
final class Version implements MetaField
{
/**
* {@inheritdoc}
*/
public function getName()
{
return '_version';
}

/**
* {@inheritdoc}
*/
public function getSettings()
{
return [];
}
}
3 changes: 3 additions & 0 deletions Mapping/DocumentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class DocumentParser
const ID_ANNOTATION = 'ONGR\ElasticsearchBundle\Annotation\Id';
const PARENT_ANNOTATION = 'ONGR\ElasticsearchBundle\Annotation\ParentDocument';
const ROUTING_ANNOTATION = 'ONGR\ElasticsearchBundle\Annotation\Routing';
const VERSION_ANNOTATION = 'ONGR\ElasticsearchBundle\Annotation\Version';

/**
* @var Reader Used to read document annotations.
Expand Down Expand Up @@ -181,6 +182,7 @@ private function getMetaFieldAnnotationData($property)
$annotation = $this->reader->getPropertyAnnotation($property, self::ID_ANNOTATION);
$annotation = $annotation ?: $this->reader->getPropertyAnnotation($property, self::PARENT_ANNOTATION);
$annotation = $annotation ?: $this->reader->getPropertyAnnotation($property, self::ROUTING_ANNOTATION);
$annotation = $annotation ?: $this->reader->getPropertyAnnotation($property, self::VERSION_ANNOTATION);

if ($annotation === null) {
return null;
Expand Down Expand Up @@ -361,6 +363,7 @@ private function registerAnnotations()
'Id',
'ParentDocument',
'Routing',
'Version',
];

foreach ($annotations as $annotation) {
Expand Down
8 changes: 8 additions & 0 deletions Tests/Functional/Command/CacheClearCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ class CacheClearCommandTest extends AbstractElasticsearchTestCase

const COMMAND_NAME = 'ongr:es:cache:clear';

/**
* {@inheritdoc}
*/
protected function getDataArray()
{
return ['default' => []];
}

/**
* Tests if command is being executed.
*/
Expand Down

0 comments on commit d03398d

Please sign in to comment.