add node view counter option
This commit is contained in:
parent
03b45e89e3
commit
1f6aaf41e1
|
@ -4,6 +4,7 @@ namespace App\Core\Entity\Site;
|
||||||
|
|
||||||
use App\Core\Doctrine\Timestampable;
|
use App\Core\Doctrine\Timestampable;
|
||||||
use App\Core\Entity\EntityInterface;
|
use App\Core\Entity\EntityInterface;
|
||||||
|
use App\Core\Entity\NodeView;
|
||||||
use App\Core\Entity\Site\Page\Page;
|
use App\Core\Entity\Site\Page\Page;
|
||||||
use App\Core\Repository\Site\NodeRepository;
|
use App\Core\Repository\Site\NodeRepository;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
@ -139,10 +140,21 @@ class Node implements EntityInterface
|
||||||
*/
|
*/
|
||||||
protected $contentType;
|
protected $contentType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="boolean", options={"default"=0})
|
||||||
|
*/
|
||||||
|
private $enableViewCounter = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\OneToMany(targetEntity=NodeView::class, mappedBy="node", orphanRemoval=true)
|
||||||
|
*/
|
||||||
|
private $nodeViews;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->children = new ArrayCollection();
|
$this->children = new ArrayCollection();
|
||||||
$this->aliasNodes = new ArrayCollection();
|
$this->aliasNodes = new ArrayCollection();
|
||||||
|
$this->nodeViews = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
|
@ -548,4 +560,46 @@ class Node implements EntityInterface
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getEnableViewCounter(): ?bool
|
||||||
|
{
|
||||||
|
return $this->enableViewCounter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEnableViewCounter(bool $enableViewCounter): self
|
||||||
|
{
|
||||||
|
$this->enableViewCounter = $enableViewCounter;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection|NodeView[]
|
||||||
|
*/
|
||||||
|
public function getNodeViews(): Collection
|
||||||
|
{
|
||||||
|
return $this->nodeViews;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addNodeView(NodeView $nodeView): self
|
||||||
|
{
|
||||||
|
if (!$this->nodeViews->contains($nodeView)) {
|
||||||
|
$this->nodeViews[] = $nodeView;
|
||||||
|
$nodeView->setNode($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeNodeView(NodeView $nodeView): self
|
||||||
|
{
|
||||||
|
if ($this->nodeViews->removeElement($nodeView)) {
|
||||||
|
// set the owning side to null (unless already changed)
|
||||||
|
if ($nodeView->getNode() === $this) {
|
||||||
|
$nodeView->setNode(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,19 @@ class NodeType extends AbstractType
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$builder->add(
|
||||||
|
'enableViewCounter',
|
||||||
|
CheckboxType::class,
|
||||||
|
[
|
||||||
|
'label' => 'Enable view counter',
|
||||||
|
'required' => false,
|
||||||
|
'attr' => [
|
||||||
|
],
|
||||||
|
'constraints' => [
|
||||||
|
],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
$builder->add(
|
$builder->add(
|
||||||
'code',
|
'code',
|
||||||
TextType::class,
|
TextType::class,
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
"Never": "Jamais"
|
"Never": "Jamais"
|
||||||
"URL": "URL"
|
"URL": "URL"
|
||||||
"Disable URL": "Désactiver l'URL"
|
"Disable URL": "Désactiver l'URL"
|
||||||
|
"Enable view counter": "Activer le compteur de vues"
|
||||||
|
"Stats": "Statistiques"
|
||||||
"Controller": "Contrôleur"
|
"Controller": "Contrôleur"
|
||||||
"Leave blank for automatic generation": "Laisser vide pour une génération automatique"
|
"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"
|
"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"
|
||||||
|
|
|
@ -205,6 +205,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ form_row(form.disableUrl) }}
|
{{ form_row(form.disableUrl) }}
|
||||||
|
{{ form_row(form.enableViewCounter) }}
|
||||||
{{ form_row(form.code) }}
|
{{ form_row(form.code) }}
|
||||||
{{ form_row(form.contentType) }}
|
{{ form_row(form.contentType) }}
|
||||||
{{ form_row(form.controller) }}
|
{{ form_row(form.controller) }}
|
||||||
|
|
Loading…
Reference in a new issue