{"id":22397132,"url":"https://github.com/putyourlightson/craft-element-status-events","last_synced_at":"2025-07-31T12:31:45.202Z","repository":{"id":34007317,"uuid":"165714307","full_name":"putyourlightson/craft-element-status-events","owner":"putyourlightson","description":"Triggers events whenever element statuses change in Craft CMS.","archived":false,"fork":false,"pushed_at":"2022-04-26T12:45:08.000Z","size":33,"stargazers_count":13,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"v2","last_synced_at":"2024-11-29T11:07:50.682Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/putyourlightson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-14T18:38:01.000Z","updated_at":"2024-04-24T13:58:06.000Z","dependencies_parsed_at":"2022-08-07T23:31:20.064Z","dependency_job_id":null,"html_url":"https://github.com/putyourlightson/craft-element-status-events","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/putyourlightson%2Fcraft-element-status-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/putyourlightson%2Fcraft-element-status-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/putyourlightson%2Fcraft-element-status-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/putyourlightson%2Fcraft-element-status-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/putyourlightson","download_url":"https://codeload.github.com/putyourlightson/craft-element-status-events/tar.gz/refs/heads/v2","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228242556,"owners_count":17890481,"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":[],"created_at":"2024-12-05T06:10:56.746Z","updated_at":"2024-12-05T06:10:57.415Z","avatar_url":"https://github.com/putyourlightson.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Element Status Events for Craft CMS 3\n\nThe Element Status Events extension provides events that are triggered whenever an element’s status changes. It is intended to be used a helper component for other Craft modules and plugins.\n\nTo get an understanding of how the module works, read the [Challenge #6 – The Chicken or the Egg](https://craftcodingchallenge.com/challenge-6-the-chicken-or-the-egg) solution.\n\n## Requirements\n\nThis extension requires Craft CMS 3.0.0 or later.\n\n## Usage\n\nInstall it manually using composer or add it as a dependency to your plugin.\n```\ncomposer require putyourlightson/craft-element-status-events\n```    \n    \nIf you work with scheduled Entries (future published or expired), make sure to set up cron that calls:\n```\nphp craft element-status-events/scheduled\n```    \n\n\n## Events\n\nWhenever an element’s status is changed, `ElementStatusEvents::EVENT_STATUS_CHANGED` is fired. The `StatusChangeEvent` object provides information about the change.\n\n```php\n\nuse putyourlightson\\elementstatusevents\\ElementStatusEvents;\nuse putyourlightson\\elementstatusevents\\events\\StatusChangeEvent;\n\n// ...\n\nEvent::on(\n    ElementStatusEvents::class, \n    ElementStatusEvents::EVENT_STATUS_CHANGED, \n    function(StatusChangeEvent $event) {\n        $oldStatus   = $event-\u003estatusBeforeSave;\n        $newStatus   = $event-\u003eelement-\u003egetStatus();\n        $isLive      = $event-\u003echangedToPublished();\n        $isDeath     = $event-\u003echangedToUnpublished();\n        $isScheduled = $event-\u003echangedTo('pending');\n    }\n);\n```\n\n\n## License\n\nThis extension is licensed for free under the MIT License.\n\n\u003csmall\u003eCreated by [PutYourLightsOn](https://putyourlightson.com/) in cooperation with [Oliver Stark](https://github.com/ostark)\u003c/small\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fputyourlightson%2Fcraft-element-status-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fputyourlightson%2Fcraft-element-status-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fputyourlightson%2Fcraft-element-status-events/lists"}