Skip to content

Commit

Permalink
Chore: Prettier files
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnitto committed Jul 2, 2023
1 parent 8cee87d commit b6710dc
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 36 deletions.
1 change: 1 addition & 0 deletions Classes/Aspect/Runtime/FusionRuntimeAspect.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace BetterEmbed\NeosEmbed\Aspect\Runtime;

use Neos\Flow\Annotations as Flow;
Expand Down
6 changes: 4 additions & 2 deletions Classes/Command/BetterCommandController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace BetterEmbed\NeosEmbed\Command;

use Neos\ContentRepository\Domain\Model\NodeInterface;
Expand All @@ -24,11 +25,12 @@ class BetterCommandController extends CommandController
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Neos\ContentRepository\Exception\NodeTypeNotFoundException
*/
public function embedCommand(string $url ) {
public function embedCommand(string $url)
{

/** @var NodeInterface $node */
$node = $this->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');
}
}
5 changes: 3 additions & 2 deletions Classes/Domain/Dto/BetterEmbedRecord.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

namespace BetterEmbed\NeosEmbed\Domain\Dto;

class BetterEmbedRecord {
class BetterEmbedRecord
{

/**
* @var string
Expand Down Expand Up @@ -276,4 +278,3 @@ public function setPublishedAt(\DateTime $publishedAt): void
$this->publishedAt = $publishedAt;
}
}

1 change: 1 addition & 0 deletions Classes/Domain/Repository/BetterEmbedRepository.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace BetterEmbed\NeosEmbed\Domain\Repository;

use Neos\Flow\Annotations as Flow;
Expand Down
1 change: 1 addition & 0 deletions Classes/Package.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace BetterEmbed\NeosEmbed;

use Neos\Flow\Core\Bootstrap;
Expand Down
10 changes: 5 additions & 5 deletions Classes/Service/EmbedService.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function nodeRemoved(NodeInterface $node): void
if ($node->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);
Expand All @@ -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.');
}

Expand Down Expand Up @@ -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)]);

Expand Down
38 changes: 19 additions & 19 deletions Classes/Service/NodeService.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace BetterEmbed\NeosEmbed\Service;

use BetterEmbed\NeosEmbed\Domain\Repository\BetterEmbedRepository;
Expand All @@ -13,7 +14,6 @@
use Neos\Eel\Exception;
use Neos\Eel\FlowQuery\FlowQuery;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Persistence\Doctrine\QueryResult;
use Neos\Flow\Persistence\Exception\IllegalObjectTypeException;
use Neos\Flow\Persistence\PersistenceManagerInterface;
use Neos\Media\Domain\Model\AssetCollection;
Expand Down Expand Up @@ -116,9 +116,9 @@ public function findOrCreateBetterEmbedRootNode(Context $context)
}

/**
* @param string $title
* @return AssetCollection
* @throws IllegalObjectTypeException
* @param string $title
* @return AssetCollection
* @throws IllegalObjectTypeException
*/
public function findOrCreateBetterEmbedAssetCollection(string $title = self::ASSET_COLLECTION_TITLE): AssetCollection
{
Expand All @@ -136,9 +136,9 @@ public function findOrCreateBetterEmbedAssetCollection(string $title = self::ASS
}

/**
* @param string $label
* @return Tag
* @throws IllegalObjectTypeException
* @param string $label
* @return Tag
* @throws IllegalObjectTypeException
*/
public function findOrCreateBetterEmbedTag(string $label, ArrayCollection $assetCollections): Tag
{
Expand All @@ -153,20 +153,20 @@ public function findOrCreateBetterEmbedTag(string $label, ArrayCollection $asset
}

/** @var AssetCollection $collection */
foreach($tag->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
{
Expand All @@ -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]);

Expand All @@ -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;
}
}


}
2 changes: 1 addition & 1 deletion Configuration/NodeTypes.BetterEmbed.Content.Item.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
label: Better Embed
icon: plus
help:
message: 'i18n'
message: 'i18n'
8 changes: 4 additions & 4 deletions Resources/Private/Assets/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Resources/Public/Main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Resources/Public/Main.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b6710dc

Please sign in to comment.