소스 검색

Components

develop
Guillaume 3 년 전
부모
커밋
9887f6be5d
11개의 변경된 파일880개의 추가작업 그리고 5개의 파일을 삭제
  1. +134
    -0
      Component/CitiesComponent.php
  2. +55
    -0
      Component/DateComponent.php
  3. +88
    -0
      Component/FileComponent.php
  4. +33
    -0
      Component/FormComponent.php
  5. +78
    -0
      Component/MetaComponent.php
  6. +14
    -0
      Component/NumberComponent.php
  7. +77
    -0
      Component/PointLocationComponent.php
  8. +198
    -0
      Component/StringComponent.php
  9. +138
    -0
      Generator/CsvGenerator.php
  10. +41
    -5
      Repository/Reminder/ReminderStore.php
  11. +24
    -0
      Resolver/UrlResolver.php

+ 134
- 0
Component/CitiesComponent.php 파일 보기

@@ -0,0 +1,134 @@
<?php

namespace Lc\SovBundle\Component;

use Geocoder\Model\Coordinates;
use Geocoder\Provider\Addok\Addok;
use Geocoder\Provider\GoogleMaps\GoogleMaps;
use Geocoder\Provider\Nominatim\Nominatim;
use Geocoder\Query\GeocodeQuery;
use Geocoder\Query\ReverseQuery;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpClient\HttplugClient;

class CitiesComponent
{
protected ParameterBagInterface $parameterBag;

public function __construct(ParameterBagInterface $parameterBag)
{
$this->parameterBag = $parameterBag;
}

public function callCitiesApi($method, $url, $data = false)
{
$url = 'https://geo.api.gouv.fr/' . $url;
$curl = curl_init();

switch ($method) {
case "POST":
curl_setopt($curl, CURLOPT_POST, 1);

if ($data) {
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
break;
case "PUT":
curl_setopt($curl, CURLOPT_PUT, 1);
break;
default:
if ($data) {
$url = sprintf("%s?%s", $url, http_build_query($data));
}
}

// Optional Authentication:
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "username:password");

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($curl);

curl_close($curl);

return $result;
}

public function getGeocoderProvider()
{
$provider = false;
$symfonyClient = new HttplugClient();
$configGeocoderProvider = $this->parameterBag->get('geocoder.provider');

/* API du gouvernement */
if ($configGeocoderProvider == 'addok') {
$provider = new Addok($symfonyClient, 'https://api-adresse.data.gouv.fr');
} /* Google Maps */
elseif ($configGeocoderProvider == 'googlemaps') {
$provider = new GoogleMaps($symfonyClient, null, $this->parameterBag->get('geocoder.api_key'));
} /* Nominatim : OpenStreetMap */
elseif ($configGeocoderProvider == 'nominatim') {
$provider = Nominatim::withOpenStreetMapServer(
$symfonyClient,
'Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion'
);
}

if (!$provider) {
throw new \ErrorException('Aucun provider (geocoding) défini');
}

return $provider;
}

public function callAddressApi($query)
{
$provider = $this->getGeocoderProvider() ;;
$query = GeocodeQuery::create($query)->withData('type', 'housenumber');
$results = $provider->geocodeQuery($query);
$resultsToReturn = array();
foreach($results as $result) {
if ($result->getStreetNumber() && strlen($result->getStreetNumber()) > 0) {
$resultsToReturn[] = $result;
}
}
return $resultsToReturn;
}

public function callReverseAddressApi($latitude, $longitude)
{
$provider = $this->getGeocoderProvider() ;;
$query = ReverseQuery::create(new Coordinates($latitude, $longitude));
$results = $provider->reverseQuery($query);
return $results->all() ;
}

public function getZipByCity($city, $code = null)
{
$zip = null;

$paramsSearch = [
'nom' => $city,
'fields' => 'nom,codesPostaux'
];

if ($code != null && $code != 0) {
$paramsSearch['code'] = $code;
}

$returnCitiesSearchZip = json_decode($this->callCitiesApi('get', 'communes', $paramsSearch));

if ($returnCitiesSearchZip) {
foreach ($returnCitiesSearchZip as $citySearchZip) {
if (strtolower(trim($city)) == strtolower(trim($citySearchZip->nom))) {
$zip = $citySearchZip->codesPostaux[0];
}
}
}

return $zip;
}

}

