Skip to content

Commit

Permalink
Use constant for 'datahub_context' instead hardcoded value (#880)
Browse files Browse the repository at this point in the history
* Use constant for  'datahub_context' instead hardcoded value

* Removed unused variable $context in DocumentTreeType.

* Removed unused imports.
  • Loading branch information
vmalyk authored Sep 27, 2024
1 parent 4d18220 commit 90cca98
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Controller/WebserviceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ public function webonyxAction(
PimcoreDataHubBundle::setNotAllowedPolicy($config['graphql']['not_allowed_policy']);
}

$longRunningHelper->addPimcoreRuntimeCacheProtectedItems(['datahub_context']);
RuntimeCache::set('datahub_context', $context);
$longRunningHelper->addPimcoreRuntimeCacheProtectedItems([PimcoreDataHubBundle::RUNTIME_CONTEXT_KEY]);
RuntimeCache::set(PimcoreDataHubBundle::RUNTIME_CONTEXT_KEY, $context);

ClassTypeDefinitions::build($service, $context);

Expand Down
3 changes: 2 additions & 1 deletion src/GraphQL/ClassTypeDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Pimcore\Bundle\DataHubBundle\Configuration;
use Pimcore\Bundle\DataHubBundle\GraphQL\DataObjectType\PimcoreObjectType;
use Pimcore\Bundle\DataHubBundle\GraphQL\Exception\ClientSafeException;
use Pimcore\Bundle\DataHubBundle\PimcoreDataHubBundle;
use Pimcore\Cache\RuntimeCache;
use Pimcore\Db;
use Pimcore\Model\DataObject\ClassDefinition;
Expand Down Expand Up @@ -81,7 +82,7 @@ public static function get($class)
public static function getAll($onlyQueryTypes = false)
{
if ($onlyQueryTypes) {
$context = RuntimeCache::get('datahub_context');
$context = RuntimeCache::get(PimcoreDataHubBundle::RUNTIME_CONTEXT_KEY);
/** @var Configuration $configuration */
$configuration = $context['configuration'];
$types = array_keys($configuration->getConfiguration()['schema']['queryEntities']);
Expand Down
3 changes: 2 additions & 1 deletion src/GraphQL/DataObjectType/ObjectTreeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Pimcore\Bundle\DataHubBundle\GraphQL\ClassTypeDefinitions;
use Pimcore\Bundle\DataHubBundle\GraphQL\Service;
use Pimcore\Bundle\DataHubBundle\GraphQL\Traits\ServiceTrait;
use Pimcore\Bundle\DataHubBundle\PimcoreDataHubBundle;
use Pimcore\Cache\RuntimeCache;
use Pimcore\Model\DataObject;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
Expand All @@ -47,7 +48,7 @@ public function __construct(Service $graphQlService, $config = ['name' => 'objec
*/
public function getTypes(): array
{
$context = RuntimeCache::get('datahub_context');
$context = RuntimeCache::get(PimcoreDataHubBundle::RUNTIME_CONTEXT_KEY);
/** @var Configuration $configuration */
$configuration = $context['configuration'];

Expand Down
3 changes: 0 additions & 3 deletions src/GraphQL/DocumentType/DocumentTreeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use GraphQL\Type\Definition\UnionType;
use Pimcore\Bundle\DataHubBundle\GraphQL\Service;
use Pimcore\Bundle\DataHubBundle\GraphQL\Traits\ServiceTrait;
use Pimcore\Cache\RuntimeCache;
use Pimcore\Model\Document;
use Pimcore\Model\Element\ElementInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
Expand Down Expand Up @@ -50,8 +49,6 @@ public function __construct(Service $graphQlService, $config = ['name' => 'docum
*/
public function getTypes(): array
{
$context = RuntimeCache::get('datahub_context');

$types = [];

$supportedTypes = [
Expand Down
2 changes: 1 addition & 1 deletion src/GraphQL/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ public function extractData($data, $target, $args = [], $context = [], ResolveIn
*/
public function querySchemaEnabled(string $type)
{
$context = RuntimeCache::get('datahub_context');
$context = RuntimeCache::get(PimcoreDataHubBundle::RUNTIME_CONTEXT_KEY);
/** @var Configuration $configuration */
$configuration = $context['configuration'];
if ($type === 'object') {
Expand Down
2 changes: 1 addition & 1 deletion src/WorkspaceHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public static function deleteConfiguration(Configuration $config)
*/
public static function checkPermission($element, $type)
{
$context = RuntimeCache::get('datahub_context');
$context = RuntimeCache::get(PimcoreDataHubBundle::RUNTIME_CONTEXT_KEY);
/** @var Configuration $configuration */
$configuration = $context['configuration'];

Expand Down

0 comments on commit 90cca98

Please sign in to comment.