kdyby / doctrine-collections-readonly
Read-only collection wrapper for easier work with Doctrine entity collections
Installs: 120 362
Dependents: 2
Suggesters: 5
Security: 0
Stars: 7
Watchers: 4
Forks: 4
Open Issues: 0
Requires
- php: ^5.6 || ^7.0
- doctrine/collections: ~1.1
Requires (Dev)
- nette/tester: ~1.7
This package is auto-updated.
Last update: 2024-10-22 03:50:56 UTC
README
This package provides an implementation of a readonly collection wrapper, so you can return collections from your entities, without having to copy the contents of the collection, or exposing the object's state outside of it's control.
Installation
The best way to install Kdyby/DoctrineCollectionsReadonly is using Composer:
$ composer require kdyby/doctrine-collections-readonly
Usage
Simply wrap your collection and return it.
public function getComments() : Collection { return new ReadOnlyCollectionWrapper($this->comments); }
Now you can use the Collection
api as you're used to, you just cannot modifying it :)
Homepage http://www.kdyby.org and repository http://github.com/Kdyby/DoctrineCollectionsReadonly.