Skip to content
Snippets Groups Projects
Commit 7c727bed authored by Mitchell Markoff's avatar Mitchell Markoff Committed by Brian Perry
Browse files

Issue #3391729 by brianperry, mitchellmarkoff, coby.sher: Associate an oauth...

Issue #3391729 by brianperry, mitchellmarkoff, coby.sher: Associate an oauth consumer with a preview site
parent 3dc97f8c
No related branches found
No related tags found
4 merge requests!18Bring fes-settings up to date with 1.0.x,!171.0.x -> fes-settings,!15Adjust Preview Site Create Form Redirect,!12DB-6443: Consumer Associated with Preview Site
......@@ -19,3 +19,5 @@ decoupled_preview.dp_preview_site.*:
type: string
content_type:
type: mapping
oauth_consumer:
type: string
......@@ -6,4 +6,5 @@ core_version_requirement: ^8.8 || ^9 || ^10
dependencies:
- decoupled_router:decoupled_router
- jsonapi_resources:jsonapi_resources
- simple_oauth:simple_oauth
configure: entity.dp_preview_site.collection
......@@ -18,6 +18,7 @@ class DpPreviewSiteListBuilder extends ConfigEntityListBuilder {
$header['id'] = $this->t('Machine name');
$header['status'] = $this->t('Status');
$header['preview_type'] = $this->t('Preview Type');
$header['oauth_consumer'] = $this->t('OAuth Consumer');
return $header + parent::buildHeader();
}
......@@ -30,6 +31,7 @@ class DpPreviewSiteListBuilder extends ConfigEntityListBuilder {
$row['id'] = $entity->id();
$row['status'] = $entity->status() ? $this->t('Enabled') : $this->t('Disabled');
$row['preview_type'] = $entity->get('preview_type');
$row['oauth_consumer'] = $entity->get('oauth_consumer');
return $row + parent::buildRow($entity);
}
......
......@@ -46,6 +46,7 @@ use Drupal\decoupled_preview\DpPreviewSiteInterface;
* "secret",
* "content_type",
* "preview_type",
* "oauth_consumer",
* }
* )
*/
......@@ -85,6 +86,13 @@ class DpPreviewSite extends ConfigEntityBase implements DpPreviewSiteInterface {
* @var array
*/
protected $content_type;
/**
* The associated oAuth consumer.
*
* @var array
*/
protected $oauth_consumer;
/**
* {@inheritdoc}
......
......@@ -99,6 +99,23 @@ class DpPreviewSiteForm extends EntityForm {
'#required' => TRUE,
];
$consumer_options = array();
$query = \Drupal::entityQuery('consumer')->accessCheck(TRUE)->execute();
$consumer_storage = \Drupal::entityTypeManager()->getStorage('consumer');
$consumers = $consumer_storage->loadMultiple($query);
foreach($consumers as $c) {
$consumer_options[$c->client_id->value] = t($c->label->value);
}
$form['oauth_consumer'] = [
'#type' => 'select',
'#title' => $this->t('OAuth Consumer'),
'#default_value' => $this->entity->get('oauth_consumer'),
"#empty_option"=>t('- Select -'),
'#options' => $consumer_options,
'#description' => $this->t('The OAuth Consumer to be used with this preview site.'),
'#required' => FALSE,
];
$form['content_type'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Select Content Type'),
......
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