ModuleBuilderComponentListBuilder.php in Module Builder 8.3
File
src/ModuleBuilderComponentListBuilder.php
View source
<?php
namespace Drupal\module_builder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use DrupalCodeBuilder\Factory;
use DrupalCodeBuilder\Exception\SanityException;
class ModuleBuilderComponentListBuilder extends ConfigEntityListBuilder {
public function render() {
\Drupal::service('module_builder.drupal_code_builder')
->loadLibrary();
try {
Factory::getEnvironment()
->verifyEnvironment('hook_data');
} catch (SanityException $e) {
ExceptionHandler::handleSanityException($e);
}
return parent::render();
}
public function buildHeader() {
$header['label'] = t('Module name');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity
->label();
return $row + parent::buildRow($entity);
}
public function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
$component_sections_handler = \Drupal::service('entity_type.manager')
->getHandler($this->entityTypeId, 'component_sections');
$form_operations = $component_sections_handler
->getOperations();
if (isset($operations['edit'])) {
$operations['edit']['title'] = t('Edit info');
$operations['edit']['weight'] = 0;
}
$weight = 1;
foreach ($form_operations as $operation_name => $title) {
$operations[$operation_name] = array(
'title' => t($title),
'url' => $entity
->toUrl("{$operation_name}-form"),
'weight' => $weight,
);
$weight++;
}
return $operations;
}
}