backports murph-skeleton

This commit is contained in:
Simon Vieille 2022-02-20 16:12:51 +01:00
parent a1e928de6e
commit a5768ae4c0
6 changed files with 85 additions and 12 deletions

View file

@ -22,7 +22,7 @@ class Referer implements EntityInterface
/**
* @ORM\ManyToOne(targetEntity=Node::class, inversedBy="nodeViews")
* @ORM\JoinColumn(nullable=false)
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $node;

View file

@ -22,7 +22,7 @@ class View implements EntityInterface
/**
* @ORM\ManyToOne(targetEntity=Node::class, inversedBy="nodeViews")
* @ORM\JoinColumn(nullable=false)
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $node;

View file

@ -12,6 +12,8 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use function Symfony\Component\String\u;
use App\Core\Entity\Analytic\View;
use App\Core\Entity\Analytic\Referer;
/**
* @Gedmo\Tree(type="nested")
@ -143,12 +145,24 @@ class Node implements EntityInterface
/**
* @ORM\Column(type="boolean", options={"default"=0})
*/
private $enableViewCounter = false;
protected $enableAnalytic = false;
/**
* @ORM\OneToMany(targetEntity=View::class, mappedBy="node")
*/
protected $analyticViews;
/**
* @ORM\OneToMany(targetEntity=Referer::class, mappedBy="node")
*/
protected $analyticReferers;
public function __construct()
{
$this->children = new ArrayCollection();
$this->aliasNodes = new ArrayCollection();
$this->analyticViews = new ArrayCollection();
$this->analyticReferers = new ArrayCollection();
}
public function getId(): ?int
@ -555,14 +569,74 @@ class Node implements EntityInterface
return $this;
}
public function getEnableViewCounter(): ?bool
public function getEnableAnalytic(): ?bool
{
return $this->enableViewCounter;
return $this->enableAnalytic;
}
public function setEnableViewCounter(bool $enableViewCounter): self
public function setEnableAnalytic(bool $enableAnalytic): self
{
$this->enableViewCounter = $enableViewCounter;
$this->enableAnalytic = $enableAnalytic;
return $this;
}
/**
* @return Collection|View[]
*/
public function getAnalyticViews(): Collection
{
return $this->analyticViews;
}
public function addAnalyticView(View $view): self
{
if (!$this->analyticViews->contains($view)) {
$this->analyticViews[] = $view;
$view->setNode($this);
}
return $this;
}
public function removeAnalyticView(View $view): self
{
if ($this->analyticViews->removeElement($view)) {
// set the owning side to null (unless already changed)
if ($view->getNode() === $this) {
$view->setNode(null);
}
}
return $this;
}
/**
* @return Collection|Referer[]
*/
public function getAnalyticReferers(): Collection
{
return $this->analyticReferers;
}
public function addAnalyticReferer(Referer $referer): self
{
if (!$this->analyticReferers->contains($referer)) {
$this->analyticReferers[] = $referer;
$referer->setNode($this);
}
return $this;
}
public function removeAnalyticReferer(Referer $referer): self
{
if ($this->analyticReferers->removeElement($referer)) {
// set the owning side to null (unless already changed)
if ($referer->getNode() === $this) {
$referer->setNode(null);
}
}
return $this;
}

View file

@ -61,10 +61,10 @@ class NodeType extends AbstractType
);
$builder->add(
'enableViewCounter',
'enableAnalytic',
CheckboxType::class,
[
'label' => 'Enable view counter',
'label' => 'Enable analytic',
'required' => false,
'attr' => [
],

View file

@ -39,8 +39,7 @@
"Never": "Jamais"
"URL": "URL"
"Disable URL": "Désactiver l'URL"
"Enable view counter": "Activer le compteur de vues"
"Stats": "Statistiques"
"Enable analytic": "Activer l'analyse"
"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

@ -205,7 +205,7 @@
</div>
{{ form_row(form.disableUrl) }}
{{ form_row(form.enableViewCounter) }}
{{ form_row(form.enableAnalytic) }}
{{ form_row(form.code) }}
{{ form_row(form.contentType) }}
{{ form_row(form.controller) }}