From b6710dce137080bd65d7d1d37a9216099ae4e850 Mon Sep 17 00:00:00 2001 From: Jon Uhlmann Date: Sun, 2 Jul 2023 15:39:56 +0200 Subject: [PATCH] Chore: Prettier files --- .../Aspect/Runtime/FusionRuntimeAspect.php | 1 + Classes/Command/BetterCommandController.php | 6 ++- Classes/Domain/Dto/BetterEmbedRecord.php | 5 ++- .../Repository/BetterEmbedRepository.php | 1 + Classes/Package.php | 1 + Classes/Service/EmbedService.php | 10 ++--- Classes/Service/NodeService.php | 38 +++++++++---------- .../NodeTypes.BetterEmbed.Content.Item.yaml | 2 +- Resources/Private/Assets/Main.js | 8 ++-- Resources/Public/Main.js | 2 +- Resources/Public/Main.js.map | 4 +- 11 files changed, 42 insertions(+), 36 deletions(-) diff --git a/Classes/Aspect/Runtime/FusionRuntimeAspect.php b/Classes/Aspect/Runtime/FusionRuntimeAspect.php index 4941d04..0cb7c78 100644 --- a/Classes/Aspect/Runtime/FusionRuntimeAspect.php +++ b/Classes/Aspect/Runtime/FusionRuntimeAspect.php @@ -1,4 +1,5 @@ embedService->getByUrl($url, true); - $this->outputLine($node ? json_encode($node->getProperties()): 'No corresponding node found'); + $this->outputLine($node ? json_encode($node->getProperties()) : 'No corresponding node found'); } } diff --git a/Classes/Domain/Dto/BetterEmbedRecord.php b/Classes/Domain/Dto/BetterEmbedRecord.php index 13cfcc7..320ec35 100644 --- a/Classes/Domain/Dto/BetterEmbedRecord.php +++ b/Classes/Domain/Dto/BetterEmbedRecord.php @@ -1,7 +1,9 @@ publishedAt = $publishedAt; } } - diff --git a/Classes/Domain/Repository/BetterEmbedRepository.php b/Classes/Domain/Repository/BetterEmbedRepository.php index 30f0894..d6a1c9d 100644 --- a/Classes/Domain/Repository/BetterEmbedRepository.php +++ b/Classes/Domain/Repository/BetterEmbedRepository.php @@ -1,4 +1,5 @@ getNodeType()->isOfType('BetterEmbed.NeosEmbed:Mixin.Item')) { $url = $node->getProperty('url'); - if (!empty($url) && count($this->nodeSearchService->findByProperties(['url' => str_replace('"','',json_encode($url))], ['BetterEmbed.NeosEmbed:Mixin.Item'], $this->context)) <= 1) { + if (!empty($url) && count($this->nodeSearchService->findByProperties(['url' => str_replace('"', '', json_encode($url))], ['BetterEmbed.NeosEmbed:Mixin.Item'], $this->context)) <= 1) { $recordNode = $this->getByUrl($url); if ($recordNode) { $this->nodeService->removeEmbedNode($recordNode); @@ -152,13 +152,13 @@ public function getByUrl(string $url, $createIfNotFound = false) if ($node == null && $createIfNotFound) { - $urlParts = parse_url( $url ); + $urlParts = parse_url($url); - if(strstr($urlParts['host'], 'facebook')) { + if (strstr($urlParts['host'], 'facebook')) { throw new Exception('Facebook URLs are not supported due GDPR consent gateway protection.'); } - if(strstr($urlParts['host'], 'instagram')) { + if (strstr($urlParts['host'], 'instagram')) { throw new Exception('Instagram URLs are not supported due GDPR consent gateway protection.'); } @@ -213,7 +213,7 @@ private function createRecordNode(BetterEmbedRecord $record) } else { $mimeType = 'image/' . $extension; } - + $resource = $this->resourceManager->importResource($assetOriginal); $tags = new ArrayCollection([$this->nodeService->findOrCreateBetterEmbedTag($record->getItemType(), $this->assetCollections)]); diff --git a/Classes/Service/NodeService.php b/Classes/Service/NodeService.php index 55ea6a7..adbbb41 100644 --- a/Classes/Service/NodeService.php +++ b/Classes/Service/NodeService.php @@ -1,4 +1,5 @@ getAssetCollections() as $collection) { //check if tag has the accoring asset collection assigned + foreach ($tag->getAssetCollections() as $collection) { //check if tag has the accoring asset collection assigned if ($collection->getTitle() === self::ASSET_COLLECTION_TITLE) { return $tag; } - } - + } + return $this->createTag($label, $assetCollections); // create tag anyway } /** - * @param string $label - * @param ArrayCollection $assetCollections - * @return Tag - * @throws IllegalObjectTypeException + * @param string $label + * @param ArrayCollection $assetCollections + * @return Tag + * @throws IllegalObjectTypeException */ private function createTag(string $label, ArrayCollection $assetCollections): Tag { @@ -178,14 +178,15 @@ private function createTag(string $label, ArrayCollection $assetCollections): Ta return $tag; } - + /** * @param NodeInterface $node * @param string $url * @return \Traversable * @throws Exception */ - public function findRecordByUrl(NodeInterface $node, string $url) { + public function findRecordByUrl(NodeInterface $node, string $url) + { $fq = new FlowQuery([$node]); @@ -195,13 +196,12 @@ public function findRecordByUrl(NodeInterface $node, string $url) { return $result; } - public function removeEmbedNode(NodeInterface $node) { + public function removeEmbedNode(NodeInterface $node) + { $node->setRemoved(true); if ($node->isRemoved()) { $this->nodeDataRepository->remove($node); return; } } - - } diff --git a/Configuration/NodeTypes.BetterEmbed.Content.Item.yaml b/Configuration/NodeTypes.BetterEmbed.Content.Item.yaml index 21db64d..0b801eb 100644 --- a/Configuration/NodeTypes.BetterEmbed.Content.Item.yaml +++ b/Configuration/NodeTypes.BetterEmbed.Content.Item.yaml @@ -6,4 +6,4 @@ label: Better Embed icon: plus help: - message: 'i18n' \ No newline at end of file + message: 'i18n' diff --git a/Resources/Private/Assets/Main.js b/Resources/Private/Assets/Main.js index fa1f2b3..8ae14ea 100644 --- a/Resources/Private/Assets/Main.js +++ b/Resources/Private/Assets/Main.js @@ -6,10 +6,10 @@ const REMOTE_VISIBLE_CLASS = `is-${NAMESPACE}-remote-visible`; const SHOW_MESSAGE_CLASS = `is-${NAMESPACE}-dialog-visible`; const CONFIRMED_MESSAGE_CLASS = `is-${NAMESPACE}-confirmed`; -const getContainer = element => element.closest(`.js-${NAMESPACE}`); -const getEmbedElement = container => container.querySelector(`.js-${NAMESPACE}-embed`); +const getContainer = (element) => element.closest(`.js-${NAMESPACE}`); +const getEmbedElement = (container) => container.querySelector(`.js-${NAMESPACE}-embed`); -document.addEventListener('click', function(event) { +document.addEventListener('click', (event) => { const TARGET = event.target; if (TARGET.classList.contains(SWITCH_CLASS)) { @@ -38,7 +38,7 @@ document.addEventListener('click', function(event) { EMBED_ELEMENT.innerHTML = JSON.parse(CONTAINER.dataset.embedHtml); // Run trough every script and active it - Array.from(EMBED_ELEMENT.querySelectorAll('script')).forEach(scriptTag => { + Array.from(EMBED_ELEMENT.querySelectorAll('script')).forEach((scriptTag) => { if (scriptTag.src) { const TAG = document.createElement('script'); TAG.src = scriptTag.src; diff --git a/Resources/Public/Main.js b/Resources/Public/Main.js index 075b2c0..1813e81 100644 --- a/Resources/Public/Main.js +++ b/Resources/Public/Main.js @@ -1,2 +1,2 @@ -(()=>{var s="betterembed",l=`js-${s}-switch`,A=`js-${s}-close`,d=`js-${s}-load-remote`,L=`is-${s}-remote-visible`,E=`is-${s}-dialog-visible`,a=`is-${s}-confirmed`,S=n=>n.closest(`.js-${s}`),C=n=>n.querySelector(`.js-${s}-embed`);document.addEventListener("click",function(n){let e=n.target;if(e.classList.contains(l)){let t=S(e).classList,o=t.contains(a);t.toggle(o?L:E)}if(e.classList.contains(A)&&S(e).classList.remove(E),e.classList.contains(d)){let c=S(e),t=c.classList,o=C(c);o.innerHTML||(o.innerHTML=JSON.parse(c.dataset.embedHtml),Array.from(o.querySelectorAll("script")).forEach(i=>{if(i.src){let r=document.createElement("script");r.src=i.src,document.head.appendChild(r)}else window.eval(i.innerHTML)})),t.add(L),t.add(a),t.remove(E)}});})(); +(()=>{var s="betterembed",l=`js-${s}-switch`,A=`js-${s}-close`,d=`js-${s}-load-remote`,L=`is-${s}-remote-visible`,E=`is-${s}-dialog-visible`,a=`is-${s}-confirmed`,S=c=>c.closest(`.js-${s}`),C=c=>c.querySelector(`.js-${s}-embed`);document.addEventListener("click",c=>{let e=c.target;if(e.classList.contains(l)){let t=S(e).classList,o=t.contains(a);t.toggle(o?L:E)}if(e.classList.contains(A)&&S(e).classList.remove(E),e.classList.contains(d)){let n=S(e),t=n.classList,o=C(n);o.innerHTML||(o.innerHTML=JSON.parse(n.dataset.embedHtml),Array.from(o.querySelectorAll("script")).forEach(i=>{if(i.src){let r=document.createElement("script");r.src=i.src,document.head.appendChild(r)}else window.eval(i.innerHTML)})),t.add(L),t.add(a),t.remove(E)}});})(); //# sourceMappingURL=Main.js.map diff --git a/Resources/Public/Main.js.map b/Resources/Public/Main.js.map index de19192..6a01af2 100644 --- a/Resources/Public/Main.js.map +++ b/Resources/Public/Main.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../Private/Assets/Main.js"], - "sourcesContent": ["const NAMESPACE = 'betterembed';\nconst SWITCH_CLASS = `js-${NAMESPACE}-switch`;\nconst CLOSE_CLASS = `js-${NAMESPACE}-close`;\nconst LOAD_REMOTE_CLASS = `js-${NAMESPACE}-load-remote`;\nconst REMOTE_VISIBLE_CLASS = `is-${NAMESPACE}-remote-visible`;\nconst SHOW_MESSAGE_CLASS = `is-${NAMESPACE}-dialog-visible`;\nconst CONFIRMED_MESSAGE_CLASS = `is-${NAMESPACE}-confirmed`;\n\nconst getContainer = element => element.closest(`.js-${NAMESPACE}`);\nconst getEmbedElement = container => container.querySelector(`.js-${NAMESPACE}-embed`);\n\ndocument.addEventListener('click', function(event) {\n const TARGET = event.target;\n\n if (TARGET.classList.contains(SWITCH_CLASS)) {\n const CONTAINER = getContainer(TARGET);\n const CLASS_LIST = CONTAINER.classList;\n const ALREADY_CONFIRMED = CLASS_LIST.contains(CONFIRMED_MESSAGE_CLASS);\n\n // toggle remote if already confirmed, otherwhise toggle message\n CLASS_LIST.toggle(ALREADY_CONFIRMED ? REMOTE_VISIBLE_CLASS : SHOW_MESSAGE_CLASS);\n }\n\n if (TARGET.classList.contains(CLOSE_CLASS)) {\n const CONTAINER = getContainer(TARGET);\n\n // Hide Message\n CONTAINER.classList.remove(SHOW_MESSAGE_CLASS);\n }\n\n if (TARGET.classList.contains(LOAD_REMOTE_CLASS)) {\n const CONTAINER = getContainer(TARGET);\n const CLASS_LIST = CONTAINER.classList;\n const EMBED_ELEMENT = getEmbedElement(CONTAINER);\n\n if (!EMBED_ELEMENT.innerHTML) {\n // This is the first-time click\n EMBED_ELEMENT.innerHTML = JSON.parse(CONTAINER.dataset.embedHtml);\n\n // Run trough every script and active it\n Array.from(EMBED_ELEMENT.querySelectorAll('script')).forEach(scriptTag => {\n if (scriptTag.src) {\n const TAG = document.createElement('script');\n TAG.src = scriptTag.src;\n document.head.appendChild(TAG);\n } else {\n // The script is an inline JS, so we have to use eval\n // jshint -W061\n window.eval(scriptTag.innerHTML);\n // jshint +W061\n }\n });\n }\n CLASS_LIST.add(REMOTE_VISIBLE_CLASS);\n CLASS_LIST.add(CONFIRMED_MESSAGE_CLASS);\n CLASS_LIST.remove(SHOW_MESSAGE_CLASS);\n }\n});\n"], - "mappings": "MAAA,IAAMA,EAAY,cACZC,EAAe,MAAMD,CAAS,UAC9BE,EAAc,MAAMF,CAAS,SAC7BG,EAAoB,MAAMH,CAAS,eACnCI,EAAuB,MAAMJ,CAAS,kBACtCK,EAAqB,MAAML,CAAS,kBACpCM,EAA0B,MAAMN,CAAS,aAEzCO,EAAeC,GAAWA,EAAQ,QAAQ,OAAOR,CAAS,EAAE,EAC5DS,EAAkBC,GAAaA,EAAU,cAAc,OAAOV,CAAS,QAAQ,EAErF,SAAS,iBAAiB,QAAS,SAASW,EAAO,CAC/C,IAAMC,EAASD,EAAM,OAErB,GAAIC,EAAO,UAAU,SAASX,CAAY,EAAG,CAEzC,IAAMY,EADYN,EAAaK,CAAM,EACR,UACvBE,EAAoBD,EAAW,SAASP,CAAuB,EAGrEO,EAAW,OAAOC,EAAoBV,EAAuBC,CAAkB,CACnF,CASA,GAPIO,EAAO,UAAU,SAASV,CAAW,GACnBK,EAAaK,CAAM,EAG3B,UAAU,OAAOP,CAAkB,EAG7CO,EAAO,UAAU,SAAST,CAAiB,EAAG,CAC9C,IAAMY,EAAYR,EAAaK,CAAM,EAC/BC,EAAaE,EAAU,UACvBC,EAAgBP,EAAgBM,CAAS,EAE1CC,EAAc,YAEfA,EAAc,UAAY,KAAK,MAAMD,EAAU,QAAQ,SAAS,EAGhE,MAAM,KAAKC,EAAc,iBAAiB,QAAQ,CAAC,EAAE,QAAQC,GAAa,CACtE,GAAIA,EAAU,IAAK,CACf,IAAMC,EAAM,SAAS,cAAc,QAAQ,EAC3CA,EAAI,IAAMD,EAAU,IACpB,SAAS,KAAK,YAAYC,CAAG,CACjC,MAGI,OAAO,KAAKD,EAAU,SAAS,CAGvC,CAAC,GAELJ,EAAW,IAAIT,CAAoB,EACnCS,EAAW,IAAIP,CAAuB,EACtCO,EAAW,OAAOR,CAAkB,CACxC,CACJ,CAAC", + "sourcesContent": ["const NAMESPACE = 'betterembed';\nconst SWITCH_CLASS = `js-${NAMESPACE}-switch`;\nconst CLOSE_CLASS = `js-${NAMESPACE}-close`;\nconst LOAD_REMOTE_CLASS = `js-${NAMESPACE}-load-remote`;\nconst REMOTE_VISIBLE_CLASS = `is-${NAMESPACE}-remote-visible`;\nconst SHOW_MESSAGE_CLASS = `is-${NAMESPACE}-dialog-visible`;\nconst CONFIRMED_MESSAGE_CLASS = `is-${NAMESPACE}-confirmed`;\n\nconst getContainer = (element) => element.closest(`.js-${NAMESPACE}`);\nconst getEmbedElement = (container) => container.querySelector(`.js-${NAMESPACE}-embed`);\n\ndocument.addEventListener('click', (event) => {\n const TARGET = event.target;\n\n if (TARGET.classList.contains(SWITCH_CLASS)) {\n const CONTAINER = getContainer(TARGET);\n const CLASS_LIST = CONTAINER.classList;\n const ALREADY_CONFIRMED = CLASS_LIST.contains(CONFIRMED_MESSAGE_CLASS);\n\n // toggle remote if already confirmed, otherwhise toggle message\n CLASS_LIST.toggle(ALREADY_CONFIRMED ? REMOTE_VISIBLE_CLASS : SHOW_MESSAGE_CLASS);\n }\n\n if (TARGET.classList.contains(CLOSE_CLASS)) {\n const CONTAINER = getContainer(TARGET);\n\n // Hide Message\n CONTAINER.classList.remove(SHOW_MESSAGE_CLASS);\n }\n\n if (TARGET.classList.contains(LOAD_REMOTE_CLASS)) {\n const CONTAINER = getContainer(TARGET);\n const CLASS_LIST = CONTAINER.classList;\n const EMBED_ELEMENT = getEmbedElement(CONTAINER);\n\n if (!EMBED_ELEMENT.innerHTML) {\n // This is the first-time click\n EMBED_ELEMENT.innerHTML = JSON.parse(CONTAINER.dataset.embedHtml);\n\n // Run trough every script and active it\n Array.from(EMBED_ELEMENT.querySelectorAll('script')).forEach((scriptTag) => {\n if (scriptTag.src) {\n const TAG = document.createElement('script');\n TAG.src = scriptTag.src;\n document.head.appendChild(TAG);\n } else {\n // The script is an inline JS, so we have to use eval\n // jshint -W061\n window.eval(scriptTag.innerHTML);\n // jshint +W061\n }\n });\n }\n CLASS_LIST.add(REMOTE_VISIBLE_CLASS);\n CLASS_LIST.add(CONFIRMED_MESSAGE_CLASS);\n CLASS_LIST.remove(SHOW_MESSAGE_CLASS);\n }\n});\n"], + "mappings": "MAAA,IAAMA,EAAY,cACZC,EAAe,MAAMD,CAAS,UAC9BE,EAAc,MAAMF,CAAS,SAC7BG,EAAoB,MAAMH,CAAS,eACnCI,EAAuB,MAAMJ,CAAS,kBACtCK,EAAqB,MAAML,CAAS,kBACpCM,EAA0B,MAAMN,CAAS,aAEzCO,EAAgBC,GAAYA,EAAQ,QAAQ,OAAOR,CAAS,EAAE,EAC9DS,EAAmBC,GAAcA,EAAU,cAAc,OAAOV,CAAS,QAAQ,EAEvF,SAAS,iBAAiB,QAAUW,GAAU,CAC1C,IAAMC,EAASD,EAAM,OAErB,GAAIC,EAAO,UAAU,SAASX,CAAY,EAAG,CAEzC,IAAMY,EADYN,EAAaK,CAAM,EACR,UACvBE,EAAoBD,EAAW,SAASP,CAAuB,EAGrEO,EAAW,OAAOC,EAAoBV,EAAuBC,CAAkB,CACnF,CASA,GAPIO,EAAO,UAAU,SAASV,CAAW,GACnBK,EAAaK,CAAM,EAG3B,UAAU,OAAOP,CAAkB,EAG7CO,EAAO,UAAU,SAAST,CAAiB,EAAG,CAC9C,IAAMY,EAAYR,EAAaK,CAAM,EAC/BC,EAAaE,EAAU,UACvBC,EAAgBP,EAAgBM,CAAS,EAE1CC,EAAc,YAEfA,EAAc,UAAY,KAAK,MAAMD,EAAU,QAAQ,SAAS,EAGhE,MAAM,KAAKC,EAAc,iBAAiB,QAAQ,CAAC,EAAE,QAASC,GAAc,CACxE,GAAIA,EAAU,IAAK,CACf,IAAMC,EAAM,SAAS,cAAc,QAAQ,EAC3CA,EAAI,IAAMD,EAAU,IACpB,SAAS,KAAK,YAAYC,CAAG,CACjC,MAGI,OAAO,KAAKD,EAAU,SAAS,CAGvC,CAAC,GAELJ,EAAW,IAAIT,CAAoB,EACnCS,EAAW,IAAIP,CAAuB,EACtCO,EAAW,OAAOR,CAAkB,CACxC,CACJ,CAAC", "names": ["NAMESPACE", "SWITCH_CLASS", "CLOSE_CLASS", "LOAD_REMOTE_CLASS", "REMOTE_VISIBLE_CLASS", "SHOW_MESSAGE_CLASS", "CONFIRMED_MESSAGE_CLASS", "getContainer", "element", "getEmbedElement", "container", "event", "TARGET", "CLASS_LIST", "ALREADY_CONFIRMED", "CONTAINER", "EMBED_ELEMENT", "scriptTag", "TAG"] }