+ 55
- 0
Component/DateComponent.php 파일 보기

@@ -0,0 +1,55 @@
<?php

namespace Lc\SovBundle\Component;

class DateComponent
{

public function date($format, $timestamp)
{
setlocale(LC_TIME, 'fr_FR.UTF8', 'fr.UTF8', 'fr_FR.UTF-8', 'fr.UTF-8');
return strftime($format, $timestamp);
}

public function getNextDay($day)
{
return new \DateTime('next ' . $day);
}

public function getNextDayByNumber($number)
{
return $this->getNextDay($this->getDayByNumber($number, 'en'));
}

public static function getDayByNumber($number, $lang = 'fr')
{
if ($lang == 'fr') {
$daysArray = [
1 => 'Lundi',
2 => 'Mardi',
3 => 'Mercredi',
4 => 'Jeudi',
5 => 'Vendredi',
6 => 'Samedi',
7 => 'Dimanche'
];
} else {
$daysArray = [
1 => 'Monday',
2 => 'Tuesday',
3 => 'Wednesday',
4 => 'Thursday',
5 => 'Friday',
6 => 'Saturday',
7 => 'Sunday',
];
}

if (isset($daysArray[$number])) {
return $daysArray[$number];
}

return '';
}

}

+ 88
- 0
Component/FileComponent.php 파일 보기

@@ -0,0 +1,88 @@
<?php

namespace Lc\SovBundle\Component;


use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

class FileComponent
{
protected ParameterBagInterface $parameterBag;

public function __construct(ParameterBagInterface $parameterBag)
{
$this->parameterBag = $parameterBag;
}

/**
* Retourne le chemin vers le dossier d'uploads de responsiveFilemanager
*
* @return string
*/
public function getFileManagerFolder()
{
return $this->parameterBag->get('app.path.images');
}

// lcLiip
public function liip($path, $thumb = 'tile', $default = 'default.jpg')
{
if (substr($path, 0, 1) === '/') $path = substr($path, 1);

if ($path) {
$fileManagerFolder = substr($this->getFileManagerFolder(), 1) ;

if (strpos($path, $fileManagerFolder) === false) {
$path = $fileManagerFolder . '/' . $path;
}

if (file_exists($path)) {
return $this->liipCacheHelper->getBrowserPath($path, $thumb);
}
}

return $this->liipCacheHelper->getBrowserPath($this->getFileManagerFolder() . '/' . $default, $thumb);
}

public function removeDir($dir)
{
$files = array_diff(scandir($dir), array('.', '..'));
foreach ($files as $file) {
(is_dir("$dir/$file")) ? $this->removeDir("$dir/$file") : unlink("$dir/$file");
}
return rmdir($dir);
}

function folderToZip($folder, &$zipFile, $subfolder = null)
{
if ($zipFile == null) {
// no resource given, exit
return false;
}
// we check if $folder has a slash at its end, if not, we append one
$tabFolder = str_split($folder);
$tabSubFolder = str_split($subfolder);
$folder .= end($tabFolder) == "/" ? "" : "/";
$subfolder .= end($tabSubFolder) == "/" ? "" : "/";
// we start by going through all files in $folder
$handle = opendir($folder);
while ($f = readdir($handle)) {
if ($f != "." && $f != "..") {
if (is_file($folder . $f)) {
// if we find a file, store it
// if we have a subfolder, store it there
if ($subfolder != null)
$zipFile->addFile($folder . $f, $subfolder . $f);
else
$zipFile->addFile($folder . $f);
} elseif (is_dir($folder . $f)) {
// if we find a folder, create a folder in the zip
$zipFile->addEmptyDir($f);
// and call the function again
folderToZip($folder . $f, $zipFile, $f);
}
}
}
}

}

+ 33
- 0
Component/FormComponent.php 파일 보기

@@ -0,0 +1,33 @@
<?php

