mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-15 20:00:08 -07:00
show only themes containing sets
This commit is contained in:
parent
be3a9cea65
commit
843d92c534
@ -62,6 +62,13 @@ The elasticsearch index must be build:
|
||||
|
||||
The import from rebrickable may complete with the message "Done with X errors.". This is normal. Most probably some parts/sets are faulty and haven't be imported.
|
||||
|
||||
## Added Features
|
||||
app/config/config.yml
|
||||
|
||||
`app.show_only_themes_containing_sets: true`
|
||||
|
||||
If this is set to true, only themes are visible in the drop down, that have sets in it.
|
||||
|
||||
---
|
||||
From this point on, the original Readme text:
|
||||
|
||||
|
@ -36,6 +36,9 @@ services:
|
||||
arguments:
|
||||
$cache: '@app.brickset.cache_provider'
|
||||
|
||||
FrontBundle\Form\Search\SetSearchType:
|
||||
arguments:
|
||||
$showOnlyThemesContainingSets: %app.show_only_themes_containing_sets%
|
||||
|
||||
# Filesystem
|
||||
|
||||
|
@ -6,4 +6,8 @@ use AppBundle\Repository\BaseRepository;
|
||||
|
||||
class ThemeRepository extends BaseRepository
|
||||
{
|
||||
public function findAll()
|
||||
{
|
||||
return $this->findBy(array(), array('name' => 'ASC'));
|
||||
}
|
||||
}
|
||||
|
@ -23,19 +23,32 @@ class SetSearchType extends AbstractType
|
||||
/** @var SetRepository */
|
||||
private $setRepository;
|
||||
|
||||
private $showOnlyThemesContainingSets;
|
||||
|
||||
/**
|
||||
* SetSearchType constructor.
|
||||
*
|
||||
* @param EntityManagerInterface $em
|
||||
*/
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
public function __construct(EntityManagerInterface $em, bool $showOnlyThemesContainingSets)
|
||||
{
|
||||
$this->themeRepository = $em->getRepository(Theme::class);
|
||||
$this->setRepository = $em->getRepository(Set::class);
|
||||
$this->showOnlyThemesContainingSets = $showOnlyThemesContainingSets;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$themes = $this->themeRepository->findAll();
|
||||
if($this->showOnlyThemesContainingSets) {
|
||||
$tmp = $themes;
|
||||
foreach($tmp as $k => $theme) {
|
||||
if($theme->getSets()->count() == 0) {
|
||||
unset($themes[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$builder
|
||||
->add('query', TextType::class, [
|
||||
'required' => false,
|
||||
@ -64,7 +77,7 @@ class SetSearchType extends AbstractType
|
||||
])
|
||||
->add('theme', ChoiceType::class, [
|
||||
'label' => 'set.form.theme',
|
||||
'choices' => $this->themeRepository->findAll(),
|
||||
'choices' => $themes,
|
||||
'choice_label' => 'fullName',
|
||||
'choice_translation_domain' => false,
|
||||
'group_by' => function ($theme, $key, $index) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user