Skip to content

Commit

Permalink
chore: ECS linting
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Jan 29, 2024
1 parent 1f84593 commit ea24172
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 54 deletions.
10 changes: 5 additions & 5 deletions src/CantoDamAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function init(): void
self::$plugin = self::getInstance();

// Defer most setup tasks until Craft is fully initialized
Craft::$app->onInit(function () {
Craft::$app->onInit(function() {
$this->attachEventHandlers();
});
}
Expand Down Expand Up @@ -74,7 +74,7 @@ protected function attachEventHandlers(): void
Event::on(
CraftVariable::class,
CraftVariable::EVENT_INIT,
function (Event $event) {
function(Event $event) {
/** @var CraftVariable $variable */
$variable = $event->sender;
$variable->set('canto', [
Expand All @@ -86,21 +86,21 @@ function (Event $event) {
Event::on(
Fields::class,
Fields::EVENT_REGISTER_FIELD_TYPES,
static function (RegisterComponentTypesEvent $event) {
static function(RegisterComponentTypesEvent $event) {
$event->types[] = CantoDamAsset::class;
});
// Add permission for Editors
Event::on(
UserPermissions::class,
UserPermissions::EVENT_REGISTER_PERMISSIONS,
function (RegisterUserPermissionsEvent $event) {
function(RegisterUserPermissionsEvent $event) {
$event->permissions[] = [
"heading" => "Canto DAM Assets Picker Extraordinaire",
"permissions" => [
'accessPlugin-_canto-dam-assets' => [
'label' => 'Use Canto DAM Assets Fields',
],
]
],
];
}
);
Expand Down
41 changes: 20 additions & 21 deletions src/fields/CantoDamAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/
class CantoDamAsset extends Field implements PreviewableFieldInterface
{

protected const PICKER_TYPE_CLASS_MAP = [
'singleImagePicker' => 'can-select-single',
'multipleImagePicker' => 'can-select-single can-select-multiple',
Expand Down Expand Up @@ -320,13 +319,13 @@ protected function getGqlArguments(): array
'fields' => [
'page' => [
'type' => Type::int(),
'description' => 'The page number'
'description' => 'The page number',
],
'items' => [
'type' => Type::int(),
'description' => 'The number of items per page'
'description' => 'The number of items per page',
],
]
],
]),
],
'where' => [
Expand All @@ -337,17 +336,17 @@ protected function getGqlArguments(): array
'fields' => [
'key' => [
'type' => Type::string(),
'description' => 'The key to search on, you can use the `field.subField` syntax for nested fields'
'description' => 'The key to search on, you can use the `field.subField` syntax for nested fields',
],
'value' => [
'type' => Type::string(),
'description' => 'The value to match when searching'
'description' => 'The value to match when searching',
],
'operator' => [
'type' => Type::string(),
'description' => 'The comparison operator to use, e.g.: `=`, `>`, `<=`, etc. The default is `=`'
]
]
'description' => 'The comparison operator to use, e.g.: `=`, `>`, `<=`, etc. The default is `=`',
],
],
]),
],
'whereNull' => [
Expand All @@ -368,13 +367,13 @@ protected function getGqlArguments(): array
'fields' => [
'key' => [
'type' => Type::string(),
'description' => 'The key to search on, you can use the `field.subField` syntax for nested fields'
'description' => 'The key to search on, you can use the `field.subField` syntax for nested fields',
],
'values' => [
'type' => Type::listOf(Type::string()),
'description' => 'The values that should be in the key'
'description' => 'The values that should be in the key',
],
]
],
]),
],
'whereNotIn' => [
Expand All @@ -385,13 +384,13 @@ protected function getGqlArguments(): array
'fields' => [
'key' => [
'type' => Type::string(),
'description' => 'The key to search on, you can use the `field.subField` syntax for nested fields'
'description' => 'The key to search on, you can use the `field.subField` syntax for nested fields',
],
'values' => [
'type' => Type::listOf(Type::string()),
'description' => 'The the values that should not be in the key'
'description' => 'The the values that should not be in the key',
],
]
],
]),
],
'whereBetween' => [
Expand All @@ -402,13 +401,13 @@ protected function getGqlArguments(): array
'fields' => [
'key' => [
'type' => Type::string(),
'description' => 'The key to search on, you can use the `field.subField` syntax for nested fields'
'description' => 'The key to search on, you can use the `field.subField` syntax for nested fields',
],
'values' => [
'type' => Type::listOf(Type::string()),
'description' => 'The values that the key should be between'
'description' => 'The values that the key should be between',
],
]
],
]),
],
'whereNotBetween' => [
Expand All @@ -419,13 +418,13 @@ protected function getGqlArguments(): array
'fields' => [
'key' => [
'type' => Type::string(),
'description' => 'The key to search on, you can use the `field.subField` syntax for nested fields'
'description' => 'The key to search on, you can use the `field.subField` syntax for nested fields',
],
'values' => [
'type' => Type::listOf(Type::string()),
'description' => 'The values the key should not be between'
'description' => 'The values the key should not be between',
],
]
],
]),
],
], 'CantoDamAssetQueryType');
Expand Down
14 changes: 7 additions & 7 deletions src/gql/interfaces/CantoDamAssetInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function getType($fields = null): Type
'name' => static::getName(),
'fields' => self::class . '::getFieldDefinitions',
'description' => 'This is the interface implemented by CantoDamAsset.',
'resolveType' => function (array $value) {
'resolveType' => function(array $value) {
return GqlEntityRegistry::getEntity(CantoDamAssetGenerator::getName());
},
]));
Expand Down Expand Up @@ -80,7 +80,7 @@ public static function getFieldDefinitions(): array
'Has Color Map' => Type::string(),
'Frame Count' => Type::string(),
'Panoramas' => Type::string(),
])
]),
]),
'height' => Type::string(),
'relatedAlbums' => Type::listOf(new ObjectType([
Expand All @@ -101,7 +101,7 @@ public static function getFieldDefinitions(): array
'id' => Type::string(),
'size' => Type::string(),
'schema' => Type::string(),
]
],
])),
'md5' => Type::string(),
'approvalStatus' => Type::string(),
Expand All @@ -126,7 +126,7 @@ public static function getFieldDefinitions(): array
],
]),
'currentVersion' => Type::string(),
]
],
])),
'created' => Type::string(),
'keyword' => Type::listOf(Type::string()),
Expand Down Expand Up @@ -167,7 +167,7 @@ public static function getFieldDefinitions(): array
'Caption **EN**' => Type::string(),
'Usage Terms' => Type::string(),
'WebDAM Media Type' => Type::string(),
])
]),
]),
'url' => new ObjectType([
'name' => 'CantoUrlType',
Expand All @@ -182,7 +182,7 @@ public static function getFieldDefinitions(): array
'directUrlPreview' => Type::string(),
'directUrlPreviewPlay' => Type::string(),
'LowJPG' => Type::string(),
]
],
]),
'width' => Type::string(),
'name' => Type::string(),
Expand All @@ -203,7 +203,7 @@ public static function getFieldDefinitions(): array
'Author' => Type::string(),
'Date Created' => Type::string(),
'Resolution' => Type::string(),
])
]),
]),
'id' => Type::string(),
'size' => Type::string(),
Expand Down
5 changes: 2 additions & 3 deletions src/gql/types/generators/CantoDamAssetGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use craft\gql\base\GeneratorInterface;
use craft\gql\GqlEntityRegistry;
use craft\gql\TypeLoader;
use GraphQL\Type\Definition\Type;
use lsst\cantodamassets\gql\interfaces\CantoDamAssetInterface;
use lsst\cantodamassets\gql\types\CantoDamAssetType;

