diff --git a/Annotation/Document.php b/Annotation/Document.php index 9e2832a0..3f5f9f6c 100644 --- a/Annotation/Document.php +++ b/Annotation/Document.php @@ -39,6 +39,11 @@ final class Document */ public $ttl; + /** + * @var bool + */ + public $enabled; + /** * Constructor. */ diff --git a/Mapping/DocumentParser.php b/Mapping/DocumentParser.php index 1d567680..72196663 100644 --- a/Mapping/DocumentParser.php +++ b/Mapping/DocumentParser.php @@ -114,6 +114,7 @@ public function parse(\ReflectionClass $reflectionClass) 'fields' => [ '_parent' => $parent === null ? null : ['type' => $parent], '_ttl' => $class->ttl, + 'enabled' => $class->enabled, ], 'aliases' => $this->getAliases($reflectionClass), 'objects' => $this->getObjects(), diff --git a/Mapping/MetadataCollector.php b/Mapping/MetadataCollector.php index 2cfb857a..ec262bfc 100644 --- a/Mapping/MetadataCollector.php +++ b/Mapping/MetadataCollector.php @@ -85,7 +85,10 @@ public function getClientMapping($namespace, $force = false) array_merge( ['properties' => $mapping['properties']], $mapping['fields'] - ) + ), + function ($value) { + return (bool)$value || is_bool($value); + } ); } } diff --git a/Tests/app/fixture/Acme/TestBundle/Document/Content.php b/Tests/app/fixture/Acme/TestBundle/Document/Content.php index 9e0a8e2e..566ddee8 100644 --- a/Tests/app/fixture/Acme/TestBundle/Document/Content.php +++ b/Tests/app/fixture/Acme/TestBundle/Document/Content.php @@ -19,7 +19,7 @@ /** * Content document for testing. * - * @ES\Document(type="fooContent") + * @ES\Document(type="fooContent", enabled=false) */ class Content extends AbstractDocument {