namespace Lc\SovBundle\Component;

use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;

class FormComponent
{
protected ParameterBagInterface $parameterBag;

public function __construct(ParameterBagInterface $parameterBag)
{
$this->parameterBag = $parameterBag;
}

public function addCaptchaType(FormBuilderInterface $builder)
{
$builder->add('specialField', HiddenType::class, [
'data' => 0,
'mapped' => false,
'attr' => [
'class' => 'special-field'
],
'constraints' => [
new NotNull(),
new EqualTo(['value' => $this->parameterBag->get('app.captcha_value'), 'message' => 'Valeur incorrecte'])
],
]);
}

}

+ 78
- 0
Component/MetaComponent.php 파일 보기

@@ -0,0 +1,78 @@
<?php

namespace Lc\SovBundle\Component;

class MetaComponent
{

public function getMetaTitle($entity)
{
if($entity) {
if(method_exists($entity, 'getMetaTitle')) {
return $entity->getMetaTitle() ;
}
elseif(method_exists($entity, 'getTitle')) {
return $entity->getTitle() ;
}
}

return '' ;
}

public function getMetaDescription($entity)
{
if($entity) {
if(method_exists($entity, 'getMetaDescription')) {
return $entity->getMetaDescription() ;
}
elseif(method_exists($entity, 'getDescription')) {
return $entity->getDescription() ;
}
}

return '' ;
}

public function getOpenGraphTitle($entity)
{
if($entity) {
if(method_exists($entity, 'getOpenGraphTitle')) {
return $entity->getOpenGraphTitle() ;
}
elseif(method_exists($entity, 'getTitle')) {
return $entity->getTitle() ;
}
}

return '' ;
}

public function getOpenGraphDescription($entity)
{
if($entity) {
if(method_exists($entity, 'getOpenGraphDescription')) {
return $entity->getOpenGraphDescription() ;
}
elseif(method_exists($entity, 'getDescription')) {
return $entity->getDescription() ;
}
}

return '' ;
}

public function getOpenGraphImage($entity)
{
if($entity) {
if(method_exists($entity, 'getOpenGraphImage')) {
return $entity->getOpenGraphImage() ;
}
elseif(method_exists($entity, 'getImage')) {
return $entity->getImage() ;
}
}

return '' ;
}

}

+ 14
- 0
Component/NumberComponent.php 파일 보기

@@ -0,0 +1,14 @@
<?php

namespace Lc\SovBundle\Component;


class NumberComponent
{
public function round($price, $precision = 2)
{
return round((($price * 100)) / 100, $precision);
}


}

+ 77
- 0
Component/PointLocationComponent.php 파일 보기

@@ -0,0 +1,77 @@
<?php

namespace Lc\SovBundle\Component;

class PointLocationComponent
{
var $pointOnVertex = true; // Check if the point sits exactly on one of the vertices?

function pointInPolygon($point, $polygon, $pointOnVertex = true)
{
$this->pointOnVertex = $pointOnVertex;

// Transform string coordinates into arrays with x and y values
$point = $this->pointStringToCoordinates($point);
$vertices = array();
foreach ($polygon as $vertex) {
$vertices[] = $this->pointStringToCoordinates($vertex);
}

// Check if the point sits exactly on a vertex
if ($this->pointOnVertex == true and $this->pointOnVertex($point, $vertices) == true) {
return "vertex";
}

// Check if the point is inside the polygon or on the boundary
$intersections = 0;
$vertices_count = count($vertices);

for ($i = 1; $i < $vertices_count; $i++) {
$vertex1 = $vertices[$i - 1];
$vertex2 = $vertices[$i];
if ($vertex1['y'] == $vertex2['y'] and $vertex1['y'] == $point['y'] and $point['x'] > min(
$vertex1['x'],
$vertex2['x']
) and $point['x'] < max(
$vertex1['x'],
$vertex2['x']
)) { // Check if point is on an horizontal polygon boundary
return "boundary";
}
if ($point['y'] > min($vertex1['y'], $vertex2['y']) and $point['y'] <= max(
$vertex1['y'],
$vertex2['y']
) and $point['x'] <= max($vertex1['x'], $vertex2['x']) and $vertex1['y'] != $vertex2['y']) {
$xinters = ($point['y'] - $vertex1['y']) * ($vertex2['x'] - $vertex1['x']) / ($vertex2['y'] - $vertex1['y']) + $vertex1['x'];
if ($xinters == $point['x']) { // Check if point is on the polygon boundary (other than horizontal)
return "boundary";
}
if ($vertex1['x'] == $vertex2['x'] || $point['x'] <= $xinters) {
$intersections++;
}
}
}
// If the number of edges we passed through is odd, then it's in the polygon.
if ($intersections % 2 != 0) {
return "inside";
} else {
return "outside";
}
}

function pointOnVertex($point, $vertices)
{
foreach ($vertices as $vertex) {
if ($point == $vertex) {
return true;
}
}
}

function pointStringToCoordinates($pointString)
{
$coordinates = explode(" ", $pointString);
return array("x" => $coordinates[0], "y" => $coordinates[1]);
}

}

