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 the Finder Indexer has finished them.
Performing further actions can be very useful in cases like:
Caching, Meta-data generation, Filters generation, Logging.
Lets add some logic to be executed on each event.
It will be nothing more than the generation of a log record, for each action.
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 items) 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 Front End Plugins |
Labels |
Added:
?
|
Category | Administration com_finder Front End Plugins | ⇒ | Administration com_finder |
Labels |
Added:
Conflicting Files
|
Category | Administration com_finder | ⇒ | Repository Administration com_admin SQL Postgresql |
This sounds sensible to me - but clearly somethings gone wrong with the rebasing here. Are you able to do this in a fresh PR please?
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-02-17 15:37:33 |
Closed_By | ⇒ | sakiss |
Title |
|
I have tested this item✅ successfully on c842c2a
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27814.