{"id":22854671,"url":"https://github.com/kanopi/kelp","last_synced_at":"2026-05-03T06:36:42.293Z","repository":{"id":199587291,"uuid":"703260804","full_name":"kanopi/kelp","owner":"kanopi","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-22T17:34:44.000Z","size":15,"stargazers_count":0,"open_issues_count":7,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-02-06T11:56:58.535Z","etag":null,"topics":["composer-package","do-not-archive","drupal","drupal-module","internal-tool"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kanopi.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-10T23:01:56.000Z","updated_at":"2024-04-01T12:24:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"cc5d441f-fc80-4ecb-8ea4-af461bd522c6","html_url":"https://github.com/kanopi/kelp","commit_stats":null,"previous_names":["kanopi/kelp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanopi%2Fkelp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanopi%2Fkelp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanopi%2Fkelp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanopi%2Fkelp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kanopi","download_url":"https://codeload.github.com/kanopi/kelp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246429640,"owners_count":20775860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer-package","do-not-archive","drupal","drupal-module","internal-tool"],"created_at":"2024-12-13T07:08:03.734Z","updated_at":"2026-05-03T06:36:37.273Z","avatar_url":"https://github.com/kanopi.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KELP\nKelp is a central place to keep Kanopi Drupal helper functions.\n\n\n\n## `KelpHelpers::fieldCheck($entity, $field_name)`\n\nThis function checks if a field exists on a Drupal entity and is not empty.\n\n```php\nuse Drupal\\kelp\\KelpHelpers;\n\n\n// Example usage:\n$node = \\Drupal::entityTypeManager()-\u003egetStorage('node')-\u003eload(1);\n\nif (KelpHelpers::fieldCheck($node, 'field_example')) {\n  // The field 'field_example' exists and is not empty.\n  // Your code here...\n} else {\n  // The field 'field_example' does not exist or is empty.\n  // Handle accordingly...\n}\n```\n\n## `KelpHelpers::linkHelper($link, $options = [])`\n\nThis function generates link properties from a link field.\n\n```php\nuse Drupal\\kelp\\KelpHelpers;\n\n\n// Example usage:\n$link = $node-\u003efield_link-\u003efirst(); // Assuming you have a link field\n$linkProperties = KelpHelpers::linkHelper($link, ['title' =\u003e 'Find out more about kelp', 'modifiers' =\u003e ['btn', 'btn-primary']]);\n\n// $linkProperties will contain an array with URL, title, target, etc.\ndump($linkProperties);\n```\n\n## `KelpHelpers::youtubeVideoId($source)`\n\nThis function extracts the YouTube video ID from a given URL.\n\n```php\nuse Drupal\\kelp\\KelpHelpers;\n\n\n// Example usage:\n$youtubeURL = 'https://www.youtube.com/watch?v=VIDEO_ID';\n$videoId = KelpHelpers::youtubeVideoId($youtubeURL);\n\nif ($videoId) {\n  // $videoId will contain the extracted YouTube video ID.\n  // Your code here...\n} else {\n  // The YouTube video ID was not found in the URL.\n  // Handle accordingly...\n}\n```\n\n## `KelpHelpers::machinify($text, $separator = '_')`\n\nThis function converts a string into a machine-friendly format with an optional separator.\n\n```php\nuse Drupal\\kelp\\KelpHelpers;\n\n\n// Example usage:\n$text = \"Convert This String\";\n$machineFriendlyText = KelpHelpers::machinify($text, '-');\n\n// $machineFriendlyText will be \"convert-this-string\"\ndump($machineFriendlyText);\n```\n\n## `KelpHelpers::getImageData($imageEntity)`\n\nThis function returns retuns an array of image related information.\n\n```php\nuse Drupal\\kelp\\KelpHelpers;\n\n\n// Example of an Image media entity on a node with the media\n// image field field_media_image:\n$node_media_image_entity = $node-\u003eget('field_media_collection_image')-\u003eentity-\u003eget('field_media_image');\n$node_media_image_entity_data = KelpHelpers::getImageData($node_media_image_entity);\n\n// Array of useful information about the image.\ndump($node_media_image_entity_data);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanopi%2Fkelp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkanopi%2Fkelp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanopi%2Fkelp/lists"}