Skip to content

Commit ff0d6d9

Browse files
committed
First commit
1 parent e491ff7 commit ff0d6d9

File tree

5 files changed

+61
-52
lines changed

5 files changed

+61
-52
lines changed

DependencyInjection/CustomRequestResponserExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function load(array $configs, ContainerBuilder $container) : void
5252

5353
$loader->load('services.yaml');
5454
$loader->load('listeners.yaml');
55+
$loader->load('middlewares.yaml');
5556

5657
if (defined('B_PROLOG_INCLUDED') && B_PROLOG_INCLUDED === true) {
5758
$loader->load('bitrix.yaml');

Resources/config/listeners.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ services:
55
autoconfigure: true
66
public: true
77

8-
Symfony\Component\ExpressionLanguage\ExpressionLanguage: ~
9-
108
custom_request_responser.set.headers:
119
class: Prokl\CustomRequestResponserBundle\Event\Listeners\SetHeaders
1210
arguments: ['@Symfony\Component\ExpressionLanguage\ExpressionLanguage', '%custom_request_responser%']

Resources/config/middlewares.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
services:
2+
# конфигурация по умолчанию в *этом* файле
3+
_defaults:
4+
autowire: true
5+
autoconfigure: true
6+
public: true
7+
8+
# Injects tags in the HEAD to enable the browser to do DNS prefetching.
9+
custom_request_responser.middleware.dns_prefetch:
10+
class: Prokl\CustomRequestResponserBundle\Services\PageSpeed\InsertDNSPrefetch
11+
tags:
12+
- { name: response.middleware, priority: 10 }
13+
14+
Prokl\CustomRequestResponserBundle\Services\PageSpeed\InsertDNSPrefetch: '@custom_request_responser.middleware.dns_prefetch'
15+
16+
# Eliminates HTML, JS and CSS comments.
17+
custom_request_responser.middleware.remove_comments:
18+
class: Prokl\CustomRequestResponserBundle\Services\PageSpeed\RemoveComments
19+
tags:
20+
- { name: response.middleware, priority: 20 }
21+
22+
Prokl\CustomRequestResponserBundle\Services\PageSpeed\RemoveComments: '@custom_request_responser.middleware.remove_comments'
23+
24+
# Reduces bytes transmitted in an HTML file by removing unnecessary whitespace.
25+
custom_request_responser.middleware.collapse_whitespace:
26+
class: Prokl\CustomRequestResponserBundle\Services\PageSpeed\CollapseWhitespace
27+
tags:
28+
- { name: response.middleware, priority: -10 }
29+
30+
Prokl\CustomRequestResponserBundle\Services\PageSpeed\CollapseWhitespace: '@custom_request_responser.middleware.collapse_whitespace'
31+
32+
# Eliminates unnecessary quotation marks from HTML attributes.
33+
custom_request_responser.middleware.remove_quotes:
34+
class: Prokl\CustomRequestResponserBundle\Services\PageSpeed\RemoveQuotes
35+
tags:
36+
- { name: response.middleware, priority: 30 }
37+
38+
Prokl\CustomRequestResponserBundle\Services\PageSpeed\RemoveQuotes: '@custom_request_responser.middleware.remove_quotes'
39+
40+
# Removing attributes from tags when the specified value is equal to the default value.
41+
custom_request_responser.middleware.elide_attributes:
42+
class: Prokl\CustomRequestResponserBundle\Services\PageSpeed\ElideAttributes
43+
tags:
44+
- { name: response.middleware, priority: 30 }
45+
46+
Prokl\CustomRequestResponserBundle\Services\PageSpeed\ElideAttributes: '@custom_request_responser.middleware.elide_attributes'
47+
48+
# Transforms the inline "style" attribute of tags into classes by moving the CSS to the header.
49+
custom_request_responser.middleware.inline_css:
50+
class: Prokl\CustomRequestResponserBundle\Services\PageSpeed\InlineCss
51+
tags:
52+
- { name: response.middleware, priority: 40 }
53+
54+
Prokl\CustomRequestResponserBundle\Services\PageSpeed\InlineCss: '@custom_request_responser.middleware.inline_css'
55+
56+
# Пример кастомного обработчика - нужно ли индексировать роут или нет.
57+
Prokl\CustomRequestResponserBundle\Services\IndexRoutesManager\AdminRouteProcessor: ~

Resources/config/services.yaml

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,4 @@ services:
55
autoconfigure: true
66
public: true
77

8-
# Injects tags in the HEAD to enable the browser to do DNS prefetching.
9-
custom_request_responser.middleware.dns_prefetch:
10-
class: Prokl\CustomRequestResponserBundle\Services\PageSpeed\InsertDNSPrefetch
11-
tags:
12-
- { name: response.middleware, priority: 10 }
13-
14-
Prokl\CustomRequestResponserBundle\Services\PageSpeed\InsertDNSPrefetch: '@custom_request_responser.middleware.dns_prefetch'
15-
16-
# Eliminates HTML, JS and CSS comments.
17-
custom_request_responser.middleware.remove_comments:
18-
class: Prokl\CustomRequestResponserBundle\Services\PageSpeed\RemoveComments
19-
tags:
20-
- { name: response.middleware, priority: 20 }
21-
22-
Prokl\CustomRequestResponserBundle\Services\PageSpeed\RemoveComments: '@custom_request_responser.middleware.remove_comments'
23-
24-
# Reduces bytes transmitted in an HTML file by removing unnecessary whitespace.
25-
custom_request_responser.middleware.collapse_whitespace:
26-
class: Prokl\CustomRequestResponserBundle\Services\PageSpeed\CollapseWhitespace
27-
tags:
28-
- { name: response.middleware, priority: -10 }
29-
30-
Prokl\CustomRequestResponserBundle\Services\PageSpeed\CollapseWhitespace: '@custom_request_responser.middleware.collapse_whitespace'
31-
32-
# Eliminates unnecessary quotation marks from HTML attributes.
33-
custom_request_responser.middleware.remove_quotes:
34-
class: Prokl\CustomRequestResponserBundle\Services\PageSpeed\RemoveQuotes
35-
tags:
36-
- { name: response.middleware, priority: 30 }
37-
38-
Prokl\CustomRequestResponserBundle\Services\PageSpeed\RemoveQuotes: '@custom_request_responser.middleware.remove_quotes'
39-
40-
# Removing attributes from tags when the specified value is equal to the default value.
41-
custom_request_responser.middleware.elide_attributes:
42-
class: Prokl\CustomRequestResponserBundle\Services\PageSpeed\ElideAttributes
43-
tags:
44-
- { name: response.middleware, priority: 30 }
45-
46-
Prokl\CustomRequestResponserBundle\Services\PageSpeed\ElideAttributes: '@custom_request_responser.middleware.elide_attributes'
47-
48-
# Transforms the inline "style" attribute of tags into classes by moving the CSS to the header.
49-
custom_request_responser.middleware.inline_css:
50-
class: Prokl\CustomRequestResponserBundle\Services\PageSpeed\InlineCss
51-
tags:
52-
- { name: response.middleware, priority: 40 }
53-
54-
Prokl\CustomRequestResponserBundle\Services\PageSpeed\InlineCss: '@custom_request_responser.middleware.inline_css'
55-
56-
# Пример кастомного обработчика - нужно ли индексировать роут или нет.
57-
Prokl\CustomRequestResponserBundle\Services\IndexRoutesManager\AdminRouteProcessor: ~
8+
Symfony\Component\ExpressionLanguage\ExpressionLanguage: ~

readme.MD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ custom_request_responser:
7676
- `custom_request_responser.middleware.elide_attributes` - removing attributes from tags when the specified value is equal to the default value
7777
- `custom_request_responser.middleware.inline_css` - transforms the inline "style" attribute of tags into classes by moving the CSS to the header
7878

79+
Помечаются тэгом `response.middleware` и должны наследоваться от `AbstractPageSpeed`.
80+
7981
### Пример кастомного обработчика - нужно ли индексировать роут или нет
8082

8183
```php

0 commit comments

Comments
 (0)