Skip to content

Commit

Permalink
Merge pull request #497 from ezsystems/ezee-2040
Browse files Browse the repository at this point in the history
EZEE-2040: Expose in config map of content type identifiers to names
  • Loading branch information
Łukasz Serwatka authored May 30, 2018
2 parents 8955e25 + 845c6ac commit 50276b4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/bundle/Resources/config/services/ui_config/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ services:
tags:
- { name: ezplatform.admin_ui.config_provider, key: 'contentTypes' }

EzSystems\EzPlatformAdminUi\UI\Config\Provider\ContentTypeNames:
tags:
- { name: ezplatform.admin_ui.config_provider, key: 'contentTypeNames' }

EzSystems\EzPlatformAdminUi\UI\Config\Provider\Module\UniversalDiscoveryWidget:
tags:
- { name: ezplatform.admin_ui.config_provider, key: 'universalDiscoveryWidget' }
Expand Down
40 changes: 40 additions & 0 deletions src/lib/UI/Config/Provider/ContentTypeNames.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace EzSystems\EzPlatformAdminUi\UI\Config\Provider;

use eZ\Publish\API\Repository\ContentTypeService;
use EzSystems\EzPlatformAdminUi\UI\Config\ProviderInterface;

class ContentTypeNames implements ProviderInterface
{
/** @var \eZ\Publish\API\Repository\ContentTypeService */
private $contentTypeService;

/**
* @param \eZ\Publish\API\Repository\ContentTypeService $contentTypeService
*/
public function __construct(ContentTypeService $contentTypeService)
{
$this->contentTypeService = $contentTypeService;
}

/**
* @return mixed Anything that is serializable via json_encode()
*/
public function getConfig()
{
$contentTypeNames = [];

foreach ($this->contentTypeService->loadContentTypeGroups() as $contentTypeGroup) {
foreach ($this->contentTypeService->loadContentTypes($contentTypeGroup) as $contentType) {
$contentTypeNames[$contentType->identifier] = $contentType->getName();
}
}

return $contentTypeNames;
}
}

0 comments on commit 50276b4

Please sign in to comment.