Procházet zdrojové kódy

Amélioration formulaire PRoductFamily & Gestion des erreurs & Intégration des caractéristqiues

reduction
Fab před 4 roky
rodič
revize
d175bd7c53
6 změnil soubory, kde provedl 52 přidání a 15 odebrání
  1. +1
    -1
      ShopBundle/Controller/Admin/MerchantController.php
  2. +1
    -1
      ShopBundle/Controller/CitiesController.php
  3. +9
    -6
      ShopBundle/Repository/NewsRepository.php
  4. +10
    -0
      ShopBundle/Repository/PointSaleRepository.php
  5. +15
    -0
      ShopBundle/Services/Utils.php
  6. +16
    -7
      ShopBundle/Twig/FrontendTwigExtension.php

+ 1
- 1
ShopBundle/Controller/Admin/MerchantController.php Zobrazit soubor

@@ -40,7 +40,7 @@ class MerchantController extends AdminController
$newMerchantConfig = new $classMerchantConfig ;
$newMerchantConfig
->setName($key)
->setMerchant($this->security->getUser()->getMerchant()) ;
->setMerchant($entity) ;
if(isset($option['default'])) {
$newMerchantConfig->setValue($option['default']) ;
}

+ 1
- 1
ShopBundle/Controller/CitiesController.php Zobrazit soubor

@@ -24,7 +24,7 @@ class CitiesController extends AbstractController
'boost' => 'population',
] ;

if(strlen($term) == 5) {
if(strlen($term) == 5 && is_numeric($term)) {
$data['codePostal'] = $term ;
}
else {

+ 9
- 6
ShopBundle/Repository/NewsRepository.php Zobrazit soubor

@@ -19,12 +19,15 @@ class NewsRepository extends BaseRepository implements DefaultRepositoryInterfac
return NewsInterface::class;
}

public function findLastNewsHome()
public function findLatests($maxResults = 0)
{
return $this->findByMerchantQuery()
->orderBy('e.date', 'DESC')
->setMaxResults(2)
->getQuery()
->getResult();
$result = $this->findByMerchantQuery()
->orderBy('e.date', 'DESC') ;

if($maxResults) {
$result->setMaxResults($maxResults) ;
}

return $result->getQuery()->getResult() ;
}
}

+ 10
- 0
ShopBundle/Repository/PointSaleRepository.php Zobrazit soubor

@@ -19,4 +19,14 @@ class PointSaleRepository extends BaseRepository implements DefaultRepositoryInt
return PointSaleInterface::class;
}

public function findAllPublics()
{
return $this->createQueryBuilder('e')
->where(':currentMerchant MEMBER OF e.merchants')
->andWhere('e.isPublic = 1')
->setParameter('currentMerchant', $this->globalParam->getCurrentMerchant())
->getQuery()
->getResult() ;
}

}

+ 15
- 0
ShopBundle/Services/Utils.php Zobrazit soubor

@@ -130,4 +130,19 @@ class Utils
return $this->em->getRepository($class)->findOneByDevAlias($devAlias) ;
}


public function isServerLocalhost()
{
return in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']) ;
}

function limitText($text, $limit) {
if (str_word_count($text, 0) > $limit) {
$words = str_word_count($text, 2);
$pos = array_keys($words);
$text = substr($text, 0, $pos[$limit]) . '...';
}
return $text;
}

}

+ 16
- 7
ShopBundle/Twig/FrontendTwigExtension.php Zobrazit soubor

@@ -2,6 +2,7 @@

namespace Lc\ShopBundle\Twig;

use App\Repository\HubRepository;
use App\Services\GlobalParam;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Form\Frontend\NewsletterType;
@@ -16,16 +17,18 @@ class FrontendTwigExtension extends AbstractExtension
{
protected $em ;
protected $security ;
protected $repositoryProductCategory ;
protected $globalParam ;
protected $formFactory ;
protected $productCategoryRepository ;
protected $hubRepository ;

public function __construct(EntityManagerInterface $em, Security $security, ProductCategoryRepository $repositoryProductCategory,
GlobalParam $globalParam, FormFactoryInterface $formFactory)
public function __construct(EntityManagerInterface $em, Security $security, ProductCategoryRepository $productCategoryRepository,
GlobalParam $globalParam, FormFactoryInterface $formFactory, HubRepository $hubRepository)
{
$this->em = $em ;
$this->security = $security ;
$this->repositoryProductCategory = $repositoryProductCategory ;
$this->productCategoryRepository = $productCategoryRepository ;
$this->hubRepository = $hubRepository ;
$this->globalParam = $globalParam ;
$this->formFactory = $formFactory ;
}
@@ -35,19 +38,20 @@ class FrontendTwigExtension extends AbstractExtension
return array(
new TwigFunction('get_product_categories', [$this, 'getProductCategories']),
new TwigFunction('get_form_newsletter', [$this, 'getFormNewsletter']),
new TwigFunction('get_merchants', [$this, 'getMerchants']),
);
}

public function getFilters()
{
return [
new TwigFilter('format_price', [$this, 'format_price']),
new TwigFilter('format_price', [$this, 'formatPrice']),
];
}

public function getProductCategories()
{
$categories = $this->repositoryProductCategory->findAllParents($this->globalParam->getCurrentMerchant()) ;
$categories = $this->productCategoryRepository->findAllParents($this->globalParam->getCurrentMerchant()) ;
return $categories ;
}

@@ -57,7 +61,7 @@ class FrontendTwigExtension extends AbstractExtension
return $form->createView() ;
}

public function format_price($price)
public function formatPrice($price)
{
$price = number_format($price, 2) ;
$price = str_replace('.',',',$price) ;
@@ -65,4 +69,9 @@ class FrontendTwigExtension extends AbstractExtension
return $price ;
}

public function getMerchants()
{
return $this->hubRepository->findAll() ;
}

}

Načítá se…
Zrušit
Uložit