mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-21 06:30:10 -07:00
Add/fix comments
This commit is contained in:
parent
2e1d919ee8
commit
41695904bb
@ -1,4 +1,5 @@
|
|||||||
.filter {
|
.filter {
|
||||||
|
padding-top: 2em !important;
|
||||||
.number-range {
|
.number-range {
|
||||||
margin: 1em 0.6em 3em;
|
margin: 1em 0.6em 3em;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ class RebrickableManager
|
|||||||
* @param $setId
|
* @param $setId
|
||||||
* @param $page
|
* @param $page
|
||||||
*
|
*
|
||||||
* @return
|
* @return Part[]
|
||||||
*/
|
*/
|
||||||
public function getSetParts($setId, $page = null)
|
public function getSetParts($setId, $page = null)
|
||||||
{
|
{
|
||||||
@ -176,7 +176,6 @@ class RebrickableManager
|
|||||||
$response = $this->rebrickableClient->call('GET', 'lego/sets/'.$setId.'/parts', $options);
|
$response = $this->rebrickableClient->call('GET', 'lego/sets/'.$setId.'/parts', $options);
|
||||||
$data = json_decode($response, true)['results'];
|
$data = json_decode($response, true)['results'];
|
||||||
|
|
||||||
dump($data);
|
|
||||||
|
|
||||||
return $this->serializer->denormalize($data, Part::class.'[]', self::FORMAT);
|
return $this->serializer->denormalize($data, Part::class.'[]', self::FORMAT);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ class Inventory_Part
|
|||||||
/**
|
/**
|
||||||
* Set type.
|
* Set type.
|
||||||
*
|
*
|
||||||
* @param bool $type
|
* @param bool $spare
|
||||||
*
|
*
|
||||||
* @return Inventory_Part
|
* @return Inventory_Part
|
||||||
*/
|
*/
|
||||||
|
@ -58,7 +58,7 @@ class Part
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Inventory_Part $invetoryPart
|
* @param Inventory_Part $inventoryPart
|
||||||
*
|
*
|
||||||
* @return Part
|
* @return Part
|
||||||
*/
|
*/
|
||||||
@ -70,7 +70,7 @@ class Part
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Inventory_Part $set
|
* @param Inventory_Part $inventoryPart
|
||||||
*
|
*
|
||||||
* @return Part
|
* @return Part
|
||||||
*/
|
*/
|
||||||
@ -90,7 +90,7 @@ class Part
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection $category
|
* @param Category $category
|
||||||
*
|
*
|
||||||
* @return Part
|
* @return Part
|
||||||
*/
|
*/
|
||||||
|
@ -130,7 +130,7 @@ class Set
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Inventory $part
|
* @param Inventory $inventory
|
||||||
*
|
*
|
||||||
* @return Set
|
* @return Set
|
||||||
*/
|
*/
|
||||||
|
@ -1,77 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace AppBundle\Form;
|
|
||||||
|
|
||||||
use AppBundle\Api\Client\Brickset\Entity\Subtheme;
|
|
||||||
use AppBundle\Api\Client\Brickset\Entity\Theme;
|
|
||||||
use AppBundle\Api\Client\Brickset\Entity\Year;
|
|
||||||
use AppBundle\Api\Manager\BricksetManager;
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
||||||
use Symfony\Component\Form\Form;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
|
||||||
use Symfony\Component\Form\FormEvent;
|
|
||||||
use Symfony\Component\Form\FormEvents;
|
|
||||||
|
|
||||||
class FilterSetType extends AbstractType
|
|
||||||
{
|
|
||||||
private $bricksetManager;
|
|
||||||
|
|
||||||
public function __construct(BricksetManager $bricksetManager)
|
|
||||||
{
|
|
||||||
$this->bricksetManager = $bricksetManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
||||||
{
|
|
||||||
$builder
|
|
||||||
->add('theme', ChoiceType::class, [
|
|
||||||
'choices' => $this->bricksetManager->getThemes(),
|
|
||||||
'choice_label' => function (Theme $theme = null) {
|
|
||||||
return $theme ? $theme->getTheme().' ('.$theme->getSetCount().')' : '';
|
|
||||||
},
|
|
||||||
'placeholder' => '',
|
|
||||||
'required' => false,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$formModifier = function (Form $form, Theme $theme = null) {
|
|
||||||
$subthemes = null === $theme ? [] : $this->bricksetManager->getSubthemesByTheme($theme);
|
|
||||||
$years = null === $theme ? [] : $this->bricksetManager->getYearsByTheme($theme);
|
|
||||||
|
|
||||||
$form->add('subtheme', ChoiceType::class, [
|
|
||||||
'choices' => $subthemes,
|
|
||||||
'choice_label' => function (Subtheme $subtheme = null) {
|
|
||||||
return $subtheme ? $subtheme->getSubtheme() : '';
|
|
||||||
},
|
|
||||||
'placeholder' => '',
|
|
||||||
'required' => false,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$form->add('years', ChoiceType::class, [
|
|
||||||
'choices' => $years,
|
|
||||||
'choice_label' => function (Year $year = null) {
|
|
||||||
return $year ? $year->getYear() : '';
|
|
||||||
},
|
|
||||||
'placeholder' => '',
|
|
||||||
'required' => false,
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
|
|
||||||
$builder->addEventListener(
|
|
||||||
FormEvents::PRE_SET_DATA,
|
|
||||||
function (FormEvent $event) use ($formModifier) {
|
|
||||||
$data = $event->getData();
|
|
||||||
$theme = $data === null ? null : $this->bricksetManager->getThemes()[$data['theme']];
|
|
||||||
$formModifier($event->getForm(), $theme);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$builder->get('theme')->addEventListener(
|
|
||||||
FormEvents::POST_SUBMIT,
|
|
||||||
function (FormEvent $event) use ($formModifier) {
|
|
||||||
$theme = $event->getForm()->getData();
|
|
||||||
$formModifier($event->getForm()->getParent(), $theme);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,6 +8,13 @@ class ModelService
|
|||||||
{
|
{
|
||||||
private $models = [];
|
private $models = [];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all subparts of model
|
||||||
|
*
|
||||||
|
* @param Model $model
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getAllSubparts(Model $model)
|
public function getAllSubparts(Model $model)
|
||||||
{
|
{
|
||||||
foreach ($model->getSubparts() as $subpart) {
|
foreach ($model->getSubparts() as $subpart) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user