diff --git a/config/bootstrap.php b/config/bootstrap.php index ef5b822b..7076e6de 100644 --- a/config/bootstrap.php +++ b/config/bootstrap.php @@ -24,7 +24,7 @@ // Attach the document context into FormHelper. EventManager::instance()->on('View.beforeRender', function ($event) { - $view = $event->subject(); + $view = $event->getSubject(); $view->Form->addContextProvider('elastic', function ($request, $data) { $first = null; if (is_array($data['entity']) || $data['entity'] instanceof Traversable) { diff --git a/src/Document.php b/src/Document.php index 4b0b4bfc..40a6b04e 100644 --- a/src/Document.php +++ b/src/Document.php @@ -65,7 +65,7 @@ public function __construct($data = [], $options = []) 'result' => null ]; if (!empty($options['source'])) { - $this->source($options['source']); + $this->setSource($options['source']); } if ($options['markNew'] !== null) { diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index 00c83600..05a36488 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -530,6 +530,25 @@ public function simpleQueryString($fields, $string) return new Elastica\Query\SimpleQueryString($string, (array)$fields); } + /** + * Returns a Match query object that query documents that have fields containing a match. + * + * ### Example: + * + * {{{ + * $builder->match('user.name', 'jose'); + * }}} + * + * @param string $field The field to query by. + * @param string $value The match to find in field. + * @return \Elastica\Query\Match + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html + */ + public function match($field, $value) + { + return new Elastica\Query\Match($field, $value); + } + /** * Returns a Match query object that query documents that have fields containing a match. * diff --git a/src/ResultSet.php b/src/ResultSet.php index f361c952..c1d825f5 100644 --- a/src/ResultSet.php +++ b/src/ResultSet.php @@ -65,7 +65,7 @@ class ResultSet extends IteratorIterator implements Countable, JsonSerializable public function __construct($resultSet, $query) { $this->resultSet = $resultSet; - $repo = $query->repository(); + $repo = $query->getRepository(); foreach ($repo->embedded() as $embed) { $this->embeds[$embed->property()] = $embed; } diff --git a/src/Type.php b/src/Type.php index 80cb1b98..4e6e7832 100644 --- a/src/Type.php +++ b/src/Type.php @@ -495,7 +495,7 @@ public function save(EntityInterface $entity, $options = []) return $event->result; } - if ($entity->errors()) { + if ($entity->getErrors()) { return false; }