+ 198
- 0
Component/StringComponent.php 파일 보기

@@ -0,0 +1,198 @@
<?php

namespace Lc\SovBundle\Component;

use Cocur\Slugify\Slugify;

class StringComponent
{
public function limitText($text, $limit)
{
$text = strip_tags($text);
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;
}

public function limitTextByLength($text, $length, $append = '...')
{
if (strlen($text) > $length) {
$text = substr($text, 0, $length) . $append;
}

return $text;
}

function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
{
if ($considerHtml) {
// if the plain text is shorter than the maximum length, return the whole text
if (strlen(preg_replace('/<.*?>/', '', $text)) <= $length) {
return $text;
}
// splits all html-tags to scanable lines
preg_match_all('/(<.+?>)?([^<>]*)/s', $text, $lines, PREG_SET_ORDER);
$total_length = strlen($ending);
$open_tags = array();
$truncate = '';
foreach ($lines as $line_matchings) {
// if there is any html-tag in this line, handle it and add it (uncounted) to the output
if (!empty($line_matchings[1])) {
// if it's an "empty element" with or without xhtml-conform closing slash
if (preg_match(
'/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is',
$line_matchings[1]
)) {
// do nothing
// if tag is a closing tag
} else {
if (preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
// delete tag from $open_tags list
$pos = array_search($tag_matchings[1], $open_tags);
if ($pos !== false) {
unset($open_tags[$pos]);
}
// if tag is an opening tag
} else {
if (preg_match('/^<\s*([^\s>!]+).*?>$/s', $line_matchings[1], $tag_matchings)) {
// add tag to the beginning of $open_tags list
array_unshift($open_tags, strtolower($tag_matchings[1]));
}
}
}
// add html-tag to $truncate'd text
$truncate .= $line_matchings[1];
}
// calculate the length of the plain text part of the line; handle entities as one character
$content_length = strlen(
preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2])
);
if ($total_length + $content_length > $length) {
// the number of characters which are left
$left = $length - $total_length;
$entities_length = 0;
// search for html entities
if (preg_match_all(
'/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i',
$line_matchings[2],
$entities,
PREG_OFFSET_CAPTURE
)) {
// calculate the real length of all entities in the legal range
foreach ($entities[0] as $entity) {
if ($entity[1] + 1 - $entities_length <= $left) {
$left--;
$entities_length += strlen($entity[0]);
} else {
// no more characters left
break;
}
}
}
$truncate .= substr($line_matchings[2], 0, $left + $entities_length);
// maximum lenght is reached, so get off the loop
break;
} else {
$truncate .= $line_matchings[2];
$total_length += $content_length;
}
// if the maximum length is reached, get off the loop
if ($total_length >= $length) {
break;
}
}
} else {
if (strlen($text) <= $length) {
return $text;
} else {
$truncate = substr($text, 0, $length - strlen($ending));
}
}
// if the words shouldn't be cut in the middle...
if (!$exact) {
// ...search the last occurance of a space...
$spacepos = strrpos($truncate, ' ');
if (isset($spacepos)) {
// ...and cut the text in this position
$truncate = substr($truncate, 0, $spacepos);
}
}
// add the defined ending to the text
$truncate .= $ending;
if ($considerHtml) {
// close all unclosed html-tags
foreach ($open_tags as $tag) {
$truncate .= '</' . $tag . '>';
}
}
return $truncate;
}

