contributte / contributte/datagrid
Doctrine & TreeView
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 296
- Forks
- 215
- PR merge metrics
- No merged PRs in 30d
Description
Hi treeview does not work with doctrine
My Entity
class MaterialCategory implements IEntity
{
use SmartObject;
use TId;
use TName;
use TSlug;
/**
* @var MaterialCategory|null
* @ORM\ManyToOne(targetEntity="MaterialCategory", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL")
*/
private $parent;
/**
* @var Collection
* @ORM\OneToMany(targetEntity="MaterialCategory", mappedBy="parent")
*/
private $children;
/**
* @ORM\OneToMany(targetEntity="Material", mappedBy="category",cascade={"all"})
*/
private $material;
/**
* MaterialCategory constructor.
*/
public function __construct()
{
$this->children = new ArrayCollection();
$this->material = new ArrayCollection();
}
/**
* @return MaterialCategory|null
*/
public function getParent(): ?MaterialCategory
{
return $this->parent;
}
/**
* @param MaterialCategory|null $parent
* @return $this
*/
public function setParent(?MaterialCategory $parent)
{
$this->parent = $parent;
return $this;
}
/**
* @return Collection
*/
public function getChildren(): Collection
{
return $this->children;
}
}
DQL
SELECT MaterialMaterialCategory FROM app\modules\Materials\entities\MaterialCategory MaterialMaterialCategory WHERE MaterialMaterialCategory.parent IS NULL
Datagrid show only root rows.
hasChildrenCallback and getChildrenCallback never run (callbacks use $entity->getChildren()
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the shown DQL query with the MaterialCategory entity and tracing the TreeView hasChildrenCallback and getChildrenCallback behavior. Compare the Doctrine entity mappings with the datagrid's tree-loading path; done means root rows display their children through the callbacks without breaking the Doctrine-backed grid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100