Skip to content
Snippets Groups Projects
Commit c0293691 authored by Eirik Morland's avatar Eirik Morland
Browse files

Issue #3360572 by eiriksm: Create controllers for projects and billing

parent cdf421b0
No related branches found
No related tags found
1 merge request!16Issue #3360572: Create controllers for projects and billing
<?php
namespace Drupal\violinist_teams\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\violinist_teams\TeamNode;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Returns responses for Violinist teams routes.
*/
class BillingController extends ControllerBase {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The controller constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity_type.manager')
);
}
/**
* Builds the response.
*/
public function build(TeamNode $team) {
$build = [];
return $build;
}
}
<?php
namespace Drupal\violinist_teams\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\violinist_teams\TeamManager;
use Drupal\violinist_teams\TeamNode;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Returns responses for Violinist teams routes.
*/
class TeamProjectController extends ControllerBase {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Team manager.
*
* @var \Drupal\violinist_teams\TeamManager
*/
protected $teamManager;
/**
* The controller constructor.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, TeamManager $teamManager) {
$this->entityTypeManager = $entity_type_manager;
$this->teamManager = $teamManager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity_type.manager'),
$container->get('violinist_teams.team_manager')
);
}
/**
* Builds the response.
*/
public function build(TeamNode $team) {
$projects = $this->teamManager->getProjects($team);
$build = [];
foreach ($projects as $project) {
$build[] = [
'#markup' => $project->label(),
];
}
return $build;
}
}
violinist_teams.projects:
path: '/teams/{team}/projects'
defaults:
_title: 'Projects'
_controller: '\Drupal\violinist_teams\Controller\TeamProjectController::build'
options:
parameters:
team:
type: entity:node
requirements:
_permission: 'access content'
violinist_teams.billing:
path: '/teams/{team}/billing'
defaults:
_title: 'Billing'
_controller: '\Drupal\violinist_teams\Controller\BillingController::build'
options:
parameters:
team:
type: entity:node
requirements:
_permission: 'access content'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment