SubscriptionController.php in Commerce Recurring Framework 8
File
src/Controller/SubscriptionController.php
View source
<?php
namespace Drupal\commerce_recurring\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
class SubscriptionController extends ControllerBase {
protected $entityTypeBundleInfo;
public function __construct(EntityTypeBundleInfoInterface $entity_type_bundle_info) {
$this->entityTypeBundleInfo = $entity_type_bundle_info;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.bundle.info'));
}
public function adminOverview() {
$header = [
$this
->t('Subscription type'),
$this
->t('Operations'),
];
$rows = [];
$bundles = $this->entityTypeBundleInfo
->getBundleInfo('commerce_subscription');
foreach ($bundles as $bundle_name => $bundle_info) {
$route_parameters = [
'bundle' => $bundle_name,
];
$links = [
'manage-fields' => [
'title' => $this
->t('Manage fields'),
'url' => Url::fromRoute('entity.commerce_subscription.field_ui_fields', $route_parameters),
],
'manage-form-display' => [
'title' => $this
->t('Manage form display'),
'url' => Url::fromRoute('entity.entity_form_display.commerce_subscription.default', $route_parameters),
],
'manage-display' => [
'title' => $this
->t('Manage display'),
'url' => Url::fromRoute('entity.entity_view_display.commerce_subscription.default', $route_parameters),
],
];
$rows[] = [
$bundle_info['label'],
[
'data' => [
'#type' => 'operations',
'#links' => $links,
],
],
];
}
$build['subscription_types'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
];
return $build;
}
}