mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-17 04:40:08 -07:00
Fix coding style
This commit is contained in:
parent
e8c225c021
commit
30c4eb8c82
@ -13,7 +13,6 @@ use AppBundle\Api\Exception\ApiException;
|
|||||||
use AppBundle\Api\Exception\AuthenticationFailedException;
|
use AppBundle\Api\Exception\AuthenticationFailedException;
|
||||||
use AppBundle\Api\Exception\CallFailedException;
|
use AppBundle\Api\Exception\CallFailedException;
|
||||||
use AppBundle\Api\Exception\EmptyResponseException;
|
use AppBundle\Api\Exception\EmptyResponseException;
|
||||||
use Symfony\Component\Asset\Exception\LogicException;
|
|
||||||
use Symfony\Component\Debug\Exception\ContextErrorException;
|
use Symfony\Component\Debug\Exception\ContextErrorException;
|
||||||
|
|
||||||
class Brickset extends \SoapClient
|
class Brickset extends \SoapClient
|
||||||
@ -79,6 +78,7 @@ class Brickset extends \SoapClient
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$this->checkApiKey();
|
$this->checkApiKey();
|
||||||
|
|
||||||
return $this->__soapCall($method, [$parameters])->{$method.'Result'};
|
return $this->__soapCall($method, [$parameters])->{$method.'Result'};
|
||||||
} catch (\SoapFault $e) {
|
} catch (\SoapFault $e) {
|
||||||
throw new CallFailedException(ApiException::BRICKSET);
|
throw new CallFailedException(ApiException::BRICKSET);
|
||||||
|
@ -9,7 +9,6 @@ use AppBundle\Api\Exception\EmptyResponseException;
|
|||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Exception\ClientException;
|
use GuzzleHttp\Exception\ClientException;
|
||||||
use GuzzleHttp\Exception\ConnectException;
|
use GuzzleHttp\Exception\ConnectException;
|
||||||
use Symfony\Component\Asset\Exception\LogicException;
|
|
||||||
|
|
||||||
class Rebrickable_v3
|
class Rebrickable_v3
|
||||||
{
|
{
|
||||||
|
@ -48,15 +48,18 @@ class BricksetManager
|
|||||||
return isset($sets[0]) ? $sets[0] : null;
|
return isset($sets[0]) ? $sets[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSetInstructions($id) {
|
public function getSetInstructions($id)
|
||||||
|
{
|
||||||
return $this->bricksetClient->getInstructions($id);
|
return $this->bricksetClient->getInstructions($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSetReviews($id) {
|
public function getSetReviews($id)
|
||||||
|
{
|
||||||
return $this->bricksetClient->getReviews($id);
|
return $this->bricksetClient->getReviews($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAdditionalImages($id) {
|
public function getAdditionalImages($id)
|
||||||
|
{
|
||||||
return $this->bricksetClient->getAdditionalImages($id);
|
return $this->bricksetClient->getAdditionalImages($id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,10 +119,11 @@ class RebrickableManager
|
|||||||
return $this->serializer->deserialize($data, PartCategory::class, self::FORMAT);
|
return $this->serializer->deserialize($data, PartCategory::class, self::FORMAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPartsByLDrawNumber($number) {
|
public function getPartsByLDrawNumber($number)
|
||||||
|
{
|
||||||
$options = [
|
$options = [
|
||||||
'query' => [
|
'query' => [
|
||||||
'ldraw_id' => $number
|
'ldraw_id' => $number,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -2,13 +2,11 @@
|
|||||||
|
|
||||||
namespace AppBundle\Controller;
|
namespace AppBundle\Controller;
|
||||||
|
|
||||||
use AppBundle\Entity\LDraw\Model;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,8 +28,7 @@ class ModelController extends Controller
|
|||||||
{
|
{
|
||||||
$form = $this->get('form.factory')->create(ModelFilterType::class);
|
$form = $this->get('form.factory')->create(ModelFilterType::class);
|
||||||
|
|
||||||
$filterBuilder = $this->get('repository.ldraw.model')
|
$filterBuilder = $this->get('repository.ldraw.model')->getFilteredQueryBuilder();
|
||||||
->createQueryBuilder('model');
|
|
||||||
|
|
||||||
if ($request->query->has($form->getName())) {
|
if ($request->query->has($form->getName())) {
|
||||||
// manually bind values from the request
|
// manually bind values from the request
|
||||||
@ -62,7 +61,7 @@ class ModelController extends Controller
|
|||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
if($model = $this->get('manager.ldraw.model')->findByNumber($number)) {
|
if ($model = $this->get('repository.ldraw.model')->findOneByNumber($number)) {
|
||||||
try {
|
try {
|
||||||
$rbParts = $model != null ? $em->getRepository(Part::class)->findAllByModel($model) : null;
|
$rbParts = $model != null ? $em->getRepository(Part::class)->findAllByModel($model) : null;
|
||||||
$sets = $model != null ? $em->getRepository(Set::class)->findAllByModel($model) : null;
|
$sets = $model != null ? $em->getRepository(Set::class)->findAllByModel($model) : null;
|
||||||
@ -73,12 +72,11 @@ class ModelController extends Controller
|
|||||||
'model' => $model,
|
'model' => $model,
|
||||||
'rbParts' => $rbParts,
|
'rbParts' => $rbParts,
|
||||||
'sets' => $sets,
|
'sets' => $sets,
|
||||||
'related' => $related
|
'related' => $related,
|
||||||
]);
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->addFlash('error', $e->getMessage());
|
$this->addFlash('error', $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('error/error.html.twig');
|
return $this->render('error/error.html.twig');
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
namespace AppBundle\Controller\Rebrickable;
|
namespace AppBundle\Controller\Rebrickable;
|
||||||
|
|
||||||
use AppBundle\Entity\Rebrickable\Color;
|
use AppBundle\Entity\Rebrickable\Color;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Part controller.
|
* Part controller.
|
||||||
@ -14,10 +14,10 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
|||||||
class ColorController extends Controller
|
class ColorController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @Route("/", name="color_index")
|
* @Route("/", name="color_index")
|
||||||
*/
|
*/
|
||||||
public function indexAction() {
|
public function indexAction()
|
||||||
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$colors = $em->getRepository(Color::class)->findAll();
|
$colors = $em->getRepository(Color::class)->findAll();
|
||||||
|
@ -2,18 +2,13 @@
|
|||||||
|
|
||||||
namespace AppBundle\Controller\Rebrickable;
|
namespace AppBundle\Controller\Rebrickable;
|
||||||
|
|
||||||
use AppBundle\Api\Exception\EmptyResponseException;
|
|
||||||
use AppBundle\Entity\LDraw\Model;
|
|
||||||
use AppBundle\Entity\Rebrickable\Color;
|
use AppBundle\Entity\Rebrickable\Color;
|
||||||
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
||||||
use AppBundle\Entity\Rebrickable\Inventory_Set;
|
use AppBundle\Entity\Rebrickable\Inventory_Set;
|
||||||
use AppBundle\Entity\Rebrickable\Part;
|
use AppBundle\Entity\Rebrickable\Part;
|
||||||
use AppBundle\Entity\Rebrickable\Set;
|
use AppBundle\Entity\Rebrickable\Set;
|
||||||
use AppBundle\Entity\Rebrickable\Theme;
|
|
||||||
use AppBundle\Form\FilterSetType;
|
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,7 +19,8 @@ class SetController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @Route("/{number}/parts", name="rebrickable_set_parts")
|
* @Route("/{number}/parts", name="rebrickable_set_parts")
|
||||||
*/
|
*/
|
||||||
public function partsAction(Set $set) {
|
public function partsAction(Set $set)
|
||||||
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$em->getRepository(Color::class)->findAll();
|
$em->getRepository(Color::class)->findAll();
|
||||||
@ -41,13 +37,15 @@ class SetController extends Controller
|
|||||||
$json = json_encode($template->getContent());
|
$json = json_encode($template->getContent());
|
||||||
$response = new Response($json, 200);
|
$response = new Response($json, 200);
|
||||||
$response->headers->set('Content-Type', 'application/json');
|
$response->headers->set('Content-Type', 'application/json');
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/{number}/sets", name="rebrickable_set_sets")
|
* @Route("/{number}/sets", name="rebrickable_set_sets")
|
||||||
*/
|
*/
|
||||||
public function setsAction(Set $set) {
|
public function setsAction(Set $set)
|
||||||
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$inventorySets = $em->getRepository(Inventory_Set::class)->findAllBySetNumber($set->getNumber());
|
$inventorySets = $em->getRepository(Inventory_Set::class)->findAllBySetNumber($set->getNumber());
|
||||||
@ -59,6 +57,7 @@ class SetController extends Controller
|
|||||||
$json = json_encode($template->getContent());
|
$json = json_encode($template->getContent());
|
||||||
$response = new Response($json, 200);
|
$response = new Response($json, 200);
|
||||||
$response->headers->set('Content-Type', 'application/json');
|
$response->headers->set('Content-Type', 'application/json');
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,9 @@ namespace AppBundle\Controller;
|
|||||||
|
|
||||||
use AppBundle\Api\Exception\ApiException;
|
use AppBundle\Api\Exception\ApiException;
|
||||||
use AppBundle\Api\Exception\EmptyResponseException;
|
use AppBundle\Api\Exception\EmptyResponseException;
|
||||||
use AppBundle\Entity\LDraw\Model;
|
|
||||||
use AppBundle\Entity\Rebrickable\Color;
|
|
||||||
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
||||||
use AppBundle\Entity\Rebrickable\Inventory_Set;
|
|
||||||
use AppBundle\Entity\Rebrickable\Part;
|
|
||||||
use AppBundle\Entity\Rebrickable\Set;
|
use AppBundle\Entity\Rebrickable\Set;
|
||||||
use AppBundle\Entity\Rebrickable\Theme;
|
|
||||||
use AppBundle\Form\Filter\Set\SetFilterType;
|
use AppBundle\Form\Filter\Set\SetFilterType;
|
||||||
use AppBundle\Form\FilterSetType;
|
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@ -50,7 +44,7 @@ class SetController extends Controller
|
|||||||
|
|
||||||
return $this->render('set/index.html.twig', [
|
return $this->render('set/index.html.twig', [
|
||||||
'sets' => $sets,
|
'sets' => $sets,
|
||||||
'form' => $form->createView()
|
'form' => $form->createView(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +58,7 @@ class SetController extends Controller
|
|||||||
try {
|
try {
|
||||||
if (($rebrickableSet = $this->getDoctrine()->getManager()->getRepository(Set::class)->find($number)) == null) {
|
if (($rebrickableSet = $this->getDoctrine()->getManager()->getRepository(Set::class)->find($number)) == null) {
|
||||||
$this->addFlash('warning', 'Set not found in Rebrickable database');
|
$this->addFlash('warning', 'Set not found in Rebrickable database');
|
||||||
};
|
}
|
||||||
|
|
||||||
$bricksetSet = $this->get('api.manager.brickset')->getSetByNumber($number);
|
$bricksetSet = $this->get('api.manager.brickset')->getSetByNumber($number);
|
||||||
dump($bricksetSet);
|
dump($bricksetSet);
|
||||||
@ -85,38 +79,4 @@ class SetController extends Controller
|
|||||||
'brset' => $bricksetSet,
|
'brset' => $bricksetSet,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/{number}/download", name="set_download")
|
|
||||||
*/
|
|
||||||
public function downloadZipAction(Request $request, $number) {
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
$inventoryParts = $em->getRepository(Inventory_Part::class)->findAllRegularBySetNumber($number);
|
|
||||||
|
|
||||||
$zip = new \ZipArchive();
|
|
||||||
$zipName = 'set_'.$number.'.zip';
|
|
||||||
$zip->open($zipName, \ZipArchive::CREATE);
|
|
||||||
/** @var Inventory_Part $part */
|
|
||||||
foreach ($inventoryParts as $part) {
|
|
||||||
$filename = $part->getPart()->getNumber().'_('.$part->getColor()->getName().'_'.$part->getQuantity().'x).stl';
|
|
||||||
|
|
||||||
try {
|
|
||||||
if($part->getPart()->getModel()) {
|
|
||||||
$zip->addFromString($filename, $this->get('oneup_flysystem.media_filesystem')->read($part->getPart()->getModel()->getPath()));
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
dump($e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$zip->close();
|
|
||||||
|
|
||||||
$response = new Response(file_get_contents($zipName));
|
|
||||||
$response->headers->set('Content-Type', 'application/zip');
|
|
||||||
$response->headers->set('Content-Disposition', 'attachment;filename="' . $zipName . '"');
|
|
||||||
$response->headers->set('Content-length', filesize($zipName));
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,6 @@ class Inventory
|
|||||||
*/
|
*/
|
||||||
protected $inventorySets;
|
protected $inventorySets;
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->inventoryParts = new ArrayCollection();
|
$this->inventoryParts = new ArrayCollection();
|
||||||
|
@ -2,18 +2,19 @@
|
|||||||
|
|
||||||
namespace AppBundle\Exception;
|
namespace AppBundle\Exception;
|
||||||
|
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
class ConvertingFailedException extends \Exception
|
class ConvertingFailedException extends \Exception
|
||||||
{
|
{
|
||||||
private $filepath;
|
private $filepath;
|
||||||
|
|
||||||
public function __construct($filepath = "", $message = "", $code = 0, Exception $previous = null)
|
public function __construct($form = '', $to = '', $message = '', $code = 0, Exception $previous = null)
|
||||||
{
|
{
|
||||||
|
$message = sprintf('Error converting "%s" file to "%s".', $form, $to);
|
||||||
|
|
||||||
parent::__construct($message, $code, $previous);
|
parent::__construct($message, $code, $previous);
|
||||||
|
|
||||||
$this->filepath = $filepath;
|
$this->filepath = $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,6 +32,4 @@ class ConvertingFailedException extends \Exception
|
|||||||
{
|
{
|
||||||
$this->filepath = $filepath;
|
$this->filepath = $filepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -7,8 +7,8 @@ use AppBundle\Repository\BaseRepository;
|
|||||||
|
|
||||||
class InventoryRepository extends BaseRepository
|
class InventoryRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
public function findNewestInventoryBySetNumber($number) {
|
public function findNewestInventoryBySetNumber($number)
|
||||||
|
{
|
||||||
$queryBuilder = $this->createQueryBuilder('inventory')
|
$queryBuilder = $this->createQueryBuilder('inventory')
|
||||||
->where('inventory.set = :setNumber')
|
->where('inventory.set = :setNumber')
|
||||||
->setParameter('setNumber', $number)
|
->setParameter('setNumber', $number)
|
||||||
|
@ -6,7 +6,6 @@ use AppBundle\Entity\LDraw\Category;
|
|||||||
use AppBundle\Entity\Rebrickable\Inventory;
|
use AppBundle\Entity\Rebrickable\Inventory;
|
||||||
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
||||||
use AppBundle\Entity\Rebrickable\Part;
|
use AppBundle\Entity\Rebrickable\Part;
|
||||||
use AppBundle\Entity\Rebrickable\Set;
|
|
||||||
use AppBundle\Repository\BaseRepository;
|
use AppBundle\Repository\BaseRepository;
|
||||||
use Doctrine\ORM\Query\Expr\Join;
|
use Doctrine\ORM\Query\Expr\Join;
|
||||||
|
|
||||||
|
@ -3,15 +3,12 @@
|
|||||||
namespace AppBundle\Repository\Rebrickable;
|
namespace AppBundle\Repository\Rebrickable;
|
||||||
|
|
||||||
use AppBundle\Entity\Rebrickable\Inventory;
|
use AppBundle\Entity\Rebrickable\Inventory;
|
||||||
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
|
||||||
use AppBundle\Entity\Rebrickable\Set;
|
|
||||||
use AppBundle\Repository\BaseRepository;
|
use AppBundle\Repository\BaseRepository;
|
||||||
use Doctrine\ORM\Query\Expr\Join;
|
|
||||||
|
|
||||||
class Inventory_SetRepository extends BaseRepository
|
class Inventory_SetRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
public function findAllBySetNumber($number) {
|
public function findAllBySetNumber($number)
|
||||||
|
{
|
||||||
$inventory = $this->getEntityManager()->getRepository(Inventory::class)->findNewestInventoryBySetNumber($number);
|
$inventory = $this->getEntityManager()->getRepository(Inventory::class)->findNewestInventoryBySetNumber($number);
|
||||||
|
|
||||||
if ($inventory) {
|
if ($inventory) {
|
||||||
|
@ -5,7 +5,6 @@ namespace AppBundle\Repository\Rebrickable;
|
|||||||
use AppBundle\Entity\LDraw\Model;
|
use AppBundle\Entity\LDraw\Model;
|
||||||
use AppBundle\Entity\Rebrickable\Inventory;
|
use AppBundle\Entity\Rebrickable\Inventory;
|
||||||
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
use AppBundle\Entity\Rebrickable\Inventory_Part;
|
||||||
use AppBundle\Entity\Rebrickable\Inventory_Set;
|
|
||||||
use AppBundle\Entity\Rebrickable\Part;
|
use AppBundle\Entity\Rebrickable\Part;
|
||||||
use AppBundle\Entity\Rebrickable\Set;
|
use AppBundle\Entity\Rebrickable\Set;
|
||||||
use AppBundle\Entity\Rebrickable\Theme;
|
use AppBundle\Entity\Rebrickable\Theme;
|
||||||
@ -14,8 +13,8 @@ use Doctrine\ORM\Query\Expr\Join;
|
|||||||
|
|
||||||
class SetRepository extends BaseRepository
|
class SetRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
public function findAllByTheme(Theme $theme) {
|
public function findAllByTheme(Theme $theme)
|
||||||
|
{
|
||||||
dump($this->getEntityManager()->getRepository(Theme::class)->findAllSubthemes($theme));
|
dump($this->getEntityManager()->getRepository(Theme::class)->findAllSubthemes($theme));
|
||||||
|
|
||||||
$queryBuilder = $this->createQueryBuilder('s')
|
$queryBuilder = $this->createQueryBuilder('s')
|
||||||
|
@ -8,8 +8,8 @@ use Doctrine\ORM\Query\Expr\Join;
|
|||||||
|
|
||||||
class ThemeRepository extends BaseRepository
|
class ThemeRepository extends BaseRepository
|
||||||
{
|
{
|
||||||
public function findAllSubthemes(Theme $theme) {
|
public function findAllSubthemes(Theme $theme)
|
||||||
|
{
|
||||||
$subQueryBuilder = $this->createQueryBuilder('subtheme');
|
$subQueryBuilder = $this->createQueryBuilder('subtheme');
|
||||||
|
|
||||||
$queryBuilder = $this->createQueryBuilder('subtheme')
|
$queryBuilder = $this->createQueryBuilder('subtheme')
|
||||||
|
@ -3,9 +3,6 @@
|
|||||||
namespace AppBundle\Twig;
|
namespace AppBundle\Twig;
|
||||||
|
|
||||||
use AppBundle\Api\Manager\RebrickableManager;
|
use AppBundle\Api\Manager\RebrickableManager;
|
||||||
use AppBundle\Entity\Rebrickable\Color;
|
|
||||||
use AppBundle\Entity\Rebrickable\Part;
|
|
||||||
use AppBundle\Entity\Rebrickable\Set;
|
|
||||||
|
|
||||||
class AppExtension extends \Twig_Extension
|
class AppExtension extends \Twig_Extension
|
||||||
{
|
{
|
||||||
@ -30,7 +27,8 @@ class AppExtension extends \Twig_Extension
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFunctions() {
|
public function getFunctions()
|
||||||
|
{
|
||||||
return [
|
return [
|
||||||
new \Twig_SimpleFunction('remoteSize', [$this, 'remoteSize']),
|
new \Twig_SimpleFunction('remoteSize', [$this, 'remoteSize']),
|
||||||
new \Twig_SimpleFunction('remoteFilename', [$this, 'remoteFilename']),
|
new \Twig_SimpleFunction('remoteFilename', [$this, 'remoteFilename']),
|
||||||
@ -47,21 +45,24 @@ class AppExtension extends \Twig_Extension
|
|||||||
return '/sets/'.strtolower($number).'.jpg';
|
return '/sets/'.strtolower($number).'.jpg';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function remoteSize($url) {
|
public function remoteSize($url)
|
||||||
|
{
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_HEADER, TRUE);
|
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||||
curl_setopt($ch, CURLOPT_NOBODY, TRUE);
|
curl_setopt($ch, CURLOPT_NOBODY, true);
|
||||||
|
|
||||||
$data = curl_exec($ch);
|
$data = curl_exec($ch);
|
||||||
$size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
|
$size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
return $size;
|
return $size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function remoteFilename($url) {
|
public function remoteFilename($url)
|
||||||
|
{
|
||||||
return basename($url);
|
return basename($url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user