{"id":37006334,"url":"https://github.com/esign/craft-cms-crud","last_synced_at":"2026-01-14T00:45:13.016Z","repository":{"id":63304478,"uuid":"561721317","full_name":"esign/craft-cms-crud","owner":"esign","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-07T08:11:54.000Z","size":95,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-11-27T14:56:41.507Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/esign.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-11-04T10:41:39.000Z","updated_at":"2024-11-07T08:11:35.000Z","dependencies_parsed_at":"2024-11-07T09:19:10.549Z","dependency_job_id":"ff629bdc-3193-4a36-801c-db1bfed413c7","html_url":"https://github.com/esign/craft-cms-crud","commit_stats":{"total_commits":23,"total_committers":2,"mean_commits":11.5,"dds":0.04347826086956519,"last_synced_commit":"b5a50bdd633a6dfa9f457807ec0bda012837329c"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/esign/craft-cms-crud","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esign%2Fcraft-cms-crud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esign%2Fcraft-cms-crud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esign%2Fcraft-cms-crud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esign%2Fcraft-cms-crud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/esign","download_url":"https://codeload.github.com/esign/craft-cms-crud/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esign%2Fcraft-cms-crud/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-01-14T00:45:12.432Z","updated_at":"2026-01-14T00:45:12.997Z","avatar_url":"https://github.com/esign.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Craft Programmatically CRUD\n\nThis module contains the basic CRUD functions for Craft CMS\n\n## Installation\n\nYou can install the package via composer, and Craft to install it:\n\n```bash\ncomposer require esign/craft-cms-crud \u0026\u0026 php craft plugin/install craft-cms-crud \n```\n\n## Usage\n\n### updateOrCreateEntry\n\nCurrently there is only one function and that is `updateOrCreateEntry`, this can update an entry with all his fields (fields, matrix blocks \u0026 nested entries)\n\n`$entry` has to be an instance of `esign\\craftcmscrud\\support\\CraftEntry` then we are sure all fields can be mapped right\n\n```php\nuse esign\\craftcmscrud\\controllers\\CraftEntryController;\n\nclass YourController extends CraftEntryController\n{\n    CraftEntryController::updateOrCreateEntry($entry);\n}\n```\n\n## Entry Objects\n---\n\n###  **CraftEntry.php**\n```php\nuse esign\\craftcmscrud\\support\\CraftEntry;\n\nnew CraftEntry(\n    $handle, \n    $identifier, \n    $fields, \n    $matrixBlocks, \n    $nestedEntries\n)\n```\n\n`$handle` -\u003e expects your section handle name\n\n`$identifier` -\u003e expects your identifier for that entry (used for updating an entry instead of creating one)\n\n`$fields` -\u003e expects a stdClass of your entry fields (including title \u0026 slug) `OR` an array of stdClasses of your entry fields (this is used for nested entries more on this later)\n\n`$matrixBlocks` -\u003e expects an array of CraftMatrixBlock classes (see section CraftMatrixBlock)\n\n`$nestedEntries` -\u003e expects an array of CraftEntry classes\n\n\n\n### **CraftMatrixBlock.php**\n```php\nuse esign\\craftcmscrud\\support\\CraftMatrixBlock;\n\nnew CraftMatrixBlock(\n    $handle, \n    $handleBlock, \n    $fields\n)\n```\n\n`$handle` -\u003e expects your field handle name\n\n`$handleBlock` -\u003e expects your matrix block handle name\n\n`$fields` -\u003e expects an array of stdClasses of your matrix fields\n\n### **CraftAsset.php**\n```php\nuse esign\\craftcmscrud\\support\\CraftAsset;\n\nnew CraftAsset(\n    $handle,\n    $imageUrl,\n    $filename,\n    $path,\n)\n```\n\n`$handle` -\u003e expects your field handle name\n\n`$imageUrl` -\u003e expects your external image url\n\n`$filename` -\u003e expects filename\n\n`$path` -\u003e expects the path of your asset field\n\n\n\n## Example\n---\n```php\nuse esign\\craftcmscrud\\controllers\\CraftEntryController;\nuse esign\\craftcmscrud\\support\\CraftEntry;\nuse esign\\craftcmscrud\\support\\CraftMatrixBlock;\n\nCraftEntryController::updateOrCreateEntry(\n    new CraftEntry(\n        self::HANDLE_CLUB,\n        self::IDENTIFIER_CLUB,\n        ClubModel::fieldsFromClub($club),\n        [\n            new CraftMatrixBlock(\n                self::HANDLE_OPENING_HOURS,\n                self::HANDLE_OPENING_HOURS_BLOCK,\n                $club-\u003e{self::HANDLE_OPENING_HOURS}\n            ),\n            ...\n        ],\n        [\n            new CraftEntry(\n                self::HANDLE_CLUB_TAGS,\n                self::IDENTIFIER_CLUB_TAGS,\n                ClubModel::collectionFieldsFromClubTags($club-\u003e{self::HANDLE_CLUB_TAGS})\n            ),\n            ...\n        ],\n        [\n            new CraftAsset(\n                self::HANDLE_IMAGE,\n                $contract-\u003emlContractImageUrl,\n                StringHelper::beforeFirst(StringHelper::afterLast($contract-\u003emlContractImageUrl, '/'), '?'),\n                self::HANDLE_IMAGE_PATH\n            )\n        ],\n    ),\n);\n```\n\n## parseNestedMatrixBlocks\n---\n```php\nuse esign\\craftcmscrud\\controllers\\CraftEntryController;\nuse esign\\craftcmscrud\\support\\CraftEntry;\nuse esign\\craftcmscrud\\support\\CraftMatrixBlock;\n\npublic const MATRIX_BLOCKS_CONTRACT_TERM = [\n    'mlTermPriceAdjustmentRules' =\u003e 'mlPriceBlock',\n    'mlTermFlatFees' =\u003e 'mlFeeBlock',\n    'mlTermOptionalModules' =\u003e 'mlOptionalBlock',\n    'mlTermRateBonusPeriods' =\u003e 'mlBonusBlock',\n];\n\nCraftEntryController::updateOrCreateEntry(\n    new CraftEntry(\n        self::HANDLE_CONTRACT,\n        self::IDENTIFIER_CONTRACT,\n        Entry::fieldsFromContract($contract),\n        null,\n        [\n            new CraftEntry(\n                self::HANDLE_CONTRACT_TERM,\n                self::IDENTIFIER_CONTRACT_TERM,\n                Entry::collectionFieldsFromContractTerms(\n                    $contract-\u003e{self::HANDLE_CONTRACT_TERM}\n                ),\n                CraftEntryController::parseNestedMatrixBlocks(\n                    $contract-\u003e{self::HANDLE_CONTRACT_TERM},\n                    self::MATRIX_BLOCKS_CONTRACT_TERM\n                ),\n            ),\n        ],\n    ),\n);\n```\n\n`CraftEntryController::parseNestedMatrixBlocks()` is used to parse the nested matrix blocks. \n\n`MATRIX_BLOCKS_CONTRACT_TERM` is the $sectionHandle =\u003e $blockHandle","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesign%2Fcraft-cms-crud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fesign%2Fcraft-cms-crud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesign%2Fcraft-cms-crud/lists"}