Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
search_api_decoupled
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
search_api_decoupled
Merge requests
!29
Issue
#3468145
: Allow search page for UI configuration
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3468145
: Allow search page for UI configuration
issue/search_api_decoupled-3468145:3468145-allow-search-page
into
1.x
Overview
0
Commits
3
Pipelines
4
Changes
6
Merged
Artem Dmitriiev
requested to merge
issue/search_api_decoupled-3468145:3468145-allow-search-page
into
1.x
9 months ago
Overview
0
Commits
3
Pipelines
4
Changes
6
Expand
Closes
#3468145
0
0
Merge request reports
Compare
1.x
version 2
31021276
6 months ago
version 1
e45d857c
9 months ago
1.x (base)
and
latest version
latest version
fb6d1ef6
3 commits,
6 months ago
version 2
31021276
2 commits,
6 months ago
version 1
e45d857c
1 commit,
9 months ago
6 files
+
114
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
modules/ui/src/Controller/SearchPage.php
0 → 100644
+
71
−
0
Options
<?php
namespace
Drupal\search_api_decoupled_ui\Controller
;
use
Drupal\Core\Controller\ControllerBase
;
use
Drupal\Core\Http\Exception\CacheableNotFoundHttpException
;
use
Drupal\search_api_decoupled_ui
\SearchApiEndpointUiInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Class SearchPage for dedicated "coupled" search page.
*/
class
SearchPage
extends
ControllerBase
{
/**
* The block manager.
*
* @var \Drupal\Core\Block\BlockManagerInterface
*/
protected
$blockManager
;
/**
* {@inheritDoc}
*/
public
static
function
create
(
ContainerInterface
$container
)
{
$instance
=
parent
::
create
(
$container
);
$instance
->
blockManager
=
$container
->
get
(
'plugin.manager.block'
);
return
$instance
;
}
/**
* Gets the dedicated search page title.
*
* @param \Drupal\search_api_decoupled_ui\SearchApiEndpointUiInterface $search_api_endpoint
* The search api endpoint.
*
* @return string
* The page title.
*/
public
function
title
(
SearchApiEndpointUiInterface
$search_api_endpoint
)
{
if
(
$search_api_endpoint
->
withSearchPage
())
{
return
$search_api_endpoint
->
label
();
}
return
$this
->
t
(
'Page not found'
);
}
/**
* Gets the dedicated search page content.
*
* @param \Drupal\search_api_decoupled_ui\SearchApiEndpointUiInterface $search_api_endpoint
* The search api endpoint.
*
* @return array
* The page content as render array.
*/
public
function
content
(
SearchApiEndpointUiInterface
$search_api_endpoint
)
{
if
(
!
$search_api_endpoint
->
withSearchPage
())
{
throw
new
CacheableNotFoundHttpException
(
$search_api_endpoint
);
}
$search_block
=
$this
->
blockManager
->
createInstance
(
'search_api_endpoint:'
.
$search_api_endpoint
->
id
());
return
[
'#theme'
=>
'block'
,
'#configuration'
=>
$search_block
->
getConfiguration
(),
'#plugin_id'
=>
$search_block
->
getPluginId
(),
'#base_plugin_id'
=>
$search_block
->
getBaseId
(),
'#derivative_plugin_id'
=>
$search_block
->
getDerivativeId
(),
'content'
=>
$search_block
->
build
(),
];
}
}
Loading