-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ContentMetadataInspector service to provide correct target classes …
- Loading branch information
1 parent
0fcecd7
commit 8913239
Showing
12 changed files
with
207 additions
and
75 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
Content/Application/ContentMetadataInspector/ContentMetadataInspector.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\ContentBundle\Content\Application\ContentMetadataInspector; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
|
||
class ContentMetadataInspector implements ContentMetadataInspectorInterface | ||
{ | ||
/** | ||
* @var EntityManagerInterface | ||
*/ | ||
private $entityManager; | ||
|
||
public function __construct(EntityManagerInterface $entityManager) | ||
{ | ||
$this->entityManager = $entityManager; | ||
} | ||
|
||
public function getDimensionContentClass(string $contentRichEntityClass): string | ||
{ | ||
$classMetadata = $this->entityManager->getClassMetadata($contentRichEntityClass); | ||
$associationMapping = $classMetadata->getAssociationMapping('dimensionContents'); | ||
|
||
return $associationMapping['targetEntity']; | ||
} | ||
|
||
public function getDimensionContentMappingProperty(string $contentRichEntityClass): string | ||
{ | ||
$classMetadata = $this->entityManager->getClassMetadata($contentRichEntityClass); | ||
$associationMapping = $classMetadata->getAssociationMapping('dimensionContents'); | ||
|
||
return $associationMapping['mappedBy']; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
Content/Application/ContentMetadataInspector/ContentMetadataInspectorInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Sulu. | ||
* | ||
* (c) Sulu GmbH | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Sulu\Bundle\ContentBundle\Content\Application\ContentMetadataInspector; | ||
|
||
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface; | ||
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface; | ||
|
||
interface ContentMetadataInspectorInterface | ||
{ | ||
/** | ||
* @param class-string<ContentRichEntityInterface> $contentRichEntityClass | ||
* | ||
* @return class-string<DimensionContentInterface> | ||
*/ | ||
public function getDimensionContentClass(string $contentRichEntityClass): string; | ||
|
||
/** | ||
* @param class-string<ContentRichEntityInterface> $contentRichEntityClass | ||
*/ | ||
public function getDimensionContentMappingProperty(string $contentRichEntityClass): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.