Expand All @@ -19,14 +18,14 @@ public static function generateTypes(mixed $context = null): array
$cantoDamAssetType = GqlEntityRegistry::getEntity($typeName)
?: GqlEntityRegistry::createEntity($typeName, new CantoDamAssetType([
'name' => $typeName,
'fields' => function () use ($cantoDamAssetFields) {
'fields' => function() use ($cantoDamAssetFields) {
return $cantoDamAssetFields;
},
'description' => 'This entity has all the Canto Dam Asset fields',
]));

$gqlTypes[$typeName] = $cantoDamAssetType;
TypeLoader::registerType($typeName, function () use ($cantoDamAssetType) {
TypeLoader::registerType($typeName, function() use ($cantoDamAssetType) {
return $cantoDamAssetType;
});

Expand Down
2 changes: 1 addition & 1 deletion src/jobs/DeleteByAlbumId.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function execute($queue): void
protected function defaultDescription(): ?string
{
return Translation::prep('_canto-dam-assets', 'Deleting Canto Album id {id}', [
'id' => $this->id
'id' => $this->id,
]);
}
}
2 changes: 1 addition & 1 deletion src/jobs/DeleteByCantoId.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function execute($queue): void
protected function defaultDescription(): ?string
{
return Translation::prep('_canto-dam-assets', 'Deleting Canto Asset id {id}', [
'id' => $this->id
'id' => $this->id,
]);
}
}
2 changes: 1 addition & 1 deletion src/jobs/UpdateByAlbumId.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function execute($queue): void
protected function defaultDescription(): ?string
{
return Translation::prep('_canto-dam-assets', 'Updating Canto Album id {id}', [
'id' => $this->id
'id' => $this->id,
]);
}
}
2 changes: 1 addition & 1 deletion src/jobs/UpdateByCantoId.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function execute($queue): void
protected function defaultDescription(): ?string
{
return Translation::prep('_canto-dam-assets', 'Updating Canto Asset id {id}', [
'id' => $this->id
'id' => $this->id,
]);
}
}
8 changes: 4 additions & 4 deletions src/lib/laravel/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function whereIn($key, $values, $strict = false)
{
$values = $this->getArrayableItems($values);

return $this->filter(function ($item) use ($key, $values, $strict) {
return $this->filter(function($item) use ($key, $values, $strict) {
$item = data_get($item, $key);
// Handle the case where the data is an array of items
if (is_array($item)) {
Expand All @@ -40,7 +40,7 @@ public function whereNotIn($key, $values, $strict = false)
{
$values = $this->getArrayableItems($values);

return $this->reject(function ($item) use ($key, $values, $strict) {
return $this->reject(function($item) use ($key, $values, $strict) {
$item = data_get($item, $key);
// Handle the case where the data is an array of items
if (is_array($item)) {
Expand Down Expand Up @@ -76,10 +76,10 @@ protected function operatorForWhere($key, $operator = null, $value = null)
$operator = '=';
}

return function ($item) use ($key, $operator, $value) {
return function($item) use ($key, $operator, $value) {
$retrieved = data_get($item, $key);

$strings = array_filter([$retrieved, $value], function ($value) {
$strings = array_filter([$retrieved, $value], function($value) {
return is_string($value) || (is_object($value) && method_exists($value, '__toString'));
});

Expand Down
1 change: 0 additions & 1 deletion src/migrations/m231108_024521_change_to_json_column.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
class m231108_024521_change_to_json_column extends Migration
{

private const CONTENT_COLUMN_KEYS = [
'cantoAssetData',
'cantoAlbumData',
Expand Down
4 changes: 2 additions & 2 deletions src/models/CantoFieldData.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public function defineRules(): array
[
[
'cantoId',
'cantoAlbumId'
'cantoAlbumId',
],
[
'string',
'skipOnEmpty' => true
'skipOnEmpty' => true,
],
],
[
Expand Down
4 changes: 2 additions & 2 deletions src/models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function defineRules(): array
'appId',
'authEndpoint',
'tenantHostName',
'secretKey'
'secretKey',
],
'required',
],
Expand All @@ -106,7 +106,7 @@ public function defineRules(): array
'url',
],
[
'authEndpoint', 'default', 'value' => 'https://oauth.canto.com/oauth/api/oauth2/token?app_id={appId}&app_secret={secretKey}&grant_type=client_credentials&refresh_token='
'authEndpoint', 'default', 'value' => 'https://oauth.canto.com/oauth/api/oauth2/token?app_id={appId}&app_secret={secretKey}&grant_type=client_credentials&refresh_token=',
],
];
}
Expand Down
6 changes: 3 additions & 3 deletions src/services/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function cantoApiRequest(string $path, array $params = []): array
if (!is_array($body)) {
return [
"status" => "error",
'errorMessage' => 'Canto endpoint failure'
'errorMessage' => 'Canto endpoint failure',
];
}

Expand Down Expand Up @@ -184,8 +184,8 @@ public function getApiHeaders(): array
return [
'headers' => [
'Authorization' => 'bearer ' . $this->getAuthToken(),
'Content-Type' => 'application/x-www-form-urlencoded'
]
'Content-Type' => 'application/x-www-form-urlencoded',
],
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/ServicesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function config(): array
'errorEntry' => 'src/js/app.ts',
'useDevServer' => true,
],
]
],
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/translations/en/_canto-dam-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
'Updating Canto Asset id {id}' => 'Updating Canto Asset id {id}',
'Deleting Canto Asset id {id}' => 'Deleting Canto Asset id {id}',
'Updating Canto Album id {id}' => 'Updating Canto Album id {id}',
'Deleting Canto Album id {id}' => 'Deleting Canto Album id {id}'
'Deleting Canto Album id {id}' => 'Deleting Canto Album id {id}',
];

0 comments on commit ea24172

Please sign in to comment.