|
2 | 2 |
|
3 | 3 | namespace Smartling\Settings; |
4 | 4 |
|
| 5 | +use Smartling\Base\ExportedAPI; |
5 | 6 | use Smartling\DbAl\EntityManagerAbstract; |
| 7 | +use Smartling\DbAl\LocalizationPluginProxyInterface; |
| 8 | +use Smartling\DbAl\SmartlingToCMSDatabaseAccessWrapperInterface; |
6 | 9 | use Smartling\Exception\BlogNotFoundException; |
7 | 10 | use Smartling\Exception\SmartlingConfigException; |
8 | 11 | use Smartling\Exception\SmartlingDbException; |
|
11 | 14 | use Smartling\Helpers\QueryBuilder\Condition\ConditionBlock; |
12 | 15 | use Smartling\Helpers\QueryBuilder\Condition\ConditionBuilder; |
13 | 16 | use Smartling\Helpers\QueryBuilder\QueryBuilder; |
| 17 | +use Smartling\Helpers\SiteHelper; |
14 | 18 | use Smartling\Helpers\TestRunHelper; |
| 19 | +use Smartling\Helpers\WordpressFunctionProxyHelper; |
15 | 20 | use Smartling\Submissions\SubmissionEntity; |
16 | 21 |
|
17 | 22 | class SettingsManager extends EntityManagerAbstract |
18 | 23 | { |
| 24 | + public function __construct( |
| 25 | + SmartlingToCMSDatabaseAccessWrapperInterface $dbal, |
| 26 | + int $pageSize, |
| 27 | + SiteHelper $siteHelper, |
| 28 | + LocalizationPluginProxyInterface $localizationProxy, |
| 29 | + private WordpressFunctionProxyHelper $wpProxy, |
| 30 | + ) { |
| 31 | + parent::__construct($dbal, $pageSize, $siteHelper, $localizationProxy); |
| 32 | + } |
| 33 | + |
19 | 34 | /** |
20 | 35 | * @return ConfigurationProfileEntity[] |
21 | 36 | */ |
@@ -44,7 +59,18 @@ public function getActiveProfiles(): array |
44 | 59 | { |
45 | 60 | $cnt = 0; |
46 | 61 |
|
47 | | - return $this->getEntities($cnt, true); |
| 62 | + $profiles = $this->wpProxy->apply_filters( |
| 63 | + ExportedAPI::FILTER_ACTIVE_PROFILES, |
| 64 | + $this->getEntities($cnt, true), |
| 65 | + ); |
| 66 | + foreach ($profiles as $profile) { |
| 67 | + if (!$profile instanceof ConfigurationProfileEntity) { |
| 68 | + throw new \RuntimeException('Expected instance of ' . ConfigurationProfileEntity::class . ', got ' . |
| 69 | + is_object($profile) ? get_class($profile) : gettype($profile)); |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + return $profiles; |
48 | 74 | } |
49 | 75 |
|
50 | 76 | /** |
|
0 commit comments