@@ 106-129 (lines=24) @@ | ||
103 | /** |
|
104 | * {@inheritdoc} |
|
105 | */ |
|
106 | public function buildCachedEntityPersister( |
|
107 | EntityManagerInterface $em, |
|
108 | EntityPersister $persister, |
|
109 | ClassMetadata $metadata |
|
110 | ) |
|
111 | { |
|
112 | $cache = $metadata->getCache(); |
|
113 | $region = $this->getRegion($cache); |
|
114 | $usage = $cache->getUsage(); |
|
115 | ||
116 | switch ($usage) { |
|
117 | case CacheUsage::READ_ONLY: |
|
118 | return new ReadOnlyCachedEntityPersister($persister, $region, $em, $metadata); |
|
119 | ||
120 | case CacheUsage::READ_WRITE: |
|
121 | return new ReadWriteCachedEntityPersister($persister, $region, $em, $metadata); |
|
122 | ||
123 | case CacheUsage::NONSTRICT_READ_WRITE: |
|
124 | return new NonStrictReadWriteCachedEntityPersister($persister, $region, $em, $metadata); |
|
125 | ||
126 | default: |
|
127 | throw new \InvalidArgumentException(sprintf("Unrecognized access strategy type [%s]", $usage)); |
|
128 | } |
|
129 | } |
|
130 | ||
131 | /** |
|
132 | * {@inheritdoc} |
|
@@ 134-159 (lines=26) @@ | ||
131 | /** |
|
132 | * {@inheritdoc} |
|
133 | */ |
|
134 | public function buildCachedCollectionPersister( |
|
135 | EntityManagerInterface $em, |
|
136 | CollectionPersister $persister, |
|
137 | AssociationMetadata $association |
|
138 | ) |
|
139 | { |
|
140 | $cache = $association->getCache(); |
|
141 | $region = $this->getRegion($cache); |
|
142 | $usage = $cache->getUsage(); |
|
143 | ||
144 | switch ($usage) { |
|
145 | case CacheUsage::READ_ONLY: |
|
146 | return new ReadOnlyCachedCollectionPersister($persister, $region, $em, $association); |
|
147 | ||
148 | case CacheUsage::READ_WRITE: |
|
149 | return new ReadWriteCachedCollectionPersister($persister, $region, $em, $association); |
|
150 | ||
151 | case CacheUsage::NONSTRICT_READ_WRITE: |
|
152 | return new NonStrictReadWriteCachedCollectionPersister($persister, $region, $em, $association); |
|
153 | ||
154 | default: |
|
155 | throw new \InvalidArgumentException( |
|
156 | sprintf("Unrecognized access strategy type [%s]", $usage) |
|
157 | ); |
|
158 | } |
|
159 | } |
|
160 | ||
161 | /** |
|
162 | * {@inheritdoc} |