From 41695904bbcea7b7a6bad72c8a171184ea8610fa Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 5 Jun 2017 15:57:56 +0200 Subject: [PATCH] Add/fix comments --- app/Resources/assets/style/filter.scss | 1 + .../Api/Manager/RebrickableManager.php | 3 +- .../Entity/Rebrickable/Inventory_Part.php | 2 +- src/AppBundle/Entity/Rebrickable/Part.php | 6 +- src/AppBundle/Entity/Rebrickable/Set.php | 2 +- src/AppBundle/Form/FilterSetType.php | 77 ------------------- src/AppBundle/Service/ModelService.php | 7 ++ 7 files changed, 14 insertions(+), 84 deletions(-) delete mode 100644 src/AppBundle/Form/FilterSetType.php diff --git a/app/Resources/assets/style/filter.scss b/app/Resources/assets/style/filter.scss index 661f77a..6c29e51 100644 --- a/app/Resources/assets/style/filter.scss +++ b/app/Resources/assets/style/filter.scss @@ -1,4 +1,5 @@ .filter { + padding-top: 2em !important; .number-range { margin: 1em 0.6em 3em; } diff --git a/src/AppBundle/Api/Manager/RebrickableManager.php b/src/AppBundle/Api/Manager/RebrickableManager.php index 1115f75..53dc538 100644 --- a/src/AppBundle/Api/Manager/RebrickableManager.php +++ b/src/AppBundle/Api/Manager/RebrickableManager.php @@ -163,7 +163,7 @@ class RebrickableManager * @param $setId * @param $page * - * @return + * @return Part[] */ public function getSetParts($setId, $page = null) { @@ -176,7 +176,6 @@ class RebrickableManager $response = $this->rebrickableClient->call('GET', 'lego/sets/'.$setId.'/parts', $options); $data = json_decode($response, true)['results']; - dump($data); return $this->serializer->denormalize($data, Part::class.'[]', self::FORMAT); } diff --git a/src/AppBundle/Entity/Rebrickable/Inventory_Part.php b/src/AppBundle/Entity/Rebrickable/Inventory_Part.php index bad24d1..b36fdfd 100644 --- a/src/AppBundle/Entity/Rebrickable/Inventory_Part.php +++ b/src/AppBundle/Entity/Rebrickable/Inventory_Part.php @@ -99,7 +99,7 @@ class Inventory_Part /** * Set type. * - * @param bool $type + * @param bool $spare * * @return Inventory_Part */ diff --git a/src/AppBundle/Entity/Rebrickable/Part.php b/src/AppBundle/Entity/Rebrickable/Part.php index d00b7d4..c9b0c1a 100644 --- a/src/AppBundle/Entity/Rebrickable/Part.php +++ b/src/AppBundle/Entity/Rebrickable/Part.php @@ -58,7 +58,7 @@ class Part } /** - * @param Inventory_Part $invetoryPart + * @param Inventory_Part $inventoryPart * * @return Part */ @@ -70,7 +70,7 @@ class Part } /** - * @param Inventory_Part $set + * @param Inventory_Part $inventoryPart * * @return Part */ @@ -90,7 +90,7 @@ class Part } /** - * @param Collection $category + * @param Category $category * * @return Part */ diff --git a/src/AppBundle/Entity/Rebrickable/Set.php b/src/AppBundle/Entity/Rebrickable/Set.php index 7a56ff4..27de06d 100644 --- a/src/AppBundle/Entity/Rebrickable/Set.php +++ b/src/AppBundle/Entity/Rebrickable/Set.php @@ -130,7 +130,7 @@ class Set } /** - * @param Inventory $part + * @param Inventory $inventory * * @return Set */ diff --git a/src/AppBundle/Form/FilterSetType.php b/src/AppBundle/Form/FilterSetType.php deleted file mode 100644 index 3305c81..0000000 --- a/src/AppBundle/Form/FilterSetType.php +++ /dev/null @@ -1,77 +0,0 @@ -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); - } - ); - } -} diff --git a/src/AppBundle/Service/ModelService.php b/src/AppBundle/Service/ModelService.php index 6599a2d..adfe2e0 100644 --- a/src/AppBundle/Service/ModelService.php +++ b/src/AppBundle/Service/ModelService.php @@ -8,6 +8,13 @@ class ModelService { private $models = []; + + /** + * Get all subparts of model + * + * @param Model $model + * @return array + */ public function getAllSubparts(Model $model) { foreach ($model->getSubparts() as $subpart) {