mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-30 03:23:48 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -85,13 +85,13 @@ class Convert
|
||||
|
||||
private function onConversionFailed(string $url, ResponseInterface $response): JsonResponse
|
||||
{
|
||||
$this->logger->error(self::LOG_PREFIX . ' could not convert document', [
|
||||
$this->logger->error(self::LOG_PREFIX.' could not convert document', [
|
||||
'response_status' => $response->getStatusCode(),
|
||||
'message' => $response->getContent(false),
|
||||
'server' => $this->collaboraDomain,
|
||||
'url' => $url,
|
||||
]);
|
||||
|
||||
return new JsonResponse(['message' => 'conversion failed : ' . $response->getContent(false)], Response::HTTP_SERVICE_UNAVAILABLE);
|
||||
return new JsonResponse(['message' => 'conversion failed : '.$response->getContent(false)], Response::HTTP_SERVICE_UNAVAILABLE);
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,6 @@ use ChampsLibres\WopiLib\Contract\Service\DocumentManagerInterface;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\WopiBundle\Service\Controller\ResponderInterface;
|
||||
use Exception;
|
||||
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
|
||||
use loophp\psr17\Psr17Interface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -29,16 +28,16 @@ use Symfony\Component\Routing\RouterInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use Twig\Environment;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final readonly class Editor
|
||||
{
|
||||
public function __construct(private ConfigurationInterface $wopiConfiguration, private DiscoveryInterface $wopiDiscovery, private DocumentManagerInterface $documentManager, private \Twig\Environment $engine, private JWTTokenManagerInterface $JWTTokenManager, private NormalizerInterface $normalizer, private ResponderInterface $responder, private Security $security, private Psr17Interface $psr17, private RouterInterface $router) {}
|
||||
public function __construct(private ConfigurationInterface $wopiConfiguration, private DiscoveryInterface $wopiDiscovery, private DocumentManagerInterface $documentManager, private Environment $engine, private JWTTokenManagerInterface $JWTTokenManager, private NormalizerInterface $normalizer, private ResponderInterface $responder, private Security $security, private Psr17Interface $psr17, private RouterInterface $router) {}
|
||||
|
||||
public function __invoke(string $fileId, Request $request): Response
|
||||
{
|
||||
@@ -69,14 +68,14 @@ final readonly class Editor
|
||||
$this->engine
|
||||
->render('@ChillWopi/Editor/stored_object_pending.html.twig', [
|
||||
'storedObject' => $this->normalizer->normalize($storedObject, 'json', [
|
||||
AbstractNormalizer::GROUPS => ['read']
|
||||
])
|
||||
AbstractNormalizer::GROUPS => ['read'],
|
||||
]),
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
if ([] === $discoverExtension = $this->wopiDiscovery->discoverMimeType($storedObject->getType())) {
|
||||
throw new Exception(sprintf('Unable to find mime type %s', $storedObject->getType()));
|
||||
throw new \Exception(sprintf('Unable to find mime type %s', $storedObject->getType()));
|
||||
}
|
||||
|
||||
$configuration['favIconUrl'] = '';
|
||||
|
@@ -28,7 +28,7 @@ final class ChillWopiExtension extends Extension
|
||||
$config
|
||||
);
|
||||
|
||||
$loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
|
||||
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('services.php');
|
||||
}
|
||||
}
|
||||
|
@@ -33,10 +33,10 @@ return static function (ContainerConfigurator $container) {
|
||||
->autoconfigure();
|
||||
|
||||
$services
|
||||
->load('Chill\\WopiBundle\\Service\\', __DIR__ . '/../../Service');
|
||||
->load('Chill\\WopiBundle\\Service\\', __DIR__.'/../../Service');
|
||||
|
||||
$services
|
||||
->load('Chill\\WopiBundle\\Controller\\', __DIR__ . '/../../Controller')
|
||||
->load('Chill\\WopiBundle\\Controller\\', __DIR__.'/../../Controller')
|
||||
->tag('controller.service_arguments');
|
||||
|
||||
$services
|
||||
|
@@ -26,7 +26,7 @@ final readonly class Responder implements ResponderInterface
|
||||
|
||||
public function file(
|
||||
$file,
|
||||
?string $filename = null,
|
||||
string $filename = null,
|
||||
string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT
|
||||
): BinaryFileResponse {
|
||||
$response = new BinaryFileResponse($file);
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\WopiBundle\Service\Controller;
|
||||
|
||||
use SplFileInfo;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
@@ -24,11 +23,11 @@ interface ResponderInterface
|
||||
/**
|
||||
* Returns a BinaryFileResponse object with original or customized file name and disposition header.
|
||||
*
|
||||
* @param SplFileInfo|string $file
|
||||
* @param \SplFileInfo|string $file
|
||||
*/
|
||||
public function file(
|
||||
$file,
|
||||
?string $filename = null,
|
||||
string $filename = null,
|
||||
string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT
|
||||
): BinaryFileResponse;
|
||||
|
||||
@@ -36,7 +35,7 @@ interface ResponderInterface
|
||||
* Returns a JsonResponse that uses the serializer component if enabled, or json_encode.
|
||||
*
|
||||
* @param array<string, list<string>|string> $headers
|
||||
* @param array<string, mixed> $context
|
||||
* @param array<string, mixed> $context
|
||||
*/
|
||||
public function json(
|
||||
mixed $data,
|
||||
@@ -55,7 +54,7 @@ interface ResponderInterface
|
||||
/**
|
||||
* Returns a RedirectResponse to the given route with the given parameters.
|
||||
*
|
||||
* @param array<array-key, scalar> $parameters
|
||||
* @param array<array-key, scalar> $parameters
|
||||
* @param array<string, list<string>> $headers
|
||||
*/
|
||||
public function redirectToRoute(
|
||||
|
@@ -15,7 +15,6 @@ use ChampsLibres\WopiLib\Contract\Entity\Document;
|
||||
use ChampsLibres\WopiLib\Contract\Service\DocumentLockManagerInterface;
|
||||
use Chill\MainBundle\Redis\ChillRedis;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use RuntimeException;
|
||||
|
||||
class ChillDocumentLockManager implements DocumentLockManagerInterface
|
||||
{
|
||||
@@ -48,7 +47,7 @@ class ChillDocumentLockManager implements DocumentLockManagerInterface
|
||||
return $value;
|
||||
}
|
||||
|
||||
throw new RuntimeException('wopi key does not exists');
|
||||
throw new \RuntimeException('wopi key does not exists');
|
||||
}
|
||||
|
||||
public function hasLock(Document $document, RequestInterface $request): bool
|
||||
|
@@ -17,20 +17,15 @@ use ChampsLibres\WopiLib\Contract\Service\DocumentManagerInterface;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\DocStoreBundle\Repository\StoredObjectRepository;
|
||||
use Chill\DocStoreBundle\Service\StoredObjectManagerInterface;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Error;
|
||||
use loophp\psr17\Psr17Interface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use RuntimeException;
|
||||
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Mime\MimeTypes;
|
||||
|
||||
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
||||
use function strlen;
|
||||
|
||||
final class ChillDocumentManager implements DocumentManagerInterface
|
||||
{
|
||||
@@ -73,7 +68,7 @@ final class ChillDocumentManager implements DocumentManagerInterface
|
||||
public function deleteLock(Document $document): void
|
||||
{
|
||||
if (false === $this->documentLockManager->deleteLock($document, $this->request)) {
|
||||
throw new RuntimeException('could not remove the lock');
|
||||
throw new \RuntimeException('could not remove the lock');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,14 +96,14 @@ final class ChillDocumentManager implements DocumentManagerInterface
|
||||
/**
|
||||
* @param StoredObject $document
|
||||
*
|
||||
* @return string The document filename with its extension.
|
||||
* @return string the document filename with its extension
|
||||
*/
|
||||
public function getBasename(Document $document): string
|
||||
{
|
||||
$exts = (new MimeTypes())->getExtensions($document->getType());
|
||||
|
||||
if ([] === $exts) {
|
||||
throw new Error('Unknown mimetype for stored document.');
|
||||
throw new \Error('Unknown mimetype for stored document.');
|
||||
}
|
||||
|
||||
return sprintf('%s.%s', $document->getFilename(), reset($exts));
|
||||
@@ -117,7 +112,7 @@ final class ChillDocumentManager implements DocumentManagerInterface
|
||||
/**
|
||||
* @param StoredObject $document
|
||||
*/
|
||||
public function getCreationDate(Document $document): DateTimeInterface
|
||||
public function getCreationDate(Document $document): \DateTimeInterface
|
||||
{
|
||||
return $document->getCreatedAt() ?? new \DateTimeImmutable('now');
|
||||
}
|
||||
@@ -133,7 +128,7 @@ final class ChillDocumentManager implements DocumentManagerInterface
|
||||
/**
|
||||
* @param StoredObject $document
|
||||
*/
|
||||
public function getLastModifiedDate(Document $document): DateTimeInterface
|
||||
public function getLastModifiedDate(Document $document): \DateTimeInterface
|
||||
{
|
||||
return $this->storedObjectManager->getLastModified($document);
|
||||
}
|
||||
@@ -150,7 +145,7 @@ final class ChillDocumentManager implements DocumentManagerInterface
|
||||
|
||||
public function getSize(Document $document): int
|
||||
{
|
||||
return strlen($this->getContent($document));
|
||||
return \strlen($this->getContent($document));
|
||||
}
|
||||
|
||||
public function getVersion(Document $document): string
|
||||
@@ -178,12 +173,12 @@ final class ChillDocumentManager implements DocumentManagerInterface
|
||||
|
||||
public function remove(Document $document): void
|
||||
{
|
||||
throw new RuntimeException('this is not implemented and should not happens');
|
||||
throw new \RuntimeException('this is not implemented and should not happens');
|
||||
}
|
||||
|
||||
public function rename(Document $document, string $requestedName): void
|
||||
{
|
||||
throw new RuntimeException('this is not implemented and should not happens');
|
||||
throw new \RuntimeException('this is not implemented and should not happens');
|
||||
}
|
||||
|
||||
public function write(Document $document, array $properties = []): void
|
||||
|
@@ -27,6 +27,7 @@ use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ConvertTest extends TestCase
|
||||
|
@@ -20,6 +20,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ChillDocumentLockManagerTest extends KernelTestCase
|
||||
|
Reference in New Issue
Block a user