2017-02-17 00:03:51 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\FullTextSearch\Search\Variants;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal utility class used to hold the state of the SearchVariant::with call
|
|
|
|
*/
|
|
|
|
class SearchVariant_Caller
|
|
|
|
{
|
|
|
|
protected $variants = null;
|
|
|
|
|
|
|
|
public function __construct($variants)
|
|
|
|
{
|
|
|
|
$this->variants = $variants;
|
|
|
|
}
|
|
|
|
|
2017-11-30 00:01:57 +01:00
|
|
|
public function call($method, &...$args)
|
2017-02-17 00:03:51 +01:00
|
|
|
{
|
|
|
|
$values = array();
|
|
|
|
|
|
|
|
foreach ($this->variants as $variant) {
|
|
|
|
if (method_exists($variant, $method)) {
|
2017-11-30 00:01:57 +01:00
|
|
|
$value = $variant->$method(...$args);
|
2017-02-17 00:03:51 +01:00
|
|
|
if ($value !== null) {
|
|
|
|
$values[] = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $values;
|
|
|
|
}
|
2017-11-14 21:48:52 +01:00
|
|
|
}
|