mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-17 12:50:08 -07:00
Update controllers and views
This commit is contained in:
parent
436624f751
commit
3540a203e3
@ -1,3 +1,5 @@
|
|||||||
|
{% import 'macros/elements.html.twig' as elements %}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@ -14,6 +16,11 @@
|
|||||||
{{ knp_menu_render('mainMenu') }}
|
{{ knp_menu_render('mainMenu') }}
|
||||||
</div>
|
</div>
|
||||||
<div class="ui main container">
|
<div class="ui main container">
|
||||||
|
{% for label, flashes in app.session.flashbag.all %}
|
||||||
|
{% for flash in flashes %}
|
||||||
|
{{ elements.flash(label,flash) }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
11
app/Resources/views/error/error.html.twig
Normal file
11
app/Resources/views/error/error.html.twig
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}{{ 'page.error.title'|trans }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2 class="ui center aligned icon header">
|
||||||
|
<i class="circular warning icon"></i>
|
||||||
|
{{ 'page.error.large'|trans }}
|
||||||
|
</h2>
|
||||||
|
<p class="ui center aligned">{{ 'page.error.text'|trans }}</p>
|
||||||
|
{% endblock %}
|
85
app/Resources/views/ldraw/model/detail.html.twig
Normal file
85
app/Resources/views/ldraw/model/detail.html.twig
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% import 'macros/elements.html.twig' as elements %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if model %}
|
||||||
|
<dl>
|
||||||
|
<dt>number:</dt><dd>{{ model.number }}</dd>
|
||||||
|
<dt>name:</dt><dd>{{ model.name }}</dd>
|
||||||
|
<dt>category:</dt><dd>{{ model.category ? model.category.name }}</dd>
|
||||||
|
<dt>type:</dt><dd>{{ model.type ? model.type.name }}</dd>
|
||||||
|
<dt>model:</dt><dd>{{ model.path }}</dd>
|
||||||
|
<dt>author:</dt><dd>{{ model.author }}</dd>
|
||||||
|
<dt>keywords:</dt>
|
||||||
|
<dd>
|
||||||
|
{% for keyword in model.keywords %}
|
||||||
|
<span class="ui label">{{ keyword.name }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
</dd>
|
||||||
|
<dt>aliases:</dt>
|
||||||
|
<dd>
|
||||||
|
{% for alias in model.aliases %}
|
||||||
|
<span class="ui label">{{ alias.number }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
</dd>
|
||||||
|
<dd>Download:</dd>
|
||||||
|
<dt><a href="{{ path('model_stl', {'number' : model.number })}}">{{ model.number }}</a></dt>
|
||||||
|
<dt>rebrickable parts ({{ rbParts|length }}):</dt>
|
||||||
|
<dd>
|
||||||
|
<p>
|
||||||
|
<div class="ui eight doubling cards">
|
||||||
|
{% for alias in rbParts %}
|
||||||
|
<a href="{{ url('rebrickable_part_show', {number:alias.number}) }}" class="ui label">{{ alias.number }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</p>
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div style="display: flex; flex-wrap: wrap">
|
||||||
|
<div id="model" style="height: 300px; width: 300px; padding: 5px; display: inline-block"></div>
|
||||||
|
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block">
|
||||||
|
<img src="{{ url('model_image', {'number': model.number}) }}" style="max-height: 90%; max-width: 100%">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h4 class="ui horizontal divider header">
|
||||||
|
<i class="puzzle icon"></i> Subparts of this model
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
{% for subpart in model.subparts %}
|
||||||
|
{{ elements.part(subpart.subpart) }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<h4 class="ui horizontal divider header">
|
||||||
|
<i class="cube icon"></i> Model is subpart of
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
{% for subpart in model.parents %}
|
||||||
|
{{ elements.part(subpart.parent) }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<h4 class="ui horizontal divider header">
|
||||||
|
<i class="cubes icon"></i> Sets ({{ sets|length }})
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
{% for set in sets %}
|
||||||
|
<span style="margin: 5px"><a href="{{ url('set_detail', {number:set.number}) }}">{{ set.number }}</a></span>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block javascripts %}
|
||||||
|
{{ parent() }}
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
window.onload = function() {
|
||||||
|
modelView = new ModelViewer();
|
||||||
|
var scene = modelView.initScene($('#model'));
|
||||||
|
modelView.loadStl('{{ path('model_stl', {'number' : model.number })}}');
|
||||||
|
modelView.render();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
@ -1,6 +1,6 @@
|
|||||||
{% extends 'base.html.twig' %}
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
{% import 'macro/part.html.twig' as macro %}
|
{% import 'macros/elements.html.twig' as elements %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<form method="get" action="." class="ui form">
|
<form method="get" action="." class="ui form">
|
||||||
@ -17,15 +17,17 @@
|
|||||||
{{ form_end(form) }}
|
{{ form_end(form) }}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<p>{{ models.getTotalItemCount }}</p>
|
||||||
<div class="ui ten column grid">
|
<div class="ui ten column grid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{% for part in parts %}
|
{% for model in models %}
|
||||||
<div class="column">
|
<div class="column">
|
||||||
{{ macro.part(part) }}
|
{{ elements.part(model) }}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ knp_pagination_render(parts) }}
|
{{ knp_pagination_render(models) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -1,90 +0,0 @@
|
|||||||
{% extends 'base.html.twig' %}
|
|
||||||
|
|
||||||
{% import 'macro/part.html.twig' as macro %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<dl>
|
|
||||||
<dt>number:</dt><dd>{{ part.number }}</dd>
|
|
||||||
<dt>name:</dt><dd>{{ part.name }}</dd>
|
|
||||||
<dt>category:</dt><dd>{{ part.category.name }}</dd>
|
|
||||||
<dt>type:</dt><dd>{{ part.type.name }}</dd>
|
|
||||||
<dt>model:</dt><dd>{{ part.model ? part.model.number }}</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
{% for keyword in part.keywords %}
|
|
||||||
<span class="ui label">{{ keyword.name }}</span>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="display: flex; flex-wrap: wrap">
|
|
||||||
{% if apiPart is not null %}
|
|
||||||
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block">
|
|
||||||
<img src="{{ apiPart.imgUrl }}" style="max-height: 90%; max-width: 100%">
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if part is defined and part is not null %}
|
|
||||||
<div id="model" style="height: 300px; width: 300px; padding: 5px; display: inline-block"></div>
|
|
||||||
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block">
|
|
||||||
<img src="{{ url('part_image', {number:part.number}) }}" style="max-height: 90%; max-width: 100%">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2 style="width: 100%">alias of</h2>
|
|
||||||
{% if part.aliasOf is not null %}
|
|
||||||
{{ macro.part(part.aliasOf) }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<h2 style="width: 100%">aliases</h2>
|
|
||||||
{% for alias in part.aliases %}
|
|
||||||
{{ macro.part(alias) }}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
<h2 style="width: 100%">subparts</h2>
|
|
||||||
{% for subpart in part.subparts %}
|
|
||||||
{{ macro.part(subpart) }}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
<h2 style="width: 100%">subpart of</h2>
|
|
||||||
{% for subpart in part.subpartOf %}
|
|
||||||
{{ macro.part(subpart) }}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% if part.printOf is not null %}
|
|
||||||
<h2 style="width: 100%">print of</h2>
|
|
||||||
{{ macro.part(part.printOf) }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if part.prints is not empty %}
|
|
||||||
<h2 style="width: 100%">prints</h2>
|
|
||||||
{% for print in part.prints %}
|
|
||||||
{{ macro.part(print) }}
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
<h2 style="width: 100%">in sets</h2>
|
|
||||||
{% for set in sets %}
|
|
||||||
<span style="margin: 5px"><a href="{{ url('set_detail', {number:set.number}) }}">{{ set.number }}</a></span>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{ dump(rbPart) }}
|
|
||||||
{{ dump(apiPart) }}
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block javascripts %}
|
|
||||||
{{ parent() }}
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
window.onload = function() {
|
|
||||||
modelView = new ModelViewer();
|
|
||||||
var scene = modelView.initScene($('#model'));
|
|
||||||
{% if part is defined and part is not null and part.model is not null %}
|
|
||||||
modelView.loadStl('{{ path('model_stl', {'id' : part.model.number })}}');
|
|
||||||
{% endif %}
|
|
||||||
modelView.render();
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
@ -1,6 +0,0 @@
|
|||||||
{% macro part(part) %}
|
|
||||||
<div style="height: 100px; width: 100px; padding: 5px; display: inline-block;">
|
|
||||||
<img src="{{ url('part_image', {number:part.number}) }}" style="max-height: 90%; max-width: 100%;">
|
|
||||||
<p><a href="{{ url('ldraw_part_show', {number:part.number}) }}">{{ part.number }}</a></p>
|
|
||||||
</div>
|
|
||||||
{% endmacro %}
|
|
34
app/Resources/views/macros/elements.html.twig
Normal file
34
app/Resources/views/macros/elements.html.twig
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{% macro part(model) %}
|
||||||
|
<div style="height: 100px; width: 100px; padding: 5px; display: inline-block;">
|
||||||
|
<img src="{{ url('model_image', {'number': model.number }) }}" style="max-height: 90%; max-width: 100%;">
|
||||||
|
<p><a href="{{ url('model_detail', {'number': model.number}) }}">{{ model.number }}</a></p>
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro flash(type,message) %}
|
||||||
|
{% if type == 'error' %}
|
||||||
|
{% set icon = 'ban' %}
|
||||||
|
{% set title = 'flash.error.title' %}
|
||||||
|
{% elseif type == 'warning' %}
|
||||||
|
{% set icon = 'warning' %}
|
||||||
|
{% set title = 'flash.warning.title' %}
|
||||||
|
{% elseif type == 'success' %}
|
||||||
|
{% set icon = 'check' %}
|
||||||
|
{% set title = 'flash.success.title' %}
|
||||||
|
{% elseif type == 'info' %}
|
||||||
|
{% set icon = 'info' %}
|
||||||
|
{% set title = 'flash.info.title' %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
<div class="ui icon {{ type ? type : '' }} message">
|
||||||
|
<i class="{{ icon }} icon"></i>
|
||||||
|
<i class="close icon"></i>
|
||||||
|
<div class="content">
|
||||||
|
<div class="header">
|
||||||
|
{{ title|trans }}
|
||||||
|
</div>
|
||||||
|
<p>{{ message|trans }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
28
app/Resources/views/rebrickable/color/index.html.twig
Normal file
28
app/Resources/views/rebrickable/color/index.html.twig
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<table class="ui celled padded table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>RGB</th>
|
||||||
|
<th>Material</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for color in colors %}
|
||||||
|
<tr>
|
||||||
|
<td style="background-color: #{{ color.rgb }}"></td>
|
||||||
|
<td>{{ color.id }}</td>
|
||||||
|
<td>{{ color.name }}</td>
|
||||||
|
<td>#{{ color.rgb }}</td>
|
||||||
|
<td>{{ color.transparent ? 'Transparent' : 'Solid' }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{% endblock %}
|
37
app/Resources/views/rebrickable/part/show.html.twig
Normal file
37
app/Resources/views/rebrickable/part/show.html.twig
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% import 'macros/elements.html.twig' as elements %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<dl>
|
||||||
|
<dt>number:</dt><dd>{{ part.number }}</dd>
|
||||||
|
<dt>name:</dt><dd>{{ part.name }}</dd>
|
||||||
|
<dt>category:</dt><dd>{{ part.category ? part.category.name }}</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<div style="display: flex; flex-wrap: wrap">
|
||||||
|
{% if apiPart is not null %}
|
||||||
|
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block">
|
||||||
|
<img src="{{ apiPart.imgUrl }}" style="max-height: 90%; max-width: 100%">
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block">
|
||||||
|
<img src="{{ url('model_image', {number:part.number}) }}" style="max-height: 90%; max-width: 100%">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if part.model %}
|
||||||
|
{{ elements.part(part.model) }}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h4 class="ui horizontal divider header">
|
||||||
|
<i class="puzzle icon"></i> Sets
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
{% for set in sets %}
|
||||||
|
<span style="margin: 5px"><a href="{{ url('set_detail', {number:set.number}) }}">{{ set.number }}</a></span>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{{ dump(apiPart) }}
|
||||||
|
|
||||||
|
{% endblock %}
|
52
app/Resources/views/rebrickable/set/detail.html.twig
Normal file
52
app/Resources/views/rebrickable/set/detail.html.twig
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{{ dump(set) }}
|
||||||
|
|
||||||
|
{{ brset ? dump(brset) }}
|
||||||
|
|
||||||
|
{#<h1>{{brset ? brset.name }}</h1>#}
|
||||||
|
{#<img src="{{brset ? brset.imageURL }}">#}
|
||||||
|
|
||||||
|
{% if set is not null %}
|
||||||
|
<h4 class="ui horizontal divider header">
|
||||||
|
<i class="cubes icon"></i> Parts {{ inventoryParts|length }}
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<div class="ui eight column grid">
|
||||||
|
{% for inventoryPart in inventoryParts %}
|
||||||
|
<div class="column">
|
||||||
|
<div class="ui fluid image {{ inventoryPart.part.model == null ? 'active dimmer'}}" style="height: 150px;">
|
||||||
|
<a class="ui right red circular label">{{ inventoryPart.quantity }}</a>
|
||||||
|
<a href="{{ path('rebrickable_part_show', {number: inventoryPart.part.number}) }}">
|
||||||
|
<img src="https://rebrickable.com/media/parts/ldraw/{{inventoryPart.color ? inventoryPart.color.id }}/{{ inventoryPart.part.number }}.png">
|
||||||
|
<div style="border-bottom: #{{ inventoryPart.color.rgb }} 2px solid" class="ui bottom attached label">{{ inventoryPart.part.number }}</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
<div>
|
||||||
|
|
||||||
|
|
||||||
|
<h4 class="ui horizontal divider header">
|
||||||
|
<i class="cubes icon"></i> Models {{ parts|length }}
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<div class="ui eight column grid">
|
||||||
|
{% for part in parts %}
|
||||||
|
<div class="column">
|
||||||
|
<div class="ui fluid image">
|
||||||
|
<a href="{{ path('model_detail', {number: part.number}) }}">
|
||||||
|
<img src="https://rebrickable.com/media/parts/ldraw/-1/{{ part.number }}.png">
|
||||||
|
<div class="ui bottom attached label">{{ part.number }}</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
<div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endblock %}
|
21
app/Resources/views/rebrickable/set/index.html.twig
Normal file
21
app/Resources/views/rebrickable/set/index.html.twig
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="ui seven column grid">
|
||||||
|
<div class="row">
|
||||||
|
{% for set in sets %}
|
||||||
|
<div class="column">
|
||||||
|
<a href="{{ url('set_detail', {'number': set.number, 'name' : set.name|escape('url') }) }}">
|
||||||
|
|
||||||
|
{#<img style="width: 100%" src="{{ set }}">#}
|
||||||
|
<p>{{ set.number }} - {{ set.name }}</p>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>{{ sets.getTotalItemCount }}</p>
|
||||||
|
|
||||||
|
{{ knp_pagination_render(sets) }}
|
||||||
|
{% endblock %}
|
@ -1,27 +0,0 @@
|
|||||||
{% extends 'base.html.twig' %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
{{ dump(set) }}
|
|
||||||
{{ dump(brset) }}
|
|
||||||
|
|
||||||
<h1>{{brset ? brset.name }}</h1>
|
|
||||||
<img src="{{brset ? brset.imageURL }}">
|
|
||||||
|
|
||||||
{% if set is not null %}
|
|
||||||
{#{% for inventory in set.inventories %}#}
|
|
||||||
<h2>Parts</h2>
|
|
||||||
<div style="display: flex; flex-wrap: wrap">
|
|
||||||
{% for inventoryPart in inventoryParts %}
|
|
||||||
<div style="height: 150px; width: 150px; padding: 5px; display: inline-block">
|
|
||||||
<img src="https://rebrickable.com/media/parts/ldraw/{{inventoryPart ? inventoryPart.color.id }}/{{ inventoryPart.part.number }}.png" style="max-height: 90%; max-width: 100%">
|
|
||||||
<p><a style="color: #{{ inventoryPart.color.rgb }}" href="{{ url('ldraw_part_show', {number:inventoryPart.part.number}) }}"><strong>{{ inventoryPart.part.number }}</strong> {{ inventoryPart.quantity }}</a></p>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
<div>
|
|
||||||
{#{% else %}#}
|
|
||||||
|
|
||||||
{#{% endfor %}#}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% endblock %}
|
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace AppBundle\Controller;
|
namespace AppBundle\Controller\Rebrickable;
|
||||||
|
|
||||||
use AppBundle\Entity\Rebrickable\Color;
|
use AppBundle\Entity\Rebrickable\Color;
|
||||||
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
||||||
@ -13,7 +13,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/sets")
|
* @Route("/brickset")
|
||||||
*/
|
*/
|
||||||
class SetController extends Controller
|
class SetController extends Controller
|
||||||
{
|
{
|
||||||
@ -30,39 +30,16 @@ class SetController extends Controller
|
|||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
$data = $form->getData();
|
$data = $form->getData();
|
||||||
|
|
||||||
$sets = $this->get('client.brickset')->getSets([
|
$sets = $this->get('api.client.brickset')->getSets([
|
||||||
'theme' => $data['theme'] ? $data['theme']->getTheme() : '',
|
'theme' => $data['theme'] ? $data['theme']->getTheme() : '',
|
||||||
'subtheme' => $data['subtheme'] ? $data['subtheme']->getSubtheme() : '',
|
'subtheme' => $data['subtheme'] ? $data['subtheme']->getSubtheme() : '',
|
||||||
'year' => $data['years'] ? $data['years']->getYear() : '',
|
'year' => $data['years'] ? $data['years']->getYear() : '',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('set/browse.html.twig', [
|
return $this->render('brickset/browse.html.twig', [
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
'sets' => $sets,
|
'sets' => $sets,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/detail/{number}_{name}", name="set_detail")
|
|
||||||
*/
|
|
||||||
public function detailAction(Request $request, $number, $name = null)
|
|
||||||
{
|
|
||||||
$brset = $this->get('manager.brickset')->getSetByNumber($number);
|
|
||||||
|
|
||||||
$set = $this->get('doctrine.orm.default_entity_manager')->getRepository(Set::class)->find($number);
|
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
$em->getRepository(Color::class)->findAll();
|
|
||||||
|
|
||||||
$em->getRepository(Theme::class)->findAll();
|
|
||||||
|
|
||||||
return $this->render('set/detail.html.twig', [
|
|
||||||
'set' => $set,
|
|
||||||
'brset' => $brset,
|
|
||||||
'parts' => $em->getRepository(Part::class)->findAllBySetNumber($number),
|
|
||||||
'inventoryParts' => $em->getRepository(Inventory_Part::class)->findAllBySetNumber($number),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
namespace AppBundle\Controller\LDraw;
|
namespace AppBundle\Controller\LDraw;
|
||||||
|
|
||||||
use AppBundle\Entity\LDraw\Part;
|
use AppBundle\Entity\LDraw\Model;
|
||||||
|
use AppBundle\Entity\Rebrickable\Part;
|
||||||
use AppBundle\Entity\Rebrickable\Set;
|
use AppBundle\Entity\Rebrickable\Set;
|
||||||
use AppBundle\Form\Filter\PartFilterType;
|
use AppBundle\Form\Filter\ModelFilterType;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
@ -13,26 +14,24 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
/**
|
/**
|
||||||
* Part controller.
|
* Part controller.
|
||||||
*
|
*
|
||||||
* @Route("ldraw_part")
|
* @Route("ldraw")
|
||||||
*/
|
*/
|
||||||
class PartController extends Controller
|
class ModelController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Lists all part entities.
|
* Lists all part entities.
|
||||||
*
|
*
|
||||||
* @Route("/", name="ldraw_part_index")
|
* @Route("/models/", name="ldraw_model_index")
|
||||||
* @Method("GET")
|
* @Method("GET")
|
||||||
*/
|
*/
|
||||||
public function indexAction(Request $request)
|
public function indexAction(Request $request)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$form = $this->get('form.factory')->create(PartFilterType::class);
|
$form = $this->get('form.factory')->create(ModelFilterType::class);
|
||||||
|
|
||||||
$filterBuilder = $this->get('repository.ldraw.part')
|
$filterBuilder = $this->get('repository.ldraw.model')
|
||||||
->createQueryBuilder('part');
|
->createQueryBuilder('model');
|
||||||
|
|
||||||
// $filterBuilder->where('part.type = 1');
|
|
||||||
|
|
||||||
if ($request->query->has($form->getName())) {
|
if ($request->query->has($form->getName())) {
|
||||||
// manually bind values from the request
|
// manually bind values from the request
|
||||||
@ -43,14 +42,14 @@ class PartController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$paginator = $this->get('knp_paginator');
|
$paginator = $this->get('knp_paginator');
|
||||||
$parts = $paginator->paginate(
|
$models = $paginator->paginate(
|
||||||
$filterBuilder->getQuery(),
|
$filterBuilder->getQuery(),
|
||||||
$request->query->getInt('page', 1)/*page number*/,
|
$request->query->getInt('page', 1)/*page number*/,
|
||||||
$request->query->getInt('limit', 100)/*limit per page*/
|
$request->query->getInt('limit', 100)/*limit per page*/
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->render('ldraw/part/index.html.twig', [
|
return $this->render('ldraw/model/index.html.twig', [
|
||||||
'parts' => $parts,
|
'models' => $models,
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -58,31 +57,29 @@ class PartController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Finds and displays a part entity.
|
* Finds and displays a part entity.
|
||||||
*
|
*
|
||||||
* @Route("/{number}", name="ldraw_part_show")
|
* @Route("/models/{number}", name="model_detail")
|
||||||
* @Method("GET")
|
* @Method("GET")
|
||||||
*/
|
*/
|
||||||
public function showAction($number)
|
public function detailAction($number)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$rbPart = $em->getRepository(\AppBundle\Entity\Rebrickable\Part::class)->find($number);
|
if($model = $this->get('manager.ldraw.model')->findByNumber($number)) {
|
||||||
|
try {
|
||||||
|
$rbParts = $model != null ? $em->getRepository(Part::class)->findAllByModel($model) : null;
|
||||||
|
$sets = $model != null ? $em->getRepository(Set::class)->findAllByModel($model) : null;
|
||||||
|
|
||||||
$part = $em->getRepository(Part::class)->find($number);
|
return $this->render('ldraw/model/detail.html.twig', [
|
||||||
|
'model' => $model,
|
||||||
|
'rbParts' => $rbParts,
|
||||||
|
'sets' => $sets,
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->addFlash('error', $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
$apiPart = null;
|
|
||||||
try {
|
|
||||||
$apiPart = $this->get('manager.rebrickable')->getPart($number);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
dump($e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$sets = $em->getRepository(Set::class)->findAllByPartNumber($number);
|
return $this->render('error/error.html.twig');
|
||||||
|
|
||||||
return $this->render('ldraw/part/show.html.twig', [
|
|
||||||
'part' => $part,
|
|
||||||
'rbPart' => $rbPart,
|
|
||||||
'apiPart' => $apiPart,
|
|
||||||
'sets' => $sets,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,7 +3,6 @@
|
|||||||
namespace AppBundle\Controller;
|
namespace AppBundle\Controller;
|
||||||
|
|
||||||
use AppBundle\Entity\LDraw\Model;
|
use AppBundle\Entity\LDraw\Model;
|
||||||
use AppBundle\Entity\LDraw\Part;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||||
@ -17,16 +16,16 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||||||
class MediaController extends Controller
|
class MediaController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Route("/model/{id}", name="model_stl")
|
* @Route("/model/stl/{number}", name="model_stl")
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function modelAction(Model $model)
|
public function stlAction(Model $model)
|
||||||
{
|
{
|
||||||
$mediaFilesystem = $this->get('oneup_flysystem.media_filesystem');
|
$mediaFilesystem = $this->get('oneup_flysystem.media_filesystem');
|
||||||
|
|
||||||
if ($mediaFilesystem->has($model->getFile())) {
|
if ($mediaFilesystem->has($model->getPath())) {
|
||||||
$response = new BinaryFileResponse($mediaFilesystem->getAdapter()->getPathPrefix().DIRECTORY_SEPARATOR.$model->getFile());
|
$response = new BinaryFileResponse($mediaFilesystem->getAdapter()->getPathPrefix().DIRECTORY_SEPARATOR.$model->getPath());
|
||||||
$response->headers->set('Content-Type', 'application/vnd.ms-pki.stl');
|
$response->headers->set('Content-Type', 'application/vnd.ms-pki.stl');
|
||||||
|
|
||||||
// Create the disposition of the file
|
// Create the disposition of the file
|
||||||
@ -39,32 +38,32 @@ class MediaController extends Controller
|
|||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
throw new FileNotFoundException($model->getFile());
|
throw new FileNotFoundException($model->getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/part/{number}", name="part_image")
|
* @Route("/model/image/{number}", name="model_image")
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function PartImageAction(Part $part)
|
public function imageAction(Model $model)
|
||||||
{
|
{
|
||||||
$mediaFilesystem = $this->get('oneup_flysystem.media_filesystem');
|
$mediaFilesystem = $this->get('oneup_flysystem.media_filesystem');
|
||||||
|
|
||||||
if ($mediaFilesystem->has('ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$part->getNumber().'.png')) {
|
if ($mediaFilesystem->has('ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$model->getNumber().'.png')) {
|
||||||
$response = new BinaryFileResponse($mediaFilesystem->getAdapter()->getPathPrefix().DIRECTORY_SEPARATOR.'ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$part->getNumber().'.png');
|
$response = new BinaryFileResponse($mediaFilesystem->getAdapter()->getPathPrefix().DIRECTORY_SEPARATOR.'ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$model->getNumber().'.png');
|
||||||
$response->headers->set('Content-Type', 'image/png');
|
$response->headers->set('Content-Type', 'image/png');
|
||||||
|
|
||||||
// Create the disposition of the file
|
// Create the disposition of the file
|
||||||
$disposition = $response->headers->makeDisposition(
|
$disposition = $response->headers->makeDisposition(
|
||||||
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
|
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
|
||||||
$part->getNumber().'png'
|
$model->getNumber().'png'
|
||||||
);
|
);
|
||||||
|
|
||||||
$response->headers->set('Content-Disposition', $disposition);
|
$response->headers->set('Content-Disposition', $disposition);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
throw new FileNotFoundException($part->getNumber().'png');
|
throw new FileNotFoundException($model->getNumber().'png');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
29
src/AppBundle/Controller/Rebrickable/ColorController.php
Normal file
29
src/AppBundle/Controller/Rebrickable/ColorController.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AppBundle\Controller\Rebrickable;
|
||||||
|
|
||||||
|
use AppBundle\Entity\Rebrickable\Color;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Part controller.
|
||||||
|
*
|
||||||
|
* @Route("rebrickable/colors")
|
||||||
|
*/
|
||||||
|
class ColorController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @Route("/", name="color_index")
|
||||||
|
*/
|
||||||
|
public function indexAction() {
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
$colors = $em->getRepository(Color::class)->findAll();
|
||||||
|
|
||||||
|
return $this->render('rebrickable/color/index.html.twig', [
|
||||||
|
'colors' => $colors,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
51
src/AppBundle/Controller/Rebrickable/PartController.php
Normal file
51
src/AppBundle/Controller/Rebrickable/PartController.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AppBundle\Controller\Rebrickable;
|
||||||
|
|
||||||
|
use AppBundle\Api\Exception\EmptyResponseException;
|
||||||
|
use AppBundle\Entity\Rebrickable\Part;
|
||||||
|
use AppBundle\Entity\Rebrickable\Set;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Part controller.
|
||||||
|
*
|
||||||
|
* @Route("rebrickable/parts")
|
||||||
|
*/
|
||||||
|
class PartController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Finds and displays a part entity.
|
||||||
|
*
|
||||||
|
* @Route("/{number}", name="rebrickable_part_show")
|
||||||
|
* @Method("GET")
|
||||||
|
*/
|
||||||
|
public function showAction(Part $part = null)
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
$apiPart = null;
|
||||||
|
|
||||||
|
if($part) {
|
||||||
|
try {
|
||||||
|
$apiPart = $this->get('api.manager.rebrickable')->getPart($part->getNumber());
|
||||||
|
} catch (EmptyResponseException $e) {
|
||||||
|
$this->addFlash('warning', 'Part not found');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->addFlash('error', $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
$sets = $part != null ? $em->getRepository(Set::class)->findAllByPartNumber($part->getNumber()) : null;
|
||||||
|
|
||||||
|
return $this->render('rebrickable/part/show.html.twig', [
|
||||||
|
'part' => $part,
|
||||||
|
'apiPart' => $apiPart,
|
||||||
|
'sets' => $sets,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('error/error.html.twig');
|
||||||
|
}
|
||||||
|
}
|
106
src/AppBundle/Controller/Rebrickable/SetController.php
Normal file
106
src/AppBundle/Controller/Rebrickable/SetController.php
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AppBundle\Controller\Rebrickable;
|
||||||
|
|
||||||
|
use AppBundle\Api\Exception\EmptyResponseException;
|
||||||
|
use AppBundle\Entity\LDraw\Model;
|
||||||
|
use AppBundle\Entity\Rebrickable\Color;
|
||||||
|
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
||||||
|
use AppBundle\Entity\Rebrickable\Part;
|
||||||
|
use AppBundle\Entity\Rebrickable\Set;
|
||||||
|
use AppBundle\Entity\Rebrickable\Theme;
|
||||||
|
use AppBundle\Form\FilterSetType;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/rebrickable/sets")
|
||||||
|
*/
|
||||||
|
class SetController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Route("/", name="set_index")
|
||||||
|
*/
|
||||||
|
public function indexAction(Request $request)
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
$qb = $em->getRepository(Set::class)->createQueryBuilder('s');
|
||||||
|
|
||||||
|
$paginator = $this->get('knp_paginator');
|
||||||
|
$sets = $paginator->paginate(
|
||||||
|
$qb->getQuery(),
|
||||||
|
$request->query->getInt('page', 1)/*page number*/,
|
||||||
|
$request->query->getInt('limit', 30)/*limit per page*/
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->render('rebrickable/set/index.html.twig', [
|
||||||
|
'sets' => $sets,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/detail/{number}_{name}", name="set_detail")
|
||||||
|
*/
|
||||||
|
public function detailAction(Request $request, $number, $name = null)
|
||||||
|
{
|
||||||
|
$brset = null;
|
||||||
|
try {
|
||||||
|
$brset = $this->get('api.manager.brickset')->getSetByNumber($number);
|
||||||
|
} catch (EmptyResponseException $e) {
|
||||||
|
$this->addFlash('warning', 'Set not found in Brickset database');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->addFlash('error', $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
$set = $this->getDoctrine()->getManager()->getRepository(Set::class)->find($number);
|
||||||
|
|
||||||
|
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$em->getRepository(Color::class)->findAll();
|
||||||
|
$em->getRepository(Theme::class)->findAll();
|
||||||
|
|
||||||
|
return $this->render('rebrickable/set/detail.html.twig', [
|
||||||
|
'set' => $set,
|
||||||
|
'brset' => $brset,
|
||||||
|
'parts' => $em->getRepository(Model::class)->findAllBySetNumber($number),
|
||||||
|
'inventoryParts' => $em->getRepository(Inventory_Part::class)->findAllBySetNumber($number),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/download/{number}", name="set_download")
|
||||||
|
*/
|
||||||
|
public function downloadZipAction(Request $request, $number) {
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
$inventoryParts = $em->getRepository(Inventory_Part::class)->findAllBySetNumber($number);
|
||||||
|
|
||||||
|
$zip = new \ZipArchive();
|
||||||
|
$zipName = 'set_'.$number.'.zip';
|
||||||
|
$zip->open($zipName, \ZipArchive::CREATE);
|
||||||
|
/** @var Inventory_Part $part */
|
||||||
|
foreach ($inventoryParts as $part) {
|
||||||
|
$filename = $part->getPart()->getNumber().'_('.$part->getColor()->getName().'_'.$part->getQuantity().'x).stl';
|
||||||
|
|
||||||
|
try {
|
||||||
|
if($part->getPart()->getModel()) {
|
||||||
|
$zip->addFromString($filename, $this->get('oneup_flysystem.media_filesystem')->read($part->getPart()->getModel()->getPath()));
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
dump($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$zip->close();
|
||||||
|
|
||||||
|
$response = new Response(file_get_contents($zipName));
|
||||||
|
$response->headers->set('Content-Type', 'application/zip');
|
||||||
|
$response->headers->set('Content-Disposition', 'attachment;filename="' . $zipName . '"');
|
||||||
|
$response->headers->set('Content-length', filesize($zipName));
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
@ -10,12 +10,12 @@ use Symfony\Component\Form\AbstractType;
|
|||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class PartFilterType extends AbstractType
|
class ModelFilterType extends AbstractType
|
||||||
{
|
{
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$builder->add('search', Filters\TextFilterType::class, [
|
$builder->add('search', Filters\TextFilterType::class, [
|
||||||
'apply_filter' => [$this, 'partSearchCallback'],
|
'apply_filter' => [$this, 'modelSearchCallback'],
|
||||||
'label' => 'filter.part.search',
|
'label' => 'filter.part.search',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ class PartFilterType extends AbstractType
|
|||||||
|
|
||||||
public function getBlockPrefix()
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'part_filter';
|
return 'model_filter';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
@ -41,7 +41,7 @@ class PartFilterType extends AbstractType
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function partSearchCallback(QueryInterface $filterQuery, $field, $values)
|
public function modelSearchCallback(QueryInterface $filterQuery, $field, $values)
|
||||||
{
|
{
|
||||||
if (empty($values['value'])) {
|
if (empty($values['value'])) {
|
||||||
return null;
|
return null;
|
||||||
@ -49,8 +49,9 @@ class PartFilterType extends AbstractType
|
|||||||
|
|
||||||
// expression that represent the condition
|
// expression that represent the condition
|
||||||
$expression = $filterQuery->getExpr()->orX(
|
$expression = $filterQuery->getExpr()->orX(
|
||||||
$filterQuery->getExpr()->like('part.number', ':value'),
|
$filterQuery->getExpr()->like('model.number', ':value'),
|
||||||
$filterQuery->getExpr()->like('part.name', ':value')
|
$filterQuery->getExpr()->like('model.name', ':value')
|
||||||
|
//TODO filter by keywords
|
||||||
);
|
);
|
||||||
|
|
||||||
return $filterQuery->createCondition($expression, ['value' => '%'.$values['value'].'%']);
|
return $filterQuery->createCondition($expression, ['value' => '%'.$values['value'].'%']);
|
@ -34,12 +34,16 @@ class Builder
|
|||||||
'route' => 'homepage',
|
'route' => 'homepage',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$menu->addChild('Parts', [
|
$menu->addChild('Models', [
|
||||||
'route' => 'ldraw_part_index',
|
'route' => 'ldraw_model_index',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$menu->addChild('Sets', [
|
$menu->addChild('Sets', [
|
||||||
'route' => 'set_browse',
|
'route' => 'set_index',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$menu->addChild('Colors', [
|
||||||
|
'route' => 'color_index',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $menu;
|
return $menu;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user