Remove vendored-in doctrine dbal

This commit is contained in:
Björn Fromme
2018-09-29 14:36:44 +02:00
parent eaf8804e46
commit 2106ad85d5
23 changed files with 403 additions and 308 deletions
-1
View File
@@ -53,7 +53,6 @@
"typo3-ter/pb-social": "^1.3",
"typo3-ter/sourceopt": "^1.0",
"typo3-ter/html-compress": "^1.1",
"doctrine/dbal": "^2.5",
"yohang/calendr": "^2.1",
"wyrihaximus/html-compress": "^1.4",
"symfony/property-access": "^3.4",
Generated
+58 -58
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0336ff7055dae975d70aea8153e7b798",
"content-hash": "40771053625b784cf25db1a787dc19b4",
"packages": [
{
"name": "christophlehmann/imageoptimizer",
@@ -1265,63 +1265,6 @@
],
"time": "2018-02-06T08:27:03+00:00"
},
{
"name": "league/period",
"version": "3.4.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/period.git",
"reference": "280b54d737b4d9d804d19f865a6496b82d1cee2a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/period/zipball/280b54d737b4d9d804d19f865a6496b82d1cee2a",
"reference": "280b54d737b4d9d804d19f865a6496b82d1cee2a",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^1.10",
"phpunit/phpunit": "^4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.2-dev"
}
},
"autoload": {
"psr-4": {
"League\\Period\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ignace Nyamagana Butera",
"email": "[email protected]",
"homepage": "https://github.com/nyamsprod/",
"role": "Developer"
}
],
"description": "A time range immutable value object",
"homepage": "http://period.thephpleague.com",
"keywords": [
"date",
"dateinterval",
"dateperiod",
"datetime",
"interval",
"range",
"time"
],
"time": "2017-11-17T11:28:33+00:00"
},
{
"name": "linkorb/jsmin-php",
"version": "1.0.0",
@@ -3636,6 +3579,63 @@
],
"time": "2018-02-27T17:29:10+00:00"
},
{
"name": "league/period",
"version": "3.4.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/period.git",
"reference": "280b54d737b4d9d804d19f865a6496b82d1cee2a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/period/zipball/280b54d737b4d9d804d19f865a6496b82d1cee2a",
"reference": "280b54d737b4d9d804d19f865a6496b82d1cee2a",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^1.10",
"phpunit/phpunit": "^4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.2-dev"
}
},
"autoload": {
"psr-4": {
"League\\Period\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ignace Nyamagana Butera",
"email": "[email protected]",
"homepage": "https://github.com/nyamsprod/",
"role": "Developer"
}
],
"description": "A time range immutable value object",
"homepage": "http://period.thephpleague.com",
"keywords": [
"date",
"dateinterval",
"dateperiod",
"datetime",
"interval",
"range",
"time"
],
"time": "2017-11-17T11:28:33+00:00"
},
{
"name": "pimple/pimple",
"version": "v3.2.3",
@@ -26,7 +26,7 @@ namespace EP\EpEvents\Hooks;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use EP\EpProducts\Utility\DbUtility;
use EP\EpProducts\Traits\DbConnectionTrait;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
@@ -34,12 +34,14 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
class Tcemain
{
use DbConnectionTrait;
/**
* @param array $fields
* @param string $table
* @param int $id
* @param DataHandler $obj
* @throws \Doctrine\DBAL\DBALException
*/
public function processDatamap_preProcessFieldArray(array &$fields, $table, $id, DataHandler $obj)
{
@@ -52,7 +54,7 @@ class Tcemain
$settings = $this->getSettings();
$detailPageUid = $settings['plugin']['tx_epevents']['settings']['offerDetailPageUid'];
if ((int) $detailPageUid > 0) {
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$qb
->delete('tx_realurl_urldata')
->where('page_id = :pageUid')
@@ -74,4 +76,5 @@ class Tcemain
$configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT)
);
}
}
@@ -28,13 +28,15 @@ namespace EP\EpProducts\Domain\Repository;
***************************************************************/
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Query\QueryBuilder;
use EP\EpProducts\Domain\Model\Date;
use EP\EpProducts\Domain\Model\FilterSettings;
use EP\EpProducts\Traits\DbConnectionTrait;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
abstract class AbstractRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{
use DbConnectionTrait;
public function initializeObject()
{
@@ -46,6 +48,7 @@ abstract class AbstractRepository extends \TYPO3\CMS\Extbase\Persistence\Reposit
/**
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public function getListByUids(array $uids = [])
{
@@ -76,7 +79,6 @@ abstract class AbstractRepository extends \TYPO3\CMS\Extbase\Persistence\Reposit
->andWhere('date.date_end <= :dateEnd')
->setParameter('dateEnd', $filterSettings->getDateTo()->format('Y-m-d'))
;
}
}
@@ -31,16 +31,17 @@ use CalendR\Event\Provider\ProviderInterface;
use EP\EpProducts\Domain\Model\Contingent;
use EP\EpProducts\Domain\Model\Hotel;
use EP\EpProducts\Domain\Model\Product;
use EP\EpProducts\Utility\DbUtility;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ContingentRepository extends AbstractRepository implements ProviderInterface
{
/**
* @param \DateTime $dateFrom
* @param \DateTime $dateTo
* @param array $options
* @return \CalendR\Event\EventInterface[]
* @throws \Doctrine\DBAL\DBALException
*/
public function getEvents(\DateTime $dateFrom, \DateTime $dateTo, array $options = [])
{
@@ -49,10 +50,12 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
$optionsResolver->setAllowedTypes('hotel', Hotel::class);
$resolvedOptions = $optionsResolver->resolve($options);
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$qb
->select('status status', 'date date', 'SUM(pax) pax', 'SUM(available) available', 'min_price minPrice')
->select('status as status', 'date as date', 'min_price as minPrice')
->addSelectLiteral('SUM(pax) as pax')
->addSelectLiteral('SUM(available) as available')
->from('tx_epproducts_domain_model_contingent')
->groupBy('hotel')
->addGroupBy('date')
@@ -96,13 +99,15 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
* @param Hotel $hotel
* @param Product $product
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getAvailableContingents(Hotel $hotel, Product $product)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$qb
->select('c.date date', 'SUM(c.available) total')
->select('c.date as date')
->addSelectLiteral('SUM(c.available) as total')
->from('tx_epproducts_domain_model_contingent', 'c')
->innerJoin('c', 'tx_epproducts_domain_model_daytrip', 'd', 'c.date = d.date AND c.hotel_code = d.hotel_code')
->where('c.hotel = :hotelUid')
@@ -125,14 +130,15 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
* @param Hotel $hotel
* @param Product $product
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getAvailableRooms(\DateTime $dateFrom, \DateTime $dateTo, Hotel $hotel, Product $product)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$qb
->select('c.room_code code', 'c.room_label label', 'c.available', 'c.min_price price',
'c.hotel_bus_pro_id hotelBusProId', 'd.bus_pro_id busProId')
->select('c.room_code as code', 'c.room_label as label', 'c.available as available', 'c.min_price as price',
'c.hotel_bus_pro_id as hotelBusProId', 'd.bus_pro_id as busProId')
->from('tx_epproducts_domain_model_contingent', 'c')
->innerJoin('c', 'tx_epproducts_domain_model_daytrip', 'd', 'c.date = d.date AND c.hotel_code = d.hotel_code')
->where('c.hotel = :hotelUid')
@@ -30,22 +30,22 @@ namespace EP\EpProducts\Domain\Repository;
use Doctrine\DBAL\Connection;
use EP\EpProducts\Domain\Model\FilterSettings;
use EP\EpProducts\Domain\Model\Product;
use EP\EpProducts\Utility\DbUtility;
class DateRepository extends AbstractRepository
{
/**
* @param Product $product
*
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getDateRange(Product $product = null)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select('MIN(date_start) dateRangeFrom, MAX(date_end) dateRangeTo')
->addSelectLiteral('MIN(date_start) dateRangeFrom')
->addSelectLiteral('MAX(date_start) dateRangeTo')
->from('tx_epproducts_domain_model_date', 'date')
->where('date_start >= NOW()')
->andWhere('product_searchable = 1')
@@ -75,23 +75,23 @@ class DateRepository extends AbstractRepository
/**
* @param FilterSettings $filterSettings
* @param array $excludedConceptUids
*
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getFilterOptions(FilterSettings $filterSettings, $excludedConceptUids = [])
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select(
'date.concept conceptUid', 'date.concept_name conceptName', 'date.concept_sorting conceptSorting',
'date.concept_code conceptCode', 'date.min_price minPrice',
'date.country countryUid','date.country_name countryName', 'date.country_code countryCode',
'date.region regionUid', 'date.region_name regionName',
'date.nights nights', 'date.board boardType', 'date.board_bus_pro_id boardUid',
'date.bus_available busAvailable',
'date.hotel_type hotelType',
'room.type roomType'
'date.concept as conceptUid', 'date.concept_name as conceptName', 'date.concept_sorting as conceptSorting',
'date.concept_code as conceptCode', 'date.min_price as minPrice',
'date.country as countryUid','date.country_name as countryName', 'date.country_code as countryCode',
'date.region as regionUid', 'date.region_name as regionName',
'date.nights as nights', 'date.board as boardType', 'date.board_bus_pro_id as boardUid',
'date.bus_available as busAvailable',
'date.hotel_type as hotelType',
'room.type as roomType'
)
->from('tx_epproducts_domain_model_date', 'date')
->innerJoin('date', 'tx_epproducts_domain_model_room', 'room', 'room.date = date.uid')
@@ -121,15 +121,16 @@ class DateRepository extends AbstractRepository
/**
* @param string $search
* @param FilterSettings $filterSettings
*
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function searchHotels($search, FilterSettings $filterSettings)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select('REPLACE(hotel_name, "\r\n", " ") name', 'hotel uid')
->select('hotel uid')
->addSelectLiteral('REPLACE(hotel_name, "\r\n", " ") name')
->from('tx_epproducts_domain_model_date', 'date')
->where('product_searchable = 1')
->andWhere($qb->expr()->orX(
@@ -156,15 +157,16 @@ class DateRepository extends AbstractRepository
* @param string $search
* @param FilterSettings $filterSettings
* @param array $excludedConceptUids
*
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function searchProducts($search, FilterSettings $filterSettings, $excludedConceptUids = [])
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select('CONCAT(REPLACE(product_name, "\r\n", " "), " (", concept_name, ")") name', 'product uid')
->select('product as uid')
->addSelectLiteral('CONCAT(REPLACE(product_name, "\r\n", " "), " (", concept_name, ")") as name')
->from('tx_epproducts_domain_model_date', 'date')
->where('product_searchable = 1')
->andWhere($qb->expr()->orX(
@@ -203,15 +205,16 @@ class DateRepository extends AbstractRepository
* @param string $type
* @param string $search
* @param FilterSettings $filterSettings
*
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function searchDestinations($type, $search, FilterSettings $filterSettings)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select('REPLACE(' . $type . '_name, "\r\n", " ") name', $type . ' uid')
->select($type . ' as uid')
->addSelectLiteral('REPLACE(' . $type . '_name, "\r\n", " ") as name')
->from('tx_epproducts_domain_model_date', 'date')
->where('product_searchable = 1')
->andWhere($qb->expr()->orX(
@@ -43,9 +43,8 @@ class FaqRepository extends AbstractRepository
' ' .$GLOBALS['TSFE']->sys_page->enableFields('tx_epproducts_domain_model_faq') .
' ORDER BY FIELD(uid, ' . $uids . ')
');
return $query
->execute()
;
return $query->execute();
}
}
@@ -29,14 +29,15 @@ namespace EP\EpProducts\Domain\Repository;
use Doctrine\DBAL\Connection;
use EP\EpProducts\Domain\Model\Hotel;
use EP\EpProducts\Utility\DbUtility;
use Symfony\Component\OptionsResolver\OptionsResolver;
class HotelRepository extends AbstractRepository
{
/**
* @param int $hotelUid
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getSingleByUid($hotelUid)
{
@@ -54,16 +55,18 @@ class HotelRepository extends AbstractRepository
/**
* @param int $hotelUid
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getDateIndependentSingleByUid($hotelUid)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$qb
->select(
'hotel.uid hotelUid', 'hotel.name hotelName', 'hotel.teaser hotelTeaser',
'hotel.category hotelCategory', 'hotel.detail_page hotelDetailPage',
'country.code countryCode', 'country.name country',
'region.name region'
'hotel.uid as hotelUid', 'hotel.name as hotelName', 'hotel.teaser as hotelTeaser',
'hotel.category as hotelCategory', 'hotel.detail_page as hotelDetailPage',
'country.code as countryCode', 'country.name as country',
'region.name as region'
)
->from('tx_epproducts_domain_model_hotel', 'hotel')
->leftJoin('hotel', 'tx_epproducts_domain_model_country', 'country', 'hotel.country = country.uid')
@@ -81,6 +84,7 @@ class HotelRepository extends AbstractRepository
/**
* @param int $productUid
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getListByProduct($productUid)
{
@@ -96,6 +100,7 @@ class HotelRepository extends AbstractRepository
/**
* @param array $criteria
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getListByCriteria(array $criteria)
{
@@ -148,6 +153,7 @@ class HotelRepository extends AbstractRepository
* @param array $criteria
* @param array $excludedHotelUids
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getDateIndependentListByCriteria(array $criteria, array $excludedHotelUids = [])
{
@@ -155,13 +161,14 @@ class HotelRepository extends AbstractRepository
$optionsResolver->setDefined(['regionUid', 'countryUid', 'conceptUid', 'productUid', 'category', 'type']);
$resolvedCriteria = $optionsResolver->resolve($criteria);
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$qb
->select(
'hotel.uid hotelUid', 'hotel.name hotelName', 'hotel.teaser hotelTeaser',
'hotel.category hotelCategory', 'hotel.detail_page hotelDetailPage',
'country.code countryCode', 'country.name country',
'region.name region'
'hotel.uid as hotelUid', 'hotel.name as hotelName', 'hotel.teaser as hotelTeaser',
'hotel.category as hotelCategory', 'hotel.detail_page as hotelDetailPage',
'country.code as countryCode', 'country.name as country',
'region.name as region'
)
->from('tx_epproducts_domain_model_hotel', 'hotel')
->leftJoin('hotel', 'tx_epproducts_domain_model_country', 'country', 'hotel.country = country.uid')
@@ -169,7 +176,7 @@ class HotelRepository extends AbstractRepository
->where('hotel.hidden = 0')
->andWhere('hotel.show_as_teaser = 1')
->andWhere('hotel.deleted = 0')
->orderBy('FIELD(hotel.type, ' . Hotel::TYPE_SPORTS_CLUB . ')', 'DESC')
->add('orderBy', 'FIELD(hotel.type, ' . Hotel::TYPE_SPORTS_CLUB . ') DESC')
->addOrderBy('hotel.name', 'ASC')
;
@@ -216,29 +223,30 @@ class HotelRepository extends AbstractRepository
/**
* @param bool $excludeNonSearchable
* @return \Doctrine\DBAL\Query\QueryBuilder
* @return \TYPO3\CMS\Core\Database\Query\QueryBuilder
* @throws \Doctrine\DBAL\DBALException
*/
protected function getQueryBuilder($excludeNonSearchable = true)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$qb
->select(
'date.hotel hotelUid', 'date.hotel_name hotelName', 'date.hotel_teaser hotelTeaser',
'date.hotel_category hotelCategory', 'date.hotel_detail_page hotelDetailPage',
'date.date_start dateStart', 'date.date_end dateEnd', 'date.earlybird earlybird',
'date.low_contingent lowContingent', 'date.board board', 'date.product_fact productFact',
'date.hotel_fact hotelFact', 'date.region_fact regionFact', 'date.services_included servicesIncluded',
'date.min_price minPrice', 'date.pseudo_price pseudoPrice', 'date.nights nights',
'date.available available', 'date.country country', 'date.country_code countryCode',
'date.region region'
'date.hotel as hotelUid', 'date.hotel_name as hotelName', 'date.hotel_teaser as hotelTeaser',
'date.hotel_category as hotelCategory', 'date.hotel_detail_page as hotelDetailPage',
'date.date_start as dateStart', 'date.date_end as dateEnd', 'date.earlybird as earlybird',
'date.low_contingent as lowContingent', 'date.board as board', 'date.product_fact as productFact',
'date.hotel_fact as hotelFact', 'date.region_fact as regionFact', 'date.services_included as servicesIncluded',
'date.min_price as minPrice', 'date.pseudo_price as pseudoPrice', 'date.nights as nights',
'date.available as available', 'date.country as country', 'date.country_code as countryCode',
'date.region as region'
)
->from('tx_epproducts_domain_model_date', 'date')
->leftJoin('date', 'tx_epproducts_product_region_mm', 'mm', 'mm.uid_local = date.product')
->addGroupBy('date.hotel')
->addGroupBy('date.date_start')
->addGroupBy('date.nights')
->orderBy('FIELD(date.hotel_type, ' . Hotel::TYPE_SPORTS_CLUB . ')', 'DESC')
->add('orderBy', 'FIELD(date.hotel_type, ' . Hotel::TYPE_SPORTS_CLUB . ') DESC')
;
if ($excludeNonSearchable) {
@@ -250,6 +258,7 @@ class HotelRepository extends AbstractRepository
/**
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public function getMapList()
{
@@ -32,32 +32,33 @@ use EP\EpProducts\Domain\Model\Date;
use EP\EpProducts\Domain\Model\FilterSettings;
use EP\EpProducts\Domain\Model\Hotel;
use EP\EpProducts\Domain\Model\Product;
use EP\EpProducts\Utility\DbUtility;
class ProductRepository extends AbstractRepository
{
/**
* @param array $productUids
* @param array $hotelUids
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getWatchlist(array $productUids, array $hotelUids)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select(
'date.concept conceptUid', 'date.concept_name conceptName', 'date.concept_code conceptCode',
'date.product productUid', 'date.product_name productName', 'date.product_detail_page productDetailPage',
'date.product_feature productFeature',
'date.country countryUid','date.country_name countryName', 'date.country_code countryCode',
'date.region regionUid', 'date.region_name regionName', 'date.region_feature regionFeature',
'date.date_start dateStart', 'date.date_end dateEnd',
'date.hotel hotelUid', 'date.hotel_name hotelName', 'date.hotel_category hotelCategory',
'date.earlybird earlybird', 'date.low_contingent lowContingent', 'date.board board',
'date.product_fact productFact', 'date.hotel_fact hotelFact', 'date.region_fact regionFact',
'date.services_included servicesIncluded', 'date.min_price minPrice', 'date.nights nights',
'date.available available', 'date.pseudo_price pseudoPrice'
'date.concept as conceptUid', 'date.concept_name as conceptName', 'date.concept_code as conceptCode',
'date.product as productUid', 'date.product_name as productName', 'date.product_detail_page as productDetailPage',
'date.product_feature as productFeature',
'date.country as countryUid','date.country_name as countryName', 'date.country_code as countryCode',
'date.region as regionUid', 'date.region_name as regionName', 'date.region_feature as regionFeature',
'date.date_start as dateStart', 'date.date_end as dateEnd',
'date.hotel as hotelUid', 'date.hotel_name as hotelName', 'date.hotel_category as hotelCategory',
'date.earlybird as earlybird', 'date.low_contingent as lowContingent', 'date.board as board',
'date.product_fact as productFact', 'date.hotel_fact as hotelFact', 'date.region_fact as regionFact',
'date.services_included as servicesIncluded', 'date.min_price as minPrice', 'date.nights as nights',
'date.available as available', 'date.pseudo_price as pseudoPrice'
)
->from('tx_epproducts_domain_model_date', 'date')
->where('date.product IN (:productUids)')
@@ -78,26 +79,26 @@ class ProductRepository extends AbstractRepository
/**
* @param FilterSettings $filterSettings
* @param array $excludedConceptUids
*
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getSearchResult(FilterSettings $filterSettings, $excludedConceptUids = [])
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select(
'date.concept conceptUid', 'date.concept_name conceptName', 'date.concept_code conceptCode',
'date.product productUid', 'date.product_name productName', 'date.product_detail_page productDetailPage',
'date.product_feature productFeature',
'date.country countryUid','date.country_name countryName', 'date.country_code countryCode',
'date.region regionUid', 'date.region_name regionName', 'date.region_feature regionFeature',
'date.date_start dateStart', 'date.date_end dateEnd',
'date.hotel hotelUid', 'date.hotel_name hotelName', 'date.hotel_category hotelCategory',
'date.earlybird earlybird', 'date.low_contingent lowContingent', 'date.board board',
'date.product_fact productFact', 'date.hotel_fact hotelFact', 'date.region_fact regionFact',
'date.services_included servicesIncluded', 'date.min_price minPrice', 'date.nights nights',
'date.available available', 'date.pseudo_price pseudoPrice'
'date.concept as conceptUid', 'date.concept_name as conceptName', 'date.concept_code as conceptCode',
'date.product as productUid', 'date.product_name as productName', 'date.product_detail_page as productDetailPage',
'date.product_feature as productFeature',
'date.country as countryUid','date.country_name as countryName', 'date.country_code as countryCode',
'date.region as regionUid', 'date.region_name as regionName', 'date.region_feature as regionFeature',
'date.date_start as dateStart', 'date.date_end as dateEnd',
'date.hotel as hotelUid', 'date.hotel_name as hotelName', 'date.hotel_category as hotelCategory',
'date.earlybird as earlybird', 'date.low_contingent as lowContingent', 'date.board as board',
'date.product_fact as productFact', 'date.hotel_fact as hotelFact', 'date.region_fact as regionFact',
'date.services_included as servicesIncluded', 'date.min_price as minPrice', 'date.nights as nights',
'date.available as available', 'date.pseudo_price as pseudoPrice'
)
->from('tx_epproducts_domain_model_date', 'date')
->innerJoin('date', 'tx_epproducts_domain_model_room', 'room', 'room.date = date.uid')
@@ -131,25 +132,26 @@ class ProductRepository extends AbstractRepository
* @param FilterSettings $filterSettings
* @param array $excludedConceptUids
* @param int $limit
*
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getTeasers(FilterSettings $filterSettings, $excludedConceptUids = [], $limit = 0)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select(
'product productUid', 'product_name productName', 'product_detail_page productDetailPage',
'product_feature productFeature', 'product_teaser productTeaser', 'product_fact productFact',
'hotel hotelUid', 'hotel_fact hotelFact', 'hotel_name hotelName', 'hotel_category hotelCategory',
'region_fact regionFact', 'region_name regionName', 'region_feature regionFeature',
'country_name countryName', 'country_code countryCode',
'date_start dateStart', 'date_end dateEnd', 'uid dateUid', 'min_price minPrice',
'pseudo_price pseudoPrice', 'nights nights', 'available available',
'skipass_included skipassIncluded', 'bus_included busIncluded',
'earlybird earlybird', 'low_contingent lowContingent',
'concept_code conceptCode', 'concept_name conceptName',
'board board'
'product as productUid', 'product_name as productName', 'product_detail_page as productDetailPage',
'product_feature as productFeature', 'product_teaser as productTeaser', 'product_fact as productFact',
'hotel as hotelUid', 'hotel_fact as hotelFact', 'hotel_name as hotelName', 'hotel_category as hotelCategory',
'region_fact as regionFact', 'region_name as regionName', 'region_feature as regionFeature',
'country_name as countryName', 'country_code as countryCode',
'date_start as dateStart', 'date_end as dateEnd', 'uid as dateUid', 'min_price as minPrice',
'pseudo_price as pseudoPrice', 'nights as nights', 'available as available',
'skipass_included as skipassIncluded', 'bus_included as busIncluded',
'earlybird', 'low_contingent as lowContingent',
'concept_code as conceptCode', 'concept_name as conceptName',
'board'
)
->from('tx_epproducts_domain_model_date', 'date')
->leftJoin('date', 'tx_epproducts_product_region_mm', 'mm', 'mm.uid_local = date.product')
@@ -196,21 +198,21 @@ class ProductRepository extends AbstractRepository
* @param Hotel $hotel
* @param FilterSettings $filterSettings
* @param Date $date
*
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getPricetable(Product $product, Hotel $hotel, FilterSettings $filterSettings, Date $date = null)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select(
'date.uid dateUid', 'date.date_start dateStart', 'date.date_end dateEnd', 'date.bus_pro_id dateBusProId',
'date.hotel hotelUid', 'date.hotel_bus_pro_id hotelBusProId', 'date.bus_included dateBusIncluded',
'date.skipass_included dateSkipassIncluded',
'room.uid as roomUid', 'room.bus_pro_id roomBusProId', 'room.name roomName',
'room.price roomPrice', 'date.discount roomDiscount', 'date.bus_price busPrice',
'room.services roomOptionalServices', 'room.nights roomNights', 'room.available roomAvailable'
'date.uid as dateUid', 'date.date_start as dateStart', 'date.date_end as dateEnd', 'date.bus_pro_id as dateBusProId',
'date.hotel as hotelUid', 'date.hotel_bus_pro_id as hotelBusProId', 'date.bus_included as dateBusIncluded',
'date.skipass_included as dateSkipassIncluded',
'room.uid as as roomUid', 'room.bus_pro_id as roomBusProId', 'room.name as roomName',
'room.price as roomPrice', 'date.discount as roomDiscount', 'date.bus_price as busPrice',
'room.services as roomOptionalServices', 'room.nights as roomNights', 'room.available as roomAvailable'
)
->from('tx_epproducts_domain_model_date', 'date')
->innerJoin('date', 'tx_epproducts_domain_model_room', 'room', 'date.uid = room.date')
@@ -243,22 +245,22 @@ class ProductRepository extends AbstractRepository
* @param Product $product
* @param Hotel $hotel
* @param FilterSettings $filterSettings
*
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getAvailableDates(Product $product, Hotel $hotel, FilterSettings $filterSettings)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select(
'date.uid dateUid', 'date.date_start dateStart', 'date.date_end dateEnd',
'date.min_price dateMinPrice', 'date.discount dateDiscount', 'date.bus_price busPrice',
'date.nights dateNights', 'date.bus_included dateBusIncluded', 'date.services_included dateServicesIncluded',
'date.services_general dateServicesGeneral', 'date.skipass_included dateSkipassIncluded',
'date.bus_pro_id dateBusProId', 'date.hotel_bus_pro_id hotelBusProId',
'SUM(room.available) available'
'date.uid as dateUid', 'date.date_start as dateStart', 'date.date_end as dateEnd',
'date.min_price as dateMinPrice', 'date.discount as dateDiscount', 'date.bus_price as busPrice',
'date.nights as dateNights', 'date.bus_included as dateBusIncluded', 'date.services_included as dateServicesIncluded',
'date.services_general as dateServicesGeneral', 'date.skipass_included as dateSkipassIncluded',
'date.bus_pro_id as dateBusProId', 'date.hotel_bus_pro_id as hotelBusProId'
)
->addSelectLiteral('SUM(room.available) as available')
->from('tx_epproducts_domain_model_date', 'date')
->innerJoin('date', 'tx_epproducts_domain_model_room', 'room', 'room.date = date.uid')
->leftJoin('date', 'tx_epproducts_product_region_mm', 'mm', 'mm.uid_local = date.product')
@@ -282,10 +284,11 @@ class ProductRepository extends AbstractRepository
/**
* @param Product $product
* @return bool
* @throws \Doctrine\DBAL\DBALException
*/
public function hasDates(Product $product)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select('date.uid')
@@ -303,23 +306,23 @@ class ProductRepository extends AbstractRepository
/**
* @param Product $product
* @param Hotel $hotel
*
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getDatesForExport(Product $product, Hotel $hotel)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select(
'date.bus_pro_id dateBusProId', 'date.date_start dateStart', 'date.date_end dateEnd',
'date.min_price dateMinPrice', 'date.discount dateDiscount', 'date.bus_price busPrice',
'date.nights dateNights', 'date.bus_included dateBusIncluded', 'date.services_included dateServicesIncluded',
'date.services_general dateServicesGeneral', 'date.skipass_included dateSkipassIncluded',
'date.bus_pro_id dateBusProId', 'date.hotel_bus_pro_id hotelBusProId', 'date.pickups pickups',
'room.uid as roomUid', 'room.bus_pro_id roomBusProId', 'room.code roomCode', 'room.name roomName',
'room.price roomPrice', 'room.pax roomPax', 'date.discount roomDiscount', 'date.bus_price busPrice',
'room.services roomOptionalServices', 'room.nights roomNights', 'room.available roomAvailable'
'date.bus_pro_id as dateBusProId', 'date.date_start as dateStart', 'date.date_end as dateEnd',
'date.min_price as dateMinPrice', 'date.discount as dateDiscount', 'date.bus_price as busPrice',
'date.nights as dateNights', 'date.bus_included as dateBusIncluded', 'date.services_included as dateServicesIncluded',
'date.services_general as dateServicesGeneral', 'date.skipass_included as dateSkipassIncluded',
'date.bus_pro_id as dateBusProId', 'date.hotel_bus_pro_id as hotelBusProId', 'date.pickups as pickups',
'room.uid as roomUid', 'room.bus_pro_id as roomBusProId', 'room.code as roomCode', 'room.name as roomName',
'room.price as roomPrice', 'room.pax as roomPax', 'date.discount as roomDiscount', 'date.bus_price as busPrice',
'room.services as roomOptionalServices', 'room.nights as roomNights', 'room.available as roomAvailable'
)
->from('tx_epproducts_domain_model_date', 'date')
->innerJoin('date', 'tx_epproducts_domain_model_room', 'room', 'room.date = date.uid')
@@ -339,18 +342,19 @@ class ProductRepository extends AbstractRepository
/**
* @param Product $product
*
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getEventPriceTable(Product $product)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select(
'date.bus_pro_id dateBusProId', 'date.hotel_bus_pro_id hotelBusProId', 'date.date_end dateEnd',
'date.hotel hotelUid', 'date.hotel_name hotelName', 'date.hotel_header_title hotelTitle',
'date.hotel_category hotelCategory',
'room.pax roomPax', 'room.price roomPrice', 'room.available available'
'date.bus_pro_id as dateBusProId', 'date.hotel_bus_pro_id as hotelBusProId', 'date.date_end as dateEnd',
'date.hotel as hotelUid', 'date.hotel_name as hotelName', 'date.hotel_header_title as hotelTitle',
'date.hotel_category as hotelCategory',
'room.pax as roomPax', 'room.price as roomPrice', 'room.available as available'
)
->from('tx_epproducts_domain_model_date', 'date')
->innerJoin('date', 'tx_epproducts_domain_model_room', 'room', 'room.date = date.uid')
@@ -35,7 +35,6 @@ class RegionRepository extends AbstractRepository
/**
* @param int $countryUid
* @param string $season
*
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
*/
public function getTeasersByCountryAndSeason($countryUid, $season = 'w')
@@ -28,7 +28,6 @@ namespace EP\EpProducts\Domain\Repository;
***************************************************************/
use Doctrine\DBAL\Connection;
use EP\EpProducts\Utility\DbUtility;
class SnowreportRepository extends AbstractRepository
{
@@ -36,19 +35,21 @@ class SnowreportRepository extends AbstractRepository
/**
* @param array $regionUids
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function getSnowreportsForRegions(array $regionUids = null)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select(
'snowreport.*',
'region.name regionName', 'region.uid regionUid', 'region.detail_page regionDetailPage',
'country.name countryName', 'country.uid countryUid', 'country.code countryCode', 'country.detail_page countryDetailPage',
'season_start seasonStart', 'season_end seasonEnd',
'(UNIX_TIMESTAMP() >= snowreport.season_start AND UNIX_TIMESTAMP() <= snowreport.season_end) inSeason'
'region.name as regionName', 'region.uid as regionUid', 'region.detail_page as regionDetailPage',
'country.name as countryName', 'country.uid as countryUid', 'country.code as countryCode',
'country.detail_page as countryDetailPage',
'season_start as seasonStart', 'season_end as seasonEnd'
)
->addSelectLiteral('(UNIX_TIMESTAMP() >= snowreport.season_start AND UNIX_TIMESTAMP() <= snowreport.season_end) as inSeason')
->from('tx_epproducts_domain_model_snowreport', 'snowreport')
->innerJoin('snowreport', 'tx_epproducts_domain_model_region', 'region', 'snowreport.uid = region.snowreport')
->innerJoin('region', 'tx_epproducts_domain_model_country', 'country', 'region.country = country.uid')
@@ -63,6 +64,7 @@ class SnowreportRepository extends AbstractRepository
->setParameter('regionUids', $regionUids, Connection::PARAM_INT_ARRAY)
;
}
return $query->execute()->fetchAll();
}
@@ -36,6 +36,11 @@ class TeammemberRepository extends AbstractRepository
'sorting' => 'ASC',
];
/**
* @param array $categories
* @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public function findByCategories(array $categories = [])
{
$qb = $this->createQuery();
@@ -27,7 +27,7 @@ namespace EP\EpProducts\Hook;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use EP\EpProducts\Utility\DbUtility;
use EP\EpProducts\Traits\DbConnectionTrait;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
@@ -36,6 +36,7 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
class Tcemain
{
use DbConnectionTrait;
/**
* @var array
@@ -51,13 +52,14 @@ class Tcemain
* @param string $table
* @param int $id
* @param DataHandler $obj
* @throws \Doctrine\DBAL\DBALException
*/
public function processDatamap_preProcessFieldArray(array &$fields, $table, $id, DataHandler $obj)
{
// Render flash message in case of duplicate entry
if ($table === 'tx_epproducts_domain_model_matchcode' && $fields['code'] !== '') {
$code = $fields['code'];
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select('uid')
->from('tx_epproducts_domain_model_matchcode')
@@ -78,7 +80,7 @@ class Tcemain
}
if ($table === 'tx_epproducts_domain_model_product' && $fields['code'] !== '') {
$code = $fields['code'];
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select('uid')
->from('tx_epproducts_domain_model_product')
@@ -98,14 +100,12 @@ class Tcemain
}
}
/**
* @param string $message
* @param string $title
* @param int $severity
*/
private function addFlashMessage($message, $title, $severity)
protected function addFlashMessage($message, $title, $severity)
{
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** @var \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService */
@@ -115,4 +115,5 @@ class Tcemain
$message = GeneralUtility::makeInstance(FlashMessage::class, $message, $title, $severity, true);
$messageQueue->addMessage($message);
}
}
@@ -29,7 +29,7 @@ namespace EP\EpProducts\Service;
use Doctrine\DBAL\Connection;
use EP\EpProducts\Domain\Model\Contingent;
use EP\EpProducts\Utility\DbUtility;
use EP\EpProducts\Traits\DbConnectionTrait;
use TYPO3\CMS\Core\Log\Logger;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -37,6 +37,8 @@ use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
class ContingentImportService implements SingletonInterface
{
use DbConnectionTrait;
const ROOMCODE_STATUS = 'BelKal';
/**
@@ -61,6 +63,7 @@ class ContingentImportService implements SingletonInterface
/**
* @param ConfigurationManagerInterface $manager
* @throws \Doctrine\DBAL\DBALException
*/
public function __construct(ConfigurationManagerInterface $manager)
{
@@ -73,7 +76,7 @@ class ContingentImportService implements SingletonInterface
} elseif (isset($settings['module']['tx_epproducts']['persistence']['storagePid'])) {
$this->pid = $settings['module']['tx_epproducts']['persistence']['storagePid'];
}
$this->db = DbUtility::getDbConnection();
$this->db = $this->getDbConnection();
$this->logger = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class)->getLogger(__CLASS__);
}
@@ -124,21 +127,33 @@ class ContingentImportService implements SingletonInterface
return $this->parseContingent($xmlData);
}
/**
* @throws \Doctrine\DBAL\DBALException
*/
public function createTempTable()
{
$this->db->exec('CREATE TABLE IF NOT EXISTS tx_epproducts_domain_model_contingent_temp LIKE tx_epproducts_domain_model_contingent');
}
/**
* @throws \Doctrine\DBAL\DBALException
*/
public function clearTable()
{
$this->db->exec('TRUNCATE TABLE tx_epproducts_domain_model_contingent');
}
/**
* @throws \Doctrine\DBAL\DBALException
*/
public function copyTable()
{
$this->db->exec('INSERT INTO tx_epproducts_domain_model_contingent SELECT * FROM tx_epproducts_domain_model_contingent_temp');
}
/**
* @throws \Doctrine\DBAL\DBALException
*/
public function clearTempTable()
{
$this->db->exec('TRUNCATE TABLE tx_epproducts_domain_model_contingent_temp');
@@ -29,7 +29,7 @@ namespace EP\EpProducts\Service;
use Doctrine\DBAL\Connection;
use EP\EpProducts\Domain\Model\Room;
use EP\EpProducts\Utility\DbUtility;
use EP\EpProducts\Traits\DbConnectionTrait;
use TYPO3\CMS\Core\Log\Logger;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -38,6 +38,8 @@ use TYPO3\CMS\Extbase\Service\CacheService;
class DateImportService implements SingletonInterface
{
use DbConnectionTrait;
const CODE_PSEUDOPRICE = 'PDGS';
const CODE_BABYROOM = 'Baby';
const LABEL_BUS = 'Busfahrt';
@@ -109,10 +111,11 @@ class DateImportService implements SingletonInterface
/**
* @param string $path
* @return int
* @throws \Doctrine\DBAL\DBALException
*/
public function import($path)
{
$this->db = DbUtility::getDbConnection();
$this->db = $this->getDbConnection();
$this->logger = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class)->getLogger(__CLASS__);
$this->getRoomMappings();
$this->getHotelMappings();
@@ -171,6 +174,9 @@ class DateImportService implements SingletonInterface
return $this->parseProduct($xmlData->reise[0]);
}
/**
* @throws \Doctrine\DBAL\DBALException
*/
public function createTempTables()
{
$this->db->exec('CREATE TABLE IF NOT EXISTS tx_epproducts_domain_model_date_temp LIKE tx_epproducts_domain_model_date');
@@ -178,6 +184,9 @@ class DateImportService implements SingletonInterface
$this->db->exec('CREATE TABLE IF NOT EXISTS tx_epproducts_domain_model_room_temp LIKE tx_epproducts_domain_model_room');
}
/**
* @throws \Doctrine\DBAL\DBALException
*/
public function clearTables()
{
$this->db->exec('TRUNCATE TABLE tx_epproducts_domain_model_date');
@@ -185,6 +194,9 @@ class DateImportService implements SingletonInterface
$this->db->exec('TRUNCATE TABLE tx_epproducts_domain_model_room');
}
/**
* @throws \Doctrine\DBAL\DBALException
*/
public function copyTables()
{
$this->db->exec('INSERT INTO tx_epproducts_domain_model_date SELECT * FROM tx_epproducts_domain_model_date_temp');
@@ -192,6 +204,9 @@ class DateImportService implements SingletonInterface
$this->db->exec('INSERT INTO tx_epproducts_domain_model_room SELECT * FROM tx_epproducts_domain_model_room_temp');
}
/**
* @throws \Doctrine\DBAL\DBALException
*/
public function clearTempTables()
{
$this->db->exec('TRUNCATE TABLE tx_epproducts_domain_model_date_temp');
@@ -328,7 +343,6 @@ class DateImportService implements SingletonInterface
/**
* @param array $product
* @param \SimpleXMLElement $xmlDate
*
* @return array
*/
protected function createDateRecord(array $product, \SimpleXMLElement $xmlDate)
@@ -467,7 +481,6 @@ class DateImportService implements SingletonInterface
/**
* @param \SimpleXMLElement $xmlHotel
* @param array $date
*
* @return bool
*/
protected function parseHotel(\SimpleXMLElement $xmlHotel, array &$date)
@@ -600,7 +613,6 @@ class DateImportService implements SingletonInterface
/**
* @param array $services
*
* @return int
*/
protected function determineDiscount(array $services)
@@ -622,7 +634,6 @@ class DateImportService implements SingletonInterface
* @param \SimpleXMLElement $xmlData
* @param string $serviceLabel
* @param bool $skipWithoutPrice
*
* @return array
*/
protected function parseService(\SimpleXMLElement $xmlData, $serviceLabel, $skipWithoutPrice = false)
@@ -683,7 +694,6 @@ class DateImportService implements SingletonInterface
/**
* @param \SimpleXMLElement $xmlDate
* @param string $label
*
* @return array
*/
protected function parseSelectionGroup(\SimpleXMLElement $xmlDate, $label)
@@ -718,9 +728,6 @@ class DateImportService implements SingletonInterface
}
}
/**
* @return array
*/
protected function getRoomMappings()
{
$sql = 'SELECT code, type FROM tx_epproducts_domain_model_roommapping';
@@ -731,9 +738,6 @@ class DateImportService implements SingletonInterface
}
}
/**
* @return array
*/
protected function getHotelMappings()
{
$sql = '
@@ -773,7 +777,6 @@ class DateImportService implements SingletonInterface
/**
* @param string $table
* @param int $uid
*
* @return array
*/
protected function getTopFactForRecord($table, $uid)
@@ -820,4 +823,5 @@ class DateImportService implements SingletonInterface
];
}
}
}
@@ -27,26 +27,31 @@ namespace EP\EpProducts\Service;
***************************************************************/
use EP\EpProducts\Domain\Model\FilterSettings;
use EP\EpProducts\Utility\DbUtility;
use EP\EpProducts\Traits\DbConnectionTrait;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\SingletonInterface;
class LogService implements SingletonInterface
{
use DbConnectionTrait;
/**
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function dumpSearchLogEpreisen()
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$result = $qb
->select('DATE_FORMAT(FROM_UNIXTIME(logs.time_micro), "%d.%m.%Y, %H:%i Uhr") date', 'logs.data data')
->select('logs.data as data')
->addSelectLiteral('DATE_FORMAT(FROM_UNIXTIME(logs.time_micro), "%d.%m.%Y, %H:%i Uhr") as date')
->from('tx_epproducts_log', 'logs')
->orderBy('time_micro')
->execute()
->fetchAll()
;
$csv = [
[
'Datum/Uhrzeit',
@@ -61,7 +66,9 @@ class LogService implements SingletonInterface
'Seiten ID',
],
];
$labels = $this->fetchEntityLabels();
foreach ($result as $row)
{
$data = json_decode(substr($row['data'], 2));
@@ -95,17 +102,21 @@ class LogService implements SingletonInterface
/**
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function dumpSearchLogEpevents()
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$result = $qb
->select('DATE_FORMAT(FROM_UNIXTIME(logs.time_micro), "%d.%m.%Y, %H:%i Uhr") date', 'logs.data data')
->select('logs.data as data')
->addSelectLiteral('DATE_FORMAT(FROM_UNIXTIME(logs.time_micro), "%d.%m.%Y, %H:%i Uhr") as date')
->from('tx_epevents_log', 'logs')
->orderBy('time_micro')
->execute()
->fetchAll()
;
$csv = [
[
'Datum/Uhrzeit',
@@ -114,6 +125,7 @@ class LogService implements SingletonInterface
'Seiten ID',
],
];
foreach ($result as $row)
{
$data = json_decode(substr($row['data'], 2));
@@ -129,11 +141,13 @@ class LogService implements SingletonInterface
$data->pageUid,
];
}
return $csv;
}
/**
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
private function fetchEntityLabels()
{
@@ -141,39 +155,50 @@ class LogService implements SingletonInterface
'country' => [],
'region' => [],
];
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$result = $qb
->select('uid', 'name')
->from('tx_epproducts_domain_model_country', 'c')
->execute()
->fetchAll()
;
foreach ($result as $row)
{
$labels['country'][$row['uid']] = $row['name'];
}
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$result = $qb
->select('uid', 'name')
->from('tx_epproducts_domain_model_region')
->execute()
->fetchAll()
;
foreach ($result as $row)
{
$labels['region'][$row['uid']] = $row['name'];
}
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$result = $qb
->select('uid', 'name')
->from('tx_epproducts_domain_model_concept')
->execute()
->fetchAll()
;
foreach ($result as $row)
{
$labels['concept'][$row['uid']] = $row['name'];
}
return $labels;
}
}
@@ -33,13 +33,15 @@ use EP\EpProducts\Domain\Model\Reseller;
use EP\EpProducts\Domain\Repository\ProductRepository;
use EP\EpProducts\Domain\Serialization\Date;
use EP\EpProducts\Domain\Serialization\Room;
use EP\EpProducts\Traits\DbConnectionTrait;
use EP\EpProducts\Utility\BookingUrlUtility;
use EP\EpProducts\Utility\DbUtility;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class ResellerDataService implements SingletonInterface
{
use DbConnectionTrait;
/**
* @var ProductRepository
*/
@@ -57,6 +59,7 @@ class ResellerDataService implements SingletonInterface
* @param Reseller $reseller
* @param array $imageProcessingInstructions
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function preprocessAll(Reseller $reseller, array $imageProcessingInstructions = null)
{
@@ -77,6 +80,7 @@ class ResellerDataService implements SingletonInterface
* @param Reseller $reseller
* @param array $imageProcessingInstructions
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function preprocessSingle(Product $product, Reseller $reseller, array $imageProcessingInstructions = null)
{
@@ -128,15 +132,16 @@ class ResellerDataService implements SingletonInterface
/**
* @return bool|array
* @throws \Doctrine\DBAL\DBALException
*/
public function getResellerForCurrentDomain()
{
$currentDomain = GeneralUtility::getIndpEnv('HTTP_HOST');
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
return $qb
->select('r.name name, r.pa_code paCode')
->select('r.name as name', 'r.pa_code as paCode')
->from('tx_epproducts_domain_model_reseller', 'r')
->innerJoin('r', 'sys_domain', 'd', 'r.uid = d.tx_epproducts_reseller')
->where('d.domainName = :domain')
@@ -148,4 +153,5 @@ class ResellerDataService implements SingletonInterface
->fetch()
;
}
}
@@ -28,16 +28,21 @@ namespace EP\EpProducts\Service;
***************************************************************/
use EP\EpProducts\Domain\Model\FilterSettings;
use EP\EpProducts\Utility\DbUtility;
use EP\EpProducts\Traits\DbConnectionTrait;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\HttpUtility;
class StaticSearchParamsRequestService
{
use DbConnectionTrait;
const PREFIX_PATH_SEGMENT = 'reiseauswahl';
const SEARCH_RESULT_URI = '/skireisen/suche/';
const REDIRECT_RESPONSE_CODE = 302;
/**
* @throws \Doctrine\DBAL\DBALException
*/
public function handleRequest()
{
$currentUri = GeneralUtility::getIndpEnv('REQUEST_URI');
@@ -48,7 +53,8 @@ class StaticSearchParamsRequestService
return;
}
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select('*')
->from('tx_epproducts_domain_model_staticsearchparams')
@@ -75,4 +81,5 @@ class StaticSearchParamsRequestService
HttpUtility::redirect($redirect, constant('\TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_' . self::REDIRECT_RESPONSE_CODE));
exit;
}
}
@@ -0,0 +1,49 @@
<?php
namespace EP\EpProducts\Traits;
/***************************************************************
*
* Copyright notice
*
* (c) 2018 Björn Fromme <[email protected]>, dreipunktnull
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
trait DbConnectionTrait
{
/**
* @param string $connectionName
* @return \TYPO3\CMS\Core\Database\Connection
* @throws \Doctrine\DBAL\DBALException
*/
protected function getDbConnection($connectionName = 'Default')
{
/** @var ConnectionPool $connectionPool */
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
return $connectionPool->getConnectionByName($connectionName);
}
}
@@ -1,64 +0,0 @@
<?php
namespace EP\EpProducts\Utility;
/***************************************************************
*
* Copyright notice
*
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
class DbUtility
{
/**
* @var Connection
*/
protected static $connection;
/**
* @param string $configIndex
*
* @return Connection
*/
public static function getDbConnection()
{
if (static::$connection === null) {
$config = new Configuration();
$connectionParams = [
'dbname' => $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['dbname'],
'user' => $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['user'],
'password' => $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['password'],
'host' => $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['host'],
'unix_socket' => $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['socket'],
'charset' => 'utf8',
'driver' => 'mysqli',
];
static::$connection = DriverManager::getConnection($connectionParams, $config);
}
return static::$connection;
}
}
@@ -27,20 +27,21 @@ namespace EP\EpTheme\DataProcessing;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use EP\EpProducts\Utility\DbUtility;
use EP\EpProducts\Traits\DbConnectionTrait;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
class ContextProcessor implements DataProcessorInterface
{
use DbConnectionTrait;
/**
* @param ContentObjectRenderer $cObj
* @param array $contentObjectConfiguration
* @param array $processorConfiguration
* @param array $processedData
*
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function process(
ContentObjectRenderer $cObj,
@@ -65,10 +66,12 @@ class ContextProcessor implements DataProcessorInterface
* @param int $uid
* @param string $table
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
private function getContextRecord($uid, $table)
{
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select('*')
->from($table)
@@ -80,4 +83,5 @@ class ContextProcessor implements DataProcessorInterface
return $query->execute()->fetch();
}
}
@@ -27,7 +27,7 @@ namespace EP\EpTheme\DataProcessing;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use EP\EpProducts\Utility\DbUtility;
use EP\EpProducts\Traits\DbConnectionTrait;
use TYPO3\CMS\Core\Resource\FileRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
@@ -35,14 +35,15 @@ use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
class SliderProcessor implements DataProcessorInterface
{
use DbConnectionTrait;
/**
* @param ContentObjectRenderer $cObj
* @param array $contentObjectConfiguration
* @param array $processorConfiguration
* @param array $processedData
*
* @return array
* @throws \Doctrine\DBAL\DBALException
*/
public function process(
ContentObjectRenderer $cObj,
@@ -61,7 +62,8 @@ class SliderProcessor implements DataProcessorInterface
return $processedData;
}
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$query = $qb
->select('uid', 'headline', 'subline', 'button', 'page_uid')
->from('tx_eptheme_domain_model_slide')
@@ -96,12 +98,14 @@ class SliderProcessor implements DataProcessorInterface
protected function getParentPageWithSlides()
{
$rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($GLOBALS['TSFE']->id);
foreach ($rootLine as $parentPage)
{
if ((int) $parentPage['tx_eptheme_slides'] > 0) {
return (int) $parentPage['uid'];
}
}
return null;
}
@@ -27,9 +27,8 @@ namespace EP\EpTrack\Service;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use EP\EpProducts\Utility\DbUtility;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\TimeTracker\NullTimeTracker;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -55,6 +54,7 @@ class RequestService
/**
* @param string $currentUri
* @throws \Doctrine\DBAL\DBALException
*/
public function matchRedirect($currentUri)
{
@@ -64,7 +64,7 @@ class RequestService
$uri .= '/';
}
$qb = DbUtility::getDbConnection()->createQueryBuilder();
$qb = $this->getDbConnection()->createQueryBuilder();
$redirect = $qb
->select('*')
@@ -190,4 +190,17 @@ class RequestService
PageGenerator::pagegenInit();
}
/**
* @return \TYPO3\CMS\Core\Database\Connection
* @throws \Doctrine\DBAL\DBALException
*/
protected function getDbConnection()
{
/** @var ConnectionPool $connectionPool */
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
return $connectionPool->getConnectionByName('Default');
}
}