mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-21 14:40:10 -07:00
Add repositories for rebrickable entities
This commit is contained in:
parent
35db648f5c
commit
21df3fa58b
@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* Category.
|
||||
*
|
||||
* @ORM\Table(name="rebrickable_category")
|
||||
* @ORM\Entity
|
||||
* @ORM\Entity(repositoryClass="AppBundle\Repository\Rebrickable\CategoryRepository")
|
||||
*/
|
||||
class Category
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* Color.
|
||||
*
|
||||
* @ORM\Table(name="rebrickable_color")
|
||||
* @ORM\Entity
|
||||
* @ORM\Entity(repositoryClass="AppBundle\Repository\Rebrickable\ColorRepository")
|
||||
*/
|
||||
class Color
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* Part.
|
||||
*
|
||||
* @ORM\Table(name="rebrickable_inventory")
|
||||
* @ORM\Entity
|
||||
* @ORM\Entity(repositoryClass="AppBundle\Repository\Rebrickable\InventoryRepository")
|
||||
*/
|
||||
class Inventory
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* Inventory_Part.
|
||||
*
|
||||
* @ORM\Table(name="rebrickable_inventory_parts")
|
||||
* @ORM\Entity
|
||||
* @ORM\Entity(repositoryClass="AppBundle\Repository\Rebrickable\Inventory_PartRepository")
|
||||
*/
|
||||
class Inventory_Part
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* Part.
|
||||
*
|
||||
* @ORM\Table(name="rebrickable_part")
|
||||
* @ORM\Entity
|
||||
* @ORM\Entity(repositoryClass="AppBundle\Repository\Rebrickable\PartRepository")
|
||||
*/
|
||||
class Part
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* Set.
|
||||
*
|
||||
* @ORM\Table(name="rebrickable_set")
|
||||
* @ORM\Entity
|
||||
* @ORM\Entity(repositoryClass="AppBundle\Repository\Rebrickable\SetRepository")
|
||||
*/
|
||||
class Set
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* Theme.
|
||||
*
|
||||
* @ORM\Table(name="rebrickable_theme")
|
||||
* @ORM\Entity
|
||||
* @ORM\Entity(repositoryClass="AppBundle\Repository\Rebrickable\ThemeRepository")
|
||||
*/
|
||||
class Theme
|
||||
{
|
||||
|
@ -2,18 +2,23 @@
|
||||
|
||||
namespace AppBundle\Repository;
|
||||
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
class BaseRepository extends EntityRepository
|
||||
{
|
||||
public function save($entity) {
|
||||
public function save($entity, $flush = true)
|
||||
{
|
||||
$this->_em->persist($entity);
|
||||
$this->_em->flush($entity);
|
||||
if ($flush) {
|
||||
$this->_em->flush($entity);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($entity) {
|
||||
public function delete($entity, $flush = true)
|
||||
{
|
||||
$this->_em->remove($entity);
|
||||
$this->_em->flush($entity);
|
||||
if ($flush) {
|
||||
$this->_em->flush($entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Repository\Rebrickable;
|
||||
|
||||
use AppBundle\Repository\BaseRepository;
|
||||
|
||||
class CategoryRepository extends BaseRepository
|
||||
{
|
||||
}
|
9
src/AppBundle/Repository/Rebrickable/ColorRepository.php
Normal file
9
src/AppBundle/Repository/Rebrickable/ColorRepository.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Repository\Rebrickable;
|
||||
|
||||
use AppBundle\Repository\BaseRepository;
|
||||
|
||||
class ColorRepository extends BaseRepository
|
||||
{
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Repository\Rebrickable;
|
||||
|
||||
use AppBundle\Repository\BaseRepository;
|
||||
|
||||
class InventoryRepository extends BaseRepository
|
||||
{
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Repository\Rebrickable;
|
||||
|
||||
use AppBundle\Entity\Rebrickable\Inventory;
|
||||
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
||||
use AppBundle\Entity\Rebrickable\Set;
|
||||
use AppBundle\Repository\BaseRepository;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
|
||||
class Inventory_PartRepository extends BaseRepository
|
||||
{
|
||||
public function findAllBySetNumber($number)
|
||||
{
|
||||
$queryBuilder = $this->createQueryBuilder('inventory_part');
|
||||
|
||||
$queryBuilder
|
||||
->join(Inventory::class, 'inventory', JOIN::WITH, 'inventory_part.inventory = inventory.id')
|
||||
->join(Set::class, 's', Join::WITH, 'inventory.set = s.number')
|
||||
->where('s.number LIKE :number')
|
||||
->setParameter('number', $number)
|
||||
->distinct(true);
|
||||
|
||||
return $queryBuilder->getQuery()->getResult();
|
||||
}
|
||||
}
|
27
src/AppBundle/Repository/Rebrickable/PartRepository.php
Normal file
27
src/AppBundle/Repository/Rebrickable/PartRepository.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Repository\Rebrickable;
|
||||
|
||||
use AppBundle\Entity\Rebrickable\Inventory;
|
||||
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
||||
use AppBundle\Entity\Rebrickable\Set;
|
||||
use AppBundle\Repository\BaseRepository;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
|
||||
class PartRepository extends BaseRepository
|
||||
{
|
||||
public function findAllBySetNumber($number)
|
||||
{
|
||||
$queryBuilder = $this->createQueryBuilder('part');
|
||||
|
||||
$queryBuilder
|
||||
->join(Inventory_Part::class, 'inventory_part', JOIN::WITH, 'part.number = inventory_part.part')
|
||||
->join(Inventory::class, 'inventory', JOIN::WITH, 'inventory_part.inventory = inventory.id')
|
||||
->join(Set::class, 's', Join::WITH, 'inventory.set = s.number')
|
||||
->where('s.number LIKE :number')
|
||||
->setParameter('number', $number)
|
||||
->distinct(true);
|
||||
|
||||
return $queryBuilder->getQuery()->getResult();
|
||||
}
|
||||
}
|
27
src/AppBundle/Repository/Rebrickable/SetRepository.php
Normal file
27
src/AppBundle/Repository/Rebrickable/SetRepository.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Repository\Rebrickable;
|
||||
|
||||
use AppBundle\Entity\Rebrickable\Inventory;
|
||||
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
||||
use AppBundle\Entity\Rebrickable\Part;
|
||||
use AppBundle\Repository\BaseRepository;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
|
||||
class SetRepository extends BaseRepository
|
||||
{
|
||||
public function findAllByPartNumber($number)
|
||||
{
|
||||
$queryBuilder = $this->createQueryBuilder('s');
|
||||
|
||||
$queryBuilder
|
||||
->join(Inventory::class, 'inventory', JOIN::WITH, 'inventory.set = s.number')
|
||||
->join(Inventory_Part::class, 'inventory_part', JOIN::WITH, 'inventory.id = inventory_part.inventory')
|
||||
->join(Part::class, 'part', Join::WITH, 'inventory_part.part = part.number')
|
||||
->where('part.number LIKE :number')
|
||||
->setParameter('number', $number.'%')
|
||||
->distinct(true);
|
||||
|
||||
return $queryBuilder->getQuery()->getResult();
|
||||
}
|
||||
}
|
9
src/AppBundle/Repository/Rebrickable/ThemeRepository.php
Normal file
9
src/AppBundle/Repository/Rebrickable/ThemeRepository.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace AppBundle\Repository\Rebrickable;
|
||||
|
||||
use AppBundle\Repository\BaseRepository;
|
||||
|
||||
class ThemeRepository extends BaseRepository
|
||||
{
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user