Skip to content

Commit

Permalink
CS
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Jan 17, 2024
1 parent 64751be commit 991ee0c
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 15 deletions.
5 changes: 4 additions & 1 deletion news-bundle/contao/classes/News.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ class News extends Frontend
* @param boolean $blnAbsolute
*
* @return string
*
* @deprecated Deprecated since Contao 5.3, to be removed in Contao 6;
* use the content URL generator instead.
*/
public static function generateNewsUrl($objItem, $blnAddArchive=false, $blnAbsolute=false)
{
trigger_deprecation('contao/core-bundle', '5.3', 'Using "%s" is deprecated, use the content URL generator instead.', __METHOD__);
trigger_deprecation('contao/core-bundle', '5.3', 'Using "%s()" has been deprecated and will no longer work in Contao 6. Use the content URL generator instead.', __METHOD__);

try
{
Expand Down
4 changes: 1 addition & 3 deletions news-bundle/contao/modules/ModuleNewsMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ public function generate()
{
try
{
$urlGenerator = System::getContainer()->get('contao.routing.content_url_generator');

$this->strUrl = $urlGenerator->generate($objTarget);
$this->strUrl = System::getContainer()->get('contao.routing.content_url_generator')->generate($objTarget);
}
catch (ExceptionInterface)
{
Expand Down
4 changes: 2 additions & 2 deletions news-bundle/contao/modules/ModuleNewsReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ public function generate()
*/
protected function compile()
{
$urlGenerator = System::getContainer()->get('contao.routing.content_url_generator');

$this->Template->articles = '';

$urlGenerator = System::getContainer()->get('contao.routing.content_url_generator');

if ($this->overviewPage && ($overviewPage = PageModel::findById($this->overviewPage)))
{
$this->Template->referer = $urlGenerator->generate($overviewPage);
Expand Down
2 changes: 1 addition & 1 deletion news-bundle/src/EventListener/GeneratePageListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public function __invoke(PageModel $pageModel, LayoutModel $layoutModel): void
continue;
}

// TODO: Use ResponseContext, once it supports appending to <head>
try {
// TODO: Use ResponseContext, once it supports appending to <head>
$GLOBALS['TL_HEAD'][] = $this->generateFeedTag($this->urlGenerator->generate($feed, [], UrlGeneratorInterface::ABSOLUTE_URL), $feed->feedFormat, $feed->title);
} catch (ExceptionInterface) {
}
Expand Down
3 changes: 3 additions & 0 deletions news-bundle/src/EventListener/NewsFeedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
use Symfony\Component\Filesystem\Path;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

/**
* @internal
*/
class NewsFeedListener
{
public function __construct(
Expand Down
4 changes: 1 addition & 3 deletions news-bundle/src/Routing/NewsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ public function getParametersForContent(object $content, PageModel $pageModel):
return [];
}

return [
'parameters' => '/'.($content->alias ?: $content->id),
];
return ['parameters' => '/'.($content->alias ?: $content->id)];
}
}
1 change: 1 addition & 0 deletions news-bundle/tests/EventListener/InsertTagsListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public function testReturnsFalseIfTheTagIsUnknown(): void
{
$urlGenerator = $this->createMock(ContentUrlGenerator::class);
$logger = $this->createMock(LoggerInterface::class);

$listener = new InsertTagsListener($this->mockContaoFramework(), $urlGenerator, $logger);

$this->assertFalse($listener('link_url::2', false, null, []));
Expand Down
4 changes: 1 addition & 3 deletions news-bundle/tests/EventListener/SitemapListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public function testNothingIsAddedIfNoPublishedArchive(): void
*/
public function testNewsArticleIsAdded(array $pageProperties, array $newsArchiveProperties, bool $hasAuthenticatedMember): void
{
$jumpToPage = $this->mockClassWithProperties(PageModel::class, $pageProperties);

$adapters = [
NewsArchiveModel::class => $this->mockConfiguredAdapter([
'findByProtected' => [
Expand All @@ -62,7 +60,7 @@ public function testNewsArticleIsAdded(array $pageProperties, array $newsArchive
],
]),
PageModel::class => $this->mockConfiguredAdapter([
'findWithDetails' => $jumpToPage,
'findWithDetails' => $this->mockClassWithProperties(PageModel::class, $pageProperties),
]),
NewsModel::class => $this->mockConfiguredAdapter([
'findPublishedDefaultByPid' => [
Expand Down
2 changes: 0 additions & 2 deletions news-bundle/tests/Routing/NewsResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public function testResolveNewsWithArticleSource(): void
public function testResolveNewsWithoutSource(): void
{
$target = $this->mockClassWithProperties(PageModel::class);

$newsArchive = $this->mockClassWithProperties(NewsArchiveModel::class, ['jumpTo' => 42]);

$content = $this->mockClassWithProperties(NewsModel::class, ['source' => '']);
Expand Down Expand Up @@ -115,7 +114,6 @@ public function testResolveNewsWithoutSource(): void
public function testGetParametersForContent(object $content, array $expected): void
{
$pageModel = $this->mockClassWithProperties(PageModel::class);

$resolver = new NewsResolver($this->mockContaoFramework());

$this->assertSame($expected, $resolver->getParametersForContent($content, $pageModel));
Expand Down

0 comments on commit 991ee0c

Please sign in to comment.