{"id":17226854,"url":"https://github.com/dantleech/phpcr-decorator","last_synced_at":"2025-03-25T17:48:28.737Z","repository":{"id":20585183,"uuid":"23865827","full_name":"dantleech/phpcr-decorator","owner":"dantleech","description":"Decorator for PHPCR","archived":false,"fork":false,"pushed_at":"2014-09-10T19:34:49.000Z","size":208,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T15:44:29.005Z","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":"sailorproject/sailor","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dantleech.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}},"created_at":"2014-09-10T07:58:00.000Z","updated_at":"2014-09-10T08:01:39.000Z","dependencies_parsed_at":"2022-09-06T05:21:33.042Z","dependency_job_id":null,"html_url":"https://github.com/dantleech/phpcr-decorator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantleech%2Fphpcr-decorator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantleech%2Fphpcr-decorator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantleech%2Fphpcr-decorator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantleech%2Fphpcr-decorator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dantleech","download_url":"https://codeload.github.com/dantleech/phpcr-decorator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245515144,"owners_count":20628113,"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-10-15T04:17:24.721Z","updated_at":"2025-03-25T17:48:28.719Z","avatar_url":"https://github.com/dantleech.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"PHPCR Decorator\n===============\n\nProxy implementation of PHPCR which enables you to decorate (a.k.a wrap) all\nclasses returned by a PHPCR implementation.\n\nFor example, you can use this library to decorate all `NodeInterface` classes\nwith a custom class.\n\nThe library can be used as a basis for expanding the functionality of PHPCR\nin the application layer.\n\nFor example:\n\n- Using a custom class in place of the implementations default class\n- Map nodes to domain classes via. node types.\n- Add logging\n\nDecorating\n----------\n\nTo use this library you will need to manually instantiate one of the decorator\nobjects. It is recommended that you wrap the `Session` object.\n\nYou will also need to pass a decorator which will handle any further\ninstantiations that happen inside the object. For example, when you call\n`$session-\u003egetNode()` the DecoratorFactory will be called and the value it returns\nwill be the value returned from the decorator.\n\nFor the purpose of demonstration the `PassthruDecoratorFactory` will\nbe used, and it will transparently return the original node.\n\n````php\n    $decoratorFactory = new Sulu\\Component\\PhpcrDecorator\\PHPCR\\PassthruDecoratorFactory();\n    $originalSession = // original PHPCR session\n    $session = new Sulu\\Component\\PhpcrDecorator\\PHPCR\\Session(\n        $originalSession, $decoratorFactory\n    );\n\n    // will return the implementation node because we use the passthru factory\n    $session-\u003egetNode('/foo'); \n````\n\nSo, thats pretty pointless. But now we can create a custom decorator:\n\n````php\n\u003c?php\n\nclass CustomDecoratorFactory implements DecoratorFactoryInterface\n{\n    public function decorate($method, $object)\n    {\n        if ($object instanceof \\PHPCR\\NodeInterface) {\n            return new MyCustomNode($object, $this);\n        }\n\n        return $object;\n    }\n}\n````\n\nNow the above will always return the `MyCustomNode` class instead of an\nimplementation node. Note that we have injected the original node.\n\nThe `MyCustomNode` class would look something like:\n\n````php\n\u003c?php\n\nclass MyCustomNode extends Sulu\\Component\\PhpcrDecorator\\Node\n{\n    public function doSomethingCool()\n    {\n        return $this-\u003egetPropertyValue('some:cool:property');\n    }\n}\n````\n\nCode Generation\n---------------\n\nThe contents `lib/PHPCR` and `tests/PHPCR` were generated by the\n`/bin/generate.php` script. If you find a bug you will need to\nmodify this script.\n\nWhy not modify the implementations factory?\n-------------------------------------------\n\nIt is possible to achieve the benefits enabled in this library by\nsubstituting the Factory used by your implementation (i.e.\n`Jackalope\\Factory`). This, however, has a big drawback.\n\nThe drawback is that you are bound to a single implementation, by the\nfact that you have modified the factory of a single implementation and,\nmore importantly, by the fact that all of your custom classes will need\nto extend the implementations classes.\n\nSo with that in mind, using this library provides a perfect abstraction\nbetween the PHPCR implementation and your application.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantleech%2Fphpcr-decorator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdantleech%2Fphpcr-decorator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantleech%2Fphpcr-decorator/lists"}