-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Updated - Support `rel` URL propety via DOM manipulation. ([#24](#24)) - Added GraphQL support. ([#25](#25)) - Updated docs ### Fixed - Fixed "Undefined index: autoplay" warnings. ([#26](#26))
- Loading branch information
1 parent
886b013
commit 067706b
Showing
10 changed files
with
207 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
vendor | ||
composer.lock | ||
composer.lock | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* oEmbed plugin for Craft CMS 3.x | ||
* | ||
* A simple plugin to extract media information from websites, like youtube videos, twitter statuses or blog articles. | ||
* | ||
* @link https://github.com/wrav | ||
* @copyright Copyright (c) 2017 reganlawton | ||
*/ | ||
|
||
namespace wrav\oembed\gql; | ||
|
||
use craft\gql\base\ObjectType; | ||
use GraphQL\Type\Definition\ResolveInfo; | ||
|
||
class OembedFieldResolver extends ObjectType | ||
{ | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function resolve($source, $arguments, $context, ResolveInfo $resolveInfo) | ||
{ | ||
$fieldName = $resolveInfo->fieldName; | ||
|
||
return $source->$fieldName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/** | ||
* oEmbed plugin for Craft CMS 3.x | ||
* | ||
* A simple plugin to extract media information from websites, like youtube videos, twitter statuses or blog articles. | ||
* | ||
* @link https://github.com/wrav | ||
* @copyright Copyright (c) 2017 reganlawton | ||
*/ | ||
|
||
namespace wrav\oembed\gql; | ||
|
||
use craft\gql\base\GeneratorInterface; | ||
use craft\gql\GqlEntityRegistry; | ||
use craft\gql\TypeLoader; | ||
use GraphQL\Type\Definition\Type; | ||
|
||
class OembedFieldTypeGenerator implements GeneratorInterface | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public static function generateTypes($context = null): array | ||
{ | ||
/** @var OembedField $context */ | ||
$typeName = self::getName($context); | ||
|
||
$properties = [ | ||
'title' => Type::string(), | ||
'description' => Type::string(), | ||
'url' => Type::string(), | ||
'type' => Type::string(), | ||
'images' => Type::string(), | ||
'image' => Type::string(), | ||
'imageWidth' => Type::string(), | ||
'imageHeight' => Type::string(), | ||
'code' => Type::string(), | ||
'width' => Type::string(), | ||
'height' => Type::string(), | ||
'aspectRatio' => Type::string(), | ||
'authorName' => Type::string(), | ||
'authorUrl' => Type::string(), | ||
'providerName' => Type::string(), | ||
'providerUrl' => Type::string(), | ||
]; | ||
|
||
$property = GqlEntityRegistry::getEntity($typeName) | ||
?: GqlEntityRegistry::createEntity($typeName, new OembedFieldResolver([ | ||
'name' => $typeName, | ||
'description' => 'This entity has all the Oembed Field properties', | ||
'fields' => function () use ($properties) { | ||
return $properties; | ||
}, | ||
])); | ||
|
||
TypeLoader::registerType($typeName, function () use ($property) { | ||
return $property; | ||
}); | ||
|
||
return [$property]; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public static function getName($context = null): string | ||
{ | ||
/** @var OembedField $context */ | ||
return $context->handle . '_OembedField'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters