SearchApiFlag.php in Flag Search API 8
File
src/Plugin/views/field/SearchApiFlag.php
View source
<?php
namespace Drupal\flag_search_api\Plugin\views\field;
use Drupal\views\ResultRow;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\Plugin\views\field\FieldHandlerInterface;
class SearchApiFlag extends FieldPluginBase implements FieldHandlerInterface {
public function render(ResultRow $values) {
$entity_info = explode(':', $values->search_api_id)[1];
list($entity_type_id, $entity_id) = explode('/', $entity_info);
$flag_id = substr($this->field, 5);
$flag_link = [
'#lazy_builder' => [
'flag.link_builder:build',
[
$entity_type_id,
$entity_id,
$flag_id,
],
],
'#create_placeholder' => TRUE,
];
return $flag_link;
}
}