TeamAppCreateFormBase.php in Apigee Edge 8
File
modules/apigee_edge_teams/src/Entity/Form/TeamAppCreateFormBase.php
View source
<?php
namespace Drupal\apigee_edge_teams\Entity\Form;
use Drupal\apigee_edge\Entity\Controller\ApiProductControllerInterface;
use Drupal\apigee_edge\Entity\Controller\AppCredentialControllerInterface;
use Drupal\apigee_edge\Entity\Form\AppCreateForm;
use Drupal\apigee_edge_teams\Entity\Controller\TeamAppCredentialControllerFactoryInterface;
use Drupal\apigee_edge_teams\TeamMemberApiProductAccessHandlerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class TeamAppCreateFormBase extends AppCreateForm {
use TeamAppFormTrait;
protected $appCredentialControllerFactory;
public function __construct(EntityTypeManagerInterface $entity_type_manager, ApiProductControllerInterface $api_product_controller, TeamAppCredentialControllerFactoryInterface $app_credential_controller_factory, TeamMemberApiProductAccessHandlerInterface $team_member_api_product_access_handler) {
parent::__construct($entity_type_manager, $api_product_controller);
$this->appCredentialControllerFactory = $app_credential_controller_factory;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'), $container
->get('apigee_edge.controller.api_product'), $container
->get('apigee_edge_teams.controller.team_app_credential_controller_factory'), $container
->get('apigee_edge_teams.team_member_api_product_access_handler'));
}
protected function alterFormWithApiProductElement(array &$form, FormStateInterface $form_state) : void {
parent::alterFormWithApiProductElement($form, $form_state);
$form['api_products'] += $this
->nonMemberApiProductAccessWarningElement($form, $form_state);
}
protected function appCredentialController(string $owner, string $app_name) : AppCredentialControllerInterface {
return $this->appCredentialControllerFactory
->teamAppCredentialController($owner, $app_name);
}
protected function getRedirectUrl() : Url {
$entity = $this
->getEntity();
if ($entity
->hasLinkTemplate('collection-by-team')) {
return $entity
->toUrl('collection-by-team');
}
return parent::getRedirectUrl();
}
}