@@ -123,8 +123,8 @@ |
||
| 123 | 123 | /** @var SlidingPagination $pagination */ |
| 124 | 124 | $pagination = $this->paginator->paginate( |
| 125 | 125 | $queryBuilder, |
| 126 | - (int) $input->getOption('page'), |
|
| 127 | - (int) $input->getOption('limit') |
|
| 126 | + (int) $input->getOption('page'), |
|
| 127 | + (int) $input->getOption('limit') |
|
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | 130 | $output->writeln(sprintf('<bg=green;options=bold>Packages found: %s</>', $pagination->getTotalItemCount())); |
@@ -31,12 +31,12 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | public function generate($name, $parameters = [], $referenceType = false) |
| 33 | 33 | { |
| 34 | - if (RouteObjectInterface::OBJECT_BASED_ROUTE_NAME === $name |
|
| 34 | + if (RouteObjectInterface::OBJECT_BASED_ROUTE_NAME === $name |
|
| 35 | 35 | && array_key_exists(RouteObjectInterface::ROUTE_OBJECT, $parameters) |
| 36 | - ) { |
|
| 36 | + ) { |
|
| 37 | 37 | $name = $parameters[RouteObjectInterface::ROUTE_OBJECT]; |
| 38 | 38 | unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | if (null === $name && isset($parameters['content_id'])) { |
| 42 | 42 | $contentId = $this->checkAndRemoveFirstSlash($parameters['content_id']); |
@@ -71,6 +71,6 @@ |
||
| 71 | 71 | $name = $parameters[RouteObjectInterface::ROUTE_OBJECT]; |
| 72 | 72 | unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
| 73 | 73 | } |
| 74 | - return 'Route for article author media ' . $name->getValues()->getId() . ' not found'; |
|
| 74 | + return 'Route for article author media '.$name->getValues()->getId().' not found'; |
|
| 75 | 75 | } |
| 76 | 76 | } |
@@ -27,53 +27,53 @@ |
||
| 27 | 27 | |
| 28 | 28 | class ArticleAuthorMediaRouter extends Router implements VersatileGeneratorInterface { |
| 29 | 29 | |
| 30 | - const OBJECT_BASED_ROUTE_NAME = "__article_author_media_router_route_name__"; |
|
| 30 | + const OBJECT_BASED_ROUTE_NAME = "__article_author_media_router_route_name__"; |
|
| 31 | 31 | |
| 32 | - protected $authorMediaManager; |
|
| 32 | + protected $authorMediaManager; |
|
| 33 | 33 | |
| 34 | - public function __construct( |
|
| 35 | - ContainerInterface $container, |
|
| 36 | - $resource, |
|
| 37 | - array $options = [], |
|
| 38 | - RequestContext $context = null, |
|
| 39 | - ContainerInterface $parameters = null, |
|
| 40 | - LoggerInterface $logger = null, |
|
| 41 | - string $defaultLocale = null |
|
| 42 | - ) { |
|
| 34 | + public function __construct( |
|
| 35 | + ContainerInterface $container, |
|
| 36 | + $resource, |
|
| 37 | + array $options = [], |
|
| 38 | + RequestContext $context = null, |
|
| 39 | + ContainerInterface $parameters = null, |
|
| 40 | + LoggerInterface $logger = null, |
|
| 41 | + string $defaultLocale = null |
|
| 42 | + ) { |
|
| 43 | 43 | $this->authorMediaManager = $container->get('swp_core_bundle.manager.author_media'); |
| 44 | 44 | |
| 45 | 45 | parent::__construct($container, $resource, $options, $context, $parameters, $logger, $defaultLocale); |
| 46 | - } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function generate($meta, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) { |
|
| 48 | + public function generate($meta, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) { |
|
| 49 | 49 | if (self::OBJECT_BASED_ROUTE_NAME === $meta |
| 50 | 50 | && array_key_exists(RouteObjectInterface::ROUTE_OBJECT, $parameters) |
| 51 | 51 | ) { |
| 52 | - $meta = $parameters[RouteObjectInterface::ROUTE_OBJECT]; |
|
| 53 | - unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
|
| 52 | + $meta = $parameters[RouteObjectInterface::ROUTE_OBJECT]; |
|
| 53 | + unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | if ($meta instanceof Meta && ($meta->getValues() instanceof AuthorMediaInterface)) { |
| 57 | - return $this->authorMediaManager->getMediaPublicUrl($meta->getValues()->getImage()); |
|
| 57 | + return $this->authorMediaManager->getMediaPublicUrl($meta->getValues()->getImage()); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | return ''; |
| 61 | - } |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * {@inheritdoc} |
|
| 65 | - */ |
|
| 66 | - public function supports($name) { |
|
| 63 | + /** |
|
| 64 | + * {@inheritdoc} |
|
| 65 | + */ |
|
| 66 | + public function supports($name) { |
|
| 67 | 67 | return (is_string($name) && $name == self::OBJECT_BASED_ROUTE_NAME) || ($name instanceof Meta && ($name->getValues() instanceof AuthorMediaInterface)); |
| 68 | - } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public function getRouteDebugMessage($name, array $parameters = []) { |
|
| 70 | + public function getRouteDebugMessage($name, array $parameters = []) { |
|
| 71 | 71 | if (self::OBJECT_BASED_ROUTE_NAME === $name |
| 72 | 72 | && array_key_exists(RouteObjectInterface::ROUTE_OBJECT, $parameters) |
| 73 | 73 | ) { |
| 74 | - $name = $parameters[RouteObjectInterface::ROUTE_OBJECT]; |
|
| 75 | - unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
|
| 74 | + $name = $parameters[RouteObjectInterface::ROUTE_OBJECT]; |
|
| 75 | + unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
|
| 76 | 76 | } |
| 77 | 77 | return 'Route for article author media ' . $name->getValues()->getId() . ' not found'; |
| 78 | - } |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
| 18 | 18 | |
| 19 | 19 | class TenantNotFoundException extends NotFoundHttpException { |
| 20 | - public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { |
|
| 20 | + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { |
|
| 21 | 21 | parent::__construct(sprintf('Tenant for host "%s" could not be found! Please check tenants configuration.', $message), $previous, $code, $headers); |
| 22 | - } |
|
| 22 | + } |
|
| 23 | 23 | } |
@@ -31,82 +31,82 @@ discard block |
||
| 31 | 31 | use Symfony\Component\Routing\RequestContext; |
| 32 | 32 | |
| 33 | 33 | class MediaRouter extends Router implements VersatileGeneratorInterface { |
| 34 | - private $mediaManager; |
|
| 35 | - |
|
| 36 | - const OBJECT_BASED_ROUTE_NAME = "__media_router_route_name__"; |
|
| 37 | - |
|
| 38 | - public function __construct( |
|
| 39 | - ContainerInterface $container, |
|
| 40 | - $resource, |
|
| 41 | - array $options = [], |
|
| 42 | - RequestContext $context = null, |
|
| 43 | - ContainerInterface $parameters = null, |
|
| 44 | - LoggerInterface $logger = null, |
|
| 45 | - string $defaultLocale = null |
|
| 46 | - ) { |
|
| 34 | + private $mediaManager; |
|
| 35 | + |
|
| 36 | + const OBJECT_BASED_ROUTE_NAME = "__media_router_route_name__"; |
|
| 37 | + |
|
| 38 | + public function __construct( |
|
| 39 | + ContainerInterface $container, |
|
| 40 | + $resource, |
|
| 41 | + array $options = [], |
|
| 42 | + RequestContext $context = null, |
|
| 43 | + ContainerInterface $parameters = null, |
|
| 44 | + LoggerInterface $logger = null, |
|
| 45 | + string $defaultLocale = null |
|
| 46 | + ) { |
|
| 47 | 47 | $this->mediaManager = $container->get('swp_content_bundle.manager.media'); |
| 48 | 48 | |
| 49 | 49 | parent::__construct($container, $resource, $options, $context, $parameters, $logger, $defaultLocale); |
| 50 | - } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - public function getRouteDebugMessage($meta, array $parameters = array()): string { |
|
| 52 | + public function getRouteDebugMessage($meta, array $parameters = array()): string { |
|
| 53 | 53 | if (self::OBJECT_BASED_ROUTE_NAME === $meta && array_key_exists(RouteObjectInterface::ROUTE_OBJECT, $parameters)) { |
| 54 | - $meta = $parameters[RouteObjectInterface::ROUTE_OBJECT]; |
|
| 55 | - unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
|
| 54 | + $meta = $parameters[RouteObjectInterface::ROUTE_OBJECT]; |
|
| 55 | + unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
|
| 56 | 56 | } |
| 57 | 57 | return 'Route for media ' . $meta->getValues()->getId() . ' not found'; |
| 58 | - } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - public function supports($name): bool { |
|
| 60 | + public function supports($name): bool { |
|
| 61 | 61 | return (is_string($name) && $name == self::OBJECT_BASED_ROUTE_NAME) || |
| 62 | 62 | ($name instanceof Meta && ( |
| 63 | 63 | $name->getValues() instanceof ArticleMediaInterface || |
| 64 | 64 | $name->getValues() instanceof ImageRenditionInterface)); |
| 65 | - } |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - public function generate($meta, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH): string { |
|
| 67 | + public function generate($meta, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH): string { |
|
| 68 | 68 | if (self::OBJECT_BASED_ROUTE_NAME === $meta && array_key_exists(RouteObjectInterface::ROUTE_OBJECT, $parameters)) { |
| 69 | - $meta = $parameters[RouteObjectInterface::ROUTE_OBJECT]; |
|
| 70 | - unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
|
| 69 | + $meta = $parameters[RouteObjectInterface::ROUTE_OBJECT]; |
|
| 70 | + unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | if (!$meta instanceof Meta) { |
| 74 | - return ''; |
|
| 74 | + return ''; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $item = $this->getItem($meta); |
| 78 | 78 | if (null === $item) { |
| 79 | - return ''; |
|
| 79 | + return ''; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | if ($meta->getValues() instanceof ImageRenditionInterface && null !== ($previewUrl = $meta->getValues()->getPreviewUrl())) { |
| 83 | - return $previewUrl; |
|
| 83 | + return $previewUrl; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | if ($item instanceof PreviewUrlAwareInterface && null !== ($previewUrl = $item->getPreviewUrl())) { |
| 87 | - return $previewUrl; |
|
| 87 | + return $previewUrl; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | return $this->getUrlWithCorrectExtension($item, $parameters); |
| 91 | - } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - private function getItem(Meta $meta): ?FileInterface { |
|
| 93 | + private function getItem(Meta $meta): ?FileInterface { |
|
| 94 | 94 | if (($rendition = $meta->getValues()) instanceof ImageRendition) { |
| 95 | - return $rendition->getImage(); |
|
| 95 | + return $rendition->getImage(); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | if (($image = $meta->getValues()->getImage()) instanceof ImageInterface) { |
| 99 | - return $image; |
|
| 99 | + return $image; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | if (($file = $meta->getValues()->getFile()) instanceof FileInterface) { |
| 103 | - return $file; |
|
| 103 | + return $file; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | return null; |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - private function getUrlWithCorrectExtension(FileInterface $item, array $parameters): string { |
|
| 109 | + private function getUrlWithCorrectExtension(FileInterface $item, array $parameters): string { |
|
| 110 | 110 | $url = $this->mediaManager->getMediaPublicUrl($item); |
| 111 | 111 | |
| 112 | 112 | if ( |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | true === $parameters['webp'] && |
| 116 | 116 | $item->hasVariant(ImageInterface::VARIANT_WEBP) |
| 117 | 117 | ) { |
| 118 | - return str_replace('.' . $item->getFileExtension(), '.webp', $url); |
|
| 118 | + return str_replace('.' . $item->getFileExtension(), '.webp', $url); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | return $url; |
| 122 | - } |
|
| 122 | + } |
|
| 123 | 123 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $meta = $parameters[RouteObjectInterface::ROUTE_OBJECT]; |
| 55 | 55 | unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
| 56 | 56 | } |
| 57 | - return 'Route for media ' . $meta->getValues()->getId() . ' not found'; |
|
| 57 | + return 'Route for media '.$meta->getValues()->getId().' not found'; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public function supports($name): bool { |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | true === $parameters['webp'] && |
| 116 | 116 | $item->hasVariant(ImageInterface::VARIANT_WEBP) |
| 117 | 117 | ) { |
| 118 | - return str_replace('.' . $item->getFileExtension(), '.webp', $url); |
|
| 118 | + return str_replace('.'.$item->getFileExtension(), '.webp', $url); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | return $url; |
@@ -34,87 +34,87 @@ discard block |
||
| 34 | 34 | use SWP\Component\Common\Exception\UnexpectedTypeException; |
| 35 | 35 | |
| 36 | 36 | final class DownloadArticleAuthorAvatarListener { |
| 37 | - /** |
|
| 38 | - * @var MediaManagerInterface |
|
| 39 | - */ |
|
| 40 | - private $authorMediaManager; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @var EntityManagerInterface |
|
| 44 | - */ |
|
| 45 | - private $entityManager; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @var string |
|
| 49 | - */ |
|
| 50 | - private $cacheDirectory; |
|
| 51 | - |
|
| 52 | - public function __construct(EntityManagerInterface $entityManager, $cacheDirectory) { |
|
| 37 | + /** |
|
| 38 | + * @var MediaManagerInterface |
|
| 39 | + */ |
|
| 40 | + private $authorMediaManager; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @var EntityManagerInterface |
|
| 44 | + */ |
|
| 45 | + private $entityManager; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @var string |
|
| 49 | + */ |
|
| 50 | + private $cacheDirectory; |
|
| 51 | + |
|
| 52 | + public function __construct(EntityManagerInterface $entityManager, $cacheDirectory) { |
|
| 53 | 53 | $this->entityManager = $entityManager; |
| 54 | 54 | $this->cacheDirectory = $cacheDirectory; |
| 55 | - } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @param MediaManagerInterface $authorMediaManager |
|
| 59 | - */ |
|
| 60 | - public function setAuthorMediaManager(MediaManagerInterface $authorMediaManager) { |
|
| 57 | + /** |
|
| 58 | + * @param MediaManagerInterface $authorMediaManager |
|
| 59 | + */ |
|
| 60 | + public function setAuthorMediaManager(MediaManagerInterface $authorMediaManager) { |
|
| 61 | 61 | $this->authorMediaManager = $authorMediaManager; |
| 62 | - } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @param GenericEvent $event |
|
| 66 | - */ |
|
| 67 | - public function processAuthors(GenericEvent $event): void { |
|
| 64 | + /** |
|
| 65 | + * @param GenericEvent $event |
|
| 66 | + */ |
|
| 67 | + public function processAuthors(GenericEvent $event): void { |
|
| 68 | 68 | $package = $event->getSubject(); |
| 69 | 69 | |
| 70 | 70 | if (!$package instanceof PackageInterface) { |
| 71 | - throw new UnexpectedTypeException($package, PackageInterface::class); |
|
| 71 | + throw new UnexpectedTypeException($package, PackageInterface::class); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $authors = []; |
| 75 | 75 | /** @var ArticleAuthorInterface $packageAuthor */ |
| 76 | 76 | foreach ($package->getAuthors() as $packageAuthor) { |
| 77 | - $authors[] = $this->handle($packageAuthor); |
|
| 77 | + $authors[] = $this->handle($packageAuthor); |
|
| 78 | 78 | } |
| 79 | 79 | $package->setAuthors(new ArrayCollection($authors)); |
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * @param ArticleAuthorInterface $object |
|
| 84 | - * |
|
| 85 | - * @return ArticleAuthorInterface |
|
| 86 | - */ |
|
| 87 | - private function handle(ArticleAuthorInterface $object): ArticleAuthorInterface { |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * @param ArticleAuthorInterface $object |
|
| 84 | + * |
|
| 85 | + * @return ArticleAuthorInterface |
|
| 86 | + */ |
|
| 87 | + private function handle(ArticleAuthorInterface $object): ArticleAuthorInterface { |
|
| 88 | 88 | if (null !== $object->getAvatarUrl()) { |
| 89 | - $filesystem = new Filesystem(); |
|
| 90 | - $pathParts = \pathinfo($object->getAvatarUrl()); |
|
| 91 | - $assetId = \sha1($pathParts['filename']); |
|
| 92 | - if (null !== $object->getSlug()) { |
|
| 89 | + $filesystem = new Filesystem(); |
|
| 90 | + $pathParts = \pathinfo($object->getAvatarUrl()); |
|
| 91 | + $assetId = \sha1($pathParts['filename']); |
|
| 92 | + if (null !== $object->getSlug()) { |
|
| 93 | 93 | $assetId = $object->getSlug() . '_' . $assetId; |
| 94 | - } |
|
| 95 | - $existingAvatar = $this->entityManager->getRepository(Image::class)->findBy(['assetId' => $assetId]); |
|
| 96 | - if (\count($existingAvatar) > 0) { |
|
| 94 | + } |
|
| 95 | + $existingAvatar = $this->entityManager->getRepository(Image::class)->findBy(['assetId' => $assetId]); |
|
| 96 | + if (\count($existingAvatar) > 0) { |
|
| 97 | 97 | $object->setAvatarUrl((string)\reset($existingAvatar)); |
| 98 | 98 | |
| 99 | 99 | return $object; |
| 100 | - } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - try { |
|
| 102 | + try { |
|
| 103 | 103 | $tempDirectory = $this->cacheDirectory . \DIRECTORY_SEPARATOR . 'downloaded_avatars'; |
| 104 | 104 | $tempLocation = $tempDirectory . \DIRECTORY_SEPARATOR . \sha1($assetId . date('his')); |
| 105 | 105 | if (!$filesystem->exists($tempDirectory)) { |
| 106 | - $filesystem->mkdir($tempDirectory); |
|
| 106 | + $filesystem->mkdir($tempDirectory); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $avatarUrl = $object->getAvatarUrl(); |
| 110 | 110 | if (strpos($avatarUrl, "http://") === 0 || strpos($avatarUrl, "https://") === 0) { |
| 111 | - self::downloadFile($avatarUrl, $tempLocation); |
|
| 111 | + self::downloadFile($avatarUrl, $tempLocation); |
|
| 112 | 112 | } else { |
| 113 | - $file = \file_get_contents($avatarUrl); |
|
| 114 | - if (false === $file) { |
|
| 113 | + $file = \file_get_contents($avatarUrl); |
|
| 114 | + if (false === $file) { |
|
| 115 | 115 | throw new \Exception('File can\'t be downloaded'); |
| 116 | - } |
|
| 117 | - $filesystem->dumpFile($tempLocation, $file); |
|
| 116 | + } |
|
| 117 | + $filesystem->dumpFile($tempLocation, $file); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | $uploadedFile = new UploadedFile($tempLocation, |
@@ -123,29 +123,29 @@ discard block |
||
| 123 | 123 | \filesize($tempLocation), |
| 124 | 124 | true |
| 125 | 125 | ); |
| 126 | - } catch (\Exception $e) { |
|
| 126 | + } catch (\Exception $e) { |
|
| 127 | 127 | return $object; |
| 128 | - } |
|
| 129 | - /** @var Image $image */ |
|
| 130 | - $image = $this->authorMediaManager->handleUploadedFile($uploadedFile, $assetId); |
|
| 131 | - $avatar = $this->createAuthorMedia($object, $image); |
|
| 132 | - $this->entityManager->persist($avatar); |
|
| 133 | - $this->entityManager->persist($image); |
|
| 134 | - |
|
| 135 | - $object->setAvatar($avatar); |
|
| 136 | - $object->setAvatarUrl((string)$image); |
|
| 128 | + } |
|
| 129 | + /** @var Image $image */ |
|
| 130 | + $image = $this->authorMediaManager->handleUploadedFile($uploadedFile, $assetId); |
|
| 131 | + $avatar = $this->createAuthorMedia($object, $image); |
|
| 132 | + $this->entityManager->persist($avatar); |
|
| 133 | + $this->entityManager->persist($image); |
|
| 134 | + |
|
| 135 | + $object->setAvatar($avatar); |
|
| 136 | + $object->setAvatarUrl((string)$image); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | return $object; |
| 140 | - } |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - private function createAuthorMedia(ArticleAuthorInterface $articleAuthor, Image $image): AuthorMediaInterface { |
|
| 142 | + private function createAuthorMedia(ArticleAuthorInterface $articleAuthor, Image $image): AuthorMediaInterface { |
|
| 143 | 143 | return new AuthorMedia('avatar', $articleAuthor, $image); |
| 144 | - } |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - private static function downloadFile($url, $location) { |
|
| 146 | + private static function downloadFile($url, $location) { |
|
| 147 | 147 | $handlerStack = HandlerStack::create(new CurlHandler()); |
| 148 | 148 | $client = new Client(['handler' => $handlerStack]); |
| 149 | 149 | $client->request('GET', $url, ['sink' => $location]); |
| 150 | - } |
|
| 150 | + } |
|
| 151 | 151 | } |
@@ -90,18 +90,18 @@ discard block |
||
| 90 | 90 | $pathParts = \pathinfo($object->getAvatarUrl()); |
| 91 | 91 | $assetId = \sha1($pathParts['filename']); |
| 92 | 92 | if (null !== $object->getSlug()) { |
| 93 | - $assetId = $object->getSlug() . '_' . $assetId; |
|
| 93 | + $assetId = $object->getSlug().'_'.$assetId; |
|
| 94 | 94 | } |
| 95 | 95 | $existingAvatar = $this->entityManager->getRepository(Image::class)->findBy(['assetId' => $assetId]); |
| 96 | 96 | if (\count($existingAvatar) > 0) { |
| 97 | - $object->setAvatarUrl((string)\reset($existingAvatar)); |
|
| 97 | + $object->setAvatarUrl((string) \reset($existingAvatar)); |
|
| 98 | 98 | |
| 99 | 99 | return $object; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | try { |
| 103 | - $tempDirectory = $this->cacheDirectory . \DIRECTORY_SEPARATOR . 'downloaded_avatars'; |
|
| 104 | - $tempLocation = $tempDirectory . \DIRECTORY_SEPARATOR . \sha1($assetId . date('his')); |
|
| 103 | + $tempDirectory = $this->cacheDirectory.\DIRECTORY_SEPARATOR.'downloaded_avatars'; |
|
| 104 | + $tempLocation = $tempDirectory.\DIRECTORY_SEPARATOR.\sha1($assetId.date('his')); |
|
| 105 | 105 | if (!$filesystem->exists($tempDirectory)) { |
| 106 | 106 | $filesystem->mkdir($tempDirectory); |
| 107 | 107 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $this->entityManager->persist($image); |
| 134 | 134 | |
| 135 | 135 | $object->setAvatar($avatar); |
| 136 | - $object->setAvatarUrl((string)$image); |
|
| 136 | + $object->setAvatarUrl((string) $image); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | return $object; |
@@ -36,88 +36,88 @@ discard block |
||
| 36 | 36 | * @Route("/reset-password") |
| 37 | 37 | */ |
| 38 | 38 | class ResetPasswordController extends AbstractController { |
| 39 | - use ResetPasswordControllerTrait; |
|
| 39 | + use ResetPasswordControllerTrait; |
|
| 40 | 40 | |
| 41 | - private ResetPasswordHelperInterface $resetPasswordHelper; |
|
| 42 | - private EntityManagerInterface $entityManager; |
|
| 41 | + private ResetPasswordHelperInterface $resetPasswordHelper; |
|
| 42 | + private EntityManagerInterface $entityManager; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @param ResetPasswordHelperInterface $resetPasswordHelper |
|
| 46 | - * @param EntityManagerInterface $entityManager |
|
| 47 | - */ |
|
| 48 | - public function __construct(ResetPasswordHelperInterface $resetPasswordHelper, |
|
| 49 | - EntityManagerInterface $entityManager) { |
|
| 44 | + /** |
|
| 45 | + * @param ResetPasswordHelperInterface $resetPasswordHelper |
|
| 46 | + * @param EntityManagerInterface $entityManager |
|
| 47 | + */ |
|
| 48 | + public function __construct(ResetPasswordHelperInterface $resetPasswordHelper, |
|
| 49 | + EntityManagerInterface $entityManager) { |
|
| 50 | 50 | $this->resetPasswordHelper = $resetPasswordHelper; |
| 51 | 51 | $this->entityManager = $entityManager; |
| 52 | - } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Display & process form to request a password reset. |
|
| 57 | - * |
|
| 58 | - * @Route("", name="swp_user_forgot_password_request") |
|
| 59 | - */ |
|
| 60 | - public function request(Request $request, MailerInterface $mailer): Response { |
|
| 55 | + /** |
|
| 56 | + * Display & process form to request a password reset. |
|
| 57 | + * |
|
| 58 | + * @Route("", name="swp_user_forgot_password_request") |
|
| 59 | + */ |
|
| 60 | + public function request(Request $request, MailerInterface $mailer): Response { |
|
| 61 | 61 | $form = $this->createForm(ResetPasswordRequestFormType::class); |
| 62 | 62 | $form->handleRequest($request); |
| 63 | 63 | |
| 64 | 64 | if ($form->isSubmitted() && $form->isValid()) { |
| 65 | - return $this->processSendingPasswordResetEmail( |
|
| 66 | - $form->get('email')->getData(), |
|
| 67 | - $mailer |
|
| 68 | - ); |
|
| 65 | + return $this->processSendingPasswordResetEmail( |
|
| 66 | + $form->get('email')->getData(), |
|
| 67 | + $mailer |
|
| 68 | + ); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | return $this->render('@SWPUser/reset_password/request.html.twig', [ |
| 72 | 72 | 'requestForm' => $form->createView(), |
| 73 | 73 | ]); |
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Confirmation page after a user has requested a password reset. |
|
| 78 | - * |
|
| 79 | - * @Route("/check-email", name="swp_user_check_email") |
|
| 80 | - */ |
|
| 81 | - public function checkEmail(): Response { |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Confirmation page after a user has requested a password reset. |
|
| 78 | + * |
|
| 79 | + * @Route("/check-email", name="swp_user_check_email") |
|
| 80 | + */ |
|
| 81 | + public function checkEmail(): Response { |
|
| 82 | 82 | // We prevent users from directly accessing this page |
| 83 | 83 | if (!$this->canCheckEmail()) { |
| 84 | - return $this->redirectToRoute('swp_user_forgot_password_request'); |
|
| 84 | + return $this->redirectToRoute('swp_user_forgot_password_request'); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | return $this->render('@SWPUser/reset_password/check_email.html.twig', [ |
| 88 | 88 | 'tokenLifetime' => $this->resetPasswordHelper->getTokenLifetime(), |
| 89 | 89 | ]); |
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Validates and process the reset URL that the user clicked in their email. |
|
| 94 | - * |
|
| 95 | - * @Route("/reset/{token}", name="swp_user_reset_password") |
|
| 96 | - */ |
|
| 97 | - public function reset(Request $request, UserPasswordEncoderInterface $passwordEncoder, |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * Validates and process the reset URL that the user clicked in their email. |
|
| 94 | + * |
|
| 95 | + * @Route("/reset/{token}", name="swp_user_reset_password") |
|
| 96 | + */ |
|
| 97 | + public function reset(Request $request, UserPasswordEncoderInterface $passwordEncoder, |
|
| 98 | 98 | string $token = null): Response { |
| 99 | 99 | if ($token) { |
| 100 | - // We store the token in session and remove it from the URL, to avoid the URL being |
|
| 101 | - // loaded in a browser and potentially leaking the token to 3rd party JavaScript. |
|
| 102 | - $this->storeTokenInSession($token); |
|
| 100 | + // We store the token in session and remove it from the URL, to avoid the URL being |
|
| 101 | + // loaded in a browser and potentially leaking the token to 3rd party JavaScript. |
|
| 102 | + $this->storeTokenInSession($token); |
|
| 103 | 103 | |
| 104 | - return $this->redirectToRoute('swp_user_reset_password'); |
|
| 104 | + return $this->redirectToRoute('swp_user_reset_password'); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | $token = $this->getTokenFromSession(); |
| 108 | 108 | if (null === $token) { |
| 109 | - throw $this->createNotFoundException('No reset password token found in the URL or in the session.'); |
|
| 109 | + throw $this->createNotFoundException('No reset password token found in the URL or in the session.'); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | try { |
| 113 | - $user = $this->resetPasswordHelper->validateTokenAndFetchUser($token); |
|
| 113 | + $user = $this->resetPasswordHelper->validateTokenAndFetchUser($token); |
|
| 114 | 114 | } catch (ResetPasswordExceptionInterface $e) { |
| 115 | - $this->addFlash('reset_password_error', sprintf( |
|
| 116 | - 'There was a problem validating your reset request - %s', |
|
| 117 | - $e->getReason() |
|
| 118 | - )); |
|
| 115 | + $this->addFlash('reset_password_error', sprintf( |
|
| 116 | + 'There was a problem validating your reset request - %s', |
|
| 117 | + $e->getReason() |
|
| 118 | + )); |
|
| 119 | 119 | |
| 120 | - return $this->redirectToRoute('swp_user_forgot_password_request'); |
|
| 120 | + return $this->redirectToRoute('swp_user_forgot_password_request'); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // The token is valid; allow the user to change their password. |
@@ -125,30 +125,30 @@ discard block |
||
| 125 | 125 | $form->handleRequest($request); |
| 126 | 126 | |
| 127 | 127 | if ($form->isSubmitted() && $form->isValid()) { |
| 128 | - // A password reset token should be used only once, remove it. |
|
| 129 | - $this->resetPasswordHelper->removeResetRequest($token); |
|
| 128 | + // A password reset token should be used only once, remove it. |
|
| 129 | + $this->resetPasswordHelper->removeResetRequest($token); |
|
| 130 | 130 | |
| 131 | - // Encode the plain password, and set it. |
|
| 132 | - $encodedPassword = $passwordEncoder->encodePassword( |
|
| 133 | - $user, |
|
| 134 | - $form->get('plainPassword')->getData() |
|
| 135 | - ); |
|
| 131 | + // Encode the plain password, and set it. |
|
| 132 | + $encodedPassword = $passwordEncoder->encodePassword( |
|
| 133 | + $user, |
|
| 134 | + $form->get('plainPassword')->getData() |
|
| 135 | + ); |
|
| 136 | 136 | |
| 137 | - $user->setPassword($encodedPassword); |
|
| 138 | - $this->entityManager->flush(); |
|
| 137 | + $user->setPassword($encodedPassword); |
|
| 138 | + $this->entityManager->flush(); |
|
| 139 | 139 | |
| 140 | - // The session is cleaned up after the password has been changed. |
|
| 141 | - $this->cleanSessionAfterReset(); |
|
| 140 | + // The session is cleaned up after the password has been changed. |
|
| 141 | + $this->cleanSessionAfterReset(); |
|
| 142 | 142 | |
| 143 | - return $this->redirectToRoute('homepage'); |
|
| 143 | + return $this->redirectToRoute('homepage'); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | return $this->render('@SWPUser/reset_password/reset.html.twig', [ |
| 147 | 147 | 'resetForm' => $form->createView(), |
| 148 | 148 | ]); |
| 149 | - } |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - private function processSendingPasswordResetEmail(string $emailFormData, MailerInterface $mailer): RedirectResponse { |
|
| 151 | + private function processSendingPasswordResetEmail(string $emailFormData, MailerInterface $mailer): RedirectResponse { |
|
| 152 | 152 | $user = $this->entityManager->getRepository(User::class)->findOneBy([ |
| 153 | 153 | 'email' => $emailFormData, |
| 154 | 154 | ]); |
@@ -158,22 +158,22 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | // Do not reveal whether a user account was found or not. |
| 160 | 160 | if (!$user) { |
| 161 | - return $this->redirectToRoute('swp_user_check_email'); |
|
| 161 | + return $this->redirectToRoute('swp_user_check_email'); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | try { |
| 165 | - $resetToken = $this->resetPasswordHelper->generateResetToken($user); |
|
| 165 | + $resetToken = $this->resetPasswordHelper->generateResetToken($user); |
|
| 166 | 166 | } catch (ResetPasswordExceptionInterface $e) { |
| 167 | - $this->addFlash('reset_password_error', sprintf( |
|
| 168 | - 'There was a problem handling your password reset request - %s', |
|
| 169 | - $e->getReason() |
|
| 170 | - )); |
|
| 167 | + $this->addFlash('reset_password_error', sprintf( |
|
| 168 | + 'There was a problem handling your password reset request - %s', |
|
| 169 | + $e->getReason() |
|
| 170 | + )); |
|
| 171 | 171 | |
| 172 | - return $this->redirectToRoute('swp_user_check_email'); |
|
| 172 | + return $this->redirectToRoute('swp_user_check_email'); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | $mailer->sendResetPasswordEmail($user, $resetToken); |
| 176 | 176 | |
| 177 | 177 | return $this->redirectToRoute('swp_user_check_email'); |
| 178 | - } |
|
| 178 | + } |
|
| 179 | 179 | } |
@@ -86,7 +86,7 @@ |
||
| 86 | 86 | unset($server['HTTP_Authorization']); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if(!array_key_exists("HTTP_HOST", $server)) { |
|
| 89 | + if (!array_key_exists("HTTP_HOST", $server)) { |
|
| 90 | 90 | $server['HTTP_HOST'] = 'localhost'; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -23,71 +23,71 @@ discard block |
||
| 23 | 23 | use Symfony\Component\Cache\Adapter\ArrayAdapter; |
| 24 | 24 | |
| 25 | 25 | class WebTestCase extends BaseWebTestCase { |
| 26 | - protected ?AbstractDatabaseTool $databaseTool; |
|
| 27 | - private static ?KernelBrowser $client = null; |
|
| 26 | + protected ?AbstractDatabaseTool $databaseTool; |
|
| 27 | + private static ?KernelBrowser $client = null; |
|
| 28 | 28 | |
| 29 | - public function setUp(): void { |
|
| 29 | + public function setUp(): void { |
|
| 30 | 30 | if (self::$client == null) { |
| 31 | - self::$client = parent::createClient(); |
|
| 31 | + self::$client = parent::createClient(); |
|
| 32 | 32 | } |
| 33 | 33 | $this->databaseTool = static::getContainer()->get(DatabaseToolCollection::class)->get(); |
| 34 | - } |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Initializes database. |
|
| 38 | - */ |
|
| 39 | - protected function initDatabase() { |
|
| 36 | + /** |
|
| 37 | + * Initializes database. |
|
| 38 | + */ |
|
| 39 | + protected function initDatabase() { |
|
| 40 | 40 | $this->clearMetadataCache(); |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Clears metadata cache of the various cache drivers. |
|
| 45 | - */ |
|
| 46 | - private function clearMetadataCache() { |
|
| 43 | + /** |
|
| 44 | + * Clears metadata cache of the various cache drivers. |
|
| 45 | + */ |
|
| 46 | + private function clearMetadataCache() { |
|
| 47 | 47 | $entityManager = $this->getContainer()->get('doctrine.orm.entity_manager'); |
| 48 | 48 | |
| 49 | 49 | $cacheDriver = $entityManager->getConfiguration()->getMetadataCacheImpl(); |
| 50 | 50 | |
| 51 | 51 | if (!$cacheDriver instanceof ArrayAdapter) { |
| 52 | - $cacheDriver->deleteAll(); |
|
| 52 | + $cacheDriver->deleteAll(); |
|
| 53 | + } |
|
| 53 | 54 | } |
| 54 | - } |
|
| 55 | 55 | |
| 56 | - protected function tearDown(): void { |
|
| 56 | + protected function tearDown(): void { |
|
| 57 | 57 | unset($this->databaseTool); |
| 58 | 58 | $reflection = new \ReflectionObject($this); |
| 59 | 59 | foreach ($reflection->getProperties() as $prop) { |
| 60 | - if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) { |
|
| 60 | + if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) { |
|
| 61 | 61 | $prop->setAccessible(true); |
| 62 | 62 | if ($prop->name == 'databaseTool') { |
| 63 | - continue; |
|
| 63 | + continue; |
|
| 64 | 64 | } |
| 65 | 65 | $prop->setValue($this, null); |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | } |
| 68 | 68 | parent::tearDown(); |
| 69 | - } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - protected function loadCustomFixtures(array $fixtures) { |
|
| 71 | + protected function loadCustomFixtures(array $fixtures) { |
|
| 72 | 72 | $env = $this->getContainer()->getParameter('test_env'); |
| 73 | 73 | |
| 74 | 74 | $registry = new FixtureRegistry(); |
| 75 | 75 | $registry->setEnvironment($env); |
| 76 | 76 | |
| 77 | 77 | return $this->databaseTool->loadFixtures($registry->getFixtures($fixtures))->getReferenceRepository(); |
| 78 | - } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - public static function createClient(array $options = [], array $server = []) { |
|
| 80 | + public static function createClient(array $options = [], array $server = []) { |
|
| 81 | 81 | if (!array_key_exists('HTTP_Authorization', $server)) { |
| 82 | - $server['HTTP_Authorization'] = base64_encode('test_token:'); |
|
| 82 | + $server['HTTP_Authorization'] = base64_encode('test_token:'); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | if (null === $server['HTTP_Authorization']) { |
| 86 | - unset($server['HTTP_Authorization']); |
|
| 86 | + unset($server['HTTP_Authorization']); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | if(!array_key_exists("HTTP_HOST", $server)) { |
| 90 | - $server['HTTP_HOST'] = 'localhost'; |
|
| 90 | + $server['HTTP_HOST'] = 'localhost'; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $newClient = clone self::$client; |
@@ -95,5 +95,5 @@ discard block |
||
| 95 | 95 | $newClient->getKernel()->shutdown(); |
| 96 | 96 | $newClient->getKernel()->boot(); |
| 97 | 97 | return $newClient; |
| 98 | - } |
|
| 98 | + } |
|
| 99 | 99 | } |
@@ -28,62 +28,62 @@ |
||
| 28 | 28 | * Class TenantContext. |
| 29 | 29 | */ |
| 30 | 30 | class TenantContext implements TenantContextInterface { |
| 31 | - /** |
|
| 32 | - * @var TenantInterface |
|
| 33 | - */ |
|
| 34 | - protected $tenant; |
|
| 31 | + /** |
|
| 32 | + * @var TenantInterface |
|
| 33 | + */ |
|
| 34 | + protected $tenant; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var TenantResolverInterface |
|
| 38 | - */ |
|
| 39 | - protected $tenantResolver; |
|
| 36 | + /** |
|
| 37 | + * @var TenantResolverInterface |
|
| 38 | + */ |
|
| 39 | + protected $tenantResolver; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var RequestStack |
|
| 43 | - */ |
|
| 44 | - protected $requestStack; |
|
| 41 | + /** |
|
| 42 | + * @var RequestStack |
|
| 43 | + */ |
|
| 44 | + protected $requestStack; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var EventDispatcherInterface |
|
| 48 | - */ |
|
| 49 | - protected $dispatcher; |
|
| 46 | + /** |
|
| 47 | + * @var EventDispatcherInterface |
|
| 48 | + */ |
|
| 49 | + protected $dispatcher; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * TenantContext constructor. |
|
| 53 | - */ |
|
| 54 | - public function __construct(TenantResolverInterface $tenantResolver, RequestStack $requestStack, |
|
| 55 | - EventDispatcherInterface $dispatcher) { |
|
| 51 | + /** |
|
| 52 | + * TenantContext constructor. |
|
| 53 | + */ |
|
| 54 | + public function __construct(TenantResolverInterface $tenantResolver, RequestStack $requestStack, |
|
| 55 | + EventDispatcherInterface $dispatcher) { |
|
| 56 | 56 | $this->tenantResolver = $tenantResolver; |
| 57 | 57 | $this->requestStack = $requestStack; |
| 58 | 58 | $this->dispatcher = $dispatcher; |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * {@inheritdoc} |
|
| 63 | - */ |
|
| 64 | - public function getTenant() { |
|
| 61 | + /** |
|
| 62 | + * {@inheritdoc} |
|
| 63 | + */ |
|
| 64 | + public function getTenant() { |
|
| 65 | 65 | if ($this->tenant !== null) |
| 66 | - return $this->tenant; |
|
| 66 | + return $this->tenant; |
|
| 67 | 67 | |
| 68 | 68 | $currentRequest = $this->requestStack->getCurrentRequest(); |
| 69 | 69 | if (null !== $currentRequest && false !== strpos($currentRequest->getRequestUri(), '_profiler')) { |
| 70 | - $profilerTenant = new Tenant(); |
|
| 71 | - $profilerTenant->setDomainName($currentRequest->getHost()); |
|
| 72 | - $this->setTenant($profilerTenant); |
|
| 73 | - return $profilerTenant; |
|
| 70 | + $profilerTenant = new Tenant(); |
|
| 71 | + $profilerTenant->setDomainName($currentRequest->getHost()); |
|
| 72 | + $this->setTenant($profilerTenant); |
|
| 73 | + return $profilerTenant; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $newTenant = $this->tenantResolver->resolve($currentRequest ? $currentRequest->getHost() : null); |
| 77 | 77 | $this->setTenant($newTenant); |
| 78 | 78 | return $newTenant; |
| 79 | - } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * {@inheritdoc} |
|
| 83 | - */ |
|
| 84 | - public function setTenant(TenantInterface $tenant) { |
|
| 81 | + /** |
|
| 82 | + * {@inheritdoc} |
|
| 83 | + */ |
|
| 84 | + public function setTenant(TenantInterface $tenant) { |
|
| 85 | 85 | $this->tenant = $tenant; |
| 86 | 86 | |
| 87 | 87 | $this->dispatcher->dispatch(new GenericEvent($tenant), MultiTenancyEvents::TENANT_SET); |
| 88 | - } |
|
| 88 | + } |
|
| 89 | 89 | } |
@@ -62,8 +62,9 @@ |
||
| 62 | 62 | * {@inheritdoc} |
| 63 | 63 | */ |
| 64 | 64 | public function getTenant() { |
| 65 | - if ($this->tenant !== null) |
|
| 66 | - return $this->tenant; |
|
| 65 | + if ($this->tenant !== null) { |
|
| 66 | + return $this->tenant; |
|
| 67 | + } |
|
| 67 | 68 | |
| 68 | 69 | $currentRequest = $this->requestStack->getCurrentRequest(); |
| 69 | 70 | if (null !== $currentRequest && false !== strpos($currentRequest->getRequestUri(), '_profiler')) { |