mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 14:05:29 +02:00
1728a62af5
Thanks to Marco Hermo and Brett Tasker for helping with this * Bump framework/cms to ^4.0@dev * WIP Silverstripe 4 compatibility fixes * more replacements and patches to migrate this module to 4.0 * Update composer.json * remove php <5.5 from travis.yml * WIP more SS4 compatibility fixes * WIP fix solr path to use DIR, avoid hardcoded module name * WIP respect current include path * WIP Namespacing and use on SearchIndex class * Namespacing for tests * WIP add namespaces to all classes * Second push of Test changes + namespacing * WIP split Solr files with multiple classes into single file / single class. Adjust namespaces * Fix PHP errors in test * break out search components with multiple classes into individual files and change namespaces * Update namespacing for Search indexes and variants in tests * Batch fixes for tests #2 * Update _config.php to use namespace * Use root namespace in referencing Apache_Solr_Document * Migrate task names so that the name is not fully qualified
66 lines
1.7 KiB
PHP
66 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace SilverStripe\FullTextSearch\Search\Updaters;
|
|
use SilverStripe\ORM\DataExtension;
|
|
|
|
/**
|
|
* Delete operations do not use database manipulations.
|
|
*
|
|
* If a delete has been requested, force a write on objects that should be
|
|
* indexed. This causes the object to be marked for deletion from the index.
|
|
*/
|
|
|
|
class SearchUpdater_ObjectHandler extends DataExtension
|
|
{
|
|
public function onAfterDelete()
|
|
{
|
|
// Calling delete() on empty objects does nothing
|
|
if (!$this->owner->ID) {
|
|
return;
|
|
}
|
|
|
|
// Force SearchUpdater to mark this record as dirty
|
|
$manipulation = array(
|
|
$this->owner->ClassName => array(
|
|
'fields' => array(),
|
|
'id' => $this->owner->ID,
|
|
'command' => 'update'
|
|
)
|
|
);
|
|
$this->owner->extend('augmentWrite', $manipulation);
|
|
SearchUpdater::handle_manipulation($manipulation);
|
|
}
|
|
|
|
/**
|
|
* Forces this object to trigger a re-index in the current state
|
|
*/
|
|
public function triggerReindex()
|
|
{
|
|
if (!$this->owner->ID) {
|
|
return;
|
|
}
|
|
|
|
$id = $this->owner->ID;
|
|
$class = $this->owner->ClassName;
|
|
$state = SearchVariant::current_state($class);
|
|
$base = ClassInfo::baseDataClass($class);
|
|
$key = "$id:$base:".serialize($state);
|
|
|
|
$statefulids = array(array(
|
|
'id' => $id,
|
|
'state' => $state
|
|
));
|
|
|
|
$writes = array(
|
|
$key => array(
|
|
'base' => $base,
|
|
'class' => $class,
|
|
'id' => $id,
|
|
'statefulids' => $statefulids,
|
|
'fields' => array()
|
|
)
|
|
);
|
|
|
|
SearchUpdater::process_writes($writes);
|
|
}
|
|
} |