SearchPage.php in Drupal 10
File
core/modules/search/src/Plugin/migrate/source/d7/SearchPage.php
View source
<?php
namespace Drupal\search\Plugin\migrate\source\d7;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\Variable;
class SearchPage extends Variable {
protected function initializeIterator() {
return new \ArrayIterator($this
->values());
}
protected function values() {
$search_active_modules = $this
->variableGet('search_active_modules', '');
$values = [];
foreach ([
'node',
'user',
] as $module) {
if (isset($search_active_modules[$module])) {
$tmp = [
'module' => $module,
'status' => $search_active_modules[$module],
];
if ($module === 'node') {
$tmp = array_merge($tmp, parent::values());
}
$values[] = $tmp;
}
}
return $values;
}
public function fields() {
return [
'module' => $this
->t('The module providing a search page.'),
'status' => $this
->t('Whether or not this module is enabled for search.'),
];
}
public function getIds() {
$ids['module']['type'] = 'string';
return $ids;
}
protected function doCount() {
return $this
->initializeIterator()
->count();
}
public function prepareRow(Row $row) {
$exists = $this
->moduleExists($row
->getSourceProperty('module'));
$row
->setSourceProperty('module_exists', $exists);
return parent::prepareRow($row);
}
}
Classes
Name |
Description |
SearchPage |
Drupal 7 search active core modules and rankings source from database. |