Skip to content

Commit

Permalink
Merge branch 'feature/sulu-update-change-link-block-type' into 'master'
Browse files Browse the repository at this point in the history
Change single page selection to link content type

See merge request webapps/sulu-demo!147
  • Loading branch information
Prokyonn committed Mar 13, 2024
2 parents 1b1fb3b + 4a7fd8d commit e973abf
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 31 deletions.
8 changes: 8 additions & 0 deletions config/packages/stof_doctrine_extensions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@
# See the official DoctrineExtensions documentation for more details: https://github.com/doctrine-extensions/DoctrineExtensions/tree/main/doc
stof_doctrine_extensions:
default_locale: '%default_locale%'

when@prod: &prod
stof_doctrine_extensions:
# fix issue with gedmo/extensions 1.8.0 and stof/doctrine-extensions-bundle: 3.12.0
# @see https://github.com/stof/StofDoctrineExtensionsBundle/issues/457
metadata_cache_pool: doctrine.system_cache_pool

when@stage: *prod
19 changes: 7 additions & 12 deletions config/templates/includes/blocks/link.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,16 @@
</meta>

<properties>
<property name="page" type="single_page_selection" mandatory="true">
<!-- @see https://docs.sulu.io/en/2.2/reference/content-types/single_page_selection.html -->
<property name="link" type="link" mandatory="true">
<meta>
<title lang="en">Page</title>
<title lang="de">Seite</title>
<title lang="en">Link</title>
<title lang="de">Link</title>
</meta>
</property>

<property name="text" type="text_line">
<meta>
<title lang="en">Text</title>
<title lang="de">Text</title>
<info_text lang="en">Leave blank if the page title should be displayed.</info_text>
<info_text lang="en">Leer lassen, wenn der Seiten-Titel angezeigt werden soll.</info_text>
</meta>
<params>
<param name="enable_anchor" value="true"/>
<param name="enable_attributes" value="true"/>
</params>
</property>
</properties>
</type>
Expand Down
3 changes: 0 additions & 3 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\Symfony\CodeQuality\Rector\ClassMethod\ActionSuffixRemoverRector;
use Rector\Symfony\Set\SymfonyLevelSetList;
use Rector\Symfony\Set\SymfonySetList;
use Sulu\Rector\Set\SuluLevelSetList;
Expand All @@ -35,8 +34,6 @@
// symfony rules
$rectorConfig->symfonyContainerPhp(__DIR__ . '/var/cache/website/dev/App_KernelDevDebugContainer.xml');

$rectorConfig->skip([ActionSuffixRemoverRector::class]);

$rectorConfig->sets([
SymfonySetList::SYMFONY_CODE_QUALITY,
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
Expand Down
6 changes: 4 additions & 2 deletions src/Build/UserBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
use Sulu\Bundle\SecurityBundle\Entity\User;
use Sulu\Bundle\SecurityBundle\Entity\UserSetting;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

class UserBuilder implements BuilderInterface, ContainerAwareInterface
{
use ContainerAwareTrait;
/**
* @var ContainerInterface
*/
protected $container;

public function __construct(private readonly SuluUserBuilder $decoratedUserBuilder, ?ContainerInterface $container = null)
{
Expand Down
10 changes: 5 additions & 5 deletions src/Controller/Admin/AlbumController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(private readonly DoctrineListRepresentationFactory $
}

#[Route(path: '/admin/api/albums/{id}', methods: ['GET'], name: 'app.get_album')]
public function getAction(int $id): Response
public function get(int $id): Response
{
$album = $this->entityManager->getRepository(Album::class)->find($id);
if (!$album instanceof Album) {
Expand All @@ -42,7 +42,7 @@ public function getAction(int $id): Response
}

#[Route(path: '/admin/api/albums/{id}', methods: ['PUT'], name: 'app.put_album')]
public function putAction(Request $request, int $id): Response
public function put(Request $request, int $id): Response
{
$album = $this->entityManager->getRepository(Album::class)->find($id);
if (!$album instanceof Album) {
Expand All @@ -57,7 +57,7 @@ public function putAction(Request $request, int $id): Response
}

#[Route(path: '/admin/api/albums', methods: ['POST'], name: 'app.post_album')]
public function postAction(Request $request): Response
public function post(Request $request): Response
{
$album = new Album();
/** @var AlbumData $data */
Expand All @@ -70,7 +70,7 @@ public function postAction(Request $request): Response
}

#[Route(path: '/admin/api/albums/{id}', methods: ['DELETE'], name: 'app.delete_album')]
public function deleteAction(int $id): Response
public function delete(int $id): Response
{
/** @var Album $album */
$album = $this->entityManager->getReference(Album::class, $id);
Expand All @@ -81,7 +81,7 @@ public function deleteAction(int $id): Response
}

#[Route(path: '/admin/api/albums', methods: ['GET'], name: 'app.get_album_list')]
public function getListAction(): Response
public function getList(): Response
{
$listRepresentation = $this->doctrineListRepresentationFactory->createDoctrineListRepresentation(
Album::RESOURCE_KEY,
Expand Down
18 changes: 14 additions & 4 deletions src/DataFixtures/Document/DocumentFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -1087,8 +1087,13 @@ private function loadHomepageEnglish(DocumentManager $documentManager, array $pa
],
[
'type' => 'link',
'page' => $aboutPage->getUuid(),
'text' => 'READ MORE',
'link' => [
'href' => $aboutPage->getUuid(),
'provider' => 'page',
'locale' => 'en',
'target' => '_self',
'title' => 'READ MORE',
],
],
[
'type' => 'teasers',
Expand Down Expand Up @@ -1152,8 +1157,13 @@ private function loadHomepageGerman(DocumentManager $documentManager, array $pag
],
[
'type' => 'link',
'page' => $aboutPage->getUuid(),
'text' => 'MEHR LESEN',
'link' => [
'href' => $aboutPage->getUuid(),
'provider' => 'page',
'locale' => 'en',
'target' => '_self',
'title' => 'MEHR LESEN',
],
],
[
'type' => 'teasers',
Expand Down
8 changes: 3 additions & 5 deletions templates/includes/blocks/link.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{# @see https://docs.sulu.io/en/2.2/reference/twig-extensions/functions/sulu_content_load.html #}
{% set page = sulu_content_load(content.page, ['title', 'url']) %}

<a href="{{ sulu_content_path(page.content.url) }}" class="button block-link">
{{ text|default(page.content.title|default('read_more'|trans)) }}
{# @see https://docs.sulu.io/en/2.5/reference/content-types/link.html #}
<a href="{{ content.link }}" class="button block-link" target="{{ view.link.target }}">
{{ view.link.title|default('read_more'|trans) }}
</a>

0 comments on commit e973abf

Please sign in to comment.