ScriptId.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace Elastica\Script;
  3. /**
  4. * Stored script referenced by ID.
  5. *
  6. * @author Tobias Schultze <http://tobion.de>
  7. * @author Martin Janser <martin.janser@liip.ch>
  8. *
  9. * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html
  10. */
  11. class ScriptId extends AbstractScript
  12. {
  13. /**
  14. * @var string
  15. */
  16. private $_scriptId;
  17. /**
  18. * @param string $scriptId Script ID
  19. * @param array|null $params
  20. * @param string|null $lang
  21. * @param string|null $documentId Document ID the script action should be performed on (only relevant in update context)
  22. */
  23. public function __construct($scriptId, array $params = null, $lang = null, $documentId = null)
  24. {
  25. parent::__construct($params, $lang, $documentId);
  26. $this->setScriptId($scriptId);
  27. }
  28. /**
  29. * @param string $scriptId
  30. *
  31. * @return $this
  32. */
  33. public function setScriptId($scriptId)
  34. {
  35. $this->_scriptId = $scriptId;
  36. return $this;
  37. }
  38. /**
  39. * @return string
  40. */
  41. public function getScriptId()
  42. {
  43. return $this->_scriptId;
  44. }
  45. /**
  46. * {@inheritdoc}
  47. */
  48. protected function getScriptTypeArray()
  49. {
  50. return ['id' => $this->_scriptId];
  51. }
  52. }