-
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.
- Loading branch information
1 parent
4bf57df
commit d3fc154
Showing
11 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
dist/config/packages/monsieurbiz_sylius_robots_txt_plugin.yaml
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,2 @@ | ||
imports: | ||
resource: '@MonsieurBizSyliusRobotsTxtPlugin/Resources/config/config.yaml' |
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,5 @@ | ||
monsieurbiz_robots_txt_render: | ||
path: /robots.txt | ||
methods: [ GET ] | ||
defaults: | ||
_controller: MonsieurBiz\SyliusRobotsTxtPlugin\Controller\RenderController |
Empty file.
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,43 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Monsieur Biz's Sylius Robots Txt Plugin for Sylius. | ||
* (c) Monsieur Biz <sylius@monsieurbiz.com> | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MonsieurBiz\SyliusRobotsTxtPlugin\Controller; | ||
|
||
use MonsieurBiz\SyliusSettingsPlugin\Settings\SettingsInterface; | ||
use Sylius\Component\Channel\Context\ChannelContextInterface; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Webmozart\Assert\Assert; | ||
|
||
final class RenderController extends AbstractController | ||
{ | ||
public function __invoke( | ||
SettingsInterface $robotstxtSettings, | ||
ChannelContextInterface $channelContext, | ||
): Response { | ||
$robotsTxtContent = $robotstxtSettings->getCurrentValue( | ||
$channelContext->getChannel(), | ||
null, | ||
'robots_txt_content' | ||
); | ||
|
||
Assert::string($robotsTxtContent); | ||
$robotsTxtContent = trim($robotsTxtContent); | ||
|
||
if (empty($robotsTxtContent)) { | ||
throw $this->createNotFoundException(); | ||
} | ||
|
||
return new Response($robotsTxtContent, Response::HTTP_OK, [ | ||
'Content-Type' => 'text/plain', | ||
]); | ||
} | ||
} |
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,36 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Monsieur Biz's Sylius Robots Txt Plugin for Sylius. | ||
* (c) Monsieur Biz <sylius@monsieurbiz.com> | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MonsieurBiz\SyliusRobotsTxtPlugin\Form\Type; | ||
|
||
use MonsieurBiz\SyliusSettingsPlugin\Form\AbstractSettingsType; | ||
use MonsieurBiz\SyliusSettingsPlugin\Form\SettingsTypeInterface; | ||
use Symfony\Component\Form\Extension\Core\Type\TextareaType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
|
||
final class RobotsTxtType extends AbstractSettingsType implements SettingsTypeInterface | ||
{ | ||
/** | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$this->addWithDefaultCheckbox( | ||
$builder, | ||
'robots_txt_content', | ||
TextareaType::class, | ||
[ | ||
'label' => 'monsieurbiz_robots_txt.form.robots_txt_content', | ||
'required' => false, | ||
] | ||
); | ||
} | ||
} |
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,2 @@ | ||
imports: | ||
- { resource: 'monsieurbiz/*.yaml' } |
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,14 @@ | ||
monsieurbiz_sylius_settings: | ||
plugins: | ||
monsieurbiz_robots_txt.robotstxt: | ||
vendor_name: Monsieur Biz | ||
plugin_name: monsieurbiz_robots_txt.settings.robots_txt.plugin_name | ||
description: monsieurbiz_robots_txt.settings.robots_txt.description | ||
icon: searchengin | ||
use_locales: false | ||
classes: | ||
form: MonsieurBiz\SyliusRobotsTxtPlugin\Form\Type\RobotsTxtType | ||
default_values: | ||
robots_txt_content: | | ||
User-agent: * | ||
Disallow: |
Empty file.
Empty file.
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,7 @@ | ||
monsieurbiz_robots_txt: | ||
form: | ||
robots_txt_content: 'Robots Txt content' | ||
settings: | ||
robots_txt: | ||
plugin_name: Robots Txt | ||
description: Edit your robots.txt file |
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,7 @@ | ||
monsieurbiz_robots_txt: | ||
form: | ||
robots_txt_content: 'Contenu du Robots Txt' | ||
settings: | ||
robots_txt: | ||
plugin_name: Robots Txt | ||
description: Editez votre fichier robots.txt |