Skip to content
Snippets Groups Projects
Commit e5c25879 authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

[FEATURE] The category tables must have an id for the categories

parent 81bafb2f
No related branches found
No related tags found
No related merge requests found
......@@ -80,7 +80,7 @@ class AttributeController extends FOSRestController {
}
/**
* REST action which returns an array of children of en attribute by it's id.
* REST action which returns an array of children of an attribute by it's id.
* Returns empty array if there is no children.
* Method: GET, url: /api/attributes/{id}/children.{_format}
*
......@@ -455,4 +455,4 @@ class AttributeController extends FOSRestController {
}
return $user->isAdmin();
}
}
}
\ No newline at end of file
......@@ -33,4 +33,4 @@ class CategoryController extends FOSRestController {
$categories = $categoryRepository->findAll();
return $categories;
}
}
}
\ No newline at end of file
......@@ -95,7 +95,6 @@ class Attribute {
/**
* @var Attribute
*
*
* @ORM\ManyToOne(targetEntity="Attribute")
* @ORM\JoinColumn(name="type_id", referencedColumnName="id", onDelete="CASCADE")
*/
......@@ -104,7 +103,6 @@ class Attribute {
/**
* @var Attribute
*
*
* @ORM\ManyToOne(targetEntity="Attribute", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
*/
......@@ -113,9 +111,8 @@ class Attribute {
/**
* @var Category
*
*
* @ORM\ManyToOne(targetEntity="Category")
* @ORM\JoinColumn(name="category", referencedColumnName="name")
* @ORM\JoinColumn(name="category", referencedColumnName="id")
*/
private $category;
......
......@@ -226,6 +226,8 @@ class AttributeRepository extends EntityRepository {
protected function selectQueryByIsTypeGroupVersion($isType, $typo3Group, $typo3Version, $orderBy = NULL) {
/** @var QueryBuilder $queryBuilder */
$queryBuilder = $this->createQueryBuilder('attribute')
->select('attribute')
->leftJoin('attribute.category', 'categoryTable')
->where(':isType IS NULL OR attribute.isType = :isType')
->andWhere(':typo3Group IS NULL OR attribute.typo3Group = :typo3Group')
->andWhere(':typo3Version IS NULL OR attribute.minVersion IS NULL OR attribute.minVersion <= :typo3Version')
......@@ -235,7 +237,7 @@ class AttributeRepository extends EntityRepository {
->setParameter('typo3Group', $typo3Group)
->setParameter('typo3Version', $typo3Version);
if ($orderBy) {
$queryBuilder->addOrderBy('attribute.category', 'DESC')
$queryBuilder->addOrderBy('categoryTable.name', 'DESC')
->addOrderBy('attribute.' . $orderBy);
}
......@@ -260,7 +262,7 @@ class AttributeRepository extends EntityRepository {
$queryBuilder = $this->createQueryBuilder('attribute')
->select('attribute.id, attribute.urlName, attribute.name AS name, categoryTable.name AS category')
->from('TypoScriptBackendBundle:Category', 'categoryTable')
->where('attribute.category = categoryTable.name')
->where('attribute.category = categoryTable.id')
->andWhere(':isType IS NULL OR attribute.isType = :isType')
->andWhere(':typo3Group IS NULL OR attribute.typo3Group = :typo3Group')
->andWhere(':typo3Version IS NULL OR attribute.minVersion IS NULL OR attribute.minVersion <= :typo3Version')
......@@ -270,7 +272,7 @@ class AttributeRepository extends EntityRepository {
->setParameter('typo3Group', $typo3Group)
->setParameter('typo3Version', $typo3Version);
if ($orderBy) {
$queryBuilder->addOrderBy('attribute.category', 'DESC')
$queryBuilder->addOrderBy('categoryTable.name', 'DESC')
->addOrderBy('attribute.' . $orderBy);
}
......@@ -278,4 +280,4 @@ class AttributeRepository extends EntityRepository {
$query = $queryBuilder->getQuery();
return $query;
}
}
}
\ No newline at end of file
......@@ -12,22 +12,36 @@ use Doctrine\ORM\Mapping as ORM;
*/
class Category
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
* @ORM\Id
*/
private $name;
/**
* @return int
*/
public function getId() {
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return Category
*/
public function setName($name)
{
public function setName($name) {
$this->name = $name;
return $this;
......@@ -38,8 +52,7 @@ class Category
*
* @return string
*/
public function getName()
{
public function getName() {
return $this->name;
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment