Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
313
Merge Requests
313
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
13e0794e
Commit
13e0794e
authored
Mar 20, 2015
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2445723
by dawehner, neclimdul: Use the $request format instead of the ContentNegotation
parent
566bc8bd
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
199 additions
and
255 deletions
+199
-255
core/core.services.yml
core/core.services.yml
+15
-11
core/lib/Drupal/Core/Ajax/AjaxSubscriber.php
core/lib/Drupal/Core/Ajax/AjaxSubscriber.php
+0
-43
core/lib/Drupal/Core/EventSubscriber/ContentControllerSubscriber.php
...upal/Core/EventSubscriber/ContentControllerSubscriber.php
+0
-35
core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php
...rupal/Core/EventSubscriber/DefaultExceptionSubscriber.php
+1
-3
core/lib/Drupal/Core/EventSubscriber/HttpExceptionSubscriberBase.php
...upal/Core/EventSubscriber/HttpExceptionSubscriberBase.php
+1
-11
core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php
core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php
+3
-16
core/lib/Drupal/Core/Routing/AcceptHeaderMatcher.php
core/lib/Drupal/Core/Routing/AcceptHeaderMatcher.php
+1
-19
core/lib/Drupal/Core/Routing/RoutePreloader.php
core/lib/Drupal/Core/Routing/RoutePreloader.php
+2
-13
core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php
...lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php
+83
-0
core/lib/Drupal/Core/StackMiddleware/PageCache.php
core/lib/Drupal/Core/StackMiddleware/PageCache.php
+2
-13
core/modules/hal/hal.services.yml
core/modules/hal/hal.services.yml
+0
-4
core/modules/hal/src/HalServiceProvider.php
core/modules/hal/src/HalServiceProvider.php
+28
-0
core/modules/hal/src/HalSubscriber.php
core/modules/hal/src/HalSubscriber.php
+0
-41
core/modules/rest/src/Plugin/views/display/RestExport.php
core/modules/rest/src/Plugin/views/display/RestExport.php
+3
-15
core/modules/rest/tests/src/Unit/CollectRoutesTest.php
core/modules/rest/tests/src/Unit/CollectRoutesTest.php
+0
-6
core/modules/system/src/Tests/Bootstrap/PageCacheTest.php
core/modules/system/src/Tests/Bootstrap/PageCacheTest.php
+45
-0
core/tests/Drupal/Tests/Core/Routing/AcceptHeaderMatcherTest.php
...sts/Drupal/Tests/Core/Routing/AcceptHeaderMatcherTest.php
+12
-8
core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php
core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php
+3
-17
No files found.
core/core.services.yml
View file @
13e0794e
...
...
@@ -486,6 +486,18 @@ services:
http_kernel.basic
:
class
:
Symfony\Component\HttpKernel\HttpKernel
arguments
:
[
'
@event_dispatcher'
,
'
@controller_resolver'
,
'
@request_stack'
]
http_negotiation.format_negotiator
:
class
:
Drupal\Core\ContentNegotiation
private
:
true
http_middleware.negotiation
:
class
:
Drupal\Core\StackMiddleware\NegotiationMiddleware
arguments
:
[
'
@http_negotiation.format_negotiator'
]
calls
:
-
[
registerFormat
,
[
'
drupal_ajax'
,
[
'
application/vnd.drupal-ajax'
]]]
-
[
registerFormat
,
[
'
drupal_dialog'
,
[
'
application/vnd.drupal-dialog'
]]]
-
[
registerFormat
,
[
'
drupal_modal'
,
[
'
application/vnd.drupal-modal'
]]]
tags
:
-
{
name
:
http_middleware
,
priority
:
400
}
http_middleware.reverse_proxy
:
class
:
Drupal\Core\StackMiddleware\ReverseProxyMiddleware
arguments
:
[
'
@settings'
]
...
...
@@ -493,7 +505,7 @@ services:
-
{
name
:
http_middleware
,
priority
:
300
}
http_middleware.page_cache
:
class
:
Drupal\Core\StackMiddleware\PageCache
arguments
:
[
'
@cache.render'
,
'
@page_cache_request_policy'
,
'
@page_cache_response_policy'
,
'
@content_negotiation'
]
arguments
:
[
'
@cache.render'
,
'
@page_cache_request_policy'
,
'
@page_cache_response_policy'
]
tags
:
-
{
name
:
http_middleware
,
priority
:
200
}
http_middleware.kernel_pre_handle
:
...
...
@@ -571,7 +583,7 @@ services:
-
{
name
:
backend_overridable
}
router.route_preloader
:
class
:
Drupal\Core\Routing\RoutePreloader
arguments
:
[
'
@router.route_provider'
,
'
@state'
,
'
@content_negotiation'
]
arguments
:
[
'
@router.route_provider'
,
'
@state'
]
tags
:
-
{
name
:
'
event_subscriber'
}
router.matcher.final_matcher
:
...
...
@@ -682,7 +694,6 @@ services:
arguments
:
[
16
]
accept_header_matcher
:
class
:
Drupal\Core\Routing\AcceptHeaderMatcher
arguments
:
[
'
@content_negotiation'
]
tags
:
-
{
name
:
route_filter
}
content_type_header_matcher
:
...
...
@@ -749,7 +760,6 @@ services:
-
{
name
:
route_enhancer
,
priority
:
20
}
route_content_controller_subscriber
:
class
:
Drupal\Core\EventSubscriber\ContentControllerSubscriber
arguments
:
[
'
@content_negotiation'
]
tags
:
-
{
name
:
event_subscriber
}
route_special_attributes_subscriber
:
...
...
@@ -799,13 +809,11 @@ services:
tags
:
-
{
name
:
event_subscriber
}
arguments
:
[
'
@router'
,
'
@router.request_context'
,
NULL
,
'
@request_stack'
]
content_negotiation
:
class
:
Drupal\Core\ContentNegotiation
view_subscriber
:
class
:
Drupal\Core\EventSubscriber\ViewSubscriber
arguments
:
[
'
@title_resolver'
]
tags
:
-
{
name
:
event_subscriber
}
arguments
:
[
'
@content_negotiation'
,
'
@title_resolver'
]
bare_html_page_renderer
:
class
:
Drupal\Core\Render\BareHtmlPageRenderer
arguments
:
[
'
@renderer'
]
...
...
@@ -1003,10 +1011,6 @@ services:
-
{
name
:
event_subscriber
}
calls
:
-
[
setContainer
,
[
'
@service_container'
]]
ajax.subscriber
:
class
:
Drupal\Core\Ajax\AjaxSubscriber
tags
:
-
{
name
:
event_subscriber
}
image.toolkit.manager
:
class
:
Drupal\Core\ImageToolkit\ImageToolkitManager
arguments
:
[
'
@config.factory'
]
...
...
core/lib/Drupal/Core/Ajax/AjaxSubscriber.php
deleted
100644 → 0
View file @
566bc8bd
<?php
/**
* @file
* Contains \Drupal\Core\Ajax\AjaxSubscriber.
*/
namespace
Drupal\Core\Ajax
;
use
Symfony\Component\HttpKernel\KernelEvents
;
use
Symfony\Component\HttpKernel\Event\GetResponseEvent
;
use
Symfony\Component\EventDispatcher\EventSubscriberInterface
;
/**
* Subscribes to the kernel request event to add the Ajax media type.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
* The event to process.
*/
class
AjaxSubscriber
implements
EventSubscriberInterface
{
/**
* Registers Ajax formats with the Request class.
*/
public
function
onKernelRequest
(
GetResponseEvent
$event
)
{
$request
=
$event
->
getRequest
();
$request
->
setFormat
(
'drupal_ajax'
,
'application/vnd.drupal-ajax'
);
$request
->
setFormat
(
'drupal_dialog'
,
'application/vnd.drupal-dialog'
);
$request
->
setFormat
(
'drupal_modal'
,
'application/vnd.drupal-modal'
);
}
/**
* Registers the methods in this class that should be listeners.
*
* @return array
* An array of event listener definitions.
*/
static
function
getSubscribedEvents
(){
$events
[
KernelEvents
::
REQUEST
][]
=
array
(
'onKernelRequest'
,
50
);
return
$events
;
}
}
\ No newline at end of file
core/lib/Drupal/Core/EventSubscriber/ContentControllerSubscriber.php
View file @
13e0794e
...
...
@@ -7,7 +7,6 @@
namespace
Drupal\Core\EventSubscriber
;
use
Drupal\Core\ContentNegotiation
;
use
Symfony\Component\EventDispatcher\EventSubscriberInterface
;
use
Symfony\Component\HttpKernel\Event\GetResponseEvent
;
use
Symfony\Component\HttpKernel\KernelEvents
;
...
...
@@ -20,39 +19,6 @@
*/
class
ContentControllerSubscriber
implements
EventSubscriberInterface
{
/**
* Content negotiation library.
*
* @var \Drupal\Core\ContentNegotiation
*/
protected
$negotiation
;
/**
* Constructs a new ContentControllerSubscriber object.
*
* @param \Drupal\Core\ContentNegotiation $negotiation
* The Content Negotiation service.
*/
public
function
__construct
(
ContentNegotiation
$negotiation
)
{
$this
->
negotiation
=
$negotiation
;
}
/**
* Sets the derived request format on the request.
*
* @todo Remove when https://www.drupal.org/node/2331919 lands.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
* The event to process.
*/
public
function
onRequestDeriveFormat
(
GetResponseEvent
$event
)
{
$request
=
$event
->
getRequest
();
if
(
!
$request
->
attributes
->
get
(
'_format'
))
{
$request
->
setRequestFormat
(
$this
->
negotiation
->
getContentType
(
$request
));
}
}
/**
* Sets the _controller on a request when a _form is defined.
*
...
...
@@ -74,7 +40,6 @@ public function onRequestDeriveFormWrapper(GetResponseEvent $event) {
* An array of event listener definitions.
*/
static
function
getSubscribedEvents
()
{
$events
[
KernelEvents
::
REQUEST
][]
=
array
(
'onRequestDeriveFormat'
,
31
);
$events
[
KernelEvents
::
REQUEST
][]
=
array
(
'onRequestDeriveFormWrapper'
,
29
);
return
$events
;
...
...
core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php
View file @
13e0794e
...
...
@@ -10,7 +10,6 @@
use
Drupal\Component\Utility\SafeMarkup
;
use
Drupal\Component\Utility\String
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\ContentNegotiation
;
use
Drupal\Core\Render\BareHtmlPageRendererInterface
;
use
Drupal\Core\StringTranslation\StringTranslationTrait
;
use
Drupal\Core\Utility\Error
;
...
...
@@ -206,8 +205,7 @@ protected function getFormat(Request $request) {
// to this code. We therefore use this style for now on the expectation
// that it will get replaced with better code later. This approach makes
// that change easier when we get to it.
$conneg
=
new
ContentNegotiation
();
$format
=
$conneg
->
getContentType
(
$request
);
$format
=
\
Drupal
::
service
(
'http_negotiation.format_negotiator'
)
->
getContentType
(
$request
);
// These are all JSON errors for our purposes. Any special handling for
// them can/should happen in earlier listeners if desired.
...
...
core/lib/Drupal/Core/EventSubscriber/HttpExceptionSubscriberBase.php
View file @
13e0794e
...
...
@@ -7,7 +7,6 @@
namespace
Drupal\Core\EventSubscriber
;
use
Drupal\Core\ContentNegotiation
;
use
Symfony\Component\EventDispatcher\EventSubscriberInterface
;
use
Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent
;
use
Symfony\Component\HttpKernel\Exception\HttpExceptionInterface
;
...
...
@@ -91,16 +90,7 @@ public function onException(GetResponseForExceptionEvent $event) {
$handled_formats
=
$this
->
getHandledFormats
();
// @todo Injecting this service would force all implementing classes to also
// handle its injection. However, we are trying to switch to a more robust
// content negotiation library in https://www.drupal.org/node/1505080 that
// will make $request->getRequestFormat() reliable as a better alternative
// to this code. We therefore use this style for now on the expectation
// that it will get replaced with better code later. That change will NOT
// be an API change for any implementing classes. (Whereas if we injected
// this class it would be an API change. That's why we're not doing it.)
$conneg
=
new
ContentNegotiation
();
$format
=
$conneg
->
getContentType
(
$event
->
getRequest
());
$format
=
$event
->
getRequest
()
->
getRequestFormat
();
if
(
$exception
instanceof
HttpExceptionInterface
&&
(
empty
(
$handled_formats
)
||
in_array
(
$format
,
$handled_formats
)))
{
$method
=
'on'
.
$exception
->
getStatusCode
();
...
...
core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php
View file @
13e0794e
...
...
@@ -16,8 +16,6 @@
use
Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent
;
use
Symfony\Component\EventDispatcher\EventSubscriberInterface
;
use
Drupal\Core\ContentNegotiation
;
/**
* Main subscriber for VIEW HTTP responses.
*
...
...
@@ -27,13 +25,6 @@
*/
class
ViewSubscriber
implements
EventSubscriberInterface
{
/**
* The content negotiation.
*
* @var \Drupal\Core\ContentNegotiation
*/
protected
$negotiation
;
/**
* The title resolver.
*
...
...
@@ -41,17 +32,13 @@ class ViewSubscriber implements EventSubscriberInterface {
*/
protected
$titleResolver
;
/**
* Constructs a new ViewSubscriber.
*
* @param \Drupal\Core\ContentNegotiation $negotiation
* The content negotiation.
* @param \Drupal\Core\Controller\TitleResolverInterface $title_resolver
* The title resolver.
*/
public
function
__construct
(
ContentNegotiation
$negotiation
,
TitleResolverInterface
$title_resolver
)
{
$this
->
negotiation
=
$negotiation
;
public
function
__construct
(
TitleResolverInterface
$title_resolver
)
{
$this
->
titleResolver
=
$title_resolver
;
}
...
...
@@ -64,14 +51,14 @@ public function __construct(ContentNegotiation $negotiation, TitleResolverInterf
* from an JSON-type response is a JSON string, so just wrap it into a
* Response object.
*
* @param Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event
* @param
\
Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event
* The Event to process.
*/
public
function
onView
(
GetResponseForControllerResultEvent
$event
)
{
$request
=
$event
->
getRequest
();
if
(
$event
->
getRequestType
()
==
HttpKernelInterface
::
MASTER_REQUEST
)
{
$method
=
'on'
.
$
this
->
negotiation
->
getContentType
(
$request
);
$method
=
'on'
.
$
request
->
getRequestFormat
(
);
if
(
method_exists
(
$this
,
$method
))
{
$event
->
setResponse
(
$this
->
$method
(
$event
));
...
...
core/lib/Drupal/Core/Routing/AcceptHeaderMatcher.php
View file @
13e0794e
...
...
@@ -8,7 +8,6 @@
namespace
Drupal\Core\Routing
;
use
Drupal\Component\Utility\String
;
use
Drupal\Core\ContentNegotiation
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException
;
use
Symfony\Component\Routing\Route
;
...
...
@@ -19,23 +18,6 @@
*/
class
AcceptHeaderMatcher
implements
RouteFilterInterface
{
/**
* The content negotiation library.
*
* @var \Drupal\Core\ContentNegotiation
*/
protected
$contentNegotiation
;
/**
* Constructs a new AcceptHeaderMatcher.
*
* @param \Drupal\Core\ContentNegotiation $content_negotiation
* The content negotiation library.
*/
public
function
__construct
(
ContentNegotiation
$content_negotiation
)
{
$this
->
contentNegotiation
=
$content_negotiation
;
}
/**
* {@inheritdoc}
*/
...
...
@@ -44,7 +26,7 @@ public function filter(RouteCollection $collection, Request $request) {
// @todo replace by proper content negotiation library.
$acceptable_mime_types
=
$request
->
getAcceptableContentTypes
();
$acceptable_formats
=
array_filter
(
array_map
(
array
(
$request
,
'getFormat'
),
$acceptable_mime_types
));
$primary_format
=
$
this
->
contentNegotiation
->
getContentType
(
$request
);
$primary_format
=
$
request
->
getRequestFormat
(
);
foreach
(
$collection
as
$name
=>
$route
)
{
// _format could be a |-delimited list of supported formats.
...
...
core/lib/Drupal/Core/Routing/RoutePreloader.php
View file @
13e0794e
...
...
@@ -7,7 +7,6 @@
namespace
Drupal\Core\Routing
;
use
Drupal\Core\ContentNegotiation
;
use
Drupal\Core\State\StateInterface
;
use
Symfony\Component\EventDispatcher\Event
;
use
Symfony\Component\EventDispatcher\EventSubscriberInterface
;
...
...
@@ -37,13 +36,6 @@ class RoutePreloader implements EventSubscriberInterface {
*/
protected
$state
;
/**
* The content negotiation.
*
* @var \Drupal\Core\ContentNegotiation
*/
protected
$negotiation
;
/**
* Contains the non-admin routes while rebuilding the routes.
*
...
...
@@ -58,13 +50,10 @@ class RoutePreloader implements EventSubscriberInterface {
* The route provider.
* @param \Drupal\Core\State\StateInterface $state
* The state key value store.
* @param \Drupal\Core\ContentNegotiation $negotiation
* The content negotiation.
*/
public
function
__construct
(
RouteProviderInterface
$route_provider
,
StateInterface
$state
,
ContentNegotiation
$negotiation
)
{
public
function
__construct
(
RouteProviderInterface
$route_provider
,
StateInterface
$state
)
{
$this
->
routeProvider
=
$route_provider
;
$this
->
state
=
$state
;
$this
->
negotiation
=
$negotiation
;
}
/**
...
...
@@ -75,7 +64,7 @@ public function __construct(RouteProviderInterface $route_provider, StateInterfa
*/
public
function
onRequest
(
KernelEvent
$event
)
{
// Just preload on normal HTML pages, as they will display menu links.
if
(
$
this
->
negotiation
->
getContentType
(
$event
->
getRequest
()
)
==
'html'
)
{
if
(
$
event
->
getRequest
()
->
getRequestFormat
(
)
==
'html'
)
{
$this
->
loadNonAdminRoutes
();
}
}
...
...
core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php
0 → 100644
View file @
13e0794e
<?php
/**
* @file
* Contains \Drupal\Core\StackMiddleware\NegotationMiddleware.
*/
namespace
Drupal\Core\StackMiddleware
;
use
Drupal\Core\ContentNegotiation
;
use
Drupal\Core\ContentNegotiationInterface
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpKernel\HttpKernelInterface
;
/**
* Provides a middleware to determine the content type upon the accept header.
*
* @todo This is a temporary solution, remove this in https://www.drupal.org/node/2364011
*/
class
NegotiationMiddleware
implements
HttpKernelInterface
{
/**
* The wrapped HTTP kernel.
*
* @var \Symfony\Component\HttpKernel\HttpKernelInterface
*/
protected
$app
;
/**
* The content negotiator.
*
* @var \Drupal\Core\ContentNegotiation
*/
protected
$negotiator
;
/**
* Contains a hashmap of format as key and mimetype as value.
*
* @var array
*/
protected
$formats
;
/**
* Constructs a new NegotiationMiddleware.
*
* @param \Symfony\Component\HttpKernel\HttpKernelInterface $app
* The wrapper HTTP kernel
* @param \Drupal\Core\ContentNegotiation $negotiator
* The content negotiator.
*/
public
function
__construct
(
HttpKernelInterface
$app
,
ContentNegotiation
$negotiator
)
{
$this
->
app
=
$app
;
$this
->
negotiator
=
$negotiator
;
}
/**
* {@inheritdoc}
*/
public
function
handle
(
Request
$request
,
$type
=
self
::
MASTER_REQUEST
,
$catch
=
true
)
{
foreach
(
$this
->
formats
as
$format
=>
$mime_type
)
{
$request
->
setFormat
(
$format
,
$mime_type
);
}
$request
->
setRequestFormat
(
$this
->
negotiator
->
getContentType
(
$request
));
return
$this
->
app
->
handle
(
$request
,
$type
,
$catch
);
}
/**
* Registers a format for a given MIME type.
*
* @param string $format
* The format.
* @param string $mime_type
* The MIME type.
*
* @return $this
*/
public
function
registerFormat
(
$format
,
$mime_type
)
{
$this
->
formats
[
$format
]
=
$mime_type
;
return
$this
;
}
}
core/lib/Drupal/Core/StackMiddleware/PageCache.php
View file @
13e0794e
...
...
@@ -9,7 +9,6 @@
use
Drupal\Core\Cache\Cache
;
use
Drupal\Core\Cache\CacheBackendInterface
;
use
Drupal\Core\ContentNegotiation
;
use
Drupal\Core\PageCache\RequestPolicyInterface
;
use
Drupal\Core\PageCache\ResponsePolicyInterface
;
use
Drupal\Core\Site\Settings
;
...
...
@@ -52,13 +51,6 @@ class PageCache implements HttpKernelInterface {
*/
protected
$responsePolicy
;
/**
* The content negotiation library.
*
* @var \Drupal\Core\ContentNegotiation
*/
protected
$contentNegotiation
;
/**
* Constructs a ReverseProxyMiddleware object.
*
...
...
@@ -70,15 +62,12 @@ class PageCache implements HttpKernelInterface {
* A policy rule determining the cacheability of a request.
* @param \Drupal\Core\PageCache\ResponsePolicyInterface $response_policy
* A policy rule determining the cacheability of the response.
* @param \Drupal\Core\ContentNegotiation $content_negotiation
* The content negotiation library.
*/
public
function
__construct
(
HttpKernelInterface
$http_kernel
,
CacheBackendInterface
$cache
,
RequestPolicyInterface
$request_policy
,
ResponsePolicyInterface
$response_policy
,
ContentNegotiation
$content_negotiation
)
{
public
function
__construct
(
HttpKernelInterface
$http_kernel
,
CacheBackendInterface
$cache
,
RequestPolicyInterface
$request_policy
,
ResponsePolicyInterface
$response_policy
)
{
$this
->
httpKernel
=
$http_kernel
;
$this
->
cache
=
$cache
;
$this
->
requestPolicy
=
$request_policy
;
$this
->
responsePolicy
=
$response_policy
;
$this
->
contentNegotiation
=
$content_negotiation
;
}
/**
...
...
@@ -332,7 +321,7 @@ protected function set(Request $request, Response $response, $expire, array $tag
protected
function
getCacheId
(
Request
$request
)
{
$cid_parts
=
array
(
$request
->
getUri
(),
$
this
->
contentNegotiation
->
getContentType
(
$request
),
$
request
->
getRequestFormat
(
),
);
return
implode
(
':'
,
$cid_parts
);
}
...
...
core/modules/hal/hal.services.yml
View file @
13e0794e
...
...
@@ -26,7 +26,3 @@ services:
class
:
Drupal\hal\Encoder\JsonEncoder
tags
:
-
{
name
:
encoder
,
priority
:
10
,
format
:
hal_json
}
hal.subscriber
:
class
:
Drupal\hal\HalSubscriber
tags
:
-
{
name
:
event_subscriber
}
core/modules/hal/src/HalServiceProvider.php
0 → 100644
View file @
13e0794e
<?php
/**
* @file
* Contains \Drupal\hal\HalServiceProvider.
*/
namespace
Drupal\hal
;
use
Drupal\Core\DependencyInjection\ContainerBuilder
;
use
Drupal\Core\DependencyInjection\ServiceModifierInterface
;
/**
* Adds hal+json as known format.
*/
class
HalServiceProvider
implements
ServiceModifierInterface
{
/**
* {@inheritdoc}
*/
public
function
alter
(
ContainerBuilder
$container
)
{
if
(
$container
->
has
(
'http_middleware.negotiation'
))
{
$container
->
getDefinition
(
'http_middleware.negotiation'
)
->
addMethodCall
(
'registerFormat'
,
[
'hal_json'
,
[
'application/hal+json'
]]);
}
}
}
core/modules/hal/src/HalSubscriber.php
deleted
100644 → 0
View file @
566bc8bd
<?php
/**
* @file
* Contains \Drupal\hal\HalSubscriber.
*/
namespace
Drupal\hal
;
use
Symfony\Component\HttpKernel\KernelEvents
;
use
Symfony\Component\HttpKernel\Event\GetResponseEvent
;
use
Symfony\Component\EventDispatcher\EventSubscriberInterface
;
/**
* Subscribes to the kernel request event to add HAL media types.
*/
class
HalSubscriber
implements
EventSubscriberInterface
{
/**
* Registers HAL formats with the Request class.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
* The event to process.
*/
public
function
onKernelRequest
(
GetResponseEvent
$event
)
{
$request
=
$event
->
getRequest
();
$request
->
setFormat
(
'hal_json'
,
'application/hal+json'
);
}
/**
* Registers the methods in this class that should be listeners.
*
* @return array
* An array of event listener definitions.
*/
static
function
getSubscribedEvents
()
{
$events
[
KernelEvents
::
REQUEST
][]
=
array
(
'onKernelRequest'
,
40
);
return
$events
;
}
}
core/modules/rest/src/Plugin/views/display/RestExport.php
View file @
13e0794e
...
...
@@ -10,7 +10,6 @@
use
Drupal\Component\Utility\String
;
use
Drupal\Core\State\StateInterface
;
use
Drupal\Core\Routing\RouteProviderInterface
;
use
Drupal\Core\ContentNegotiation
;
use
Drupal\views\ViewExecutable
;
use
Drupal\views\Plugin\views\display\PathPluginBase
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
...
...
@@ -72,13 +71,6 @@ class RestExport extends PathPluginBase {
*/
protected
$mimeType
;
/**
* The content negotiation library.
*
* @var \Drupal\Core\ContentNegotiation
*/
protected
$contentNegotiation
;
/**
* Constructs a Drupal\rest\Plugin\ResourceBase object.
*
...
...
@@ -92,12 +84,9 @@ class RestExport extends PathPluginBase {
* The route provider
* @param \Drupal\Core\State\StateInterface $state
* The state key value store.
* @param \Drupal\Core\ContentNegotiation $content_negotiation
* The content negotiation library.
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
RouteProviderInterface
$route_provider
,
StateInterface
$state
,
ContentNegotiation
$content_negotiation
)
{
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
RouteProviderInterface
$route_provider
,
StateInterface
$state
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$route_provider
,
$state
);
$this
->
contentNegotiation
=
$content_negotiation
;
}
/**
...
...
@@ -109,8 +98,7 @@ public static function create(ContainerInterface $container, array $configuratio
$plugin_id
,