mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-18 13:10:08 -07:00
Merged branch feat/rebrickable-v3 into dev
This commit is contained in:
commit
b4ba2dc85b
@ -7,7 +7,7 @@
|
|||||||
{{ dump(localPart) }}
|
{{ dump(localPart) }}
|
||||||
|
|
||||||
<div id="model" style="height: 300px; width: 300px; padding: 5px; display: inline-block"></div>
|
<div id="model" style="height: 300px; width: 300px; padding: 5px; display: inline-block"></div>
|
||||||
<img src="{{ part.partImgUrl }}">
|
<img src="{{ part.imgUrl }}">
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ services:
|
|||||||
class: AppBundle\Api\Client\Brickset\Brickset
|
class: AppBundle\Api\Client\Brickset\Brickset
|
||||||
arguments: ['%brickset_apikey%']
|
arguments: ['%brickset_apikey%']
|
||||||
client.rebrickable:
|
client.rebrickable:
|
||||||
class: AppBundle\Api\Client\Rebrickable\Rebrickable
|
class: AppBundle\Api\Client\Rebrickable\Rebrickable_v3
|
||||||
arguments: ['%rebrickable_apikey%']
|
arguments: ['%rebrickable_apikey%']
|
||||||
|
|
||||||
manager.brickset:
|
manager.brickset:
|
||||||
@ -27,8 +27,11 @@ services:
|
|||||||
arguments: ['%ldview_bin%', '@oneup_flysystem.ldraw_filesystem']
|
arguments: ['%ldview_bin%', '@oneup_flysystem.ldraw_filesystem']
|
||||||
|
|
||||||
loader.rebrickable:
|
loader.rebrickable:
|
||||||
class: AppBundle\Command\Loader\RebrickableLoader
|
class: AppBundle\Loader\RebrickableLoader
|
||||||
arguments: ['@doctrine.orm.entity_manager', '@manager.rebrickable', '%rebrickable_url%' ]
|
calls:
|
||||||
|
- [setArguments, ['@manager.rebrickable', '%rebrickable_url%']]
|
||||||
|
parent: service.loader
|
||||||
|
|
||||||
loader.ldraw:
|
loader.ldraw:
|
||||||
class: AppBundle\Loader\LDrawLoader
|
class: AppBundle\Loader\LDrawLoader
|
||||||
calls:
|
calls:
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace AppBundle\Api\Client\Rebrickable\Converter;
|
|
||||||
|
|
||||||
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
|
|
||||||
|
|
||||||
class PartPropertyNameConverter implements NameConverterInterface
|
|
||||||
{
|
|
||||||
public function normalize($propertyName)
|
|
||||||
{
|
|
||||||
return $propertyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function denormalize($propertyName)
|
|
||||||
{
|
|
||||||
switch ($propertyName) {
|
|
||||||
case 'part_name': return 'name';
|
|
||||||
case 'part_id': return 'id';
|
|
||||||
case 'part_type_id': return 'typeId';
|
|
||||||
default: return $propertyName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AppBundle\Api\Client\Rebrickable\Converter;
|
||||||
|
|
||||||
|
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
|
||||||
|
|
||||||
|
class PropertyNameConverter implements NameConverterInterface
|
||||||
|
{
|
||||||
|
public function normalize($propertyName)
|
||||||
|
{
|
||||||
|
return $propertyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function denormalize($propertyName)
|
||||||
|
{
|
||||||
|
switch ($propertyName) {
|
||||||
|
case 'part_num': return 'number';
|
||||||
|
case 'part_cat_id': return 'categoryId';
|
||||||
|
case 'part_img_url': return 'imgUrl';
|
||||||
|
case 'part_url': return 'url';
|
||||||
|
case 'set_num': return 'number';
|
||||||
|
case 'set_img_url': return 'imgUrl';
|
||||||
|
case 'set_url': return 'url';
|
||||||
|
default: return $propertyName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,215 +5,60 @@ namespace AppBundle\Api\Client\Rebrickable\Entity;
|
|||||||
class Color
|
class Color
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Internal Rebrickable color ID used.
|
* Internal Rebrickable color ID.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $rb_color_id;
|
private $id;
|
||||||
/**
|
|
||||||
* Array of mapped LDraw colors.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $ldraw_color_id;
|
|
||||||
/**
|
|
||||||
* Array of mapped BrickLink colors.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $bricklink_color_id;
|
|
||||||
/**
|
|
||||||
* Array of mapped BrickOwl colors.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $brickowl_color_id;
|
|
||||||
/**
|
/**
|
||||||
* Color name.
|
* Color name.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $color_name;
|
private $name;
|
||||||
/**
|
/**
|
||||||
* Number of parts the color appears in.
|
* RGB hex code.
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $num_parts;
|
|
||||||
/**
|
|
||||||
* Number of sets the color appears in.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $num_sets;
|
|
||||||
/**
|
|
||||||
* First year it was used.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $year1;
|
|
||||||
/**
|
|
||||||
* Last year it was used.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
protected $year2;
|
|
||||||
/**
|
|
||||||
* Hex codes for the RGB value of this color: RRGGBB.
|
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $rgb;
|
private $rgb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color constructor.
|
* Wether color is transparent.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
private $isTrans;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getRbColorId()
|
public function getId()
|
||||||
{
|
{
|
||||||
return $this->rb_color_id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $rb_color_id
|
* @param int $id
|
||||||
*/
|
*/
|
||||||
public function setRbColorId($rb_color_id)
|
public function setId($id)
|
||||||
{
|
{
|
||||||
$this->rb_color_id = $rb_color_id;
|
$this->id = $id;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getLdrawColorId()
|
|
||||||
{
|
|
||||||
return $this->ldraw_color_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $ldraw_color_id
|
|
||||||
*/
|
|
||||||
public function setLdrawColorId($ldraw_color_id)
|
|
||||||
{
|
|
||||||
$this->ldraw_color_id = $ldraw_color_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getBricklinkColorId()
|
|
||||||
{
|
|
||||||
return $this->bricklink_color_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $bricklink_color_id
|
|
||||||
*/
|
|
||||||
public function setBricklinkColorId($bricklink_color_id)
|
|
||||||
{
|
|
||||||
$this->bricklink_color_id = $bricklink_color_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getBrickowlColorId()
|
|
||||||
{
|
|
||||||
return $this->brickowl_color_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $brickowl_color_id
|
|
||||||
*/
|
|
||||||
public function setBrickowlColorId($brickowl_color_id)
|
|
||||||
{
|
|
||||||
$this->brickowl_color_id = $brickowl_color_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getColorName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return $this->color_name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $color_name
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
public function setColorName($color_name)
|
public function setName($name)
|
||||||
{
|
{
|
||||||
$this->color_name = $color_name;
|
$this->name = $name;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getNumParts()
|
|
||||||
{
|
|
||||||
return $this->num_parts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $num_parts
|
|
||||||
*/
|
|
||||||
public function setNumParts($num_parts)
|
|
||||||
{
|
|
||||||
$this->num_parts = $num_parts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getNumSets()
|
|
||||||
{
|
|
||||||
return $this->num_sets;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $num_sets
|
|
||||||
*/
|
|
||||||
public function setNumSets($num_sets)
|
|
||||||
{
|
|
||||||
$this->num_sets = $num_sets;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getYear1()
|
|
||||||
{
|
|
||||||
return $this->year1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $year1
|
|
||||||
*/
|
|
||||||
public function setYear1($year1)
|
|
||||||
{
|
|
||||||
$this->year1 = $year1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getYear2()
|
|
||||||
{
|
|
||||||
return $this->year2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $year2
|
|
||||||
*/
|
|
||||||
public function setYear2($year2)
|
|
||||||
{
|
|
||||||
$this->year2 = $year2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -225,10 +70,26 @@ class Color
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $rgbl
|
* @param string $rgb
|
||||||
*/
|
*/
|
||||||
public function setRgb($rgb)
|
public function setRgb($rgb)
|
||||||
{
|
{
|
||||||
$this->rgb = $rgb;
|
$this->rgb = $rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isIsTrans()
|
||||||
|
{
|
||||||
|
return $this->isTrans;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $isTrans
|
||||||
|
*/
|
||||||
|
public function setIsTrans($isTrans)
|
||||||
|
{
|
||||||
|
$this->isTrans = $isTrans;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,17 +5,11 @@ namespace AppBundle\Api\Client\Rebrickable\Entity;
|
|||||||
class Part
|
class Part
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Part ID.
|
* Part ID number.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $id;
|
private $number;
|
||||||
/**
|
|
||||||
* Quantity of part in set returned from getSetParts.
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $qty;
|
|
||||||
/**
|
/**
|
||||||
* Part Name.
|
* Part Name.
|
||||||
*
|
*
|
||||||
@ -23,72 +17,89 @@ class Part
|
|||||||
*/
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
/**
|
/**
|
||||||
* Part type 1 = normal part, 2 = spare part.
|
* Part category id.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $type;
|
private $categoryId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Year the part first appeared in sets.
|
* Year the part first appeared in sets.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $year1;
|
private $yearFrom;
|
||||||
/**
|
/**
|
||||||
* Year the part was last seen in sets.
|
* Year the part was last seen in sets.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $year2;
|
private $yearTo;
|
||||||
/**
|
|
||||||
* Part category/type description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $category;
|
|
||||||
/**
|
/**
|
||||||
* Array of colors the part appears in.
|
* Array of colors the part appears in.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $colors;
|
private $externalIds;
|
||||||
/**
|
|
||||||
* Array of related Part IDs used by external systems.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $external_part_ids;
|
|
||||||
/**
|
/**
|
||||||
* Rebrickable URL to the Part Details page.
|
* Rebrickable URL to the Part Details page.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $part_url;
|
private $url;
|
||||||
/**
|
/**
|
||||||
* Rebrickable URL of the main part image (tries to use most common color).
|
* Rebrickable URL of the main part image (tries to use most common color).
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $part_img_url;
|
private $imgUrl;
|
||||||
|
|
||||||
public function __construct()
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getNumber()
|
||||||
{
|
{
|
||||||
|
return $this->number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $number
|
||||||
|
*/
|
||||||
|
public function setNumber($number)
|
||||||
|
{
|
||||||
|
$this->number = $number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
*/
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getId()
|
public function getCategoryId()
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->categoryId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $part_id
|
* @param int $categoryId
|
||||||
*/
|
*/
|
||||||
public function setId($id)
|
public function setCategoryId($categoryId)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->categoryId = $categoryId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,144 +121,80 @@ class Part
|
|||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getQty()
|
public function getYearFrom()
|
||||||
{
|
{
|
||||||
return $this->qty;
|
return $this->yearFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $qty
|
* @param int $yearFrom
|
||||||
*/
|
*/
|
||||||
public function setQty($qty)
|
public function setYearFrom($yearFrom)
|
||||||
{
|
{
|
||||||
$this->qty = $qty;
|
$this->yearFrom = $yearFrom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getYearTo()
|
||||||
|
{
|
||||||
|
return $this->yearTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $yearTo
|
||||||
|
*/
|
||||||
|
public function setYearTo($yearTo)
|
||||||
|
{
|
||||||
|
$this->yearTo = $yearTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getExternalIds()
|
||||||
|
{
|
||||||
|
return $this->externalIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $externalIds
|
||||||
|
*/
|
||||||
|
public function setExternalIds($externalIds)
|
||||||
|
{
|
||||||
|
$this->externalIds = $externalIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getUrl()
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $name
|
* @param string $url
|
||||||
*/
|
*/
|
||||||
public function setName($name)
|
public function setUrl($url)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->url = $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getYear1()
|
public function getImgUrl()
|
||||||
{
|
{
|
||||||
return $this->year1;
|
return $this->imgUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $year1
|
* @param string $imgUrl
|
||||||
*/
|
*/
|
||||||
public function setYear1($year1)
|
public function setImgUrl($imgUrl)
|
||||||
{
|
{
|
||||||
$this->year1 = $year1;
|
$this->imgUrl = $imgUrl;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getYear2()
|
|
||||||
{
|
|
||||||
return $this->year2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mixed $year2
|
|
||||||
*/
|
|
||||||
public function setYear2($year2)
|
|
||||||
{
|
|
||||||
$this->year2 = $year2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getCategory()
|
|
||||||
{
|
|
||||||
return $this->category;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mixed $category
|
|
||||||
*/
|
|
||||||
public function setCategory($category)
|
|
||||||
{
|
|
||||||
$this->category = $category;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getColors()
|
|
||||||
{
|
|
||||||
return $this->colors;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mixed $colors
|
|
||||||
*/
|
|
||||||
public function setColors($colors)
|
|
||||||
{
|
|
||||||
$this->colors = $colors;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getExternalPartIds()
|
|
||||||
{
|
|
||||||
return $this->external_part_ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mixed $external_part_ids
|
|
||||||
*/
|
|
||||||
public function setExternalPartIds($external_part_ids)
|
|
||||||
{
|
|
||||||
$this->external_part_ids = $external_part_ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getPartUrl()
|
|
||||||
{
|
|
||||||
return $this->part_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mixed $part_url
|
|
||||||
*/
|
|
||||||
public function setPartUrl($part_url)
|
|
||||||
{
|
|
||||||
$this->part_url = $part_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getPartImgUrl()
|
|
||||||
{
|
|
||||||
return $this->part_img_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $part_img_url
|
|
||||||
*/
|
|
||||||
public function setPartImgUrl($part_img_url)
|
|
||||||
{
|
|
||||||
$this->part_img_url = $part_img_url;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
69
src/AppBundle/Api/Client/Rebrickable/Entity/PartCategory.php
Normal file
69
src/AppBundle/Api/Client/Rebrickable/Entity/PartCategory.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AppBundle\Api\Client\Rebrickable\Entity;
|
||||||
|
|
||||||
|
class PartCategory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $partCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
*/
|
||||||
|
public function setId($id)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
*/
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPartCount()
|
||||||
|
{
|
||||||
|
return $this->partCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $partCount
|
||||||
|
*/
|
||||||
|
public function setPartCount($partCount)
|
||||||
|
{
|
||||||
|
$this->partCount = $partCount;
|
||||||
|
}
|
||||||
|
}
|
@ -9,41 +9,58 @@ class Set
|
|||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $set_id;
|
private $number;
|
||||||
/**
|
/**
|
||||||
* Set description.
|
* Set description.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $name;
|
private $name;
|
||||||
/**
|
/**
|
||||||
* Number of sets the part appears in.
|
* Year of set release.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $num_parts;
|
private $year;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set constructor.
|
* Count of parts in set.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
private $numParts;
|
||||||
{
|
/**
|
||||||
}
|
* Rebrickable internal theme id.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $themeId;
|
||||||
|
/**
|
||||||
|
* Rebrickable URL of the main set image.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $imgUrl;
|
||||||
|
/**
|
||||||
|
* Rebrickable URL to the Set Details page.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getSetId()
|
public function getNumber()
|
||||||
{
|
{
|
||||||
return $this->set_id;
|
return $this->number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $set_id
|
* @param int $number
|
||||||
*/
|
*/
|
||||||
public function setSetId($set_id)
|
public function setNumber($number)
|
||||||
{
|
{
|
||||||
$this->set_id = $set_id;
|
$this->number = $number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,16 +82,80 @@ class Set
|
|||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getNumParts()
|
public function getYear()
|
||||||
{
|
{
|
||||||
return $this->num_parts;
|
return $this->year;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $num_parts
|
* @param int $year
|
||||||
*/
|
*/
|
||||||
public function setNumParts($num_parts)
|
public function setYear($year)
|
||||||
{
|
{
|
||||||
$this->num_parts = $num_parts;
|
$this->year = $year;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getNumParts()
|
||||||
|
{
|
||||||
|
return $this->numParts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $numParts
|
||||||
|
*/
|
||||||
|
public function setNumParts($numParts)
|
||||||
|
{
|
||||||
|
$this->numParts = $numParts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getThemeId()
|
||||||
|
{
|
||||||
|
return $this->themeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $themeId
|
||||||
|
*/
|
||||||
|
public function setThemeId($themeId)
|
||||||
|
{
|
||||||
|
$this->themeId = $themeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getImgUrl()
|
||||||
|
{
|
||||||
|
return $this->imgUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $imgUrl
|
||||||
|
*/
|
||||||
|
public function setImgUrl($imgUrl)
|
||||||
|
{
|
||||||
|
$this->imgUrl = $imgUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUrl()
|
||||||
|
{
|
||||||
|
return $this->url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $url
|
||||||
|
*/
|
||||||
|
public function setUrl($url)
|
||||||
|
{
|
||||||
|
$this->url = $url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
75
src/AppBundle/Api/Client/Rebrickable/Entity/Theme.php
Normal file
75
src/AppBundle/Api/Client/Rebrickable/Entity/Theme.php
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AppBundle\Api\Client\Rebrickable\Entity;
|
||||||
|
|
||||||
|
class Theme
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Rebrickable internal id of theme.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rebrickable internal id of parent theme.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $parentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of theme.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
*/
|
||||||
|
public function setId($id)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getParentId()
|
||||||
|
{
|
||||||
|
return $this->parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $parentId
|
||||||
|
*/
|
||||||
|
public function setParentId($parentId)
|
||||||
|
{
|
||||||
|
$this->parentId = $parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
*/
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
}
|
||||||
|
}
|
@ -1,69 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace AppBundle\Api\Client\Rebrickable;
|
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
|
||||||
use GuzzleHttp\Exception\ClientException;
|
|
||||||
use GuzzleHttp\Exception\ConnectException;
|
|
||||||
use Symfony\Component\Asset\Exception\LogicException;
|
|
||||||
|
|
||||||
class Rebrickable
|
|
||||||
{
|
|
||||||
const BASE_URI = 'https://rebrickable.com/api/';
|
|
||||||
const FORMAT = 'json';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Client
|
|
||||||
*/
|
|
||||||
private $client;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $apiKey;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RebrickableAPI constructor.
|
|
||||||
*/
|
|
||||||
public function __construct($apiKey)
|
|
||||||
{
|
|
||||||
$this->client = new Client(['base_uri' => self::BASE_URI]);
|
|
||||||
$this->apiKey = $apiKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $method
|
|
||||||
* @param $parameters
|
|
||||||
*
|
|
||||||
* @return null|string
|
|
||||||
*/
|
|
||||||
public function call($method, $parameters = [])
|
|
||||||
{
|
|
||||||
$parameters['query']['key'] = $this->apiKey;
|
|
||||||
$parameters['query']['format'] = self::FORMAT;
|
|
||||||
|
|
||||||
try {
|
|
||||||
$response = $this->client->request('GET', $method, $parameters);
|
|
||||||
|
|
||||||
if ($response->getStatusCode() === 200) {
|
|
||||||
$content = $response->getBody()->getContents();
|
|
||||||
if ($content === 'INVALIDKEY') {
|
|
||||||
//TODO
|
|
||||||
throw new LogicException('Invalid API Key');
|
|
||||||
} elseif ($content === 'NOSET' || $content === 'NOPART') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
//TODO
|
|
||||||
throw new LogicException($response->getStatusCode());
|
|
||||||
} catch (ConnectException $e) {
|
|
||||||
//TODO
|
|
||||||
throw new LogicException($e->getMessage());
|
|
||||||
} catch (ClientException $e) {
|
|
||||||
//TODO
|
|
||||||
throw new LogicException($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
67
src/AppBundle/Api/Client/Rebrickable/Rebrickable_v3.php
Normal file
67
src/AppBundle/Api/Client/Rebrickable/Rebrickable_v3.php
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AppBundle\Api\Client\Rebrickable;
|
||||||
|
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use GuzzleHttp\Exception\ClientException;
|
||||||
|
use GuzzleHttp\Exception\ConnectException;
|
||||||
|
use Symfony\Component\Asset\Exception\LogicException;
|
||||||
|
|
||||||
|
class Rebrickable_v3
|
||||||
|
{
|
||||||
|
const BASE_URI = 'https://rebrickable.com/api/v3/';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Client
|
||||||
|
*/
|
||||||
|
private $client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $apiKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RebrickableAPI constructor.
|
||||||
|
*/
|
||||||
|
public function __construct($apiKey)
|
||||||
|
{
|
||||||
|
$this->client = new Client(['base_uri' => self::BASE_URI]);
|
||||||
|
$this->apiKey = $apiKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $method
|
||||||
|
* @param $uri
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function call($method, $uri, $options = [])
|
||||||
|
{
|
||||||
|
$options['query']['key'] = $this->apiKey;
|
||||||
|
$options['headers'] = [
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
];
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = $this->client->request($method, $uri, $options);
|
||||||
|
|
||||||
|
$content = $response->getBody()->getContents();
|
||||||
|
|
||||||
|
return $content;
|
||||||
|
} catch (ConnectException $e) {
|
||||||
|
//TODO
|
||||||
|
throw new LogicException($e);
|
||||||
|
} catch (ClientException $e) {
|
||||||
|
//TODO
|
||||||
|
if ($e->getCode() == 404) {
|
||||||
|
throw new LogicException('Not Found');
|
||||||
|
}
|
||||||
|
if ($e->getCode() == 500) {
|
||||||
|
throw new LogicException('Invalid token');
|
||||||
|
}
|
||||||
|
throw new LogicException($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
namespace AppBundle\Api\Manager;
|
namespace AppBundle\Api\Manager;
|
||||||
|
|
||||||
use AppBundle\Api\Client\Rebrickable\Converter\PartPropertyNameConverter;
|
use AppBundle\Api\Client\Rebrickable\Converter\PropertyNameConverter;
|
||||||
use AppBundle\Api\Client\Rebrickable\Entity\Color;
|
use AppBundle\Api\Client\Rebrickable\Entity\Color;
|
||||||
use AppBundle\Api\Client\Rebrickable\Entity\Part;
|
use AppBundle\Api\Client\Rebrickable\Entity\Part;
|
||||||
|
use AppBundle\Api\Client\Rebrickable\Entity\PartCategory;
|
||||||
use AppBundle\Api\Client\Rebrickable\Entity\Set;
|
use AppBundle\Api\Client\Rebrickable\Entity\Set;
|
||||||
use AppBundle\Api\Client\Rebrickable\Rebrickable;
|
use AppBundle\Api\Client\Rebrickable\Entity\Theme;
|
||||||
|
use AppBundle\Api\Client\Rebrickable\Rebrickable_v3;
|
||||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||||
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
|
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
|
||||||
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
||||||
@ -17,151 +19,149 @@ class RebrickableManager
|
|||||||
const FORMAT = 'json';
|
const FORMAT = 'json';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Rebrickable
|
* @var Rebrickable_v3
|
||||||
*/
|
*/
|
||||||
private $rebrickableClient;
|
private $rebrickableClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Serializer
|
||||||
|
*/
|
||||||
|
private $serializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RebrickableManager constructor.
|
* RebrickableManager constructor.
|
||||||
*
|
*
|
||||||
* @param Rebrickable $rebrickableClient
|
* @param Rebrickable_v3 $rebrickableClient
|
||||||
*/
|
*/
|
||||||
public function __construct(Rebrickable $rebrickableClient)
|
public function __construct(Rebrickable_v3 $rebrickableClient)
|
||||||
{
|
{
|
||||||
$this->rebrickableClient = $rebrickableClient;
|
$this->rebrickableClient = $rebrickableClient;
|
||||||
|
$this->serializer = $this->initSerializer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getSerializer()
|
private function initSerializer()
|
||||||
{
|
{
|
||||||
$encoders = [new JsonEncoder()];
|
$encoders = [new JsonEncoder()];
|
||||||
$nameConverter = new PartPropertyNameConverter();
|
$objectNormalizer = new ObjectNormalizer(null, new PropertyNameConverter());
|
||||||
$objectNormalizer = new ObjectNormalizer(null, $nameConverter);
|
|
||||||
$normalizers = [$objectNormalizer, new ArrayDenormalizer()];
|
$normalizers = [$objectNormalizer, new ArrayDenormalizer()];
|
||||||
$serializer = new Serializer($normalizers, $encoders);
|
$serializer = new Serializer($normalizers, $encoders);
|
||||||
|
|
||||||
return $serializer;
|
return $serializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a list of all parts (normal + spare) used in a set.
|
|
||||||
*
|
|
||||||
* @param string $setName unique rebrickable set name
|
|
||||||
*
|
|
||||||
* @return Part[]|null
|
|
||||||
*/
|
|
||||||
public function getSetParts($setName)
|
|
||||||
{
|
|
||||||
$parameters = [
|
|
||||||
'query' => [
|
|
||||||
'set' => $setName,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
$data = $this->rebrickableClient->call('get_set_parts', $parameters);
|
|
||||||
|
|
||||||
$serializer = $this->getSerializer();
|
|
||||||
$partsSTD = json_decode($data, true)[0]['parts'];
|
|
||||||
|
|
||||||
if ($data) {
|
|
||||||
$parts = $serializer->denormalize($partsSTD, Part::class.'[]', self::FORMAT);
|
|
||||||
foreach ($parts as $key => &$part) {
|
|
||||||
$part->setCategory($this->getPartTypes()[$partsSTD[$key]['part_type_id']]);
|
|
||||||
$part->setColors([
|
|
||||||
0 => [
|
|
||||||
'color_name' => $partsSTD[$key]['color_name'],
|
|
||||||
'rb_color_id' => $partsSTD[$key]['rb_color_id'],
|
|
||||||
'ldraw_color_id' => $partsSTD[$key]['ldraw_color_id'],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get details about a specific part.
|
* Get details about a specific part.
|
||||||
*
|
*
|
||||||
* @param $partID
|
* @param $id
|
||||||
*
|
*
|
||||||
* @return Part|null
|
* @return Part
|
||||||
*/
|
*/
|
||||||
public function getPart($partID)
|
public function getPart($id)
|
||||||
{
|
{
|
||||||
$parameters = [
|
$data = $this->rebrickableClient->call('GET', 'lego/parts/'.$id);
|
||||||
'query' => [
|
|
||||||
'part_id' => $partID,
|
|
||||||
'inc_ext' => 1,
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
$data = $this->rebrickableClient->call('get_part', $parameters);
|
return $this->serializer->deserialize($data, Part::class, self::FORMAT);
|
||||||
$serializer = $this->getSerializer();
|
|
||||||
|
|
||||||
return $data ? $serializer->deserialize($data, Part::class, self::FORMAT) : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get associative array of colors used by all parts where key == rb_color_id.
|
* Get details about a specific Color.
|
||||||
*
|
*
|
||||||
* @return Color[]|null
|
* @param $id
|
||||||
|
*
|
||||||
|
* @return Color
|
||||||
*/
|
*/
|
||||||
public function getColors()
|
public function getColor($id)
|
||||||
{
|
{
|
||||||
$data = json_decode($this->rebrickableClient->call('get_colors'), true);
|
$data = $this->rebrickableClient->call('GET', 'lego/colors/'.$id);
|
||||||
|
|
||||||
$serializer = $this->getSerializer();
|
return $this->serializer->deserialize($data, Color::class, self::FORMAT);
|
||||||
|
|
||||||
$colors = [];
|
|
||||||
|
|
||||||
foreach ($data as $item) {
|
|
||||||
$color = $serializer->denormalize($item, Color::class, self::FORMAT);
|
|
||||||
$colors[$color->getRbColorId()] = $color;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data ? $colors : [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get associative array of themes used by all parts where key == part_type_id.
|
* Get details for a specific Set.
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @param $id
|
||||||
|
*
|
||||||
|
* @return Set
|
||||||
*/
|
*/
|
||||||
public function getPartTypes()
|
public function getSet($id)
|
||||||
{
|
{
|
||||||
$data = json_decode($this->rebrickableClient->call('get_part_types'), true)['part_types'];
|
$data = $this->rebrickableClient->call('GET', 'lego/sets/'.$id);
|
||||||
|
|
||||||
$types = [];
|
return $this->serializer->deserialize($data, Set::class, self::FORMAT);
|
||||||
foreach ($data as $item) {
|
|
||||||
$types[$item['part_type_id']] = $item['desc'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data ? $types : null;
|
/**
|
||||||
|
* Return details for a specific Theme.
|
||||||
|
*
|
||||||
|
* @param $id
|
||||||
|
*
|
||||||
|
* @return Theme
|
||||||
|
*/
|
||||||
|
public function getTheme($id)
|
||||||
|
{
|
||||||
|
$data = $this->rebrickableClient->call('GET', 'lego/themes/'.$id);
|
||||||
|
|
||||||
|
return $this->serializer->deserialize($data, Theme::class, self::FORMAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return details for a specific PartCategory.
|
||||||
|
*
|
||||||
|
* @param $id
|
||||||
|
*
|
||||||
|
* @return PartCategory
|
||||||
|
*/
|
||||||
|
public function getPartCategory($id)
|
||||||
|
{
|
||||||
|
$data = $this->rebrickableClient->call('GET', 'lego/part_categories/'.$id);
|
||||||
|
|
||||||
|
return $this->serializer->deserialize($data, PartCategory::class, self::FORMAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of sets that a specific part/color appears in.
|
* Get the list of sets that a specific part/color appears in.
|
||||||
*
|
*
|
||||||
* @param $partID
|
* @param $partId
|
||||||
* @param $colorID
|
* @param $colorId
|
||||||
|
* @param $page
|
||||||
*
|
*
|
||||||
* @return Set[]
|
* @return Set[]
|
||||||
*/
|
*/
|
||||||
public function getPartSets($partID, $colorID)
|
public function getPartSets($partId, $colorId, $page = null)
|
||||||
{
|
{
|
||||||
$parameters = [
|
$options = [
|
||||||
'query' => [
|
'query' => [
|
||||||
'part_id' => $partID,
|
'page' => $page,
|
||||||
'color_id' => $colorID,
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$serializer = $this->getSerializer();
|
$response = $this->rebrickableClient->call('GET', 'lego/parts/'.$partId.'/colors/'.$colorId.'/sets', $options);
|
||||||
|
$data = json_decode($response, true)['results'];
|
||||||
|
|
||||||
$data = json_decode($this->rebrickableClient->call('get_part_sets', $parameters), true)[0]['sets'];
|
return $this->serializer->denormalize($data, Set::class.'[]', self::FORMAT);
|
||||||
|
}
|
||||||
|
|
||||||
return $data ? $serializer->denormalize($data, Set::class.'[]', self::FORMAT) : null;
|
/**
|
||||||
|
* Get a list of all parts (normal + spare) used in a set.
|
||||||
|
*
|
||||||
|
* @param $setId
|
||||||
|
* @param $page
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public function getSetParts($setId, $page = null)
|
||||||
|
{
|
||||||
|
$options = [
|
||||||
|
'query' => [
|
||||||
|
'page' => $page,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
//
|
||||||
|
// $response = $this->rebrickableClient->call('GET','lego/sets/'.$setId.'/parts', $options);
|
||||||
|
//
|
||||||
|
// $data = json_decode($response, true)['results'];
|
||||||
|
//
|
||||||
|
// return $this->serializer->denormalize($data, Part::class . '[]', self::FORMAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,32 +3,27 @@
|
|||||||
namespace AppBundle\Command;
|
namespace AppBundle\Command;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
class LoadLibraryCommand extends ContainerAwareCommand
|
class LoadRebrickableDataCommand extends ContainerAwareCommand
|
||||||
{
|
{
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('app:load:library')
|
->setName('app:load:rebrickable')
|
||||||
->setDescription('Loads LDraw library parts')
|
->setDescription('Loads Rebrickable database')
|
||||||
->setHelp('This command allows you to..')
|
->setHelp('This command allows you to..');
|
||||||
->addArgument('ldraw', InputArgument::OPTIONAL, 'Path to LDraw library folder');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$ldrawLoader = $this->getContainer()->get('loader.ldraw');
|
|
||||||
$ldrawLoader->setOutput($output);
|
|
||||||
|
|
||||||
$rebrickableLoader = $this->getContainer()->get('loader.rebrickable');
|
$rebrickableLoader = $this->getContainer()->get('loader.rebrickable');
|
||||||
$rebrickableLoader->setOutput($output);
|
$rebrickableLoader->setOutput($output);
|
||||||
|
|
||||||
try {
|
//TODO log errors
|
||||||
$ldrawLoader->loadModels($input->getArgument('ldraw'));
|
|
||||||
|
|
||||||
|
try {
|
||||||
$rebrickableLoader->loadColors();
|
$rebrickableLoader->loadColors();
|
||||||
|
|
||||||
$rebrickableLoader->loadParts();
|
$rebrickableLoader->loadParts();
|
@ -1,112 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace AppBundle\Entity;
|
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Keyword.
|
|
||||||
*
|
|
||||||
* @ORM\Table(name="keyword")
|
|
||||||
* @ORM\Entity(repositoryClass="AppBundle\Repository\KeywordRepository")
|
|
||||||
*/
|
|
||||||
class Keyword
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*
|
|
||||||
* @ORM\Column(name="id", type="integer")
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
|
||||||
*/
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*
|
|
||||||
* @ORM\Column(name="name", type="string", length=255, unique=true)
|
|
||||||
*/
|
|
||||||
private $name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var ArrayCollection
|
|
||||||
*
|
|
||||||
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\BuildingKit", inversedBy="keywords")
|
|
||||||
*/
|
|
||||||
private $building_kits;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Keyword constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->building_kits = new ArrayCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get id.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getId()
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set name.
|
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
*
|
|
||||||
* @return Keyword
|
|
||||||
*/
|
|
||||||
public function setName($name)
|
|
||||||
{
|
|
||||||
$this->name = $name;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get name.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
return $this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return ArrayCollection
|
|
||||||
*/
|
|
||||||
public function getBuildingKits()
|
|
||||||
{
|
|
||||||
return $this->building_kits;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param BuildingKit $building_kit
|
|
||||||
*
|
|
||||||
* @return Keyword
|
|
||||||
*/
|
|
||||||
public function addBuildingKit(BuildingKit $building_kit)
|
|
||||||
{
|
|
||||||
$this->building_kits->add($building_kit);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param BuildingKit $building_kit
|
|
||||||
*
|
|
||||||
* @return Keyword
|
|
||||||
*/
|
|
||||||
public function removeBuildingKit(BuildingKit $building_kit)
|
|
||||||
{
|
|
||||||
$this->building_kits->remove($building_kit);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace AppBundle\Entity;
|
namespace AppBundle\Entity\Rebrickable;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
* Category.
|
* Category.
|
||||||
*
|
*
|
||||||
* @ORM\Table(name="category")
|
* @ORM\Table(name="category")
|
||||||
* @ORM\Entity(repositoryClass="AppBundle\Repository\CategoryRepository")
|
* @ORM\Entity
|
||||||
*/
|
*/
|
||||||
class Category
|
class Category
|
||||||
{
|
{
|
||||||
@ -33,14 +33,7 @@ class Category
|
|||||||
/**
|
/**
|
||||||
* @var Collection
|
* @var Collection
|
||||||
*
|
*
|
||||||
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Model", mappedBy="category")
|
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Rebrickable\Part", mappedBy="category")
|
||||||
*/
|
|
||||||
private $models;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Collection
|
|
||||||
*
|
|
||||||
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Part", mappedBy="category")
|
|
||||||
*/
|
*/
|
||||||
private $parts;
|
private $parts;
|
||||||
|
|
||||||
@ -49,7 +42,6 @@ class Category
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->models = new ArrayCollection();
|
|
||||||
$this->parts = new ArrayCollection();
|
$this->parts = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,40 +79,6 @@ class Category
|
|||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get models.
|
|
||||||
*
|
|
||||||
* @return ArrayCollection
|
|
||||||
*/
|
|
||||||
public function getModels()
|
|
||||||
{
|
|
||||||
return $this->models;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Model $model
|
|
||||||
*
|
|
||||||
* @return Category
|
|
||||||
*/
|
|
||||||
public function addModel(Model $model)
|
|
||||||
{
|
|
||||||
$this->models->add($model);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Model $model
|
|
||||||
*
|
|
||||||
* @return Category
|
|
||||||
*/
|
|
||||||
public function removeModel(Model $model)
|
|
||||||
{
|
|
||||||
$this->models->remove($model);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parts.
|
* Get parts.
|
||||||
*
|
*
|
@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace AppBundle\Entity;
|
namespace AppBundle\Entity\Rebrickable;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
@ -9,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
* Color.
|
* Color.
|
||||||
*
|
*
|
||||||
* @ORM\Table(name="color")
|
* @ORM\Table(name="color")
|
||||||
* @ORM\Entity(repositoryClass="AppBundle\Repository\ColorRepository")
|
* @ORM\Entity
|
||||||
*/
|
*/
|
||||||
class Color
|
class Color
|
||||||
{
|
{
|
||||||
@ -35,12 +36,27 @@ class Color
|
|||||||
*/
|
*/
|
||||||
private $rgb;
|
private $rgb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*
|
||||||
|
* @ORM\Column(name="transparent", type="boolean")
|
||||||
|
*/
|
||||||
|
private $transparent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection
|
* @var Collection
|
||||||
*
|
*
|
||||||
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Part_BuildingKit", mappedBy="color")
|
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Rebrickable\Part_Set", mappedBy="color")
|
||||||
*/
|
*/
|
||||||
private $part_building_kits;
|
private $part_sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->part_sets = new ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set id.
|
* Set id.
|
||||||
@ -114,43 +130,55 @@ class Color
|
|||||||
return $this->rgb;
|
return $this->rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is transparent.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isTransparent()
|
||||||
|
{
|
||||||
|
return $this->transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set transparent.
|
||||||
|
*
|
||||||
|
* @param bool $transparent
|
||||||
|
*/
|
||||||
|
public function setTransparent($transparent)
|
||||||
|
{
|
||||||
|
$this->transparent = $transparent;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getPartBuildingKits()
|
public function getPartBuildingKits()
|
||||||
{
|
{
|
||||||
return $this->part_building_kits;
|
return $this->part_sets;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Part_BuildingKit $part_building_kit
|
* @param Part_Set $part_building_kit
|
||||||
*
|
*
|
||||||
* @return Color
|
* @return Color
|
||||||
*/
|
*/
|
||||||
public function addPartBuildingKit(Part_BuildingKit $part_building_kit)
|
public function addPartBuildingKit(Part_Set $part_set)
|
||||||
{
|
{
|
||||||
$this->part_building_kits->add($part_building_kit);
|
$this->part_sets->add($part_set);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Part_BuildingKit $part_building_kit
|
* @param Part_Set $part_building_kit
|
||||||
*
|
*
|
||||||
* @return Color
|
* @return Color
|
||||||
*/
|
*/
|
||||||
public function removePartBuildingKit(Part_BuildingKit $part_building_kit)
|
public function removePartBuildingKit(Part_Set $part_set)
|
||||||
{
|
{
|
||||||
$this->part_building_kits->remove($part_building_kit);
|
$this->part_sets->remove($part_set);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->part_building_kits = new \Doctrine\Common\Collections\ArrayCollection();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace AppBundle\Entity;
|
namespace AppBundle\Entity\Rebrickable;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
@ -10,23 +10,26 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
* Part.
|
* Part.
|
||||||
*
|
*
|
||||||
* @ORM\Table(name="part")
|
* @ORM\Table(name="part")
|
||||||
* @ORM\Entity(repositoryClass="AppBundle\Repository\PartRepository")
|
* @ORM\Entity
|
||||||
*/
|
*/
|
||||||
class Part
|
class Part
|
||||||
{
|
{
|
||||||
/**
|
// /**
|
||||||
* @var int
|
// * @var int
|
||||||
*
|
// *
|
||||||
* @ORM\Column(name="id", type="integer")
|
// * @ORM\Column(name="id", type="integer")
|
||||||
* @ORM\Id
|
// * @ORM\Id
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
// * @ORM\GeneratedValue(strategy="AUTO")
|
||||||
*/
|
// */
|
||||||
private $id;
|
// private $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Part ID number.
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(name="number", type="string", length=255, unique=true)
|
* @ORM\Id
|
||||||
|
* @ORM\Column(name="id", type="string", length=255, unique=true)
|
||||||
*/
|
*/
|
||||||
private $number;
|
private $number;
|
||||||
|
|
||||||
@ -40,40 +43,23 @@ class Part
|
|||||||
/**
|
/**
|
||||||
* @var Category
|
* @var Category
|
||||||
*
|
*
|
||||||
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Category", inversedBy="parts")
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Rebrickable\Category", inversedBy="parts")
|
||||||
*/
|
*/
|
||||||
private $category;
|
private $category;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Model
|
|
||||||
*
|
|
||||||
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Model", inversedBy="parts")
|
|
||||||
*/
|
|
||||||
private $model;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection
|
* @var Collection
|
||||||
*
|
*
|
||||||
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Part_BuildingKit", mappedBy="part")
|
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Rebrickable\Part_Set", mappedBy="part")
|
||||||
*/
|
*/
|
||||||
private $building_kits;
|
private $sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Part constructor.
|
* Part constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->building_kits = new ArrayCollection();
|
$this->sets = new ArrayCollection();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get id.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getId()
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -124,54 +110,34 @@ class Part
|
|||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Model
|
|
||||||
*/
|
|
||||||
public function getModel()
|
|
||||||
{
|
|
||||||
return $this->model;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Model $model
|
|
||||||
*
|
|
||||||
* @return Part
|
|
||||||
*/
|
|
||||||
public function setModel($model)
|
|
||||||
{
|
|
||||||
$this->model = $model;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getBuildingKits()
|
public function getSets()
|
||||||
{
|
{
|
||||||
return $this->building_kits;
|
return $this->sets;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Part_BuildingKit $building_kit
|
* @param Part_Set $set
|
||||||
*
|
*
|
||||||
* @return Part
|
* @return Part
|
||||||
*/
|
*/
|
||||||
public function addBuildingKit(Part_BuildingKit $building_kit)
|
public function addSet(Part_Set $set)
|
||||||
{
|
{
|
||||||
$this->building_kits->add($building_kit);
|
$this->sets->add($set);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Part_BuildingKit $building_kit
|
* @param Part_Set $set
|
||||||
*
|
*
|
||||||
* @return Part
|
* @return Part
|
||||||
*/
|
*/
|
||||||
public function removeBuildingKit($building_kit)
|
public function removeSet($set)
|
||||||
{
|
{
|
||||||
$this->building_kits->remove($building_kit);
|
$this->sets->removeElement($set);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
@ -1,16 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace AppBundle\Entity;
|
namespace AppBundle\Entity\Rebrickable;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Part_BuildingKit.
|
* Part_Set.
|
||||||
*
|
*
|
||||||
* @ORM\Table(name="part__building_kit")
|
* @ORM\Table(name="part_set")
|
||||||
* @ORM\Entity(repositoryClass="AppBundle\Repository\Part_BuildingKitRepository")
|
* @ORM\Entity
|
||||||
*/
|
*/
|
||||||
class Part_BuildingKit
|
class Part_Set
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
@ -31,7 +31,7 @@ class Part_BuildingKit
|
|||||||
/**
|
/**
|
||||||
* @var Color
|
* @var Color
|
||||||
*
|
*
|
||||||
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Color", inversedBy="part_building_kits")
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Rebrickable\Color", inversedBy="part_sets")
|
||||||
*/
|
*/
|
||||||
private $color;
|
private $color;
|
||||||
|
|
||||||
@ -45,16 +45,16 @@ class Part_BuildingKit
|
|||||||
/**
|
/**
|
||||||
* @var Part
|
* @var Part
|
||||||
*
|
*
|
||||||
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Part", inversedBy="building_kits" )
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Rebrickable\Part", inversedBy="sets" )
|
||||||
*/
|
*/
|
||||||
private $part;
|
private $part;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var BuildingKit
|
* @var Set
|
||||||
*
|
*
|
||||||
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\BuildingKit", inversedBy="parts")
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Rebrickable\Set", inversedBy="parts")
|
||||||
*/
|
*/
|
||||||
private $building_kit;
|
private $set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get id.
|
* Get id.
|
||||||
@ -71,7 +71,7 @@ class Part_BuildingKit
|
|||||||
*
|
*
|
||||||
* @param int $count
|
* @param int $count
|
||||||
*
|
*
|
||||||
* @return Part_BuildingKit
|
* @return Part_Set
|
||||||
*/
|
*/
|
||||||
public function setCount($count)
|
public function setCount($count)
|
||||||
{
|
{
|
||||||
@ -95,7 +95,7 @@ class Part_BuildingKit
|
|||||||
*
|
*
|
||||||
* @param Color $color
|
* @param Color $color
|
||||||
*
|
*
|
||||||
* @return Part_BuildingKit
|
* @return Part_Set
|
||||||
*/
|
*/
|
||||||
public function setColor($color)
|
public function setColor($color)
|
||||||
{
|
{
|
||||||
@ -119,7 +119,7 @@ class Part_BuildingKit
|
|||||||
*
|
*
|
||||||
* @param bool $type
|
* @param bool $type
|
||||||
*
|
*
|
||||||
* @return Part_BuildingKit
|
* @return Part_Set
|
||||||
*/
|
*/
|
||||||
public function setType($type)
|
public function setType($type)
|
||||||
{
|
{
|
||||||
@ -149,33 +149,33 @@ class Part_BuildingKit
|
|||||||
/**
|
/**
|
||||||
* @param Part $part
|
* @param Part $part
|
||||||
*
|
*
|
||||||
* @return Part_BuildingKit
|
* @return Part_Set
|
||||||
*/
|
*/
|
||||||
public function setPart(Part $part)
|
public function setPart(Part $part)
|
||||||
{
|
{
|
||||||
$part->addBuildingKit($this);
|
$part->addSet($this);
|
||||||
$this->part = $part;
|
$this->part = $part;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return BuildingKit
|
* @return Set
|
||||||
*/
|
*/
|
||||||
public function getBuildingKit()
|
public function getSet()
|
||||||
{
|
{
|
||||||
return $this->building_kit;
|
return $this->set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param BuildingKit $building_kit
|
* @param Set $set
|
||||||
*
|
*
|
||||||
* @return Part_BuildingKit
|
* @return Part_Set
|
||||||
*/
|
*/
|
||||||
public function setBuildingKit(BuildingKit $building_kit)
|
public function setSet(Set $set)
|
||||||
{
|
{
|
||||||
$building_kit->addPart($this);
|
$set->addPart($this);
|
||||||
$this->building_kit = $building_kit;
|
$this->set = $set;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
@ -1,32 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace AppBundle\Entity;
|
namespace AppBundle\Entity\Rebrickable;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BuildingKit.
|
* Set.
|
||||||
*
|
*
|
||||||
* @ORM\Table(name="building_kit")
|
* @ORM\Table(name="set")
|
||||||
* @ORM\Entity(repositoryClass="AppBundle\Repository\BuildingKitRepository")
|
* @ORM\Entity
|
||||||
*/
|
*/
|
||||||
class BuildingKit
|
class Set
|
||||||
{
|
{
|
||||||
/**
|
// /**
|
||||||
* @var int
|
// * @var int
|
||||||
*
|
// *
|
||||||
* @ORM\Column(name="id", type="integer")
|
// * @ORM\Column(name="id", type="integer")
|
||||||
* @ORM\Id
|
// * @ORM\Id
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
// * @ORM\GeneratedValue(strategy="AUTO")
|
||||||
*/
|
// */
|
||||||
private $id;
|
// private $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(name="number", type="string", length=255, unique=true)
|
* @ORM\Id
|
||||||
|
* @ORM\Column(name="id", type="string", length=255, unique=true)
|
||||||
*/
|
*/
|
||||||
private $number;
|
private $number;
|
||||||
|
|
||||||
@ -54,35 +55,35 @@ class BuildingKit
|
|||||||
/**
|
/**
|
||||||
* @var Collection
|
* @var Collection
|
||||||
*
|
*
|
||||||
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Part_BuildingKit", mappedBy="building_kit")
|
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Rebrickable\Part_Set", mappedBy="set")
|
||||||
*/
|
*/
|
||||||
private $parts;
|
private $parts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection
|
* @var Collection
|
||||||
*
|
*
|
||||||
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\Keyword", mappedBy="building_kits")
|
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\Rebrickable\Theme", mappedBy="sets")
|
||||||
*/
|
*/
|
||||||
private $keywords;
|
private $themes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BuildingKit constructor.
|
* Set constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->parts = new ArrayCollection();
|
$this->parts = new ArrayCollection();
|
||||||
$this->keywords = new ArrayCollection();
|
$this->themes = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Get id.
|
// * Get id.
|
||||||
*
|
// *
|
||||||
* @return int
|
// * @return int
|
||||||
*/
|
// */
|
||||||
public function getId()
|
// public function getId()
|
||||||
{
|
// {
|
||||||
return $this->id;
|
// return $this->id;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
@ -95,7 +96,7 @@ class BuildingKit
|
|||||||
/**
|
/**
|
||||||
* @param string $number
|
* @param string $number
|
||||||
*
|
*
|
||||||
* @return BuildingKit
|
* @return Set
|
||||||
*/
|
*/
|
||||||
public function setNumber($number)
|
public function setNumber($number)
|
||||||
{
|
{
|
||||||
@ -109,7 +110,7 @@ class BuildingKit
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*
|
*
|
||||||
* @return BuildingKit
|
* @return Set
|
||||||
*/
|
*/
|
||||||
public function setName($name)
|
public function setName($name)
|
||||||
{
|
{
|
||||||
@ -133,7 +134,7 @@ class BuildingKit
|
|||||||
*
|
*
|
||||||
* @param int $year
|
* @param int $year
|
||||||
*
|
*
|
||||||
* @return BuildingKit
|
* @return Set
|
||||||
*/
|
*/
|
||||||
public function setYear($year)
|
public function setYear($year)
|
||||||
{
|
{
|
||||||
@ -163,7 +164,7 @@ class BuildingKit
|
|||||||
/**
|
/**
|
||||||
* @param int $partCount
|
* @param int $partCount
|
||||||
*
|
*
|
||||||
* @return BuildingKit
|
* @return Set
|
||||||
*/
|
*/
|
||||||
public function setPartCount($partCount)
|
public function setPartCount($partCount)
|
||||||
{
|
{
|
||||||
@ -183,11 +184,11 @@ class BuildingKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Part_BuildingKit $part
|
* @param Part_Set $part
|
||||||
*
|
*
|
||||||
* @return BuildingKit
|
* @return Set
|
||||||
*/
|
*/
|
||||||
public function addPart(Part_BuildingKit $part)
|
public function addPart(Part_Set $part)
|
||||||
{
|
{
|
||||||
$this->parts->add($part);
|
$this->parts->add($part);
|
||||||
|
|
||||||
@ -195,48 +196,14 @@ class BuildingKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Part_BuildingKit $part
|
* @param Part_Set $part
|
||||||
*
|
*
|
||||||
* @return BuildingKit
|
* @return Set
|
||||||
*/
|
*/
|
||||||
public function removePart(Part_BuildingKit $part)
|
public function removePart(Part_Set $part)
|
||||||
{
|
{
|
||||||
$this->parts->remove($part);
|
$this->parts->remove($part);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get keywords.
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getKeywords()
|
|
||||||
{
|
|
||||||
return $this->keywords;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Keyword $keyword
|
|
||||||
*
|
|
||||||
* @return BuildingKit
|
|
||||||
*/
|
|
||||||
public function addKeyword(Keyword $keyword)
|
|
||||||
{
|
|
||||||
$this->keywords->add($keyword);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Keyword $keyword
|
|
||||||
*
|
|
||||||
* @return BuildingKit
|
|
||||||
*/
|
|
||||||
public function removeKeyword(Keyword $keyword)
|
|
||||||
{
|
|
||||||
$this->keywords->remove($keyword);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
}
|
125
src/AppBundle/Entity/Rebrickable/Theme.php
Normal file
125
src/AppBundle/Entity/Rebrickable/Theme.php
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AppBundle\Entity\Rebrickable;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Theme.
|
||||||
|
*
|
||||||
|
* @ORM\Table(name="theme")
|
||||||
|
* @ORM\Entity
|
||||||
|
*/
|
||||||
|
class Theme
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*
|
||||||
|
* @ORM\Column(name="id", type="integer")
|
||||||
|
* @ORM\Id
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @ORM\Column(name="name", type="string", length=255)
|
||||||
|
*/
|
||||||
|
private $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection
|
||||||
|
*
|
||||||
|
* @ORM\ManyToOne(targetEntity="Theme")
|
||||||
|
* @ORM\JoinColumn(onDelete="SET NULL")
|
||||||
|
*/
|
||||||
|
private $parent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Collection
|
||||||
|
*
|
||||||
|
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\Rebrickable\Set", inversedBy="themes")
|
||||||
|
*/
|
||||||
|
private $sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
*/
|
||||||
|
public function setId($id)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
*/
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getParent()
|
||||||
|
{
|
||||||
|
return $this->parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $parent
|
||||||
|
*/
|
||||||
|
public function setParent($parent)
|
||||||
|
{
|
||||||
|
$this->parent = $parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getSets()
|
||||||
|
{
|
||||||
|
return $this->sets;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Part_Set $set
|
||||||
|
*
|
||||||
|
* @return Theme
|
||||||
|
*/
|
||||||
|
public function addSet(Part_Set $set)
|
||||||
|
{
|
||||||
|
$this->sets->add($set);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Part_Set $set
|
||||||
|
*
|
||||||
|
* @return Theme
|
||||||
|
*/
|
||||||
|
public function removeSet($set)
|
||||||
|
{
|
||||||
|
$this->sets->removeElement($set);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace AppBundle\Command\Loader;
|
namespace AppBundle\Loader;
|
||||||
|
|
||||||
use AppBundle\Api\Manager\RebrickableManager;
|
use AppBundle\Api\Manager\RebrickableManager;
|
||||||
use AppBundle\Entity\BuildingKit;
|
use AppBundle\Entity\BuildingKit;
|
||||||
@ -24,9 +24,8 @@ class RebrickableLoader extends Loader
|
|||||||
/**
|
/**
|
||||||
* ModelLoaderService constructor.
|
* ModelLoaderService constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct($em, $rebrickableManager, $rebrickable_url)
|
public function setArguments($rebrickableManager, $rebrickable_url)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
|
||||||
$this->rebrickableManager = $rebrickableManager;
|
$this->rebrickableManager = $rebrickableManager;
|
||||||
$this->rebrickable_url = $rebrickable_url;
|
$this->rebrickable_url = $rebrickable_url;
|
||||||
}
|
}
|
@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace AppBundle\Repository;
|
|
||||||
|
|
||||||
use AppBundle\Entity\Part;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BuildingSetRepository.
|
|
||||||
*
|
|
||||||
* This class was generated by the Doctrine ORM. Add your own custom
|
|
||||||
* repository methods below.
|
|
||||||
*/
|
|
||||||
class BuildingKitRepository extends \Doctrine\ORM\EntityRepository
|
|
||||||
{
|
|
||||||
public function findAllByPart(Part $part)
|
|
||||||
{
|
|
||||||
$qb = $this->getEntityManager()->createQueryBuilder();
|
|
||||||
|
|
||||||
$qb->select('building_kit')
|
|
||||||
->from('AppBundle:BuildingKit', 'building_kit')
|
|
||||||
->innerJoin('building_kit.parts', 'parts')
|
|
||||||
->where('parts.part = :id')->setParameter('id', $part->getId());
|
|
||||||
|
|
||||||
return $qb->getQuery()->getResult();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace AppBundle\Repository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CategoryRepository.
|
|
||||||
*
|
|
||||||
* This class was generated by the Doctrine ORM. Add your own custom
|
|
||||||
* repository methods below.
|
|
||||||
*/
|
|
||||||
class CategoryRepository extends \Doctrine\ORM\EntityRepository
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace AppBundle\Repository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ColorRepository.
|
|
||||||
*
|
|
||||||
* This class was generated by the Doctrine ORM. Add your own custom
|
|
||||||
* repository methods below.
|
|
||||||
*/
|
|
||||||
class ColorRepository extends \Doctrine\ORM\EntityRepository
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace AppBundle\Repository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* KeywordRepository.
|
|
||||||
*
|
|
||||||
* This class was generated by the Doctrine ORM. Add your own custom
|
|
||||||
* repository methods below.
|
|
||||||
*/
|
|
||||||
class KeywordRepository extends \Doctrine\ORM\EntityRepository
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace AppBundle\Repository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ModelRepository.
|
|
||||||
*
|
|
||||||
* This class was generated by the Doctrine ORM. Add your own custom
|
|
||||||
* repository methods below.
|
|
||||||
*/
|
|
||||||
class ModelRepository extends \Doctrine\ORM\EntityRepository
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace AppBundle\Repository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PartRepository.
|
|
||||||
*
|
|
||||||
* This class was generated by the Doctrine ORM. Add your own custom
|
|
||||||
* repository methods below.
|
|
||||||
*/
|
|
||||||
class PartRepository extends \Doctrine\ORM\EntityRepository
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace AppBundle\Repository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Part_BuildingKitRepository.
|
|
||||||
*
|
|
||||||
* This class was generated by the Doctrine ORM. Add your own custom
|
|
||||||
* repository methods below.
|
|
||||||
*/
|
|
||||||
class Part_BuildingKitRepository extends \Doctrine\ORM\EntityRepository
|
|
||||||
{
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user