Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK]: Remove Pimcore\Config\Config #12911

Merged
merged 7 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function saveAction(Request $request): JsonResponse
if ($request->get('task') !== self::TASK_SAVE) {
//check, if to cleanup existing elements of document
$config = Config::getWeb2PrintConfig();
if ($config->get('generalDocumentSaveMode') == 'cleanup') {
if ($config['generalDocumentSaveMode'] == 'cleanup') {
$page->setEditables([]);
}
}
Expand Down
11 changes: 3 additions & 8 deletions bundles/AdminBundle/Controller/Admin/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,9 @@ public function setSystemAction(

$values = $this->decodeJson($request->get('data'));

$existingValues = [];

try {
$file = Config::locateConfigFile('system.yml');
$existingValues = Config::getConfigInstance($file, true);
Config::getConfigInstance($file);
} catch (\Exception $e) {
// nothing to do
}
Expand All @@ -460,7 +458,6 @@ public function setSystemAction(

// fallback languages
$fallbackLanguages = [];
$existingValues['pimcore']['general']['fallback_languages'] = [];
$languages = explode(',', $values['general.validLanguages']);
$filteredLanguages = [];

Expand Down Expand Up @@ -594,8 +591,7 @@ public function getWeb2printAction(Request $request)
{
$this->checkPermission('web2print_settings');

$values = Config::getWeb2PrintConfig();
$valueArray = $values->toArray();
$valueArray = Config::getWeb2PrintConfig();

$optionsString = [];
if ($valueArray['wkhtml2pdfOptions'] ?? false) {
Expand Down Expand Up @@ -1595,7 +1591,6 @@ public function robotsTxtGetAction()
$this->checkPermission('robots.txt');

$config = Config::getRobotsConfig();
$config = $config->toArray();

return $this->adminJson([
'success' => true,
Expand Down Expand Up @@ -1842,7 +1837,7 @@ public function testWeb2printAction(Request $request)
];
} elseif ($adapter instanceof \Pimcore\Web2Print\Processor\HeadlessChrome) {
$params = Config::getWeb2PrintConfig();
$params = $params->get('headlessChromeSettings');
$params = $params['headlessChromeSettings'];
$params = json_decode($params, true);
}

Expand Down
10 changes: 5 additions & 5 deletions bundles/AdminBundle/Controller/Reports/AnalyticsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function deeplinkAction(Request $request, SiteConfigProvider $siteConfigP
$config = $siteConfigProvider->getSiteConfig();

$url = $request->get('url');
$url = str_replace(['{accountId}', '{internalWebPropertyId}', '{id}'], [$config->accountid, $config->internalid, $config->profile], $url);
$url = str_replace(['{accountId}', '{internalWebPropertyId}', '{id}'], [$config['accountid'], $config['internalid'], $config['profile']], $url);
$url = 'https://www.google.com/analytics/web/' . $url;

return $this->redirect($url);
Expand Down Expand Up @@ -207,7 +207,7 @@ public function chartmetricdataAction(Request $request, SiteConfigProvider $site
}

$result = $this->service->data_ga->get(
'ga:' . $config->profile,
'ga:' . $config['profile'],
$startDate,
$endDate,
implode(',', $metrics),
Expand Down Expand Up @@ -271,7 +271,7 @@ public function summaryAction(Request $request, SiteConfigProvider $siteConfigPr
}

$result = $this->service->data_ga->get(
'ga:' . $config->profile,
'ga:' . $config['profile'],
$startDate,
$endDate,
'ga:uniquePageviews,ga:pageviews,ga:exits,ga:bounces,ga:entrances',
Expand Down Expand Up @@ -351,7 +351,7 @@ public function sourceAction(Request $request, SiteConfigProvider $siteConfigPro
}

$result = $this->service->data_ga->get(
'ga:' . $config->profile,
'ga:' . $config['profile'],
$startDate,
$endDate,
'ga:pageviews',
Expand Down Expand Up @@ -423,7 +423,7 @@ public function dataExplorerAction(Request $request, SiteConfigProvider $siteCon
}

$result = $this->service->data_ga->get(
'ga:' . $config->profile,
'ga:' . $config['profile'],
$startDate,
$endDate,
$metric,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
abstract class ReportsControllerBase extends AdminController
{
/**
* @return \Pimcore\Config\Config
* @return array
*/
public function getConfig()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SettingsController extends ReportsControllerBase
public function getAction(Request $request)
{
$this->checkPermission('system_settings');
$config = $this->getConfig()->toArray();
$config = $this->getConfig();

$response = [
'values' => $config,
Expand Down
2 changes: 1 addition & 1 deletion bundles/CoreBundle/Controller/PublicServicesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function robotsTxtAction(Request $request)
$domain = \Pimcore\Tool::getHostname();
$site = Site::getByDomain($domain);

$config = Config::getRobotsConfig()->toArray();
$config = Config::getRobotsConfig();

$siteId = 'default';
if ($site instanceof Site) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public function onKernelRequest(RequestEvent $event)

$conf = \Pimcore\Config::getReportConfig();

if (!is_null($conf->get('webmastertools')) && isset($conf->get('webmastertools')->sites)) {
$sites = $conf->get('webmastertools')->sites->toArray();
if (isset($conf['webmastertools']) && isset($conf['webmastertools']['sites'])) {
$sites = $conf['webmastertools']['sites'];

if (is_array($sites)) {
foreach ($sites as $site) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ public function onKernelResponse(ResponseEvent $event)
$siteKey = $siteId->getConfigKey();

$reportConfig = Config::getReportConfig();
if (!isset($reportConfig->get('tagmanager')->sites->$siteKey->containerId)) {
if (!isset($reportConfig['tagmanager']['sites'][$siteKey]['containerId'])) {
return;
}

$containerId = $reportConfig->get('tagmanager')->sites->$siteKey->containerId;
$containerId = $reportConfig['tagmanager']['sites'][$siteKey]['containerId'];
if (!$containerId) {
return;
}
Expand Down
1 change: 0 additions & 1 deletion bundles/CoreBundle/Migrations/Version20210323110055.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public function up(Schema $schema): void
}

$config = Config::getConfigInstance($file);
$config = $config->toArray();

foreach ($config as $siteId => $robotsContent) {
SettingsStore::set('robots.txt-' . $siteId, $robotsContent, 'string', 'robots.txt');
Expand Down
1 change: 0 additions & 1 deletion bundles/CoreBundle/Migrations/Version20210630062445.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public function up(Schema $schema): void
}

$config = Config::getConfigInstance($file);
$config = $config->toArray();

SettingsStore::set(
ReportConfigWriter::REPORT_SETTING_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\Worker\WorkerInterface;
use Pimcore\Bundle\EcommerceFrameworkBundle\Model\AbstractCategory;
use Pimcore\Bundle\EcommerceFrameworkBundle\Model\IndexableInterface;
use Pimcore\Config\Config;
use Pimcore\Model\DataObject;

abstract class AbstractConfig implements ConfigInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Examples:
### Access the Settings

In controllers and views, you can use view helpers or argument resolves to access the config.
The returned configuration is a `Pimcore\Config\Config` object containing your settings.
The returned configuration is an array containing your settings.


### Example Configuration
Expand All @@ -39,9 +39,9 @@ Usage in a controller:
<?php
class TestController
{
public function testAction(\Pimcore\Config\Config $websiteConfig)
public function testAction(array $websiteConfig)
{
$recaptchaKeyPublic = $websiteConfig->get('recaptchaPublic');
$recaptchaKeyPublic = $websiteConfig['recaptchaPublic'];
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
- [Listings] Removed `JsonListing`, please see [#12877](https://github.com/pimcore/pimcore/pull/12877) for details.
- [Traits] The traits PackageVersionTrait and StateHelperTrait in lib/Extension/Bundle/Traits have been marked as
internal, please see [#12757](https://github.com/pimcore/pimcore/pull/12757) for details.

- [Config] `Pimcore\Config\Config` has been removed, see [#12477](https://github.com/pimcore/pimcore/issues/12477). Please use the returned array instead, e.g.
```php
$web2printConfig = Config::getWeb2PrintConfig();
$web2printConfig = $web2printConfig['headlessChromeSettings'];
- ```

## 10.5.0
- [Sessions] Changed default value for `symfony.session.cookie_secure` to `auto`
Expand Down
32 changes: 15 additions & 17 deletions lib/Analytics/Google/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,31 @@

namespace Pimcore\Analytics\Google\Config;

use Pimcore\Config\Config as ConfigObject;

class Config
{
/**
* @var ConfigObject
* @var array
*/
private $config;

public function __construct(ConfigObject $config)
public function __construct(array $config)
{
$this->config = $config;
}

public static function fromReportConfig(ConfigObject $reportConfig): self
public static function fromReportConfig(array $reportConfig): self
{
$config = null;
if ($reportConfig->get('analytics')) {
$config = $reportConfig->get('analytics');
if ($reportConfig['analytics']) {
$config = $reportConfig['analytics'];
} else {
$config = new ConfigObject([]);
$config = [];
}

return new self($config);
}

public function getConfig(): ConfigObject
public function getConfig(): array
{
return $this->config;
}
Expand All @@ -56,7 +54,7 @@ public function isSiteConfigured(string $configKey): bool
return false;
}

$trackId = $this->normalizeStringValue($config->get('trackid'));
$trackId = $this->normalizeStringValue($config['trackid']);
if (null === $trackId) {
return false;
}
Expand All @@ -67,22 +65,22 @@ public function isSiteConfigured(string $configKey): bool
/**
* @param string $configKey
*
* @return null|ConfigObject
* @return null|array
*/
public function getConfigForSite(string $configKey)
{
if (!$this->config->get('sites') || !$this->config->get('sites')->$configKey) {
if (!isset($this->config['sites']) || !isset($this->config['sites'][$configKey])) {
return null;
}

return $this->config->get('sites')->$configKey;
return $this->config['sites'][$configKey];
}

public function getConfiguredSites(): array
{
$sites = $this->config->get('sites');
if ($sites && $sites instanceof ConfigObject) {
return array_keys($sites->toArray());
$sites = $this->config['sites'];
if (is_array($sites)) {
return $sites;
}

return [];
Expand All @@ -96,7 +94,7 @@ public function isReportingConfigured(string $configKey): bool
return false;
}

$profile = $this->normalizeStringValue($config->get('profile'));
$profile = $this->normalizeStringValue($config['profile']);
if (null === $profile) {
return false;
}
Expand Down
18 changes: 8 additions & 10 deletions lib/Analytics/Google/Config/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

namespace Pimcore\Analytics\Google\Config;

use Pimcore\Config\Config as ConfigObject;

class ConfigProvider
{
/**
Expand All @@ -27,14 +25,14 @@ class ConfigProvider
private $config;

/**
* @var ConfigObject|null
* @var array|null
*/
private $configObject;

/**
* @param ConfigObject|null $configObject
* @param array|null $configObject
*/
public function __construct(ConfigObject $configObject = null)
public function __construct(array $configObject = null)
{
$this->configObject = $configObject;
}
Expand All @@ -48,7 +46,7 @@ public function getConfig(): Config
return $this->config;
}

private function getConfigObject(): ConfigObject
private function getConfigObject(): array
{
if (null === $this->configObject) {
$this->configObject = $this->loadDefaultConfigObject();
Expand All @@ -57,13 +55,13 @@ private function getConfigObject(): ConfigObject
return $this->configObject;
}

protected function loadDefaultConfigObject(): ConfigObject
protected function loadDefaultConfigObject(): array
{
$reportConfig = \Pimcore\Config::getReportConfig();

$config = $reportConfig->get('analytics');
if (!$config instanceof ConfigObject) {
$config = new ConfigObject([]);
$config = $reportConfig['analytics'];
if (!is_array($config)) {
$config = [];
}

return $config;
Expand Down
2 changes: 1 addition & 1 deletion lib/Analytics/Google/Config/SiteConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(
/**
* @param Site|null $site
*
* @return \Pimcore\Config\Config|null
* @return array|null
*/
public function getSiteConfig(Site $site = null)
{
Expand Down
Loading