mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-16 20:30:09 -07:00
WIP
This commit is contained in:
parent
f226447a36
commit
f79d63be1b
@ -19,7 +19,9 @@ class AppKernel extends Kernel
|
|||||||
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
|
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
|
||||||
new Oneup\FlysystemBundle\OneupFlysystemBundle(),
|
new Oneup\FlysystemBundle\OneupFlysystemBundle(),
|
||||||
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
|
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
|
||||||
|
new Knp\Bundle\GaufretteBundle\KnpGaufretteBundle(),
|
||||||
new Lexik\Bundle\FormFilterBundle\LexikFormFilterBundle(),
|
new Lexik\Bundle\FormFilterBundle\LexikFormFilterBundle(),
|
||||||
|
new Liip\ImagineBundle\LiipImagineBundle(),
|
||||||
];
|
];
|
||||||
|
|
||||||
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
|
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
@import "variables";
|
@import "variables";
|
||||||
|
|
||||||
@import "main";
|
@import "main";
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
<dt>number:</dt><dd>{{ model.number }}</dd>
|
<dt>number:</dt><dd>{{ model.number }}</dd>
|
||||||
<dt>name:</dt><dd>{{ model.name }}</dd>
|
<dt>name:</dt><dd>{{ model.name }}</dd>
|
||||||
<dt>category:</dt><dd>{{ model.category ? model.category.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>model:</dt><dd>{{ model.path }}</dd>
|
||||||
<dt>author:</dt><dd>{{ model.author }}</dd>
|
<dt>author:</dt><dd>{{ model.author }}</dd>
|
||||||
<dt>keywords:</dt>
|
<dt>keywords:</dt>
|
||||||
@ -24,7 +23,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</dd>
|
</dd>
|
||||||
<dd>Download:</dd>
|
<dd>Download:</dd>
|
||||||
<dt><a href="{{ path('model_stl', {'number' : model.number })}}">{{ model.number }}</a></dt>
|
<dt><a href="{{ url('media_file', {'path': model.path}) }}">{{ model.number }}</a></dt>
|
||||||
<dt>rebrickable parts ({{ rbParts|length }}):</dt>
|
<dt>rebrickable parts ({{ rbParts|length }}):</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p>
|
<p>
|
||||||
@ -42,7 +41,7 @@
|
|||||||
<div style="display: flex; flex-wrap: wrap">
|
<div style="display: flex; flex-wrap: wrap">
|
||||||
<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>
|
||||||
<div style="height: 300px; width: 300px; padding: 5px; display: inline-block">
|
<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%">
|
<img src="{{ url('media_file', {'path': 'ldraw/images/'~model.number~'.png'}) }}" style="max-height: 90%; max-width: 100%">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h4 class="ui horizontal divider header">
|
<h4 class="ui horizontal divider header">
|
||||||
@ -78,7 +77,7 @@
|
|||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
modelView = new ModelViewer();
|
modelView = new ModelViewer();
|
||||||
var scene = modelView.initScene($('#model'));
|
var scene = modelView.initScene($('#model'));
|
||||||
modelView.loadStl('{{ path('model_stl', {'number' : model.number })}}');
|
modelView.loadStl('{{ url('media_file', {'path': model.path }) }}');
|
||||||
modelView.render();
|
modelView.render();
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{% macro part(model) %}
|
{% macro part(model) %}
|
||||||
<div style="height: 100px; width: 100px; padding: 5px; display: inline-block;">
|
<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%;">
|
<img src="{{ url('media_file', {'path': 'ldraw/images/'~model.number~'.png'}) }}" style="max-height: 90%; max-width: 100%">
|
||||||
<p><a href="{{ url('model_detail', {'number': model.number}) }}">{{ model.number }}</a></p>
|
<p><a href="{{ url('model_detail', {'number': model.number}) }}">{{ model.number }}</a></p>
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
|
||||||
use Composer\Autoload\ClassLoader;
|
use Composer\Autoload\ClassLoader;
|
||||||
|
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||||
|
|
||||||
/** @var ClassLoader $loader */
|
/** @var ClassLoader $loader */
|
||||||
$loader = require __DIR__.'/../vendor/autoload.php';
|
$loader = require __DIR__.'/../vendor/autoload.php';
|
||||||
|
@ -92,11 +92,26 @@ knp_paginator:
|
|||||||
pagination: KnpPaginatorBundle:Pagination:semantic_ui_pagination.html.twig # sliding pagination controls template
|
pagination: KnpPaginatorBundle:Pagination:semantic_ui_pagination.html.twig # sliding pagination controls template
|
||||||
sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig # sort link template
|
sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig # sort link template
|
||||||
|
|
||||||
|
#liip_imagine:
|
||||||
|
# filter_sets:
|
||||||
|
# cache: ~
|
||||||
|
# square_thumb:
|
||||||
|
### cache: my_remote_resolver
|
||||||
|
# data_loader: remote.loader
|
||||||
|
## quality: 75
|
||||||
|
## filters:
|
||||||
|
## thumbnail: { size: [150, 150], mode: outbound }
|
||||||
|
|
||||||
oneup_flysystem:
|
oneup_flysystem:
|
||||||
adapters:
|
adapters:
|
||||||
media_adapter:
|
media_adapter:
|
||||||
local:
|
local:
|
||||||
directory: "%kernel.root_dir%/../var/media/"
|
directory: "%kernel.root_dir%/../var/media/"
|
||||||
|
ldraw_library_adapter:
|
||||||
|
local:
|
||||||
|
directory: "%ldraw_library%"
|
||||||
filesystems:
|
filesystems:
|
||||||
media:
|
media:
|
||||||
adapter: media_adapter
|
adapter: media_adapter
|
||||||
|
ldraw_library:
|
||||||
|
adapter: ldraw_library_adapter
|
@ -26,3 +26,6 @@ parameters:
|
|||||||
|
|
||||||
# Absolute path to OSMesa port of LDView
|
# Absolute path to OSMesa port of LDView
|
||||||
ldview_bin: /usr/bin/ldview
|
ldview_bin: /usr/bin/ldview
|
||||||
|
|
||||||
|
# Path to LDraw library
|
||||||
|
ldraw_library: ~
|
@ -1,3 +1,5 @@
|
|||||||
app:
|
app:
|
||||||
resource: "@AppBundle/Controller/"
|
resource: "@AppBundle/Controller/"
|
||||||
type: annotation
|
type: annotation
|
||||||
|
_liip_imagine:
|
||||||
|
resource: "@LiipImagineBundle/Resources/config/routing.xml"
|
@ -7,7 +7,7 @@ services:
|
|||||||
|
|
||||||
service.ldview:
|
service.ldview:
|
||||||
class: AppBundle\Service\LDViewService
|
class: AppBundle\Service\LDViewService
|
||||||
arguments: ['%ldview_bin%', '@oneup_flysystem.media_filesystem']
|
arguments: ['%ldview_bin%', '@oneup_flysystem.media_filesystem', '@oneup_flysystem.ldraw_library_filesystem']
|
||||||
|
|
||||||
service.loader.rebrickable:
|
service.loader.rebrickable:
|
||||||
class: AppBundle\Service\Loader\RebrickableLoaderService
|
class: AppBundle\Service\Loader\RebrickableLoaderService
|
||||||
@ -20,7 +20,7 @@ services:
|
|||||||
|
|
||||||
service.loader.ldraw:
|
service.loader.ldraw:
|
||||||
class: AppBundle\Service\Loader\LDrawLoaderService
|
class: AppBundle\Service\Loader\LDrawLoaderService
|
||||||
arguments: ['@service.ldview', '%ldraw_url%', '@manager.ldraw', '@util.dat.parser']
|
arguments: ['@oneup_flysystem.ldraw_library_filesystem','@service.ldview', '%ldraw_url%', '@manager.ldraw', '@util.dat.parser']
|
||||||
parent: service.loader
|
parent: service.loader
|
||||||
|
|
||||||
service.loader.relation:
|
service.loader.relation:
|
||||||
|
@ -7,10 +7,6 @@ services:
|
|||||||
class: AppBundle\Manager\LDraw\CategoryManager
|
class: AppBundle\Manager\LDraw\CategoryManager
|
||||||
arguments:
|
arguments:
|
||||||
- "@repository.ldraw.category"
|
- "@repository.ldraw.category"
|
||||||
manager.ldraw.type:
|
|
||||||
class: AppBundle\Manager\LDraw\TypeManager
|
|
||||||
arguments:
|
|
||||||
- "@repository.ldraw.type"
|
|
||||||
manager.ldraw.subpart:
|
manager.ldraw.subpart:
|
||||||
class: AppBundle\Manager\LDraw\SubpartManager
|
class: AppBundle\Manager\LDraw\SubpartManager
|
||||||
arguments:
|
arguments:
|
||||||
|
@ -4,7 +4,6 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
- '@manager.ldraw.category'
|
- '@manager.ldraw.category'
|
||||||
- '@manager.ldraw.keyword'
|
- '@manager.ldraw.keyword'
|
||||||
- '@manager.ldraw.type'
|
|
||||||
- '@manager.ldraw.subpart'
|
- '@manager.ldraw.subpart'
|
||||||
- '@manager.ldraw.model'
|
- '@manager.ldraw.model'
|
||||||
- '@manager.ldraw.alias'
|
- '@manager.ldraw.alias'
|
||||||
@ -15,7 +14,21 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: form.type }
|
- { name: form.type }
|
||||||
|
|
||||||
|
app.twig_extension:
|
||||||
|
class: AppBundle\Twig\AppExtension
|
||||||
|
public: false
|
||||||
|
arguments: ['api.@manager.rebrickable']
|
||||||
|
tags:
|
||||||
|
- { name: twig.extension }
|
||||||
|
|
||||||
app.relation.mapper:
|
app.relation.mapper:
|
||||||
class: AppBundle\Utils\RelationMapper
|
class: AppBundle\Utils\RelationMapper
|
||||||
arguments:
|
arguments:
|
||||||
- ['%kernel.root_dir%/Resources/relations']
|
- ['%kernel.root_dir%/Resources/relations']
|
||||||
|
|
||||||
|
imagine.data.loader.remote:
|
||||||
|
class: AppBundle\Imagine\Loader\RemoteStreamLoader
|
||||||
|
arguments:
|
||||||
|
- 'http://rebrickable.com/media/'
|
||||||
|
tags:
|
||||||
|
- { name: "liip_imagine.remote.steram.loader", loader: remote.loader }
|
@ -26,7 +26,9 @@
|
|||||||
"knplabs/knp-menu-bundle": "^2.0",
|
"knplabs/knp-menu-bundle": "^2.0",
|
||||||
"oneup/flysystem-bundle": "^1.7",
|
"oneup/flysystem-bundle": "^1.7",
|
||||||
"knplabs/knp-paginator-bundle": "^2.5",
|
"knplabs/knp-paginator-bundle": "^2.5",
|
||||||
"lexik/form-filter-bundle": "~5.0"
|
"knplabs/knp-gaufrette-bundle": "~0.3",
|
||||||
|
"lexik/form-filter-bundle": "~5.0",
|
||||||
|
"liip/imagine-bundle": "^1.7"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"sensio/generator-bundle": "^3.0",
|
"sensio/generator-bundle": "^3.0",
|
||||||
|
331
composer.lock
generated
331
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "6956e65252fd75b8d2e258fcc54fa3a9",
|
"content-hash": "fcff1b4aff59fb1710a57c91e6a04a6c",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "doctrine/annotations",
|
"name": "doctrine/annotations",
|
||||||
@ -952,6 +952,63 @@
|
|||||||
],
|
],
|
||||||
"time": "2017-03-20T17:10:46+00:00"
|
"time": "2017-03-20T17:10:46+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "imagine/imagine",
|
||||||
|
"version": "v0.6.3",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/avalanche123/Imagine.git",
|
||||||
|
"reference": "149041d2a1b517107bfe270ca2b1a17aa341715d"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/avalanche123/Imagine/zipball/149041d2a1b517107bfe270ca2b1a17aa341715d",
|
||||||
|
"reference": "149041d2a1b517107bfe270ca2b1a17aa341715d",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"sami/sami": "dev-master"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-gd": "to use the GD implementation",
|
||||||
|
"ext-gmagick": "to use the Gmagick implementation",
|
||||||
|
"ext-imagick": "to use the Imagick implementation"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-develop": "0.7-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-0": {
|
||||||
|
"Imagine": "lib/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Bulat Shakirzyanov",
|
||||||
|
"email": "mallluhuct@gmail.com",
|
||||||
|
"homepage": "http://avalanche123.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Image processing for PHP 5.3",
|
||||||
|
"homepage": "http://imagine.readthedocs.org/",
|
||||||
|
"keywords": [
|
||||||
|
"drawing",
|
||||||
|
"graphics",
|
||||||
|
"image manipulation",
|
||||||
|
"image processing"
|
||||||
|
],
|
||||||
|
"time": "2015-09-19T16:54:05+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "incenteev/composer-parameter-handler",
|
"name": "incenteev/composer-parameter-handler",
|
||||||
"version": "v2.1.2",
|
"version": "v2.1.2",
|
||||||
@ -1053,6 +1110,94 @@
|
|||||||
],
|
],
|
||||||
"time": "2014-01-12T16:20:24+00:00"
|
"time": "2014-01-12T16:20:24+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "knplabs/gaufrette",
|
||||||
|
"version": "v0.3.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/KnpLabs/Gaufrette.git",
|
||||||
|
"reference": "771ad16f4b2e7f9d35f44b201956e83c6fbf5dde"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/KnpLabs/Gaufrette/zipball/771ad16f4b2e7f9d35f44b201956e83c6fbf5dde",
|
||||||
|
"reference": "771ad16f4b2e7f9d35f44b201956e83c6fbf5dde",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.4"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"microsoft/windowsazure": "<0.4.3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"amazonwebservices/aws-sdk-for-php": "1.5.*",
|
||||||
|
"aws/aws-sdk-php": "^2.4.12",
|
||||||
|
"doctrine/dbal": ">=2.3",
|
||||||
|
"dropbox-php/dropbox-php": "*",
|
||||||
|
"google/apiclient": "~1.1.3",
|
||||||
|
"herzult/php-ssh": "*",
|
||||||
|
"league/flysystem": "~1.0",
|
||||||
|
"mikey179/vfsstream": "~1.2.0",
|
||||||
|
"phpseclib/phpseclib": "^2.0",
|
||||||
|
"phpspec/phpspec": "~2.4",
|
||||||
|
"phpunit/phpunit": "3.7.*",
|
||||||
|
"rackspace/php-opencloud": "^1.9.2"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"amazonwebservices/aws-sdk-for-php": "to use the legacy Amazon S3 adapters",
|
||||||
|
"aws/aws-sdk-php": "to use the Amazon S3 adapter",
|
||||||
|
"doctrine/dbal": "to use the Doctrine DBAL adapter",
|
||||||
|
"dropbox-php/dropbox-php": "to use the Dropbox adapter",
|
||||||
|
"ext-apc": "to use the APC adapter",
|
||||||
|
"ext-curl": "*",
|
||||||
|
"ext-fileinfo": "This extension is used to automatically detect the content-type of a file in the AwsS3, OpenCloud, AzureBlogStorage and GoogleCloudStorage adapters",
|
||||||
|
"ext-mbstring": "*",
|
||||||
|
"ext-mongo": "*",
|
||||||
|
"ext-zip": "to use the Zip adapter",
|
||||||
|
"google/apiclient": "to use GoogleCloudStorage adapter",
|
||||||
|
"herzult/php-ssh": "to use SFtp adapter",
|
||||||
|
"knplabs/knp-gaufrette-bundle": "to use with Symfony2",
|
||||||
|
"league/flysystem": "to use Flysystem adapters",
|
||||||
|
"microsoft/windowsazure": "to use Microsoft Azure Blob Storage adapter",
|
||||||
|
"phpseclib/phpseclib": "to use PhpseclibSftp adapter",
|
||||||
|
"rackspace/php-opencloud": "to use Opencloud adapter"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "0.4.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-0": {
|
||||||
|
"Gaufrette": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "The contributors",
|
||||||
|
"homepage": "http://github.com/knplabs/Gaufrette/contributors"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "KnpLabs Team",
|
||||||
|
"homepage": "http://knplabs.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP5 library that provides a filesystem abstraction layer",
|
||||||
|
"homepage": "http://knplabs.com",
|
||||||
|
"keywords": [
|
||||||
|
"abstraction",
|
||||||
|
"file",
|
||||||
|
"filesystem",
|
||||||
|
"media"
|
||||||
|
],
|
||||||
|
"time": "2017-03-20T01:23:34+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "knplabs/knp-components",
|
"name": "knplabs/knp-components",
|
||||||
"version": "1.3.4",
|
"version": "1.3.4",
|
||||||
@ -1124,6 +1269,64 @@
|
|||||||
],
|
],
|
||||||
"time": "2016-12-06T18:10:24+00:00"
|
"time": "2016-12-06T18:10:24+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "knplabs/knp-gaufrette-bundle",
|
||||||
|
"version": "v0.4.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/KnpLabs/KnpGaufretteBundle.git",
|
||||||
|
"reference": "06d91a8a575773cd0361c1246c9c499b6bdd5d68"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/KnpLabs/KnpGaufretteBundle/zipball/06d91a8a575773cd0361c1246c9c499b6bdd5d68",
|
||||||
|
"reference": "06d91a8a575773cd0361c1246c9c499b6bdd5d68",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"knplabs/gaufrette": "~0.1.7|~0.2|~0.3",
|
||||||
|
"symfony/framework-bundle": "~2.0|~3.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "~4.2",
|
||||||
|
"symfony/console": "~2.0|~3.0",
|
||||||
|
"symfony/yaml": "~2.0|~3.0"
|
||||||
|
},
|
||||||
|
"type": "symfony-bundle",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "0.4.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Knp\\Bundle\\GaufretteBundle\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "The contributors",
|
||||||
|
"homepage": "https://github.com/knplabs/KnpGaufretteBundle/contributors"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Antoine Hérault",
|
||||||
|
"email": "antoine.herault@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Allows to easily use the Gaufrette library in a Symfony project",
|
||||||
|
"homepage": "http://knplabs.com",
|
||||||
|
"keywords": [
|
||||||
|
"abstraction",
|
||||||
|
"file",
|
||||||
|
"filesystem",
|
||||||
|
"media"
|
||||||
|
],
|
||||||
|
"time": "2017-03-16T21:01:25+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "knplabs/knp-menu",
|
"name": "knplabs/knp-menu",
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
@ -1394,16 +1597,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "lexik/form-filter-bundle",
|
"name": "lexik/form-filter-bundle",
|
||||||
"version": "v5.0.3",
|
"version": "v5.0.4",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/lexik/LexikFormFilterBundle.git",
|
"url": "https://github.com/lexik/LexikFormFilterBundle.git",
|
||||||
"reference": "124a6c8e9eb109e7616a18d916bbc33137bb308d"
|
"reference": "28c09d6d9f278875ca9648c4b66eeb457c37d3b6"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/lexik/LexikFormFilterBundle/zipball/124a6c8e9eb109e7616a18d916bbc33137bb308d",
|
"url": "https://api.github.com/repos/lexik/LexikFormFilterBundle/zipball/28c09d6d9f278875ca9648c4b66eeb457c37d3b6",
|
||||||
"reference": "124a6c8e9eb109e7616a18d916bbc33137bb308d",
|
"reference": "28c09d6d9f278875ca9648c4b66eeb457c37d3b6",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1444,13 +1647,113 @@
|
|||||||
"description": "This bundle aim to provide classes to build some form filters and then build a doctrine query from this form filter.",
|
"description": "This bundle aim to provide classes to build some form filters and then build a doctrine query from this form filter.",
|
||||||
"homepage": "https://github.com/lexik/LexikFormFilterBundle",
|
"homepage": "https://github.com/lexik/LexikFormFilterBundle",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Symfony2",
|
|
||||||
"bundle",
|
"bundle",
|
||||||
"doctrine",
|
"doctrine",
|
||||||
"filter",
|
"filter",
|
||||||
"form"
|
"form",
|
||||||
|
"symfony"
|
||||||
],
|
],
|
||||||
"time": "2017-01-24T13:03:45+00:00"
|
"time": "2017-03-27T07:28:34+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "liip/imagine-bundle",
|
||||||
|
"version": "1.7.4",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/liip/LiipImagineBundle.git",
|
||||||
|
"reference": "105dd9c3446e3eb44e33161d4e636a3abafb6d7f"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/liip/LiipImagineBundle/zipball/105dd9c3446e3eb44e33161d4e636a3abafb6d7f",
|
||||||
|
"reference": "105dd9c3446e3eb44e33161d4e636a3abafb6d7f",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"imagine/imagine": "^0.6.3,<0.7",
|
||||||
|
"php": "^5.3.9|^7.0",
|
||||||
|
"symfony/asset": "~2.3|~3.0",
|
||||||
|
"symfony/filesystem": "~2.3|~3.0",
|
||||||
|
"symfony/finder": "~2.3|~3.0",
|
||||||
|
"symfony/framework-bundle": "~2.3|~3.0",
|
||||||
|
"symfony/options-resolver": "~2.3|~3.0",
|
||||||
|
"symfony/process": "~2.3|~3.0",
|
||||||
|
"symfony/templating": "~2.3|~3.0",
|
||||||
|
"symfony/translation": "~2.3|~3.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"amazonwebservices/aws-sdk-for-php": "~1.0",
|
||||||
|
"aws/aws-sdk-php": "~2.4",
|
||||||
|
"doctrine/cache": "~1.1",
|
||||||
|
"doctrine/orm": "~2.3",
|
||||||
|
"ext-gd": "*",
|
||||||
|
"friendsofphp/php-cs-fixer": "~2.0",
|
||||||
|
"phpunit/phpunit": "~4.3|~5.0",
|
||||||
|
"psr/log": "~1.0",
|
||||||
|
"satooshi/php-coveralls": "~1.0",
|
||||||
|
"sllh/php-cs-fixer-styleci-bridge": "~2.1",
|
||||||
|
"symfony/browser-kit": "~2.3|~3.0",
|
||||||
|
"symfony/console": "~2.3|~3.0",
|
||||||
|
"symfony/dependency-injection": "~2.3|~3.0",
|
||||||
|
"symfony/form": "~2.3|~3.0",
|
||||||
|
"symfony/phpunit-bridge": "~2.3|~3.0",
|
||||||
|
"symfony/validator": "~2.3|~3.0",
|
||||||
|
"symfony/yaml": "~2.3|~3.0",
|
||||||
|
"twig/twig": "~1.12|~2.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"alcaeus/mongo-php-adapter": "required on PHP >= 7.0 to use mongo components with mongodb extension",
|
||||||
|
"amazonwebservices/aws-sdk-for-php": "required to use AWS version 1 cache resolver",
|
||||||
|
"aws/aws-sdk-php": "required to use AWS version 2/3 cache resolver",
|
||||||
|
"doctrine/mongodb-odm": "required to use mongodb-backed doctrine components",
|
||||||
|
"ext-exif": "required to read EXIF metadata from images",
|
||||||
|
"ext-gd": "required to use gd driver",
|
||||||
|
"ext-gmagick": "required to use gmagick driver",
|
||||||
|
"ext-imagick": "required to use imagick driver",
|
||||||
|
"ext-mongo": "required for mongodb components on PHP <7.0",
|
||||||
|
"ext-mongodb": "required for mongodb components on PHP >=7.0",
|
||||||
|
"league/flysystem": "required to use FlySystem data loader or cache resolver",
|
||||||
|
"monolog/monolog": "A psr/log compatible logger is required to enable logging",
|
||||||
|
"twig/twig": "required to use the provided Twig extension. Version 1.12 or greater needed"
|
||||||
|
},
|
||||||
|
"type": "symfony-bundle",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-1.0": "1.7-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Liip\\ImagineBundle\\": ""
|
||||||
|
},
|
||||||
|
"exclude-from-classmap": [
|
||||||
|
"/Tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Liip and other contributors",
|
||||||
|
"homepage": "https://github.com/liip/LiipImagineBundle/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "This bundle provides an image manipulation abstraction toolkit for Symfony-based projects.",
|
||||||
|
"homepage": "http://liip.ch",
|
||||||
|
"keywords": [
|
||||||
|
"bundle",
|
||||||
|
"image",
|
||||||
|
"imagine",
|
||||||
|
"liip",
|
||||||
|
"manipulation",
|
||||||
|
"photos",
|
||||||
|
"pictures",
|
||||||
|
"symfony",
|
||||||
|
"transformation"
|
||||||
|
],
|
||||||
|
"time": "2017-03-02T20:18:55+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "monolog/monolog",
|
"name": "monolog/monolog",
|
||||||
@ -1532,16 +1835,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "oneup/flysystem-bundle",
|
"name": "oneup/flysystem-bundle",
|
||||||
"version": "1.11.0",
|
"version": "1.12.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/1up-lab/OneupFlysystemBundle.git",
|
"url": "https://github.com/1up-lab/OneupFlysystemBundle.git",
|
||||||
"reference": "a68f83415e3af2313c529be6b22bfddfcfe8e90f"
|
"reference": "2addd1077360790a7722fef09388a003576d585c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/1up-lab/OneupFlysystemBundle/zipball/a68f83415e3af2313c529be6b22bfddfcfe8e90f",
|
"url": "https://api.github.com/repos/1up-lab/OneupFlysystemBundle/zipball/2addd1077360790a7722fef09388a003576d585c",
|
||||||
"reference": "a68f83415e3af2313c529be6b22bfddfcfe8e90f",
|
"reference": "2addd1077360790a7722fef09388a003576d585c",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1562,6 +1865,7 @@
|
|||||||
"league/flysystem-ziparchive": "~1.0",
|
"league/flysystem-ziparchive": "~1.0",
|
||||||
"litipk/flysystem-fallback-adapter": "~0.1",
|
"litipk/flysystem-fallback-adapter": "~0.1",
|
||||||
"phpunit/phpunit": "^4.4",
|
"phpunit/phpunit": "^4.4",
|
||||||
|
"superbalist/flysystem-google-storage": "~4.0",
|
||||||
"symfony/asset": "~2.0|~3.0",
|
"symfony/asset": "~2.0|~3.0",
|
||||||
"symfony/browser-kit": "~2.0|~3.0",
|
"symfony/browser-kit": "~2.0|~3.0",
|
||||||
"symfony/finder": "~2.0|~3.0",
|
"symfony/finder": "~2.0|~3.0",
|
||||||
@ -1583,6 +1887,7 @@
|
|||||||
"league/flysystem-webdav": "Allows you to use WebDAV storage",
|
"league/flysystem-webdav": "Allows you to use WebDAV storage",
|
||||||
"league/flysystem-ziparchive": "Allows you to use ZipArchive adapter",
|
"league/flysystem-ziparchive": "Allows you to use ZipArchive adapter",
|
||||||
"litipk/flysystem-fallback-adapter": "Allows you to use a fallback filesystem",
|
"litipk/flysystem-fallback-adapter": "Allows you to use a fallback filesystem",
|
||||||
|
"superbalist/flysystem-google-storage": "Allows you to use Google Cloud Storage buckets",
|
||||||
"twistor/flysystem-stream-wrapper": "Allows you to use stream wrapper"
|
"twistor/flysystem-stream-wrapper": "Allows you to use stream wrapper"
|
||||||
},
|
},
|
||||||
"type": "symfony-bundle",
|
"type": "symfony-bundle",
|
||||||
@ -1611,7 +1916,7 @@
|
|||||||
"abstraction",
|
"abstraction",
|
||||||
"filesystem"
|
"filesystem"
|
||||||
],
|
],
|
||||||
"time": "2017-03-03T13:41:53+00:00"
|
"time": "2017-03-27T08:48:46+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "paragonie/random_compat",
|
"name": "paragonie/random_compat",
|
||||||
|
@ -15,7 +15,7 @@ class LoadLDRawLibraryCommand extends ContainerAwareCommand
|
|||||||
->setName('app:load:ldraw')
|
->setName('app:load:ldraw')
|
||||||
->setDescription('Loads LDraw library parts')
|
->setDescription('Loads LDraw library parts')
|
||||||
->setHelp('This command allows you to..')
|
->setHelp('This command allows you to..')
|
||||||
->addArgument('ldraw_path', InputArgument::OPTIONAL, 'Path to LDraw library folder');
|
->addArgument('file', InputArgument::OPTIONAL, 'Model to load');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
@ -27,11 +27,11 @@ class LoadLDRawLibraryCommand extends ContainerAwareCommand
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO handle relative path to dir
|
// TODO handle relative path to dir
|
||||||
if (($ldrawPath = $input->getArgument('ldraw_path')) == null) {
|
if (($ldrawPath = $input->getArgument('file')) != null) {
|
||||||
$ldrawPath = $ldrawLoader->downloadLibrary();
|
$ldrawPath = $ldrawLoader->loadModel($ldrawPath);
|
||||||
|
} else {
|
||||||
|
$ldrawLoader->loadAllModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
$ldrawLoader->loadData($ldrawPath);
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
printf($e->getMessage());
|
printf($e->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
|||||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
|
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
|
||||||
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,54 +17,28 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||||||
class MediaController extends Controller
|
class MediaController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Route("/model/stl/{number}", name="model_stl")
|
* @Route("/{path}", name="media_file", requirements={"path"=".+"})
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function stlAction(Model $model)
|
public function stlAction($path)
|
||||||
{
|
{
|
||||||
$mediaFilesystem = $this->get('oneup_flysystem.media_filesystem');
|
$mediaFilesystem = $this->get('oneup_flysystem.media_filesystem');
|
||||||
|
|
||||||
if ($mediaFilesystem->has($model->getPath())) {
|
if ($mediaFilesystem->has($path)) {
|
||||||
$response = new BinaryFileResponse($mediaFilesystem->getAdapter()->getPathPrefix().DIRECTORY_SEPARATOR.$model->getPath());
|
$response = new BinaryFileResponse($mediaFilesystem->getAdapter()->getPathPrefix().DIRECTORY_SEPARATOR.$path);
|
||||||
$response->headers->set('Content-Type', 'application/vnd.ms-pki.stl');
|
$response->headers->set('Content-Type', $mediaFilesystem->getMimetype($path));
|
||||||
|
|
||||||
// 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,
|
||||||
$model->getNumber().'.stl'
|
basename($path)
|
||||||
);
|
);
|
||||||
|
|
||||||
$response->headers->set('Content-Disposition', $disposition);
|
$response->headers->set('Content-Disposition', $disposition);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
throw new FileNotFoundException($model->getPath());
|
throw new FileNotFoundException($path);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/model/image/{number}", name="model_image")
|
|
||||||
*
|
|
||||||
* @return Response
|
|
||||||
*/
|
|
||||||
public function imageAction(Model $model)
|
|
||||||
{
|
|
||||||
$mediaFilesystem = $this->get('oneup_flysystem.media_filesystem');
|
|
||||||
|
|
||||||
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.$model->getNumber().'.png');
|
|
||||||
$response->headers->set('Content-Type', 'image/png');
|
|
||||||
|
|
||||||
// Create the disposition of the file
|
|
||||||
$disposition = $response->headers->makeDisposition(
|
|
||||||
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
|
|
||||||
$model->getNumber().'png'
|
|
||||||
);
|
|
||||||
|
|
||||||
$response->headers->set('Content-Disposition', $disposition);
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
throw new FileNotFoundException($model->getNumber().'png');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,6 @@ class Model
|
|||||||
{
|
{
|
||||||
use NumberTrait;
|
use NumberTrait;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Type
|
|
||||||
*
|
|
||||||
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\LDraw\Type", inversedBy="models", cascade={"persist"})
|
|
||||||
*/
|
|
||||||
private $type;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
@ -163,22 +156,6 @@ class Model
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getType()
|
|
||||||
{
|
|
||||||
return $this->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $type
|
|
||||||
*/
|
|
||||||
public function setType($type)
|
|
||||||
{
|
|
||||||
$this->type = $type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -1,91 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace AppBundle\Entity\LDraw;
|
|
||||||
|
|
||||||
use AppBundle\Entity\Traits\IdentityTrait;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type.
|
|
||||||
*
|
|
||||||
* @ORM\Table(name="ldraw_type")
|
|
||||||
* @ORM\Entity(repositoryClass="AppBundle\Repository\LDraw\TypeRepository")
|
|
||||||
*/
|
|
||||||
class Type
|
|
||||||
{
|
|
||||||
use IdentityTrait;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*
|
|
||||||
* @ORM\Column(type="string", length=60, unique=true)
|
|
||||||
*/
|
|
||||||
private $name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Collection
|
|
||||||
*
|
|
||||||
* @ORM\OneToMany(targetEntity="Model", mappedBy="type")
|
|
||||||
*/
|
|
||||||
private $models;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BuildingKit constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->models = new ArrayCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
return $this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $name
|
|
||||||
*/
|
|
||||||
public function setName($name)
|
|
||||||
{
|
|
||||||
$this->name = $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get models.
|
|
||||||
*
|
|
||||||
* @return ArrayCollection
|
|
||||||
*/
|
|
||||||
public function getModels()
|
|
||||||
{
|
|
||||||
return $this->models;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Model $model
|
|
||||||
*
|
|
||||||
* @return Type
|
|
||||||
*/
|
|
||||||
public function addModel(Model $model)
|
|
||||||
{
|
|
||||||
$this->models->add($model);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Model $model
|
|
||||||
*
|
|
||||||
* @return Type
|
|
||||||
*/
|
|
||||||
public function removeModel(Model $model)
|
|
||||||
{
|
|
||||||
$this->models->remove($model);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
15
src/AppBundle/Exception/FileNotFoundException.php
Normal file
15
src/AppBundle/Exception/FileNotFoundException.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: hubnedav
|
||||||
|
* Date: 4/6/17
|
||||||
|
* Time: 2:31 PM
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace AppBundle\Exception;
|
||||||
|
|
||||||
|
|
||||||
|
class FileNotFoundException extends \Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
22
src/AppBundle/Imagine/Loader/RemoteStreamLoader.php
Normal file
22
src/AppBundle/Imagine/Loader/RemoteStreamLoader.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AppBundle\Imagine\Loader;
|
||||||
|
|
||||||
|
use Liip\ImagineBundle\Binary\Loader\StreamLoader;
|
||||||
|
|
||||||
|
class RemoteStreamLoader extends StreamLoader
|
||||||
|
{
|
||||||
|
public function __construct($wrapperPrefix, $context = null)
|
||||||
|
{
|
||||||
|
dump($wrapperPrefix);
|
||||||
|
|
||||||
|
parent::__construct($wrapperPrefix, $context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function find($path)
|
||||||
|
{
|
||||||
|
dump($path);
|
||||||
|
|
||||||
|
return parent::find($path); // TODO: Change the autogenerated stub
|
||||||
|
}
|
||||||
|
}
|
@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace AppBundle\Manager\LDraw;
|
|
||||||
|
|
||||||
use AppBundle\Entity\LDraw\Type;
|
|
||||||
use AppBundle\Manager\BaseManager;
|
|
||||||
use AppBundle\Repository\LDraw\TypeRepository;
|
|
||||||
|
|
||||||
class TypeManager extends BaseManager
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* TypeManager constructor.
|
|
||||||
*
|
|
||||||
* @param TypeRepository $typeRepository
|
|
||||||
*/
|
|
||||||
public function __construct(TypeRepository $repository)
|
|
||||||
{
|
|
||||||
$this->repository = $repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create new Keyword entity with $name or retrieve one.
|
|
||||||
*
|
|
||||||
* @param $name
|
|
||||||
*
|
|
||||||
* @return Type
|
|
||||||
*/
|
|
||||||
public function create($name)
|
|
||||||
{
|
|
||||||
if (($type = $this->repository->findByName($name)) == null) {
|
|
||||||
$type = new Type();
|
|
||||||
$type->setName($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $type;
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,9 +17,6 @@ class LDrawManager
|
|||||||
/** @var KeywordManager */
|
/** @var KeywordManager */
|
||||||
private $keywordManager;
|
private $keywordManager;
|
||||||
|
|
||||||
/** @var TypeManager */
|
|
||||||
private $typeManager;
|
|
||||||
|
|
||||||
/** @var SubpartManager */
|
/** @var SubpartManager */
|
||||||
private $subpartManager;
|
private $subpartManager;
|
||||||
|
|
||||||
@ -34,16 +31,14 @@ class LDrawManager
|
|||||||
*
|
*
|
||||||
* @param CategoryManager $categoryManager
|
* @param CategoryManager $categoryManager
|
||||||
* @param KeywordManager $keywordManager
|
* @param KeywordManager $keywordManager
|
||||||
* @param TypeManager $typeManager
|
|
||||||
* @param SubpartManager $subpartManager
|
* @param SubpartManager $subpartManager
|
||||||
* @param ModelManager $modelManager
|
* @param ModelManager $modelManager
|
||||||
* @param AliasManager $aliasManager
|
* @param AliasManager $aliasManager
|
||||||
*/
|
*/
|
||||||
public function __construct(CategoryManager $categoryManager, KeywordManager $keywordManager, TypeManager $typeManager, SubpartManager $subpartManager, ModelManager $modelManager, AliasManager $aliasManager)
|
public function __construct(CategoryManager $categoryManager, KeywordManager $keywordManager, SubpartManager $subpartManager, ModelManager $modelManager, AliasManager $aliasManager)
|
||||||
{
|
{
|
||||||
$this->categoryManager = $categoryManager;
|
$this->categoryManager = $categoryManager;
|
||||||
$this->keywordManager = $keywordManager;
|
$this->keywordManager = $keywordManager;
|
||||||
$this->typeManager = $typeManager;
|
|
||||||
$this->subpartManager = $subpartManager;
|
$this->subpartManager = $subpartManager;
|
||||||
$this->modelManager = $modelManager;
|
$this->modelManager = $modelManager;
|
||||||
$this->aliasManager = $aliasManager;
|
$this->aliasManager = $aliasManager;
|
||||||
@ -65,14 +60,6 @@ class LDrawManager
|
|||||||
return $this->keywordManager;
|
return $this->keywordManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return TypeManager
|
|
||||||
*/
|
|
||||||
public function getTypeManager()
|
|
||||||
{
|
|
||||||
return $this->typeManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return SubpartManager
|
* @return SubpartManager
|
||||||
*/
|
*/
|
||||||
|
18
src/AppBundle/Manager/RebrickableManager.php
Normal file
18
src/AppBundle/Manager/RebrickableManager.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: hubnedav
|
||||||
|
* Date: 4/1/17
|
||||||
|
* Time: 2:40 AM.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace AppBundle\Manager;
|
||||||
|
|
||||||
|
use AppBundle\Entity\Rebrickable\Set;
|
||||||
|
|
||||||
|
class RebrickableManager extends BaseManager
|
||||||
|
{
|
||||||
|
public function findInventoryParts(Set $set)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace AppBundle\Repository\LDraw;
|
|
||||||
|
|
||||||
use AppBundle\Repository\BaseRepository;
|
|
||||||
|
|
||||||
class PartRepository extends BaseRepository
|
|
||||||
{
|
|
||||||
}
|
|
@ -5,6 +5,7 @@ namespace AppBundle\Service;
|
|||||||
use League\Flysystem\File;
|
use League\Flysystem\File;
|
||||||
use League\Flysystem\Filesystem;
|
use League\Flysystem\Filesystem;
|
||||||
use Symfony\Component\Asset\Exception\LogicException;
|
use Symfony\Component\Asset\Exception\LogicException;
|
||||||
|
use Symfony\Component\Finder\Finder;
|
||||||
use Symfony\Component\Process\ProcessBuilder;
|
use Symfony\Component\Process\ProcessBuilder;
|
||||||
|
|
||||||
//TODO enable file overwrite
|
//TODO enable file overwrite
|
||||||
@ -23,26 +24,28 @@ class LDViewService
|
|||||||
/**
|
/**
|
||||||
* @var Filesystem
|
* @var Filesystem
|
||||||
*/
|
*/
|
||||||
private $ldrawFilesystem;
|
private $ldrawLibraryFilesystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LDViewService constructor.
|
* LDViewService constructor.
|
||||||
*
|
*
|
||||||
* @param string $ldview Path to LDView OSMesa binary file
|
* @param string $ldview Path to LDView OSMesa binary file
|
||||||
* @param Filesystem $mediaFilesystem Filesystem for generated web assets
|
* @param Filesystem $mediaFilesystem Filesystem for generated web assets
|
||||||
|
* @param Filesystem $ldrawLibraryFilesystem Filesystem with ldraw source files library
|
||||||
*/
|
*/
|
||||||
public function __construct($ldview, $mediaFilesystem)
|
public function __construct($ldview, $mediaFilesystem, $ldrawLibraryFilesystem)
|
||||||
{
|
{
|
||||||
$this->ldview = $ldview;
|
$this->ldview = $ldview;
|
||||||
$this->mediaFilesystem = $mediaFilesystem;
|
$this->mediaFilesystem = $mediaFilesystem;
|
||||||
|
$this->ldrawLibraryFilesystem = $ldrawLibraryFilesystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Filesystem $ldrawFilesystem
|
* @param Filesystem $ldrawFilesystem
|
||||||
*/
|
*/
|
||||||
public function setLdrawFilesystem($ldrawFilesystem)
|
public function setLdrawFilesystem($ldrawLibraryFilesystem)
|
||||||
{
|
{
|
||||||
$this->ldrawFilesystem = $ldrawFilesystem;
|
$this->ldrawLibraryFilesystem = $ldrawLibraryFilesystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,18 +56,18 @@ class LDViewService
|
|||||||
*
|
*
|
||||||
* @return File
|
* @return File
|
||||||
*/
|
*/
|
||||||
public function datToStl($file, $LDrawDir = null)
|
public function datToStl($file)
|
||||||
{
|
{
|
||||||
if (!$this->mediaFilesystem->has('ldraw'.DIRECTORY_SEPARATOR.'models')) {
|
if (!$this->mediaFilesystem->has('ldraw'.DIRECTORY_SEPARATOR.'models')) {
|
||||||
$this->mediaFilesystem->createDir('ldraw'.DIRECTORY_SEPARATOR.'models');
|
$this->mediaFilesystem->createDir('ldraw'.DIRECTORY_SEPARATOR.'models');
|
||||||
}
|
}
|
||||||
|
|
||||||
$newFile = 'ldraw'.DIRECTORY_SEPARATOR.'models'.DIRECTORY_SEPARATOR.$file['filename'].'.stl';
|
$newFile = 'ldraw'.DIRECTORY_SEPARATOR.'models'.DIRECTORY_SEPARATOR.basename($file,'.dat').'.stl';
|
||||||
|
|
||||||
if (!$this->mediaFilesystem->has($newFile)) {
|
if (!file_exists($newFile)) {
|
||||||
$this->runLDView([
|
$this->runLDView([
|
||||||
$this->ldrawFilesystem->getAdapter()->getPathPrefix().$file['path'],
|
$file,
|
||||||
'-LDrawDir='.$this->ldrawFilesystem->getAdapter()->getPathPrefix(),
|
'-LDrawDir='.$this->ldrawLibraryFilesystem->getAdapter()->getPathPrefix(),
|
||||||
'-ExportFiles=1',
|
'-ExportFiles=1',
|
||||||
'-ExportSuffix=.stl',
|
'-ExportSuffix=.stl',
|
||||||
'-ExportsDir='.$this->mediaFilesystem->getAdapter()->getPathPrefix().'ldraw'.DIRECTORY_SEPARATOR.'models',
|
'-ExportsDir='.$this->mediaFilesystem->getAdapter()->getPathPrefix().'ldraw'.DIRECTORY_SEPARATOR.'models',
|
||||||
@ -87,18 +90,18 @@ class LDViewService
|
|||||||
*
|
*
|
||||||
* @return File
|
* @return File
|
||||||
*/
|
*/
|
||||||
public function datToPng($file, $LDrawDir = null)
|
public function datToPng($file)
|
||||||
{
|
{
|
||||||
if (!$this->mediaFilesystem->has('ldraw'.DIRECTORY_SEPARATOR.'images')) {
|
if (!$this->mediaFilesystem->has('ldraw'.DIRECTORY_SEPARATOR.'images')) {
|
||||||
$this->mediaFilesystem->createDir('ldraw'.DIRECTORY_SEPARATOR.'images');
|
$this->mediaFilesystem->createDir('ldraw'.DIRECTORY_SEPARATOR.'images');
|
||||||
}
|
}
|
||||||
|
|
||||||
$newFile = 'ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$file['filename'].'.png';
|
$newFile = 'ldraw'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.basename($file,'.dat').'.png';
|
||||||
|
|
||||||
if (!$this->mediaFilesystem->has($newFile)) {
|
if (!$this->mediaFilesystem->has($newFile)) {
|
||||||
$this->runLDView([
|
$this->runLDView([
|
||||||
$this->ldrawFilesystem->getAdapter()->getPathPrefix().$file['path'],
|
$file,
|
||||||
'-LDrawDir='.$this->ldrawFilesystem->getAdapter()->getPathPrefix(),
|
'-LDrawDir='.$this->ldrawLibraryFilesystem->getAdapter()->getPathPrefix(),
|
||||||
'-AutoCrop=1',
|
'-AutoCrop=1',
|
||||||
'-SaveAlpha=0',
|
'-SaveAlpha=0',
|
||||||
'-SnapshotSuffix=.png',
|
'-SnapshotSuffix=.png',
|
||||||
|
@ -5,8 +5,8 @@ namespace AppBundle\Service\Loader;
|
|||||||
use AppBundle\Entity\LDraw\Category;
|
use AppBundle\Entity\LDraw\Category;
|
||||||
use AppBundle\Entity\LDraw\Model;
|
use AppBundle\Entity\LDraw\Model;
|
||||||
use AppBundle\Entity\LDraw\Type;
|
use AppBundle\Entity\LDraw\Type;
|
||||||
|
use AppBundle\Exception\FileNotFoundException;
|
||||||
use AppBundle\Manager\LDrawManager;
|
use AppBundle\Manager\LDrawManager;
|
||||||
use AppBundle\Service\LDrawService;
|
|
||||||
use AppBundle\Service\LDViewService;
|
use AppBundle\Service\LDViewService;
|
||||||
use AppBundle\Utils\DatParser;
|
use AppBundle\Utils\DatParser;
|
||||||
use League\Flysystem\Adapter\Local;
|
use League\Flysystem\Adapter\Local;
|
||||||
@ -22,7 +22,7 @@ class LDrawLoaderService extends BaseLoaderService
|
|||||||
/**
|
/**
|
||||||
* @var Filesystem
|
* @var Filesystem
|
||||||
*/
|
*/
|
||||||
private $ldraw;
|
private $ldrawLibraryFilesystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string download URL with current LDraw library
|
* @var string download URL with current LDraw library
|
||||||
@ -41,67 +41,35 @@ class LDrawLoaderService extends BaseLoaderService
|
|||||||
private $datParser;
|
private $datParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $ldraw_url
|
* LDrawLoaderService constructor.
|
||||||
|
* @param Filesystem $ldrawLibraryFilesystem
|
||||||
|
* @param LDViewService $LDViewService
|
||||||
|
* @param $ldraw_url
|
||||||
|
* @param LDrawManager $ldrawService
|
||||||
|
* @param DatParser $datParser
|
||||||
*/
|
*/
|
||||||
public function __construct(LDViewService $LDViewService, $ldraw_url, LDrawManager $ldrawService, $datParser)
|
public function __construct($ldrawLibraryFilesystem, $LDViewService, $ldraw_url, $ldrawService, $datParser)
|
||||||
{
|
{
|
||||||
$this->LDViewService = $LDViewService;
|
$this->LDViewService = $LDViewService;
|
||||||
$this->ldraw_url = $ldraw_url;
|
$this->ldraw_url = $ldraw_url;
|
||||||
$this->ldrawService = $ldrawService;
|
$this->ldrawService = $ldrawService;
|
||||||
$this->datParser = $datParser;
|
$this->datParser = $datParser;
|
||||||
|
$this->ldrawLibraryFilesystem = $ldrawLibraryFilesystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function loadAllModels()
|
||||||
* Download current LDraw library and extract it to system tmp directory.
|
|
||||||
*
|
|
||||||
* @return string Absolute path to temporary Ldraw library
|
|
||||||
*/
|
|
||||||
public function downloadLibrary()
|
|
||||||
{
|
{
|
||||||
$temp = $this->downloadFile($this->ldraw_url);
|
$files = $this->ldrawLibraryFilesystem->get('parts')->getContents();
|
||||||
|
$modelManager = $this->ldrawService->getModelManager();
|
||||||
// Create unique temporary directory
|
|
||||||
$temp_dir = tempnam(sys_get_temp_dir(), 'printabrick.');
|
|
||||||
mkdir($temp_dir);
|
|
||||||
|
|
||||||
// Unzip downloaded library zip file to temporary directory
|
|
||||||
$zip = new \ZipArchive();
|
|
||||||
if ($zip->open($temp) != 'true') {
|
|
||||||
throw new LogicException('Error :- Unable to open the Zip File');
|
|
||||||
}
|
|
||||||
$zip->extractTo($temp_dir);
|
|
||||||
$zip->close();
|
|
||||||
|
|
||||||
// Unlink downloaded zip file
|
|
||||||
unlink($temp);
|
|
||||||
|
|
||||||
return $temp_dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $LDrawLibrary
|
|
||||||
*/
|
|
||||||
public function loadData($LDrawLibrary)
|
|
||||||
{
|
|
||||||
$adapter = new Local($LDrawLibrary);
|
|
||||||
$this->ldraw = new Filesystem($adapter);
|
|
||||||
|
|
||||||
$this->LDViewService->setLdrawFilesystem($this->ldraw);
|
|
||||||
|
|
||||||
$this->loadParts();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO refactor
|
|
||||||
|
|
||||||
public function loadParts()
|
|
||||||
{
|
|
||||||
$files = $this->ldraw->get('parts')->getContents();
|
|
||||||
|
|
||||||
$this->initProgressBar(count($files));
|
$this->initProgressBar(count($files));
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if ($file['type'] == 'file' && $file['extension'] == 'dat') {
|
if ($file['type'] == 'file' && $file['extension'] == 'dat') {
|
||||||
$this->loadModel($file);
|
$model = $this->loadModel($this->ldrawLibraryFilesystem->getAdapter()->getPathPrefix().$file['path']);
|
||||||
|
|
||||||
|
if($model)
|
||||||
|
$modelManager->getRepository()->save($model);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->progressBar->advance();
|
$this->progressBar->advance();
|
||||||
@ -116,31 +84,32 @@ class LDrawLoaderService extends BaseLoaderService
|
|||||||
*
|
*
|
||||||
* @return Model|null
|
* @return Model|null
|
||||||
*/
|
*/
|
||||||
private function loadModel($file)
|
public function loadModel($file)
|
||||||
{
|
{
|
||||||
$modelManager = $this->ldrawService->getModelManager();
|
$modelManager = $this->ldrawService->getModelManager();
|
||||||
$subpartManager = $this->ldrawService->getSubpartManager();
|
$subpartManager = $this->ldrawService->getSubpartManager();
|
||||||
$aliasManager = $this->ldrawService->getAliasManager();
|
$aliasManager = $this->ldrawService->getAliasManager();
|
||||||
|
|
||||||
$header = $this->datParser->parse($this->ldraw->get($file['path']));
|
if($model = $modelManager->findByNumber(basename($file,'.dat'))) {
|
||||||
|
|
||||||
if ($this->isModelIncluded($header)) {
|
|
||||||
if (isset($header['parent']) && ($parent = $this->getModelParent($header['parent'])) && ($parentFile = $this->getModelFile($parent))) {
|
|
||||||
$parentHeader = $this->datParser->parse($parentFile);
|
|
||||||
|
|
||||||
if ($this->isModelIncluded($parentHeader)) {
|
|
||||||
$model = $modelManager->create($parentHeader['id']);
|
|
||||||
$alias = $aliasManager->create($header['id'], $model);
|
|
||||||
$aliasManager->getRepository()->save($alias);
|
|
||||||
|
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$header = $this->datParser->parse($file);
|
||||||
|
|
||||||
|
if ($this->isModelIncluded($header)) {
|
||||||
|
if (isset($header['parent']) && ($parent = $this->getModelParent($header['parent'])) && ($parentFile = $this->findModelFile($parent))) {
|
||||||
|
$parentModel = $this->loadModel($parentFile);
|
||||||
|
|
||||||
|
if ($parentModel) {
|
||||||
|
$alias = $aliasManager->create($header['id'], $parentModel);
|
||||||
|
$aliasManager->getRepository()->save($alias);
|
||||||
|
$this->progressBar->advance();
|
||||||
|
}
|
||||||
|
return $parentModel;
|
||||||
} else {
|
} else {
|
||||||
$model = $modelManager->create($header['id']);
|
$model = $modelManager->create($header['id']);
|
||||||
$model->setName($header['name']);
|
$model->setName($header['name']);
|
||||||
$model
|
$model->setCategory($this->ldrawService->getCategoryManager()->create($header['category']));
|
||||||
->setCategory($this->ldrawService->getCategoryManager()->create($header['category']))
|
|
||||||
->setType($this->ldrawService->getTypeManager()->create($header['type']));
|
|
||||||
|
|
||||||
if (isset($header['keywords'])) {
|
if (isset($header['keywords'])) {
|
||||||
foreach ($header['keywords'] as $keyword) {
|
foreach ($header['keywords'] as $keyword) {
|
||||||
@ -150,20 +119,19 @@ class LDrawLoaderService extends BaseLoaderService
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($header['subparts'])) {
|
if (isset($header['subparts'])) {
|
||||||
$model->setType($this->ldrawService->getTypeManager()->create('Shortcut'));
|
foreach ($header['subparts'] as $subpartId) {
|
||||||
|
$subpartId = $this->getModelParent($subpartId);
|
||||||
|
|
||||||
foreach ($header['subparts'] as $subpart) {
|
$subModel = $modelManager->getRepository()->findOneBy(['number'=>$subpartId]);
|
||||||
$subpart = $this->getModelParent($subpart);
|
|
||||||
|
|
||||||
if ($subpartFile = $this->getModelFile($subpart)) {
|
if(!$subModel && ($subpartFile = $this->findModelFile($subpartId)) != null) {
|
||||||
$subpartHeader = $this->datParser->parse($subpartFile);
|
$subModel = $this->loadModel($subpartFile);
|
||||||
|
|
||||||
if ($this->isModelIncluded($subpartHeader)) {
|
|
||||||
$subpartModel = $modelManager->create($subpartHeader['id']);
|
|
||||||
|
|
||||||
$subpart = $subpartManager->create($model, $subpartModel);
|
|
||||||
$subpartManager->getRepository()->save($subpart);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($subModel) {
|
||||||
|
$subpart = $subpartManager->create($model, $subModel);
|
||||||
|
$subpartManager->getRepository()->save($subpart);
|
||||||
|
$this->progressBar->advance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -172,13 +140,9 @@ class LDrawLoaderService extends BaseLoaderService
|
|||||||
$model->setModified($header['modified']);
|
$model->setModified($header['modified']);
|
||||||
$model->setPath($this->loadStlModel($file));
|
$model->setPath($this->loadStlModel($file));
|
||||||
|
|
||||||
$modelManager->getRepository()->save($model);
|
|
||||||
|
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -186,13 +150,13 @@ class LDrawLoaderService extends BaseLoaderService
|
|||||||
*
|
*
|
||||||
* @param $id
|
* @param $id
|
||||||
*
|
*
|
||||||
* @return \League\Flysystem\Directory|File|\League\Flysystem\Handler|null
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getModelFile($id)
|
private function findModelFile($id)
|
||||||
{
|
{
|
||||||
$path = 'parts/'.strtolower($id).'.dat';
|
$path = 'parts/'.strtolower($id).'.dat';
|
||||||
if ($this->ldraw->has($path)) {
|
if ($this->ldrawLibraryFilesystem->has($path)) {
|
||||||
return $this->ldraw->get($path);
|
return $this->ldrawLibraryFilesystem->getAdapter()->getPathPrefix().$path;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -207,7 +171,7 @@ class LDrawLoaderService extends BaseLoaderService
|
|||||||
*/
|
*/
|
||||||
private function getModelParent($number)
|
private function getModelParent($number)
|
||||||
{
|
{
|
||||||
if (($file = $this->getModelFile($number)) == null) {
|
if (($file = $this->findModelFile($number)) == null) {
|
||||||
return $number;
|
return $number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +180,7 @@ class LDrawLoaderService extends BaseLoaderService
|
|||||||
do {
|
do {
|
||||||
$parent = isset($header['parent']) ? $header['parent'] : null;
|
$parent = isset($header['parent']) ? $header['parent'] : null;
|
||||||
|
|
||||||
if ($file = $this->getModelFile($parent)) {
|
if ($file = $this->findModelFile($parent)) {
|
||||||
$header = $this->datParser->parse($file);
|
$header = $this->datParser->parse($file);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@ -240,7 +204,7 @@ class LDrawLoaderService extends BaseLoaderService
|
|||||||
strpos($header['id'], 's') !== 0
|
strpos($header['id'], 's') !== 0
|
||||||
&& $header['type'] != 'Subpart'
|
&& $header['type'] != 'Subpart'
|
||||||
&& $header['type'] != 'Sticker'
|
&& $header['type'] != 'Sticker'
|
||||||
&& !(($header['type'] == 'Printed') && $this->getModelFile($header['parent']))
|
&& !(($header['type'] == 'Printed') && $this->findModelFile($header['parent']))
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -260,7 +224,7 @@ class LDrawLoaderService extends BaseLoaderService
|
|||||||
private function loadStlModel($file)
|
private function loadStlModel($file)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return $this->LDViewService->datToStl($file, $this->ldraw)->getPath();
|
return $this->LDViewService->datToStl($file)->getPath();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw $e; //TODO
|
throw $e; //TODO
|
||||||
}
|
}
|
||||||
|
8
src/AppBundle/Service/ZipService.php
Normal file
8
src/AppBundle/Service/ZipService.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AppBundle\Service;
|
||||||
|
|
||||||
|
class ZipService
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AppBundle\Tests\Controller\LDraw;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
|
|
||||||
|
class CategoryControllerTest extends WebTestCase
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
public function testCompleteScenario()
|
||||||
|
{
|
||||||
|
// Create a new client to browse the application
|
||||||
|
$client = static::createClient();
|
||||||
|
|
||||||
|
// Go to the list view
|
||||||
|
$crawler = $client->request('GET', '/ldraw_category/');
|
||||||
|
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /ldraw_category/");
|
||||||
|
|
||||||
|
// Go to the show view
|
||||||
|
$crawler = $client->click($crawler->selectLink('show')->link());
|
||||||
|
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code");
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
}
|
25
src/AppBundle/Tests/Controller/LDraw/PartControllerTest.php
Normal file
25
src/AppBundle/Tests/Controller/LDraw/PartControllerTest.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AppBundle\Tests\Controller\LDraw;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
|
|
||||||
|
class PartControllerTest extends WebTestCase
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
public function testCompleteScenario()
|
||||||
|
{
|
||||||
|
// Create a new client to browse the application
|
||||||
|
$client = static::createClient();
|
||||||
|
|
||||||
|
// Go to the list view
|
||||||
|
$crawler = $client->request('GET', '/ldraw_part/');
|
||||||
|
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /ldraw_part/");
|
||||||
|
|
||||||
|
// Go to the show view
|
||||||
|
$crawler = $client->click($crawler->selectLink('show')->link());
|
||||||
|
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code");
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
}
|
35
src/AppBundle/Twig/AppExtension.php
Normal file
35
src/AppBundle/Twig/AppExtension.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AppBundle\Twig;
|
||||||
|
|
||||||
|
use AppBundle\Api\Manager\RebrickableManager;
|
||||||
|
|
||||||
|
class AppExtension extends \Twig_Extension
|
||||||
|
{
|
||||||
|
/** @var RebrickableManager */
|
||||||
|
private $rebrickableAPIManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AppExtension constructor.
|
||||||
|
*
|
||||||
|
* @param $rebrickableAPIManager
|
||||||
|
*/
|
||||||
|
public function __construct($rebrickableAPIManager)
|
||||||
|
{
|
||||||
|
$this->rebrickableAPIManager = $rebrickableAPIManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilters()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new \Twig_SimpleFilter('partImage', [$this, 'partImage']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function partImage($number)
|
||||||
|
{
|
||||||
|
if ($part = $this->rebrickableAPIManager->getPart($number)) {
|
||||||
|
return $part->getImgUrl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace AppBundle\Utils;
|
namespace AppBundle\Utils;
|
||||||
|
|
||||||
|
use AppBundle\Exception\FileNotFoundException;
|
||||||
use League\Flysystem\File;
|
use League\Flysystem\File;
|
||||||
use Symfony\Component\Asset\Exception\LogicException;
|
use Symfony\Component\Asset\Exception\LogicException;
|
||||||
|
|
||||||
@ -38,11 +39,13 @@ class DatParser
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function parse(File $file)
|
public function parse($file)
|
||||||
{
|
{
|
||||||
$header = [];
|
$header = [];
|
||||||
|
|
||||||
$handle = $file->readStream();
|
if(file_exists($file)) {
|
||||||
|
try {
|
||||||
|
$handle = fopen($file, 'r');
|
||||||
|
|
||||||
if ($handle) {
|
if ($handle) {
|
||||||
$firstLine = false;
|
$firstLine = false;
|
||||||
@ -61,26 +64,21 @@ class DatParser
|
|||||||
$header['name'] = preg_replace('/ {2,}/', ' ', ltrim($line, '=_'));
|
$header['name'] = preg_replace('/ {2,}/', ' ', ltrim($line, '=_'));
|
||||||
|
|
||||||
$firstLine = true;
|
$firstLine = true;
|
||||||
}
|
} // 0 !CATEGORY <CategoryName>
|
||||||
// 0 !CATEGORY <CategoryName>
|
|
||||||
elseif (strpos($line, '!CATEGORY ') === 0) {
|
elseif (strpos($line, '!CATEGORY ') === 0) {
|
||||||
$header['category'] = trim(preg_replace('/^!CATEGORY /', '', $line));
|
$header['category'] = trim(preg_replace('/^!CATEGORY /', '', $line));
|
||||||
}
|
} // 0 !KEYWORDS <first keyword>, <second keyword>, ..., <last keyword>
|
||||||
// 0 !KEYWORDS <first keyword>, <second keyword>, ..., <last keyword>
|
|
||||||
elseif (strpos($line, '!KEYWORDS ') === 0) {
|
elseif (strpos($line, '!KEYWORDS ') === 0) {
|
||||||
$header['keywords'] = explode(', ', preg_replace('/^!KEYWORDS /', '', $line));
|
$header['keywords'] = explode(', ', preg_replace('/^!KEYWORDS /', '', $line));
|
||||||
}
|
} // 0 Name: <Filename>.dat
|
||||||
// 0 Name: <Filename>.dat
|
|
||||||
elseif (strpos($line, 'Name: ') === 0) {
|
elseif (strpos($line, 'Name: ') === 0) {
|
||||||
if (!isset($header['id'])) {
|
if (!isset($header['id'])) {
|
||||||
$header['id'] = preg_replace('/(^Name: )(.*)(.dat)/', '$2', $line);
|
$header['id'] = preg_replace('/(^Name: )(.*)(.dat)/', '$2', $line);
|
||||||
}
|
}
|
||||||
}
|
} // 0 Author: <Realname> [<Username>]
|
||||||
// 0 Author: <Realname> [<Username>]
|
|
||||||
elseif (strpos($line, 'Author: ') === 0) {
|
elseif (strpos($line, 'Author: ') === 0) {
|
||||||
$header['author'] = preg_replace('/^Author: /', '', $line);
|
$header['author'] = preg_replace('/^Author: /', '', $line);
|
||||||
}
|
} // 0 !LDRAW_ORG Part|Subpart|Primitive|48_Primitive|Shortcut (optional qualifier(s)) ORIGINAL|UPDATE YYYY-RR
|
||||||
// 0 !LDRAW_ORG Part|Subpart|Primitive|48_Primitive|Shortcut (optional qualifier(s)) ORIGINAL|UPDATE YYYY-RR
|
|
||||||
elseif (strpos($line, '!LDRAW_ORG ') === 0) {
|
elseif (strpos($line, '!LDRAW_ORG ') === 0) {
|
||||||
$type = preg_replace('/(^!LDRAW_ORG )(.*)( UPDATE| ORIGINAL)(.*)/', '$2', $line);
|
$type = preg_replace('/(^!LDRAW_ORG )(.*)( UPDATE| ORIGINAL)(.*)/', '$2', $line);
|
||||||
|
|
||||||
@ -89,7 +87,7 @@ class DatParser
|
|||||||
// Last modification date in format YYYY-RR
|
// Last modification date in format YYYY-RR
|
||||||
$date = preg_replace('/(^!LDRAW_ORG )(.*)( UPDATE | ORIGINAL )(.*)/', '$4', $line);
|
$date = preg_replace('/(^!LDRAW_ORG )(.*)( UPDATE | ORIGINAL )(.*)/', '$4', $line);
|
||||||
if (preg_match('/^[1-2][0-9]{3}-[0-9]{2}$/', $date)) {
|
if (preg_match('/^[1-2][0-9]{3}-[0-9]{2}$/', $date)) {
|
||||||
$header['modified'] = \DateTime::createFromFormat('Y-m-d H:i:s', $date.'-01 00:00:00');
|
$header['modified'] = \DateTime::createFromFormat('Y-m-d H:i:s', $date . '-01 00:00:00');
|
||||||
} else {
|
} else {
|
||||||
$header['modified'] = null;
|
$header['modified'] = null;
|
||||||
}
|
}
|
||||||
@ -103,15 +101,18 @@ class DatParser
|
|||||||
$header['type'] = 'Sticker';
|
$header['type'] = 'Sticker';
|
||||||
} elseif (($parent = $this->relationMapper->find($header['id'], 'alias_model')) != $header['id']) {
|
} elseif (($parent = $this->relationMapper->find($header['id'], 'alias_model')) != $header['id']) {
|
||||||
$header['type'] = 'Alias';
|
$header['type'] = 'Alias';
|
||||||
|
$header['subparts'] = null;
|
||||||
$header['parent'] = $parent;
|
$header['parent'] = $parent;
|
||||||
} elseif (isset($header['subparts']) && count($header['subparts']) == 1 && in_array($header['type'], ['Part Alias', 'Shortcut Physical_Colour', 'Shortcut Alias', 'Part Physical_Colour'])) {
|
} elseif (isset($header['subparts']) && count($header['subparts']) == 1 && in_array($header['type'], ['Part Alias', 'Shortcut Physical_Colour', 'Shortcut Alias', 'Part Physical_Colour'])) {
|
||||||
$header['parent'] = $header['subparts'][0];
|
$header['parent'] = $header['subparts'][0];
|
||||||
$header['subparts'] = null;
|
$header['subparts'] = null;
|
||||||
} elseif ($parent = $this->getPrintedParentId($header['id'])) {
|
} elseif ($parent = $this->getPrintedParentId($header['id'])) {
|
||||||
$header['type'] = 'Printed';
|
$header['type'] = 'Printed';
|
||||||
|
$header['subparts'] = null;
|
||||||
$header['parent'] = $parent;
|
$header['parent'] = $parent;
|
||||||
} elseif ($parent = $this->getObsoleteParentId($header['name'])) {
|
} elseif ($parent = $this->getObsoleteParentId($header['name'])) {
|
||||||
$header['type'] = 'Alias';
|
$header['type'] = 'Alias';
|
||||||
|
$header['subparts'] = null;
|
||||||
$header['parent'] = $parent;
|
$header['parent'] = $parent;
|
||||||
} elseif (strpos($header['name'], '~') === 0 && $header['type'] != 'Alias') {
|
} elseif (strpos($header['name'], '~') === 0 && $header['type'] != 'Alias') {
|
||||||
$header['type'] = 'Obsolete/Subpart';
|
$header['type'] = 'Obsolete/Subpart';
|
||||||
@ -123,8 +124,13 @@ class DatParser
|
|||||||
|
|
||||||
return $header;
|
return $header;
|
||||||
}
|
}
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
dump($exception->getMessage());
|
||||||
|
|
||||||
throw new LogicException('Error parsing DAT file'); //TODO
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -780,7 +780,11 @@ class SymfonyRequirements extends RequirementCollection
|
|||||||
{
|
{
|
||||||
$size = ini_get('realpath_cache_size');
|
$size = ini_get('realpath_cache_size');
|
||||||
$size = trim($size);
|
$size = trim($size);
|
||||||
|
$unit = '';
|
||||||
|
if (!ctype_digit($size)) {
|
||||||
$unit = strtolower(substr($size, -1, 1));
|
$unit = strtolower(substr($size, -1, 1));
|
||||||
|
$size = (int) substr($size, 0, -1);
|
||||||
|
}
|
||||||
switch ($unit) {
|
switch ($unit) {
|
||||||
case 'g':
|
case 'g':
|
||||||
return $size * 1024 * 1024 * 1024;
|
return $size * 1024 * 1024 * 1024;
|
||||||
|
@ -270,7 +270,7 @@ $hasMinorProblems = (bool) count($minorProblems);
|
|||||||
}
|
}
|
||||||
.sf-reset ul a,
|
.sf-reset ul a,
|
||||||
.sf-reset ul a:hover {
|
.sf-reset ul a:hover {
|
||||||
background: url(../images/blue-arrow.png) no-repeat right 6px;
|
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAICAYAAAAx8TU7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAFdJREFUeNpiYACBjjOhDEiACSggCKTLgXQ5TJARqhIkcReIKxgqTGYxwvV0nDEGkmeAOIwJySiQ4HsgvseIpGo3ELsCtZ9lRDIvDCiwhwHJPEFkJwEEGACq6hdnax8y1AAAAABJRU5ErkJggg==) no-repeat right 7px;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
}
|
}
|
||||||
.sf-reset ul, ol {
|
.sf-reset ul, ol {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user