mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-16 12:20:09 -07:00
Fix coding style
This commit is contained in:
parent
71bb607772
commit
85ec4e5481
@ -21,7 +21,7 @@ services:
|
||||
|
||||
service.set:
|
||||
class: AppBundle\Service\SetService
|
||||
arguments: ['@repository.rebrickable.inventorypart']
|
||||
arguments: ['@repository.rebrickable.inventoryPart']
|
||||
|
||||
service.model:
|
||||
class: AppBundle\Service\ModelService
|
||||
|
@ -38,6 +38,8 @@ class Rebrickable_v3
|
||||
* @param $uri
|
||||
* @param array $options
|
||||
*
|
||||
* @throws ApiException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function call($method, $uri, $options = [])
|
||||
|
@ -19,7 +19,8 @@ class BricksetManager
|
||||
/**
|
||||
* BricksetManager constructor.
|
||||
*
|
||||
* @param Brickset $bricksetClient
|
||||
* @param Brickset $bricksetClient
|
||||
* @param CacheProvider $cache
|
||||
*/
|
||||
public function __construct(Brickset $bricksetClient, CacheProvider $cache)
|
||||
{
|
||||
|
@ -4,7 +4,6 @@ namespace AppBundle\Command;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
@ -20,7 +19,7 @@ class InitDataCommand extends ContainerAwareCommand
|
||||
->setHelp('This command allows you to load initial data of models and sets into aplication')
|
||||
->setDefinition(
|
||||
new InputDefinition([
|
||||
new InputOption('ldraw', 'l',InputOption::VALUE_OPTIONAL, 'Path to LDraw library directory'),
|
||||
new InputOption('ldraw', 'l', InputOption::VALUE_OPTIONAL, 'Path to LDraw library directory'),
|
||||
])
|
||||
);
|
||||
}
|
||||
@ -34,7 +33,7 @@ class InitDataCommand extends ContainerAwareCommand
|
||||
'--all' => true,
|
||||
];
|
||||
|
||||
if($ldraw = $input->getOption('ldraw')) {
|
||||
if ($ldraw = $input->getOption('ldraw')) {
|
||||
$loadModelsInput['--ldraw'] = $ldraw;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ namespace AppBundle\Command;
|
||||
use AppBundle\Service\Loader\ModelLoader;
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Command\LockableTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
@ -50,7 +49,7 @@ class LoadModelsCommand extends ContainerAwareCommand
|
||||
return 1;
|
||||
}
|
||||
|
||||
if($ldraw = $input->getOption('ldraw')) {
|
||||
if ($ldraw = $input->getOption('ldraw')) {
|
||||
$modelLoader->setLDrawLibraryContext(realpath($ldraw));
|
||||
} else {
|
||||
$ldraw = $modelLoader->downloadLibrary($this->getContainer()->getParameter('app.ld_library_download_url'));
|
||||
|
@ -20,6 +20,7 @@ class DefaultController extends Controller
|
||||
|
||||
/** @var SetRepository $setRepository */
|
||||
$setRepository = $this->get('repository.rebrickable.set');
|
||||
|
||||
return $this->render('default/index.html.twig', [
|
||||
'models' => $modelRepository->count(),
|
||||
'sets' => $setRepository->count(),
|
||||
|
@ -33,7 +33,7 @@ class ModelController extends Controller
|
||||
$form->handleRequest($request);
|
||||
|
||||
$elasticaManager = $this->get('fos_elastica.manager');
|
||||
$results = $elasticaManager->getRepository(Model::class)->search($modelSearch,5000);
|
||||
$results = $elasticaManager->getRepository(Model::class)->search($modelSearch, 5000);
|
||||
|
||||
/** @var Paginator $paginator */
|
||||
$paginator = $this->get('knp_paginator');
|
||||
@ -94,7 +94,7 @@ class ModelController extends Controller
|
||||
$response->headers->set('Content-Type', 'application/zip');
|
||||
|
||||
// escape forbidden characters from filename
|
||||
$filename = preg_replace('/[^a-z0-9\.]/i', '_',"model_{$model->getId()}_{$model->getName()}.zip");
|
||||
$filename = preg_replace('/[^a-z0-9\.]/i', '_', "model_{$model->getId()}_{$model->getName()}.zip");
|
||||
|
||||
// Create the disposition of the file
|
||||
$disposition = $response->headers->makeDisposition(
|
||||
|
@ -4,7 +4,6 @@ namespace AppBundle\Controller;
|
||||
|
||||
use AppBundle\Api\Exception\EmptyResponseException;
|
||||
use AppBundle\Entity\Rebrickable\Part;
|
||||
use AppBundle\Entity\Rebrickable\Set;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
|
||||
@ -24,8 +23,8 @@ class PartController extends Controller
|
||||
{
|
||||
$apiPart = null;
|
||||
if ($part) {
|
||||
if($model = $part->getModel()) {
|
||||
$this->redirectToRoute('model_detail',['id' => $model->getId()]);
|
||||
if ($model = $part->getModel()) {
|
||||
$this->redirectToRoute('model_detail', ['id' => $model->getId()]);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -9,9 +9,7 @@ use AppBundle\Model\SetSearch;
|
||||
use AppBundle\Repository\Search\ModelRepository;
|
||||
use AppBundle\Repository\Search\SetRepository;
|
||||
use FOS\ElasticaBundle\HybridResult;
|
||||
use FOS\ElasticaBundle\Repository;
|
||||
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
|
||||
use Liip\ImagineBundle\Imagine\Cache\Resolver\CacheResolver;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
@ -81,7 +79,7 @@ class SearchController extends Controller
|
||||
'id' => $id,
|
||||
'name' => $name,
|
||||
'url' => $this->generateUrl('model_detail', ['id' => $model->getTransformed()->getId()]),
|
||||
'img' => $liip->getBrowserPath('-1/'.$model->getTransformed()->getId().'.png','part_min'),
|
||||
'img' => $liip->getBrowserPath('-1/'.$model->getTransformed()->getId().'.png', 'part_min'),
|
||||
];
|
||||
}
|
||||
|
||||
@ -95,7 +93,7 @@ class SearchController extends Controller
|
||||
'id' => $id,
|
||||
'name' => $name,
|
||||
'url' => $this->generateUrl('set_detail', ['id' => $set->getTransformed()->getId()]),
|
||||
'img' => $liip->getBrowserPath($set->getTransformed()->getId().'.jpg','set_min'),
|
||||
'img' => $liip->getBrowserPath($set->getTransformed()->getId().'.jpg', 'set_min'),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class SetController extends Controller
|
||||
|
||||
/** @var SetRepository $setRepository */
|
||||
$setRepository = $this->get('fos_elastica.manager')->getRepository(Set::class);
|
||||
$results = $setRepository->search($setSearch,5000);
|
||||
$results = $setRepository->search($setSearch, 5000);
|
||||
|
||||
$paginator = $this->get('knp_paginator');
|
||||
$sets = $paginator->paginate(
|
||||
@ -90,7 +90,6 @@ class SetController extends Controller
|
||||
$setService = $this->get('service.set');
|
||||
$inventoryPartRepository = $this->get('repository.rebrickable.inventoryPart');
|
||||
|
||||
|
||||
$models = $setService->getModels($set, false);
|
||||
$missing = $setService->getParts($set, false, false);
|
||||
$missingCount = $inventoryPartRepository->getPartCount($set, false, false);
|
||||
@ -163,7 +162,7 @@ class SetController extends Controller
|
||||
|
||||
try {
|
||||
$colors = $setService->getModelsGroupedByColor($set, false);
|
||||
$missing = $setService->getParts($set,false,false);
|
||||
$missing = $setService->getParts($set, false, false);
|
||||
} catch (\Exception $e) {
|
||||
$this->addFlash('error', $e->getMessage());
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace AppBundle\DataFixtures\ORM;
|
||||
|
||||
|
||||
use AppBundle\Entity\Color;
|
||||
use Doctrine\Common\DataFixtures\FixtureInterface;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
@ -43,4 +42,4 @@ class LoadColors implements FixtureInterface, ContainerAwareInterface
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,8 @@ class Theme
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFullName() {
|
||||
public function getFullName()
|
||||
{
|
||||
$theme = $this;
|
||||
$name = [];
|
||||
|
||||
|
@ -60,8 +60,9 @@ class SetSearchType extends AbstractType
|
||||
'choices' => $this->themeRepository->findAll(),
|
||||
'choice_label' => 'fullName',
|
||||
'choice_translation_domain' => false,
|
||||
'group_by' => function($theme, $key, $index) {
|
||||
'group_by' => function ($theme, $key, $index) {
|
||||
$parent = $theme->getParent();
|
||||
|
||||
return $parent ? $parent->getParent() ? $parent->getParent()->getName() : $parent->getName() : $theme->getName();
|
||||
},
|
||||
'choice_value' => 'id',
|
||||
@ -79,7 +80,7 @@ class SetSearchType extends AbstractType
|
||||
$resolver->setDefaults([
|
||||
'csrf_protection' => false,
|
||||
'data_class' => SetSearch::class,
|
||||
'method' => 'GET'
|
||||
'method' => 'GET',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,9 @@ class PartImageLoader extends BaseImageLoader
|
||||
// try to load image from rebrickable website
|
||||
try {
|
||||
if ($this->remoteFileExists($this->rebrickableContext.$path)) {
|
||||
$context = stream_context_create(array('http' => array('header'=>'Connection: close\r\n')));
|
||||
return file_get_contents($this->rebrickableContext.strtolower($path),false,$context);
|
||||
$context = stream_context_create(['http' => ['header' => 'Connection: close\r\n']]);
|
||||
|
||||
return file_get_contents($this->rebrickableContext.strtolower($path), false, $context);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new NotLoadableException(sprintf('Source image %s could not be loaded.', $path), $e->getCode(), $e);
|
||||
|
@ -32,8 +32,9 @@ class SetImageLoader extends BaseImageLoader
|
||||
// try to load image from rebrickable website
|
||||
try {
|
||||
if ($this->remoteFileExists($this->rebrickableContext.strtolower($path))) {
|
||||
$context = stream_context_create(array('http' => array('header'=>'Connection: close\r\n')));
|
||||
return file_get_contents($this->rebrickableContext.strtolower($path),false,$context);
|
||||
$context = stream_context_create(['http' => ['header' => 'Connection: close\r\n']]);
|
||||
|
||||
return file_get_contents($this->rebrickableContext.strtolower($path), false, $context);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new NotLoadableException(sprintf('Source image %s could not be loaded.', $path), $e->getCode(), $e);
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace AppBundle\Menu;
|
||||
|
||||
use Knp\Menu\FactoryInterface;
|
||||
use Knp\Menu\ItemInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
class Builder
|
||||
@ -26,7 +25,6 @@ class Builder
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
|
||||
|
||||
public function mainMenu(array $options)
|
||||
{
|
||||
$request = $this->requestStack->getCurrentRequest();
|
||||
@ -37,7 +35,7 @@ class Builder
|
||||
],
|
||||
]);
|
||||
|
||||
$models = $menu->addChild( 'page.model.index', [
|
||||
$models = $menu->addChild('page.model.index', [
|
||||
'route' => 'model_index',
|
||||
]);
|
||||
|
||||
@ -46,7 +44,7 @@ class Builder
|
||||
'routeParameters' => ['id' => $request->get('id', 0)],
|
||||
'display' => false,
|
||||
'extras' => [
|
||||
'value' => $request->get('id', 0)
|
||||
'value' => $request->get('id', 0),
|
||||
],
|
||||
]);
|
||||
|
||||
@ -54,7 +52,7 @@ class Builder
|
||||
'route' => 'set_index',
|
||||
'options' => [
|
||||
// 'icon' => 'edit',
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
$sets->addChild('page.set.detail', [
|
||||
@ -62,7 +60,7 @@ class Builder
|
||||
'routeParameters' => ['id' => $request->get('id', 0)],
|
||||
'display' => false,
|
||||
'extras' => [
|
||||
'value' => $request->get('id', 0)
|
||||
'value' => $request->get('id', 0),
|
||||
],
|
||||
]);
|
||||
|
||||
@ -70,7 +68,7 @@ class Builder
|
||||
'route' => 'search_results',
|
||||
'display' => false,
|
||||
'extras' => [
|
||||
'value' => $request->get('query', 0)
|
||||
'value' => $request->get('query', 0),
|
||||
],
|
||||
]);
|
||||
|
||||
@ -83,7 +81,7 @@ class Builder
|
||||
'display' => false,
|
||||
'options' => [
|
||||
// 'icon' => 'edit',
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
$parts->addChild('page.part.detail', [
|
||||
@ -91,11 +89,10 @@ class Builder
|
||||
'routeParameters' => ['id' => $request->get('id', 0)],
|
||||
'display' => false,
|
||||
'extras' => [
|
||||
'value' => $request->get('id', 0)
|
||||
'value' => $request->get('id', 0),
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
return $menu;
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ class ModelSearch
|
||||
|
||||
/**
|
||||
* ModelSearch constructor.
|
||||
*
|
||||
* @param string $query
|
||||
*/
|
||||
public function __construct($query = '')
|
||||
|
@ -20,6 +20,7 @@ class SetSearch
|
||||
|
||||
/**
|
||||
* SetSearch constructor.
|
||||
*
|
||||
* @param string $query
|
||||
*/
|
||||
public function __construct($query = '')
|
||||
|
@ -106,7 +106,8 @@ class ModelRepository extends BaseRepository
|
||||
return $queryBuilder->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function count() {
|
||||
public function count()
|
||||
{
|
||||
$queryBuilder = $this->createQueryBuilder('model');
|
||||
$queryBuilder->select('count(model)');
|
||||
|
||||
|
@ -73,7 +73,8 @@ class SetRepository extends BaseRepository
|
||||
return $queryBuilder->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function count() {
|
||||
public function count()
|
||||
{
|
||||
$queryBuilder = $this->createQueryBuilder('s');
|
||||
$queryBuilder->select('count(s)');
|
||||
|
||||
|
@ -10,9 +10,11 @@ class ModelRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* @param ModelSearch $modelSearch
|
||||
*
|
||||
* @return \Elastica\Query
|
||||
*/
|
||||
public function getSearchQuery(ModelSearch $modelSearch) {
|
||||
public function getSearchQuery(ModelSearch $modelSearch)
|
||||
{
|
||||
$boolQuery = new Query\BoolQuery();
|
||||
|
||||
if ($searchQuery = $modelSearch->getQuery()) {
|
||||
@ -23,7 +25,6 @@ class ModelRepository extends Repository
|
||||
$query->setFuzziness(0.7);
|
||||
$query->setMinimumShouldMatch('80%');
|
||||
$query->setOperator('and');
|
||||
|
||||
} else {
|
||||
$query = new Query\MatchAll();
|
||||
}
|
||||
@ -41,11 +42,13 @@ class ModelRepository extends Repository
|
||||
|
||||
public function search(ModelSearch $modelSearch, $limit = 500)
|
||||
{
|
||||
$query = $this->getSearchQuery($modelSearch);
|
||||
$query = $this->getSearchQuery($modelSearch);
|
||||
|
||||
return $this->find($query, $limit);
|
||||
}
|
||||
|
||||
public function findHighlighted($query, $limit = 500) {
|
||||
public function findHighlighted($query, $limit = 500)
|
||||
{
|
||||
$modelSearch = new ModelSearch();
|
||||
$modelSearch->setQuery($query);
|
||||
|
||||
@ -55,10 +58,10 @@ class ModelRepository extends Repository
|
||||
$query->setHighlight([
|
||||
'pre_tags' => ['<em>'],
|
||||
'post_tags' => ['</em>'],
|
||||
"fields" => [
|
||||
"name" => new \stdClass(),
|
||||
"id" => new \stdClass()
|
||||
]
|
||||
'fields' => [
|
||||
'name' => new \stdClass(),
|
||||
'id' => new \stdClass(),
|
||||
],
|
||||
]);
|
||||
|
||||
return $this->findHybrid($query, $limit);
|
||||
|
@ -6,18 +6,18 @@ use AppBundle\Model\SetSearch;
|
||||
use Elastica\Query;
|
||||
use Elastica\Query\BoolQuery;
|
||||
use Elastica\Query\Match;
|
||||
use Elastica\Query\MultiMatch;
|
||||
use Elastica\Query\Range;
|
||||
use Elastica\Query\Wildcard;
|
||||
use FOS\ElasticaBundle\Repository;
|
||||
|
||||
class SetRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* @param SetSearch $setSearch
|
||||
*
|
||||
* @return Query
|
||||
*/
|
||||
public function getSearchQuery(SetSearch $setSearch) {
|
||||
public function getSearchQuery(SetSearch $setSearch)
|
||||
{
|
||||
$boolQuery = new BoolQuery();
|
||||
|
||||
if ($searchQuery = $setSearch->getQuery()) {
|
||||
@ -28,7 +28,7 @@ class SetRepository extends Repository
|
||||
$query->setFuzziness(0.7);
|
||||
$query->setMinimumShouldMatch('80%');
|
||||
$query->setOperator('and');
|
||||
|
||||
|
||||
$boolQuery->addMust($query);
|
||||
} else {
|
||||
$query = new \Elastica\Query\MatchAll();
|
||||
@ -69,7 +69,8 @@ class SetRepository extends Repository
|
||||
return $this->find($query, $limit);
|
||||
}
|
||||
|
||||
public function findHighlighted($query, $limit = 500) {
|
||||
public function findHighlighted($query, $limit = 500)
|
||||
{
|
||||
$setSearch = new SetSearch();
|
||||
$setSearch->setQuery($query);
|
||||
|
||||
@ -79,10 +80,10 @@ class SetRepository extends Repository
|
||||
$query->setHighlight([
|
||||
'pre_tags' => ['<em>'],
|
||||
'post_tags' => ['</em>'],
|
||||
"fields" => [
|
||||
"name" => new \stdClass(),
|
||||
"id" => new \stdClass()
|
||||
]
|
||||
'fields' => [
|
||||
'name' => new \stdClass(),
|
||||
'id' => new \stdClass(),
|
||||
],
|
||||
]);
|
||||
|
||||
return $this->findHybrid($query, $limit);
|
||||
|
@ -10,7 +10,6 @@ use Monolog\Logger;
|
||||
use Symfony\Bundle\FrameworkBundle\Translation\Translator;
|
||||
use Symfony\Component\Asset\Exception\LogicException;
|
||||
use Symfony\Component\Console\Helper\ProgressBar;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Debug\Exception\ContextErrorException;
|
||||
|
||||
@ -45,7 +44,7 @@ abstract class BaseLoader
|
||||
* Loader constructor.
|
||||
*
|
||||
* @param EntityManager $em
|
||||
* @param Logger $logger
|
||||
* @param Logger $logger
|
||||
* @param Translator $formatTransformer
|
||||
*/
|
||||
public function setArguments(EntityManager $em, $logger, $formatTransformer)
|
||||
|
@ -19,8 +19,6 @@ use AppBundle\Util\RelationMapper;
|
||||
use League\Flysystem\Adapter\Local;
|
||||
use League\Flysystem\Exception;
|
||||
use League\Flysystem\Filesystem;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\Finder\SplFileInfo;
|
||||
|
||||
class ModelLoader extends BaseLoader
|
||||
{
|
||||
@ -116,13 +114,13 @@ class ModelLoader extends BaseLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* Load one model into database
|
||||
* Load one model into database.
|
||||
*
|
||||
* @param string $file Absolute filepath of model to load
|
||||
*/
|
||||
public function loadOne($file)
|
||||
{
|
||||
if(!$this->ldrawLibraryContext) {
|
||||
if (!$this->ldrawLibraryContext) {
|
||||
throw new MissingContextException('LDrawLibrary');
|
||||
}
|
||||
|
||||
@ -140,13 +138,12 @@ class ModelLoader extends BaseLoader
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load all models from ldraw library context into database
|
||||
* Load all models from ldraw library context into database.
|
||||
*/
|
||||
public function loadAll()
|
||||
{
|
||||
if(!$this->ldrawLibraryContext) {
|
||||
if (!$this->ldrawLibraryContext) {
|
||||
throw new MissingContextException('LDrawLibrary');
|
||||
}
|
||||
|
||||
@ -162,7 +159,7 @@ class ModelLoader extends BaseLoader
|
||||
foreach ($files as $file) {
|
||||
$this->progressBar->setMessage($file['basename']);
|
||||
|
||||
if($file['type'] == 'file' && $file['extension'] == 'dat') {
|
||||
if ($file['type'] == 'file' && $file['extension'] == 'dat') {
|
||||
$connection = $this->em->getConnection();
|
||||
$connection->beginTransaction();
|
||||
|
||||
@ -217,7 +214,7 @@ class ModelLoader extends BaseLoader
|
||||
if (($parentId = $this->getParentId($modelArray)) && ($parentModelFile = $this->findSubmodelFile($parentId)) !== null) {
|
||||
if ($parentModel = $this->loadModel($parentModelFile)) {
|
||||
// Remove old model if ~moved to
|
||||
if($this->rewrite && ($old = $modelRepository->find($modelArray['id'])) != null) {
|
||||
if ($this->rewrite && ($old = $modelRepository->find($modelArray['id'])) != null) {
|
||||
$modelRepository->delete($old);
|
||||
}
|
||||
|
||||
@ -331,8 +328,7 @@ class ModelLoader extends BaseLoader
|
||||
// Try to find model in current file's directory
|
||||
if ($this->fileContext && $this->fileContext->has($filename)) {
|
||||
return $this->fileContext->getAdapter()->getPathPrefix().$filename;
|
||||
}
|
||||
elseif ($this->ldrawLibraryContext) {
|
||||
} elseif ($this->ldrawLibraryContext) {
|
||||
// Try to find model in current LDRAW\PARTS sub-directory
|
||||
if ($this->ldrawLibraryContext->has('parts'.DIRECTORY_SEPARATOR.$filename)) {
|
||||
return $this->ldrawLibraryContext->getAdapter()->getPathPrefix().'parts'.DIRECTORY_SEPARATOR.$filename;
|
||||
@ -357,7 +353,7 @@ class ModelLoader extends BaseLoader
|
||||
{
|
||||
try {
|
||||
$adapter = new Local(dirname($file));
|
||||
$this->fileContext = new Filesystem($adapter);
|
||||
$this->fileContext = new Filesystem($adapter);
|
||||
} catch (Exception $exception) {
|
||||
$this->logger->error($exception->getMessage());
|
||||
|
||||
|
@ -35,9 +35,9 @@ class StlConverterService
|
||||
/**
|
||||
* StlConverterService constructor.
|
||||
*
|
||||
* @param string $ldview Path to LDView OSMesa binary file
|
||||
* @param string $ldview Path to LDView OSMesa binary file
|
||||
* @param FilesystemInterface $mediaFilesystem Filesystem for generated web assets
|
||||
* @param StlFixerService $stlFixer
|
||||
* @param StlFixerService $stlFixer
|
||||
*/
|
||||
public function __construct($ldview, $mediaFilesystem, $stlFixer)
|
||||
{
|
||||
@ -59,7 +59,7 @@ class StlConverterService
|
||||
* stores created file to $stlStorage filesystem.
|
||||
*
|
||||
* @param string $file
|
||||
* @param bool $rewrite
|
||||
* @param bool $rewrite
|
||||
*
|
||||
* @throws ConvertingFailedException
|
||||
*
|
||||
@ -104,7 +104,7 @@ class StlConverterService
|
||||
* stores created file to $stlStorage filesystem.
|
||||
*
|
||||
* @param string $file
|
||||
* @param bool $rewrite
|
||||
* @param bool $rewrite
|
||||
*
|
||||
* @throws ConvertingFailedException
|
||||
*
|
||||
|
@ -160,7 +160,7 @@ class StlRendererService
|
||||
* http://www.povray.org/
|
||||
*
|
||||
* @param string $file The full path to .pov file to be rendered
|
||||
* @param string $to Destination directory path
|
||||
* @param string $to Destination directory path
|
||||
*
|
||||
* @throws RenderFailedException throws exception if there are problems rendering image
|
||||
* @throws FileNotFoundException throws exception if source file not found
|
||||
@ -173,7 +173,7 @@ class StlRendererService
|
||||
throw new FileNotFoundException($file);
|
||||
}
|
||||
|
||||
if(!file_exists($to)) {
|
||||
if (!file_exists($to)) {
|
||||
mkdir($to);
|
||||
}
|
||||
|
||||
|
@ -73,12 +73,14 @@ class AppExtension extends \Twig_Extension
|
||||
return $size;
|
||||
}
|
||||
|
||||
public function fileTimestamp($filePath) {
|
||||
public function fileTimestamp($filePath)
|
||||
{
|
||||
$changeDate = filemtime($_SERVER['DOCUMENT_ROOT'].'/'.$filePath);
|
||||
if (!$changeDate) {
|
||||
//Fallback if mtime could not be found:
|
||||
$changeDate = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
|
||||
}
|
||||
|
||||
return $filePath.'?'.$changeDate;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ class LDModelParser
|
||||
$keywords = explode(',', preg_replace('/^!KEYWORDS /', '', $line));
|
||||
foreach ($keywords as $keyword) {
|
||||
$keyword = trim($keyword);
|
||||
if ($keyword && !in_array($keyword,$model['keywords'])) {
|
||||
if ($keyword && !in_array($keyword, $model['keywords'])) {
|
||||
$model['keywords'][] = $keyword;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user