User tests: Successful: Unsuccessful:
It triggers events after performing the basic finder indexer's actions.
The Indexer performs 3 tasks (index, delete, purge), though no any event triggered after they are finished.
Performing further actions can be very useful in cases like:
Caching, Meta-data generation, Filters generation, Logging.
Lets generate some log records for each event.
Open the file: plugins/finder/content/content.php
Within the class add/append the following code:
/**
* Triggered after saving an item or after running the indexer.
*
* @param Result $item
* @param Int $linkid
*
*/
public function onFinderIndexAfterIndex(Result $item, $linkId)
{
\Joomla\CMS\Log\Log::addLogger(array('text_file' => 'finder.log.php'), \Joomla\CMS\Log\Log::ALL, array('finder_plugin'));
\Joomla\CMS\Log\Log::add('onFinderIndexAfterIndex Run after:' . $linkId, \Joomla\CMS\Log\Log::INFO, 'finder_plugin');
}
/**
* Triggered after deleting an item or pressing 'Delete' in com_finder.
* @param int $linkId
*
*/
public function onFinderIndexAfterDelete($linkId)
{
\Joomla\CMS\Log\Log::addLogger(array('text_file' => 'finder.log.php'), \Joomla\CMS\Log\Log::ALL, array('finder_plugin'));
\Joomla\CMS\Log\Log::add('onFinderIndexAfterDelete Run after:' . $linkId, \Joomla\CMS\Log\Log::INFO, 'finder_plugin');
}
/**
* Triggered after purging (press 'Clear Index') in com_finder.
*/
public function onFinderIndexAfterPurge()
{
\Joomla\CMS\Log\Log::addLogger(array('text_file' => 'finder.log.php'), \Joomla\CMS\Log\Log::ALL, array('finder_plugin'));
\Joomla\CMS\Log\Log::add('onFinderIndexAfterPurge Run after', \Joomla\CMS\Log\Log::INFO, 'finder_plugin');
}
After appending the above code, log events will be created for each Indexer's actions.
You can check the log records in the file: administrator/logs/finder.log.php
Saving an existing article in com_content, 2 log records should be created:
a. One with the message: onFinderIndexAfterDelete Run after
b. One with the message: onFinderIndexAfterIndex Run after
Pressing the "Clear Index" in the com_finder, 1 log record should be created with the message: onFinderIndexAfterPurge
Deleting an item in com_finder, 1 log record should be created, with the message: onFinderIndexAfterDelete Run after
Pressing the "Index" in the com_finder, multiple log records (as many as the indexed articles) should be created with the message: onFinderIndexAfterIndex Run after
*As it is clear all the above is just for testing purpose.
Not sure
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_finder |
Labels |
Added:
?
|
Title |
|
I have tested this item
I have tested this item succesfully - SHA: 3e1674
Status | Pending | ⇒ | Ready to Commit |
RTC.
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-02-24 19:56:40 |
Closed_By | ⇒ | rdeutz | |
Labels |
Added:
?
?
|
I have tested this item✅ successfully on 3e1674f
Works as described
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27965.