From be37602832bb32c5d1b26edfbb1b9e37a1c66be0 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Tue, 21 Nov 2023 16:47:45 +0100 Subject: [PATCH] Prevent Doctrine from visiting Concrete9-specific files (#820) --- controller.php | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/controller.php b/controller.php index fe978182..19c5a351 100755 --- a/controller.php +++ b/controller.php @@ -4,6 +4,8 @@ use Concrete\Core\Asset\Asset; use Concrete\Core\Asset\AssetList; use Concrete\Core\Command\Task\Manager as TaskManager; +use Concrete\Core\Database\EntityManager\Provider\ProviderAggregateInterface; +use Concrete\Core\Database\EntityManager\Provider\StandardPackageProvider; use Concrete\Core\Multilingual\Page\Section\Section; use Concrete\Core\Package\Package; use Concrete\Core\Page\Page; @@ -19,7 +21,7 @@ use Doctrine\ORM\EntityManagerInterface; use Whoops\Exception\ErrorException; -class Controller extends Package +class Controller extends Package implements ProviderAggregateInterface { protected $pkgHandle = 'community_store'; protected $appVersionRequired = '8.5'; @@ -37,7 +39,7 @@ class Controller extends Package /** * @var string - */ + */ private static $upgradingFromVersion = ''; public function getPackageDescription() @@ -100,7 +102,7 @@ public function upgradeCoreData() self::$upgradingFromVersion = $packageEntity === null ? '' : (string) $packageEntity->getPackageVersion(); parent::upgradeCoreData(); } - + public function upgrade() { if (self::$upgradingFromVersion !== '' && version_compare(self::$upgradingFromVersion, '2.6.0') < 0) { @@ -205,7 +207,7 @@ public function on_start() ] ); - $select2 = $al->getAssetGroup('select2'); + $select2 = $al->getAssetGroup('select2'); if (!$select2) { $al->register('css', 'select2', 'css/select2/select2.css', ['version' => '3.5.4', 'position' => Asset::ASSET_POSITION_HEADER, 'minify' => false, 'combine' => false], $this); @@ -316,9 +318,9 @@ public static function returnHeaderJS() var QTYMESSAGE = '" . t('Quantity must be greater than zero') . "'; var CHECKOUTSCROLLOFFSET = " . Config::get('community_store.checkout_scroll_offset', 0) . "; var CURRENCYCODE = '" . (Config::get('community_store.currency') ? Config::get('community_store.currency') : '') . "'; - var CURRENCYSYMBOL = '" . Config::get('community_store.symbol') . "'; - var CURRENCYDECIMAL = '" . Config::get('community_store.whole') . "'; - var CURRENCYGROUP = '" . Config::get('community_store.thousand') . "'; + var CURRENCYSYMBOL = '" . Config::get('community_store.symbol') . "'; + var CURRENCYDECIMAL = '" . Config::get('community_store.whole') . "'; + var CURRENCYGROUP = '" . Config::get('community_store.thousand') . "'; "; } @@ -346,4 +348,31 @@ private function registerEventSubscribers() $entityManager = $this->app->make(EntityManagerInterface::class); $entityManager->getEventManager()->addEventSubscriber($subscriber); } + + /** + * {@inheritdoc} + * + * @see \Concrete\Core\Database\EntityManager\Provider\ProviderAggregateInterface::getEntityManagerProvider() + */ + public function getEntityManagerProvider() + { + $locations = [ + 'src/Concrete/Entity' => 'Concrete\Package\CommunityStore\Entity', + ]; + foreach ([ + 'Discount', + 'Group', + 'Manufacturer', + 'Multilingual', + 'Order', + 'Payment', + 'Product', + 'Shipping', + 'Tax', + ] as $chunk) { + $locations['src/CommunityStore/' . $chunk] = 'Concrete\Package\CommunityStore\Src\CommunityStore\\' . $chunk; + } + + return new StandardPackageProvider($this->app, $this, $locations);; + } }