Кастомизация процессора получения групп (тэгов)

Как создать свой процессор:  

 Пример: Фильтрация по resource_id (Что группы были для каждого ресурса свои и не повторялись в других) Создайте файл: в core/components/gallery3x/src/Processors/GetGroupsByResource.php 

 <?php

namespace Gallery3x\Processors;

use Gallery3x\Model\Gallery3xFile;

class GetGroupsByResource extends GetGroupsCombined

{

 public function process()

 {

 $resourceId = $this->getProperty('resource_id');

 $allGroups = [];

 // Только для текущего ресурса

 $fileTableName = $this->modx->getTableName(Gallery3xFile::class);

 $sql = "SELECT DISTINCT `group` FROM {$fileTableName} 

 WHERE `group` IS NOT NULL 

 AND `group` != '' 

 AND `resource_id` = :resource_id

 ORDER BY `group` ASC";

 $stmt = $this->modx->prepare($sql);

 $stmt->bindValue(':resource_id', $resourceId);

 if ($stmt->execute()) {

 while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {

 $groupsInRow = explode('||', $row['group']);

 foreach ($groupsInRow as $group) {

 $group = trim($group);

 if (!empty($group)) {

 $allGroups[] = $group;

 }

 }

 }

 }

 // То же для видео...

 $uniqueGroups = array_unique($allGroups);

 sort($uniqueGroups);

 $groups = [];

 foreach ($uniqueGroups as $group) {

 $groups[] = ['name' => $group];

 }

 return $this->success('', ['results' => $groups, 'total' => count($groups)]);

 }

} 

 Затем в настройках: 

 gallery3x.groups_processor = Gallery3x\Processors\GetGroupsByResource