function stripAccents($stripAccents)
{
return strtr(
$stripAccents,
'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ',
'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY'
);
}

function cleanStringToCompare($string)
{
return $this->stripAccents(trim(strtolower($string)));
}

public function slugify($string)
{
$slugify = new Slugify();
return $slugify->slugify($string);
}

function camelCase($str)
{
$i = array("-", "_");
$str = preg_replace('/([a-z])([A-Z])/', "\\1 \\2", $str);
$str = preg_replace('@[^a-zA-Z0-9\-_ ]+@', '', $str);
$str = str_replace($i, ' ', $str);
$str = str_replace(' ', '', ucwords(strtolower($str)));
$str = strtolower(substr($str, 0, 1)) . substr($str, 1);
return $str;
}

function snakeCase($str)
{
$str = preg_replace('/([a-z])([A-Z])/', "\\1_\\2", $str);
$str = strtolower($str);
return $str;
}

public function csvEscape($str)
{
return str_replace(array("\r", "\n"), ' ', $str);
}

public function urlEncryptData($datas){
$key = 'secretToken';
foreach ($datas as $data) {
$key .= $data;
}
return md5($key);
}

public function formatPhoneNumber($phone)
{
$phone = preg_replace('`[^0-9]`', '', $phone);
if(strlen($phone) == 10) {
$phone = '+33'.substr($phone, 1, 9) ;
}
elseif(strlen($phone) == 11 && substr($phone, 0, 2) == '33') {
$phone = '+'.$phone ;
}

return $phone ;
}

}

+ 138
- 0
Generator/CsvGenerator.php 파일 보기

@@ -0,0 +1,138 @@
<?php

namespace Lc\SovBundle\Generator;

use Symfony\Component\HttpFoundation\StreamedResponse;

class CsvGenerator
{
protected $arrayToExport;
protected $columns;
protected $titleDocument;

protected $convertEncoding ;
protected $fromEncoding ;
protected $toEncoding ;
protected $delimiter ;

public function __construct()
{
$this->arrayToExport = array();
$this->titleDocument = 'csv_file';
$this->convertEncoding = false ;
$this->fromEncoding = 'UTF-8' ;
$this->toEncoding = 'ISO-8859-1' ;
$this->delimiter = ';' ;
}

public function enableConvertEncoding($toEncoding, $fromEncoding = null)
{
$this->convertEncoding = true ;
$this->toEncoding = $toEncoding ;

if(!is_null($fromEncoding)) {
$this->fromEncoding = $fromEncoding ;
}
}

public function encode($value)
{
if($this->convertEncoding) {
return mb_convert_encoding(
$value,
$this->toEncoding,
$this->fromEncoding) ;
}

return $value ;
}

public function encodeArray($array)
{
if($array && is_array($array)) {
return array_map(function($value) {
return $this->encode($value) ;
}, $array) ;
}

return $array ;
}

public function setTitle($title, $displayHeader = false){

$this->titleDocument = $this->formatTitle($title);

if($displayHeader) {
array_unshift($this->arrayToExport, array(''));
array_unshift($this->arrayToExport, array($title));
}
}

public function setColumns($columns, $displayLegend = true) {
$this->columns = array_fill_keys(array_keys($columns), null);
if($displayLegend) $this->row($columns);
}

public function cell($column, $value){
$this->arrayToExport[] = array_merge(
$this->columns,
array($column => $this->encode($value))
);
}

public function row($values = null, $row = false){

$values = $this->encodeArray($values) ;

if(!$row){
if($values)$this->arrayToExport[] = array_merge($this->columns, $values);
else $this->arrayToExport[] = array();
}else{
if($values)$this->arrayToExport[$row] = array_merge($this->columns, $values);
else $this->arrayToExport[$row] = array();
}
}

public function emptyRow()
{
$this->row([]) ;
}

public function dump(){
dump($this->arrayToExport);
}

public function createCsv($path)
{
$handle = fopen($path, 'w+');

foreach ($this->arrayToExport as $line) {
fputcsv($handle, $line, $this->getDelimiter(), "\"");
}
fclose($handle);
}

public function getReponse(){
$response = new StreamedResponse(function () {
$this->createCsv('php://output');
});
$response->headers->set('Content-Encoding', $this->toEncoding);
$response->headers->set('Content-Type', 'application/force-download');
$response->headers->set('Content-Disposition', 'attachment; filename="'.$this->titleDocument.'.csv"');
return $response;
}
private function formatTitle($str) {
$str = str_replace("-", ' ', $str);
$str = preg_replace('/\s+/', '_',$str);;
//$str = str_replace(" ", '_', $str);
$str = iconv('UTF-8', 'ASCII//TRANSLIT', $str);

return $str;
}


public function getDelimiter()
{
return $this->delimiter ;
}
}

