Skip to content

Commit

Permalink
Merge 5902d26 into 8435b81
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-rath committed Oct 18, 2022
2 parents 8435b81 + 5902d26 commit 46d02fc
Show file tree
Hide file tree
Showing 49 changed files with 470 additions and 248 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ public function map(
throw new \RuntimeException(\sprintf('No route mapping found for "%s".', $resourceKey));
}

/** @var string|null $routePath */
$routePath = $data[$name] ?? null;

if (!$routePath) {
/** @var mixed $routeGenerationData */
/** @var mixed[] $routeGenerationData */
$routeGenerationData = \array_merge(
$data,
[
Expand Down Expand Up @@ -161,7 +162,7 @@ public function map(
// route should only be updated in live dimension
$route = $this->routeManager->createOrUpdateByAttributes(
$entityClass,
(string) $localizedDimensionContent->getResourceId(),
(string) $localizedDimensionContent->getResourceId(), // @phpstan-ignore-line
$locale,
$routePath,
false
Expand All @@ -173,7 +174,7 @@ public function map(
$route->setPath($routePath);
$route->setLocale($locale);
$route->setEntityClass($entityClass);
$route->setEntityId((string) $localizedDimensionContent->getResourceId());
$route->setEntityId((string) $localizedDimensionContent->getResourceId()); // @phpstan-ignore-line

$routePath = $this->conflictResolver->resolve($route)
->getPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,28 @@ public function map(
return;
}

/** @var array{
* seoTitle?: string|null,
* seoDescription?: string|null,
* seoKeywords?: string|null,
* seoCanonicalUrl?: string|null,
* seoHideInSitemap?: bool,
* seoNoFollow?: bool,
* seoNoIndex?: bool,
* } $data */
$this->setSeoData($localizedDimensionContent, $data);
}

/**
* @param mixed[] $data
* @param array{
* seoTitle?: string|null,
* seoDescription?: string|null,
* seoKeywords?: string|null,
* seoCanonicalUrl?: string|null,
* seoHideInSitemap?: bool,
* seoNoFollow?: bool,
* seoNoIndex?: bool,
* } $data
*/
private function setSeoData(SeoInterface $dimensionContent, array $data): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ private function setPublishedToLiveDimension(WorkflowInterface $object, array $d
return;
}

/** @var string|null $published */
$published = $data['published'] ?? null;

if (!$published) {
Expand Down
1 change: 1 addition & 0 deletions Content/Application/ContentIndexer/ContentIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function deindex(string $resourceKey, $id, array $dimensionAttributes = [
$locale = $dimensionAttributes['locale'] ?? null;
$stage = $dimensionAttributes['stage'] ?? null;

/** @var scalar $id */
$search = $this->searchManager->createSearch(\sprintf('__id:"%s"', $id))
->indexes($this->getIndexes($resourceKey, $stage));

Expand Down
4 changes: 2 additions & 2 deletions Content/Application/ContentMerger/Merger/ExcerptMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public function merge(object $targetObject, object $sourceObject): void
}

if ($excerptTags = $sourceObject->getExcerptTags()) {
if (!empty($excerptTags)) {
if ([] !== $excerptTags) {
$targetObject->setExcerptTags($excerptTags);
}
}

if ($excerptCategories = $sourceObject->getExcerptCategories()) {
if (!empty($excerptCategories)) {
if ([] !== $excerptCategories) {
$targetObject->setExcerptCategories($excerptCategories);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public function enhance(object $object, array $normalizedData): array
return $normalizedData;
}

$normalizedData = \array_merge($normalizedData['templateData'], $normalizedData);
/** @var mixed[] $templateData */
$templateData = $normalizedData['templateData'];
$normalizedData = \array_merge($templateData, $normalizedData);
unset($normalizedData['templateData']);

$normalizedData['template'] = $normalizedData['templateKey'];
Expand Down
3 changes: 3 additions & 0 deletions Content/Application/ContentResolver/ContentResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public function __construct(
$this->contentMerger = $contentMerger;
}

/**
* @param array<string, scalar> $dimensionAttributes
*/
public function resolve(ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes): DimensionContentInterface
{
$dimensionContentCollection = $this->dimensionContentRepository->load($contentRichEntity, $dimensionAttributes);
Expand Down
3 changes: 3 additions & 0 deletions Content/Application/ContentWorkflow/ContentWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ public function apply(
*/

$dimensionContentCollection = $this->dimensionContentRepository->load($contentRichEntity, $dimensionAttributes);

/** @var array<string, bool|float|int|string|null> $dimensionAttributes */
$dimensionAttributes = $dimensionContentCollection->getDimensionAttributes();

$localizedDimensionContent = $dimensionContentCollection->getDimensionContent($dimensionAttributes);

if (!$localizedDimensionContent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ public function create(
);
}

$localizedDimensionContent = null;
/** @var string|null $locale */
$locale = $dimensionAttributes['locale'] ?? null;
$localizedDimensionContent = null;

if ($locale) {
$localizedDimensionContent = $dimensionContentCollection->getDimensionContent($dimensionAttributes);

Expand Down
5 changes: 4 additions & 1 deletion Content/Domain/Exception/ContentNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ class ContentNotFoundException extends \Exception
*/
public function __construct(ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes)
{
/** @var string|int $id */
$id = $contentRichEntity->getId();

parent::__construct(\sprintf(
'Could not load content with id "%s" and attributes: %s',
$contentRichEntity->getId(),
$id,
\json_encode($dimensionAttributes)
));
}
Expand Down
11 changes: 0 additions & 11 deletions Content/Infrastructure/Doctrine/DimensionContentQueryEnhancer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@
*/
class DimensionContentQueryEnhancer
{
/**
* @var ContentMetadataInspectorInterface
*/
private $contentMetadataInspector;

public function __construct(
ContentMetadataInspectorInterface $contentMetadataInspector
) {
$this->contentMetadataInspector = $contentMetadataInspector;
}

/**
* Withs represents additional selects which can be load to join and select specific sub entities.
* They are used by groups and fields.
Expand Down
2 changes: 2 additions & 0 deletions Content/Infrastructure/Doctrine/MetadataLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $event): void
* @codeCoverageIgnore
*
* @param ClassMetadataInfo<object> $metadata
* @param class-string<object> $class
*/
private function addManyToOne(
LoadClassMetadataEventArgs $event,
Expand Down Expand Up @@ -148,6 +149,7 @@ private function addManyToOne(

/**
* @param ClassMetadataInfo<object> $metadata
* @param class-string<object> $class
*/
private function addManyToMany(
LoadClassMetadataEventArgs $event,
Expand Down
5 changes: 4 additions & 1 deletion Content/Infrastructure/Doctrine/RouteRemover.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ public function preRemove(LifecycleEventArgs $event): void
return;
}

foreach ($this->routeRepository->findAllByEntity($entityClass, $object->getId()) as $route) {
/** @var string $entityId */
$entityId = $object->getId();

foreach ($this->routeRepository->findAllByEntity($entityClass, $entityId) as $route) {
$event->getEntityManager()->remove($route);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,10 @@ private function createSettingsFormView(
): ViewBuilderInterface {
$forms = [];
foreach ($this->settingsForms as $key => $tag) {
if (\is_subclass_of($dimensionContentClass, $tag['instanceOf'])) {
/** @var string $instanceOf */
$instanceOf = $tag['instanceOf'];

if (\is_subclass_of($dimensionContentClass, $instanceOf)) {
$forms[] = $key;
}
}
Expand Down
4 changes: 4 additions & 0 deletions Content/Infrastructure/Sulu/Preview/ContentObjectProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public function getObject($id, $locale)
*/
public function getId($object)
{
/** @var string */
return $object->getResource()->getId();
}

Expand Down Expand Up @@ -153,9 +154,12 @@ public function serialize($object)
*/
public function deserialize($serializedObject, $objectClass)
{
/** @var mixed[] $data */
$data = \json_decode($serializedObject, true);

/** @var string|null $id */
$id = $data['id'] ?? null;
/** @var string|null $locale */
$locale = $data['locale'] ?? null;

if (!$id || !$locale) {
Expand Down
2 changes: 2 additions & 0 deletions Content/Infrastructure/Sulu/Search/ContentReindexProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function provide($classFqn, $offset, $maxResults)
->setFirstResult($offset)
->setMaxResults($maxResults);

/** @var ContentRichEntityInterface[] */
return $queryBuilder->getQuery()->execute();
}

Expand All @@ -99,6 +100,7 @@ public function getCount($classFqn)
->from($this->contentRichEntityClass, 'contentRichEntity')
->select('COUNT(contentRichEntity)');

/** @var int */
return $queryBuilder->getQuery()->getSingleScalarResult();
}

Expand Down
10 changes: 5 additions & 5 deletions Content/Infrastructure/Sulu/Sitemap/ContentSitemapProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public function build($page, $scheme, $host): array
$mainRoute = $entityRoutes[$defaultLocale];
unset($entityRoutes[$defaultLocale]);
} else {
/** @var RouteInterface $mainRoute */
$mainRoute = \array_shift($entityRoutes);
}

Expand Down Expand Up @@ -168,7 +169,7 @@ public function getMaxPage($scheme, $host): int
/**
* @param RouteInterface[] $routes
*
* @return mixed[]
* @return array<string, array<string, RouteInterface>>
*/
protected function groupRoutesByEntityId(array $routes): array
{
Expand All @@ -188,7 +189,7 @@ protected function groupRoutesByEntityId(array $routes): array
}

/**
* @return mixed[]
* @return RouteInterface[]
*/
protected function getRoutes(int $limit, int $offset): array
{
Expand All @@ -201,9 +202,8 @@ protected function getRoutes(int $limit, int $offset): array
->setFirstResult($offset)
->setMaxResults($limit);

$result = $queryBuilder->getQuery()->getResult();

return $result;
/** @var RouteInterface[] */
return $queryBuilder->getQuery()->getResult();
}

protected function createRoutesQueryBuilder(): QueryBuilder
Expand Down
Loading

0 comments on commit 46d02fc

Please sign in to comment.