Skip to content

Commit

Permalink
Use RoutableStructureInterface (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-rath committed Oct 18, 2022
1 parent b9cc927 commit b7b899a
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Content/Infrastructure/Sulu/Structure/ContentStructureBridge.php
Expand Up @@ -26,7 +26,7 @@
use Sulu\Component\Content\Metadata\PropertyMetadata;
use Sulu\Component\Content\Metadata\StructureMetadata;

class ContentStructureBridge implements StructureInterface
class ContentStructureBridge implements StructureInterface, RoutableStructureInterface
{
/**
* @var StructureMetadata
Expand Down Expand Up @@ -130,6 +130,21 @@ public function getController(): ?string
return $this->structure->getController();
}

/**
* @return array{
* type: string,
* value: string,
* }
*/
public function getCacheLifeTime(): array
{
/** @var array{
* type: string,
* value: string,
* } */
return $this->structure->getCacheLifetime();
}

public function getCreator(): ?int
{
return null;
Expand Down
@@ -0,0 +1,61 @@
<?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\Infrastructure\Sulu\Structure;

use Sulu\Component\Content\Compat\RoutableStructureInterface as SuluRoutableStructureInterface;

if (interface_exists(SuluRoutableStructureInterface::class)) {
/**
* @deprecated will be removed, as soon as the ArticleBundle rises the minimum requirement of sulu to a version,
* where this interface exists
*
* @internal
*/
interface RoutableStructureInterface extends SuluRoutableStructureInterface
{
}
} else {
/**
* @deprecated will be removed, as soon as the ArticleBundle rises the minimum requirement of sulu to a version,
* where this interface exists
*
* @internal
*/
interface RoutableStructureInterface
{
/**
* twig template of template definition.
*
* @return string
*/
public function getView();

/**
* controller which renders the twig template.
*
* @return string
*/
public function getController();

/**
* cacheLifeTime of template definition.
*
* @return array{
* type: string,
* value: string,
* }
*/
public function getCacheLifeTime();
}
}
Expand Up @@ -157,6 +157,20 @@ public function testGetController(): void
);
}

public function testGetCacheLifeTime(): void
{
$structure = $this->prophesize(StructureMetadata::class);

$structure->getCacheLifeTime()->willReturn(['type' => 'type', 'value' => 'value']);

$structure = $this->createStructureBridge(null, $structure->reveal());

$this->assertSame(
['type' => 'type', 'value' => 'value'],
$structure->getCacheLifeTime()
);
}

public function testGetKey(): void
{
$structure = $this->prophesize(StructureMetadata::class);
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Expand Up @@ -29,6 +29,7 @@
<directory>Tests/</directory>
<directory>vendor/</directory>
<file>.php-cs-fixer.dist.php</file>
<file>Content/Infrastructure/Sulu/Structure/RoutableStructureInterface.php</file>
</exclude>
</whitelist>
</filter>
Expand Down

0 comments on commit b7b899a

Please sign in to comment.