+ 41
- 5
Repository/Reminder/ReminderStore.php 파일 보기

@@ -15,25 +15,25 @@ class ReminderStore extends AbstractStore implements ReminderStoreInterface

public function get($params = [], $query = null)
{
if(is_null($query)) {
if (is_null($query)) {
$query = $this->query->create();
}

$query->filterDone();

if(array_key_exists('user', $params)) {
if (array_key_exists('user', $params)) {
$query->filterUser($params['user']);
}

if(array_key_exists('crudAction', $params)) {
if (array_key_exists('crudAction', $params)) {
$query->filterCrudAction($params['crudAction']);
}

if(array_key_exists('crudControllerFqcn', $params)) {
if (array_key_exists('crudControllerFqcn', $params)) {
$query->filterCrudControllerFqcn($params['crudControllerFqcn']);
}

if(array_key_exists('entityId', $params)) {
if (array_key_exists('entityId', $params)) {
$query->filterEntityId($params['entityId']);
}

@@ -42,6 +42,42 @@ class ReminderStore extends AbstractStore implements ReminderStoreInterface
return $query->find();
}

/*

public function getRemindersByUser($user)
{
$reminderRepo = $this->em->getRepository(ReminderInterface::class);


$reminders = $reminderRepo->findByUser($user);

$entitiesRepo = array();
$entitiesConfig = array();
if (count($reminders) > 0) {
foreach ($reminders as $reminder) {
if ($reminder->getEntityName()) {
if (!isset($entitiesConfig[$reminder->getEntityName()])) {
$entitiesConfig[$reminder->getEntityName()] = $this->configManager->getEntityConfig($reminder->getEntityName());
}
if ($reminder->getEntityAction() == 'edit' || $reminder->getEntityAction() == 'show') {
if (!isset($entitiesRepo[$reminder->getEntityName()])) {
$entitiesRepo[$reminder->getEntityName()] = $this->em->getRepository($entitiesConfig[$reminder->getEntityName()]['class']);
}

if ($reminder->getEntityId()) {
$reminder->relatedPage = $entitiesRepo[$reminder->getEntityName()]->find($reminder->getEntityId())->__toString();
}
} else {
$reminder->relatedPage = 'Liste de ' . $entitiesConfig[$reminder->getEntityName()]['label'];
}
}
}
}
return $reminders;
}

*/

/*
public function findByUser($user)
{

+ 24
- 0
Resolver/UrlResolver.php 파일 보기

@@ -7,13 +7,37 @@
namespace Lc\SovBundle\Resolver;


use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

class UrlResolver
{
protected ParameterBagInterface $parameterBag;

public function __construct(ParameterBagInterface $parameterBag)
{
$this->parameterBag = $parameterBag;
}

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

public function getCookieDomain()
{
return ($this->isServerLocalhost()) ? null : $this->parameterBag->get('app.cookie_domain_distant');
}

public function isBot()
{
if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match(
'/bot|crawl|slurp|spider/i',
$_SERVER['HTTP_USER_AGENT']
)) {
return true;
} else {
return false;
}
}

}

Loading…
취소
저장