mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 12:03:14 +00:00
58 lines
1.2 KiB
PHP
58 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Alchemy\Phrasea\SearchEngine\Elastic\AST\KeyValue;
|
|
|
|
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext;
|
|
|
|
class NativeKey implements Key
|
|
{
|
|
const TYPE_DATABASE = 'database';
|
|
const TYPE_COLLECTION = 'collection';
|
|
const TYPE_MEDIA_TYPE = 'media_type';
|
|
const TYPE_RECORD_IDENTIFIER = 'record_identifier';
|
|
|
|
private $type;
|
|
private $key;
|
|
|
|
public static function database()
|
|
{
|
|
return new self(self::TYPE_DATABASE, 'databox_name');
|
|
}
|
|
|
|
public static function collection()
|
|
{
|
|
return new self(self::TYPE_COLLECTION, 'collection_name');
|
|
}
|
|
|
|
public static function mediaType()
|
|
{
|
|
return new self(self::TYPE_MEDIA_TYPE, 'type');
|
|
}
|
|
|
|
public static function recordIdentifier()
|
|
{
|
|
return new self(self::TYPE_RECORD_IDENTIFIER, 'record_id');
|
|
}
|
|
|
|
private function __construct($type, $key)
|
|
{
|
|
$this->type = $type;
|
|
$this->key = $key;
|
|
}
|
|
|
|
public function getIndexField(QueryContext $context, $raw = false)
|
|
{
|
|
return $this->key;
|
|
}
|
|
|
|
public function isValueCompatible($value, QueryContext $context)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function __toString()
|
|
{
|
|
return $this->type;
|
|
}
|
|
}
|