backports murph-skeleton

This commit is contained in:
Simon Vieille 2021-05-14 17:36:52 +02:00
parent af4dbaa570
commit 3965aaadda
6 changed files with 56 additions and 15 deletions

View file

@ -44,6 +44,11 @@ class Node implements EntityInterface
*/
private $url;
/**
* @ORM\Column(type="boolean", options={"default"=0})
*/
private $disableUrl = false;
/**
* @ORM\Column(type="boolean", options={"default"=0})
*/
@ -298,6 +303,18 @@ class Node implements EntityInterface
return $this;
}
public function getDisableUrl(): ?bool
{
return $this->disableUrl;
}
public function setDisableUrl(bool $disableUrl): self
{
$this->disableUrl = $disableUrl;
return $this;
}
public function getTreeLabel()
{
$prefix = str_repeat('-', ($this->getTreeLevel() - 1) * 5);

View file

@ -60,6 +60,12 @@ class NodeEventSubscriber extends EntityManagerEventSubscriber
$node->setCode($this->codeSlugify->slugify($node->getCode()));
if ($node->getDisableUrl()) {
$node->setUrl(null);
return;
}
if ($node->getUrl()) {
$generatedUrl = $node->getUrl();
} else {

View file

@ -13,6 +13,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
class NodeType extends AbstractType
{
@ -46,6 +47,19 @@ class NodeType extends AbstractType
]
);
$builder->add(
'disableUrl',
CheckboxType::class,
[
'label' => 'Disable URL',
'required' => false,
'attr' => [
],
'constraints' => [
],
]
);
$builder->add(
'code',
TextType::class,

View file

@ -37,6 +37,7 @@
"Yearly": "Annuelle"
"Never": "Jamais"
"URL": "URL"
"Disable URL": "Désactiver l'URL"
"Controller": "Contrôleur"
"Leave blank for automatic generation": "Laisser vide pour une génération automatique"
"Leave blank to use the default one. Example: App\\Controller\\FooController::barAction": "Laisser vide pour utiliser celui par défaut. Exemple : App\\Controller\\FooController::barAction"

View file

@ -144,6 +144,7 @@
{{ 'Route name: <code>%routeName%</code>'|trans({'%routeName%': entity.routeName})|raw }}
</div>
{{ form_row(form.disableUrl) }}
{{ form_row(form.code) }}
{{ form_row(form.controller) }}

View file

@ -84,23 +84,25 @@
<span class="fa fa-sign-out-alt text-muted"></span>
</a>
{% else %}
{% if node.parameters|length %}
<span class="btn btn-sm border border-secondary btn-light">
{{ node.url }}
</span>
{% else %}
{% set url = safe_node_url(node) %}
{% if url %}
<a href="{{ url ? url : '#' }}" target="_blank" class="btn btn-sm border border-secondary btn-light">
{% if not node.disableUrl %}
{% if node.parameters|length %}
<span class="btn btn-sm border border-secondary btn-light">
{{ node.url }}
</a>
{% endif %}
{% if url is same as(null) %}
<span class="btn btn-sm border border-secondary btn-light" title="{{ 'Edit the routing'|trans }}">
<span class="fa fa-exclamation"></span>
</span>
{% else %}
{% set url = safe_node_url(node) %}
{% if url %}
<a href="{{ url ? url : '#' }}" target="_blank" class="btn btn-sm border border-secondary btn-light">
{{ node.url }}
</a>
{% endif %}
{% if url is same as(null) %}
<span class="btn btn-sm border border-secondary btn-light" title="{{ 'Edit the routing'|trans }}">
<span class="fa fa-exclamation"></span>
</span>
{% endif %}
{% endif %}
{% endif %}