You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 23, 2018. It is now read-only.
@return boolean TRUE if this collection contained the specified element, FALSE otherwise.
*/
public function removeChild(\AppBundle\Entity\SupvPageCategories $child)
{
return $this->children->removeElement($child);
}
/**
Get children.
@return \Doctrine\Common\Collections\Collection
*/
public function getChildren()
{
return $this->children;
}
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;
class SupvPageCategoriesAdmin extends AbstractAdmin
{
protected $datagridValues = array(
'_sort_by' => 'pcCatname',
);
protected function configureRoutes(RouteCollection $collection)
{
$collection->add('up', $this->getRouterIdParameter().'/up');
$collection->add('down', $this->getRouterIdParameter().'/down');
}
protected function configureFormFields(FormMapper $formMapper)
{
// create custom query to hide the current element by `id`
$subjectId = $this->getRoot()->getSubject()->getPcId();
$query = null;
if ($subjectId)
{
$query = $this->modelManager
->getEntityManager('AppBundle\Entity\SupvPageCategories')
->createQueryBuilder('c')
->select('c')
->from('AppBundle:SupvPageCategories', 'c')
->where('c.pcId != '. $subjectId);
}
// ...
$formMapper->add('parent', 'sonata_type_model', array(
'query' => $query,
'required' => false, // remove this row after the root element is created
'btn_add' => false,
'property' => 'pcCatname'
))
->add('pcCatname', 'text');
}
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper->add('pcCatname');
}
protected function configureListFields(ListMapper $listMapper)
{
$listMapper->addIdentifier('pcCatname', 'text')
->addIdentifier('_action', null, array(
'actions' => array(
'up' => array(
'template' => 'MevSortableTreeBundle:Default:list__action_up.html.twig'
),
'down' => array(
'template' => 'MevSortableTreeBundle:Default:list__action_down.html.twig'
)
)
));
}
public function createQuery($context = 'list')
{
$proxyQuery = parent::createQuery('list');
// Default Alias is "o"
// You can use `id` to hide root element
// $proxyQuery->where('o.id != 1');
$proxyQuery->addOrderBy('o.root', 'ASC');
$proxyQuery->addOrderBy('o.lft', 'ASC');
return $proxyQuery;
}
}`
What I'm doing wrong?
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have configured all, but I can't get work this bundle.
I can't see the buttons up/down
Here my ORM
AppBundle\Entity\SupvPageCategories:
type: entity
repositoryClass: Gedmo\Tree\Entity\Repository\NestedTreeRepository
table: supv_page_categories
gedmo:
tree:
type: nested
id:
pcId:
type: integer
nullable: false
options:
unsigned: false
id: true
column: pc_id
generator:
strategy: IDENTITY
fields:
pcCatname:
type: string
nullable: false
length: 100
options:
fixed: false
column: pc_catname
pcCattype:
type: string
nullable: false
length: 100
options:
fixed: false
column: pc_catType
lft:
type: integer
gedmo:
- treeLeft
rgt:
type: integer
gedmo:
- treeRight
lvl:
type: integer
gedmo:
- treeLevel
pcIsactive:
type: boolean
nullable: false
column: pc_isActive
pcUpdatedat:
type: datetime
nullable: true
column: pc_updatedAt
pcCreatedat:
type: datetime
nullable: false
column: pc_createdAt
manyToOne:
root:
targetEntity: AppBundle\Entity\SupvPageCategories
joinColumn:
referencedColumnName: pc_id
onDelete: CASCADE
gedmo:
- treeRoot
parent:
targetEntity: AppBundle\Entity\SupvPageCategories
inversedBy: children
joinColumn:
referencedColumnName: pc_id
onDelete: CASCADE
gedmo:
- treeParent
oneToMany:
children:
targetEntity: AppBundle\Entity\SupvPageCategories
mappedBy: parent
orderBy:
lft: ASC
lifecycleCallbacks: { }
Here my Entity
`<?php
namespace AppBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
/**
SupvPageCategories
/
class SupvPageCategories
{
/*
*/
private $pcId;
/**
*/
private $pcCatname;
/**
*/
private $pcCattype;
/**
*/
private $pcIsactive;
/**
*/
private $pcUpdatedat;
/**
*/
private $pcCreatedat;
public function __construct()
{
$this->pcIsactive = true;
$this->pcCreatedat = new \DateTime();
$this->children = new ArrayCollection();
}
/**
*/
public function getPcId()
{
return $this->pcId;
}
/**
Set pcCatname.
@param string $pcCatname
@return SupvPageCategories
*/
public function setPcCatname($pcCatname)
{
$this->pcCatname = $pcCatname;
return $this;
}
/**
*/
public function getPcCatname()
{
return $this->pcCatname;
}
/**
Set pcCattype.
@param string $pcCattype
@return SupvPageCategories
*/
public function setPcCattype($pcCattype)
{
$this->pcCattype = $pcCattype;
return $this;
}
/**
*/
public function getPcCattype()
{
return $this->pcCattype;
}
/**
Set pcIsactive.
@param bool $pcIsactive
@return SupvPageCategories
*/
public function setPcIsactive($pcIsactive)
{
$this->pcIsactive = $pcIsactive;
return $this;
}
/**
*/
public function getPcIsactive()
{
return $this->pcIsactive;
}
/**
Set pcUpdatedat.
@param \DateTime|null $pcUpdatedat
@return SupvPageCategories
*/
public function setPcUpdatedat($pcUpdatedat = null)
{
$this->pcUpdatedat = $pcUpdatedat;
return $this;
}
/**
*/
public function getPcUpdatedat()
{
return $this->pcUpdatedat;
}
/**
Set pcCreatedat.
@param \DateTime $pcCreatedat
@return SupvPageCategories
*/
public function setPcCreatedat($pcCreatedat)
{
$this->pcCreatedat = $pcCreatedat;
return $this;
}
/**
*/
public function getPcCreatedat()
{
return $this->pcCreatedat;
}
public function __toString()
{
if( is_null( $this->getPcCatname() ) ) {
return 'NULL';
}else{
return $this->getPcCatname();
}
}
/**
*/
private $pcParentcat;
/**
Set pcParentcat.
@param \AppBundle\Entity\SupvPageCategories|null $pcParentcat
@return SupvPageCategories
*/
public function setPcParentcat(\AppBundle\Entity\SupvPageCategories $pcParentcat = null)
{
$this->pcParentcat = $pcParentcat;
return $this;
}
/**
/
public function getPcParentcat()
{
return $this->pcParentcat;
}
/*
*/
private $lft;
/**
*/
private $rgt;
/**
*/
private $lvl;
/**
*/
private $children;
/**
*/
private $root;
/**
*/
private $parent;
/**
Set lft.
@param int $lft
@return SupvPageCategories
*/
public function setLft($lft)
{
$this->lft = $lft;
return $this;
}
/**
*/
public function getLft()
{
return $this->lft;
}
/**
Set rgt.
@param int $rgt
@return SupvPageCategories
*/
public function setRgt($rgt)
{
$this->rgt = $rgt;
return $this;
}
/**
*/
public function getRgt()
{
return $this->rgt;
}
/**
Set lvl.
@param int $lvl
@return SupvPageCategories
*/
public function setLvl($lvl)
{
$this->lvl = $lvl;
return $this;
}
/**
*/
public function getLvl()
{
return $this->lvl;
}
/**
Add child.
@param \AppBundle\Entity\SupvPageCategories $child
@return SupvPageCategories
*/
public function addChild(\AppBundle\Entity\SupvPageCategories $child)
{
$this->children[] = $child;
return $this;
}
/**
*/
public function removeChild(\AppBundle\Entity\SupvPageCategories $child)
{
return $this->children->removeElement($child);
}
/**
*/
public function getChildren()
{
return $this->children;
}
/**
Set root.
@param \AppBundle\Entity\SupvPageCategories|null $root
@return SupvPageCategories
*/
public function setRoot(\AppBundle\Entity\SupvPageCategories $root = null)
{
$this->root = $root;
return $this;
}
/**
*/
public function getRoot()
{
return $this->root;
}
/**
Set parent.
@param \AppBundle\Entity\SupvPageCategories|null $parent
@return SupvPageCategories
*/
public function setParent(\AppBundle\Entity\SupvPageCategories $parent = null)
{
$this->parent = $parent;
return $this;
}
/**
*/
public function getParent()
{
return $this->parent;
}
}
`
And here my categoryAdmin
`<?php
// src/AppBundle/Admin/SupvPageCategoriesAdmin.php
namespace AppBundle\Admin;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;
class SupvPageCategoriesAdmin extends AbstractAdmin
{
}`
What I'm doing wrong?
The text was updated successfully, but these errors were encountered: