Skip to content

Commit

Permalink
Merge branch 'alpha'
Browse files Browse the repository at this point in the history
  • Loading branch information
reganlawton committed Jun 29, 2020
2 parents eb129e2 + 4ba5c2d commit a785046
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 45 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# oEmbed Changelog

## 1.3.3 - 2020-06-29

### Updated
- Fix to GraphQL bug caused by PHP NULL coalescing operator from issue ([#46](https://github.com/wrav/oembed/issues/46)).

## 1.3.2 - 2020-06-05

### Updated
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "wrav/oembed",
"description": "A simple plugin to extract media information from websites, like youtube videos, twitter statuses or blog articles.",
"type": "craft-plugin",
"version": "1.3.2",
"version": "1.3.3",
"keywords": [
"craft",
"cms",
Expand Down Expand Up @@ -31,7 +31,7 @@
],
"require": {
"craftcms/cms": "^3.0.0-beta.23",
"embed/embed": "^3.3"
"embed/embed": "^3.0"
},
"repositories": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/gql/OembedFieldResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ protected function resolve($source, $arguments, $context, ResolveInfo $resolveIn
{
$fieldName = $resolveInfo->fieldName;

return $source->$fieldName ?? null;
return $source->$fieldName;
}
}
43 changes: 3 additions & 40 deletions src/gql/OembedFieldTypeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
namespace wrav\oembed\gql;

use craft\gql\base\GeneratorInterface;
use craft\gql\base\SingleGeneratorInterface;
use craft\gql\GqlEntityRegistry;
use craft\gql\TypeLoader;
use GraphQL\Type\Definition\Type;
use wrav\oembed\fields\OembedField;

class OembedFieldTypeGenerator implements GeneratorInterface, SingleGeneratorInterface
class OembedFieldTypeGenerator implements GeneratorInterface
{
/**
* @inheritdoc
Expand All @@ -31,7 +31,6 @@ public static function generateTypes($context = null): array
'description' => Type::string(),
'url' => Type::string(),
'type' => Type::string(),
'images' => Type::string(),
'image' => Type::string(),
'imageWidth' => Type::string(),
'imageHeight' => Type::string(),
Expand Down Expand Up @@ -61,43 +60,6 @@ public static function generateTypes($context = null): array
return [$property];
}



/**
* @inheritdoc
*/
public static function generateType($context = null): ObjectType
{
/** @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(),
];

return GqlEntityRegistry::getEntity($typeName) ?: GqlEntityRegistry::createEntity($typeName, new Element([
'name' => $typeName,
'fields' => function() use ($properties) {
return $properties;
}
]));
}

/**
* @inheritdoc
*/
Expand All @@ -106,4 +68,5 @@ public static function getName($context = null): string
/** @var OembedField $context */
return $context->handle . '_OembedField';
}

}
4 changes: 2 additions & 2 deletions src/models/OembedModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __toString()
public function __get($name)
{
if (property_exists($this , $name)) {
return $this->$name;
return $this->$name ?? null;
}

if ($this->oembed === null) {
Expand All @@ -69,7 +69,7 @@ public function __get($name)
$this->oembed = $oembed;
}

return $this->oembed->$name;
return $this->oembed->$name ?? null;
}


Expand Down

0 comments on commit a785046

Please sign in to comment.