Skip to content

Commit 0a3bc3e

Browse files
committed
remove config, update readme
1 parent 071f8c9 commit 0a3bc3e

9 files changed

Lines changed: 32 additions & 132 deletions

README.md

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Enhance your website's SEO and social media presence with more meta- and structu
77

88
## Features
99
- Set open graph tags like og:title, og:description, og:url and og:image
10-
-
1110
- Provide a nice api to set head tags like meta, title, base, link
1211
- Provide additional schema.org json-ld data
1312
- Sets important meta tags like og:title, og:description, og:url and twitter:card out of the box
@@ -20,18 +19,11 @@ Enhance your website's SEO and social media presence with more meta- and structu
2019

2120
1. Install with composer
2221
2. Update your database
23-
3. Set following config variables (if you don't need the legacy implementation)
24-
25-
```yaml
26-
huh_head:
27-
use_contao_head: true
28-
use_contao_variables: true
29-
```
30-
4. Optional: Set fallback image and twitter author in root page(s)
22+
3. Optional: Set fallback image and twitter author in root page(s)
3123

3224
### Add additional meta tags
3325

34-
In your root page, you can activate to add fallback image (og:image and twitter:image) and twitter username (twitter:site) meta tags to you web page.
26+
In your root page, you can activate to add fallback image (og:image) and X/Twitter username (twitter:site) meta tags to you web page.
3527

3628
![Screenshot Meta Data Settings](docs%2Fimg%2Fscreenshot_backend_meta_data.png)
3729

@@ -171,17 +163,13 @@ class SomeEventListener
171163

172164
## Template output
173165

174-
Be sure, `huh_head.use_contao_head` and/or `huh_head.use_contao_variables` are not set to true.
175-
176-
Output `$this->meta()` in your fe_page template ()
166+
Output the `TL_HEAD` dynamic script tag in your `fe_page` template:
177167

178168
```
179-
<?php $this->block('meta'); ?>
180-
<?= $this->meta(); ?>
181-
<?php $this->endblock(); ?>
169+
[[TL_HEAD]]
182170
```
183171

184-
Make sure, that you remove (are outputted by $this->meta() if `huh_head.use_contao_head` is not true):
172+
Make sure that you remove the following tags from custom `fe_page` templates, because they are output by `TL_HEAD`:
185173

186174
```
187175
<meta charset="<?= $this->charset ?>">
@@ -191,8 +179,6 @@ Make sure, that you remove (are outputted by $this->meta() if `huh_head.use_cont
191179
<meta name="description" content="<?= $this->description ?>">
192180
```
193181

194-
The `meta` function accepts currently one parameter that can contain tag names (array) that should be skipped.
195-
196182
## Developers
197183

198184
### Backend field
@@ -234,16 +220,3 @@ class SomeEventListener {
234220
}
235221
}
236222
```
237-
238-
## Config reference
239-
240-
```yaml
241-
# Default configuration for extension with alias: "huh_head"
242-
huh_head:
243-
244-
# Use the default head variables for title,base,robots and description instead of removing them from the page template.
245-
use_contao_head: false
246-
247-
# Use the default contao template variables for outputting head tags instead of the meta function.
248-
use_contao_variables: false
249-
```

config/services.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
use HeimrichHannot\HeadBundle\HeadTag\HeadTagFactory;
4+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
5+
6+
return static function (ContainerConfigurator $container): void {
7+
$services = $container->services()
8+
->defaults()
9+
->autowire()
10+
->autoconfigure()
11+
;
12+
13+
$services->load('HeimrichHannot\\HeadBundle\\', '../src/{EventListener,Helper,Twig}/*');
14+
15+
$services->load('HeimrichHannot\\HeadBundle\\Manager\\', '../src/Manager/*')
16+
->public()
17+
->autoconfigure(false)
18+
;
19+
20+
$services->set(HeadTagFactory::class)
21+
->autoconfigure()
22+
;
23+
};

config/services.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.
579 Bytes
Loading
-20.7 KB
Loading

src/EventListener/Contao/GeneratePageListener.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,16 @@
1616
use Contao\LayoutModel;
1717
use Contao\PageModel;
1818
use Contao\PageRegular;
19-
use HeimrichHannot\HeadBundle\HeadTag\BaseTag;
20-
use HeimrichHannot\HeadBundle\HeadTag\Meta\CharsetMetaTag;
2119
use HeimrichHannot\HeadBundle\HeadTag\Meta\PropertyMetaTag;
2220
use HeimrichHannot\HeadBundle\HeadTag\MetaTag;
2321
use HeimrichHannot\HeadBundle\Helper\TagHelper;
2422
use HeimrichHannot\HeadBundle\Manager\HtmlHeadTagManager;
2523
use HeimrichHannot\UtilsBundle\Util\Utils;
2624
use Psr\Container\ContainerExceptionInterface;
27-
use Psr\Container\ContainerInterface;
2825
use Psr\Container\NotFoundExceptionInterface;
2926
use Spatie\SchemaOrg\BaseType;
3027
use Symfony\Component\HttpFoundation\Request;
3128
use Symfony\Component\HttpFoundation\RequestStack;
32-
use Symfony\Contracts\Service\ServiceSubscriberInterface;
3329

3430
#[AsHook('generatePage', priority: -10)]
3531
readonly class GeneratePageListener

src/EventListener/Contao/ParseTemplateListener.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/EventListener/Contao/ReplaceDynamicScriptTagsListener.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,16 @@
1313
use HeimrichHannot\HeadBundle\Manager\HtmlHeadTagManager;
1414

1515
#[AsHook('replaceDynamicScriptTags')]
16-
class ReplaceDynamicScriptTagsListener
16+
readonly class ReplaceDynamicScriptTagsListener
1717
{
1818
public function __construct(
19-
private array $bundleConfig,
20-
private readonly HtmlHeadTagManager $headTagManager,
19+
private HtmlHeadTagManager $headTagManager,
2120
) {
2221
}
2322

24-
/**
25-
* @noinspection PhpUnnecessaryLocalVariableInspection
26-
*/
2723
public function __invoke(string $buffer): string
2824
{
29-
$buffer = $this->addHeadTags($buffer);
30-
31-
return $buffer;
32-
}
33-
34-
private function addHeadTags(string $buffer): string
35-
{
36-
if ($this->bundleConfig['use_contao_variables'] ?? false) {
37-
return $this->replace($buffer, 'TL_HEAD', $this->headTagManager->renderTags());
38-
}
39-
40-
return $buffer;
25+
return $this->replace($buffer, 'TL_HEAD', $this->headTagManager->renderTags());
4126
}
4227

4328
private function replace(string $buffer, string $tag, string $content): string

src/HeimrichHannotContaoHeadBundle.php

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace HeimrichHannot\HeadBundle;
1010

11-
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
1211
use Symfony\Component\DependencyInjection\ContainerBuilder;
1312
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
1413
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
@@ -17,27 +16,9 @@ class HeimrichHannotContaoHeadBundle extends AbstractBundle
1716
{
1817
protected string $extensionAlias = 'huh_head';
1918

20-
public function configure(DefinitionConfigurator $definition): void
21-
{
22-
$definition->rootNode()
23-
->children()
24-
->booleanNode('use_contao_head')
25-
->defaultFalse()
26-
->info('Use the default head variables for title,base,robots and description instead of removing them from the page template.')
27-
->end()
28-
->booleanNode('use_contao_variables')
29-
->defaultFalse()
30-
->info('Use the default contao template variables for outputting head tags instead of the meta function.')
31-
->end()
32-
->end()
33-
;
34-
}
35-
3619
public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
3720
{
38-
$builder->setParameter('huh_head', $config);
39-
40-
$container->import('../config/services.yaml');
21+
$container->import('../config/services.php');
4122
}
4223

4324
public function getPath(): string

0 commit comments

Comments
 (0)