Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Jun 7, 2024
1 parent 4230b77 commit 98474c7
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
coverage: none

- name: Remove not required tooling
run: composer remove php-cs-fixer/shim --dev --no-interaction --no-update
run: composer remove php-cs-fixer/shim "*phpstan*" --dev --no-interaction --no-update

- name: Require elasticsearch dependency
run: composer require --dev elasticsearch/elasticsearch:"${{ matrix.elasticsearch-package-constraint }}" --no-interaction --no-update
Expand Down
25 changes: 14 additions & 11 deletions Document/ArticleViewDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,22 +498,15 @@ public function setSeo(SeoViewObject $seo)
return $this;
}

/**
* @return \DateTime|null
*/
public function getLastModified()
{
return $this->lastModified;
}

/**
* @param \DateTime|null $lastModified
*
* @return $this|ArticleViewDocument
*/
public function setLastModified($lastModified)
{
$this->lastModified = $lastModified;
$this->updateLastModifiedOrAuthored();

return $this;
}
Expand All @@ -524,11 +517,20 @@ public function getLastModifiedOrAuthored(): \DateTime
}

/**
* @param \DateTime|null $lastModified
* @internal Setter is required for ONGR but should not be used.
*
* @param \DateTime $lastModifiedOrAuthored
*
* @return $this|ArticleViewDocument
* @return static
*/
public function setLastModifiedOrAuthored()
public function setLastModifiedOrAuthored(\DateTime $lastModifiedOrAuthored)
{
$this->lastModifiedOrAuthored = $lastModifiedOrAuthored;

return $this;
}

public function updateLastModifiedOrAuthored()
{
$this->lastModifiedOrAuthored = $this->lastModified ?? $this->authored;

Expand All @@ -543,6 +545,7 @@ public function getAuthored()
public function setAuthored(?\DateTime $authored = null)
{
$this->authored = $authored;
$this->updateLastModifiedOrAuthored();

return $this;
}
Expand Down
5 changes: 4 additions & 1 deletion Document/ArticleViewDocumentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@ public function setAuthored(?\DateTime $authored = null);
*/
public function getLastModifiedOrAuthored();

public function setLastModifiedOrAuthored();
/**
* @return $this
*/
public function updateLastModifiedOrAuthored();

/**
* Returns author full name.
Expand Down
30 changes: 30 additions & 0 deletions Document/LocalizedLastModifiedBehavior.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/*
* 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\ArticleBundle\Document;

use Sulu\Component\DocumentManager\Behavior\LocalizedLastModifiedBehavior as SuluLocalizedLastModifiedBehavior;

if (\interface_exists(SuluLocalizedLastModifiedBehavior::class)) {
/**
* @internal BC Layer for Sulu <2.6
*/
interface LocalizedLastModifiedBehavior extends SuluLocalizedLastModifiedBehavior
{
}
} else {
/**
* @internal BC Layer for Sulu <2.6
*/
interface LocalizedLastModifiedBehavior
{
}
}
3 changes: 3 additions & 0 deletions Tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public function process(ContainerBuilder $container)
->setPublic(true);
}

/**
* @return array<string, mixed>
*/
protected function getKernelParameters(): array
{
$parameters = parent::getKernelParameters();
Expand Down
2 changes: 1 addition & 1 deletion Trash/ArticleTrashItemHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function restore(TrashItemInterface $trashItem, array $restoreFormData =
$localizedArticle->setParent($this->documentManager->find($data['parentUuid']));
$localizedArticle->setUuid($uuid);
}
$lastModified = array_key_exists('lastModified', $localeData) && $localeData['lastModified'] ? new \DateTime($localeData['lastModified']) : null;
$lastModified = \array_key_exists('lastModified', $localeData) && $localeData['lastModified'] ? new \DateTime($localeData['lastModified']) : null;

$localizedArticle->setTitle($localeData['title']);
$localizedArticle->setLocale($locale);
Expand Down

0 comments on commit 98474c7

Please sign in to comment.