If you use Doctrine and want to copy an entity, you will need to use the DoctrineCollectionFilter: use DeepCopy\ DeepCopy $copier-> addFilter( new ChainableFilter( new DoctrineProxyFilter()), new DoctrineProxyMatcher()) Įcho $copy-> id // null DoctrineCollectionFilter (filter) Use DeepCopy\ Matcher\ Doctrine\ DoctrineProxyMatcher Use DeepCopy\ Filter\ Doctrine\ DoctrineProxyFilter You can use the ChainableFilter as a decorator of the proxy loader filter, which won't stop the chain of filters (i.e. If you use cloning on proxy classes, you might want to apply two filters for: $copy->category has not been touched ChainableFilter (filter) $copier-> addFilter( new KeepFilter(), new PropertyMatcher( 'M圜lass', 'category')) If you want a property to remain untouched (for example, an association to an object): use DeepCopy\ DeepCopy $copier-> addFilter( new SetNullFilter(), new PropertyNameMatcher( 'id')) Įcho $copy-> id // null KeepFilter (filter) Use DeepCopy\ Matcher\ PropertyNameMatcher Įcho $object-> id // 123 $copier = new DeepCopy() Let's say for example that you are copying a database record (or a Doctrine entity), so you want the copy not to have Using the ( ChainableFilter) won't stop the chain of filters.
0 Comments
Leave a Reply. |