-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Next preview plugin and event subscriber
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Drupal\stanford_profile_helper\Plugin\Next\PreviewUrlGenerator; | ||
|
||
use Drupal\Core\Entity\EntityInterface; | ||
use Drupal\Core\Url; | ||
use Drupal\next\Entity\NextSiteInterface; | ||
use Drupal\next\Plugin\PreviewUrlGeneratorBase; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
/** | ||
* Provides the preview_url_generator plugin based on simple query string. | ||
* | ||
* @PreviewUrlGenerator( | ||
* id = "simple_preview", | ||
* label = "Simple Preview", | ||
* description = "Use the preview token string for the parameter." | ||
* ) | ||
*/ | ||
class SimplePreview extends PreviewUrlGeneratorBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function generate(NextSiteInterface $next_site, EntityInterface $entity, string $resource_version = NULL): ?Url { | ||
$query = []; | ||
$query['slug'] = $entity->toUrl()->toString(); | ||
$query['secret'] = $next_site->getPreviewSecret(); | ||
|
||
return Url::fromUri($next_site->getPreviewUrl(), [ | ||
'query' => $query, | ||
]); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function validate(Request $request) {} | ||
|
||
} |