| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * This file is part of the Sonata Project package. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * (c) Thomas Rabaix <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | namespace Sonata\DoctrineMongoDBAdminBundle\Model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Doctrine\ODM\MongoDB\Query\Builder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Sonata\AdminBundle\Admin\FieldDescriptionInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Sonata\AdminBundle\Datagrid\DatagridInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Sonata\AdminBundle\Datagrid\ProxyQueryInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Sonata\AdminBundle\Model\ModelManagerInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Sonata\DoctrineMongoDBAdminBundle\Admin\FieldDescription; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | use Sonata\DoctrineMongoDBAdminBundle\Datagrid\ProxyQuery; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | use Sonata\Exporter\Source\DoctrineODMQuerySourceIterator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | use Symfony\Bridge\Doctrine\ManagerRegistry; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | use Symfony\Component\Form\Exception\PropertyAccessDeniedException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | class ModelManager implements ModelManagerInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     public const ID_SEPARATOR = '-'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     protected $registry; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     public function __construct(ManagerRegistry $registry) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         $this->registry = $registry; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     public function getMetadata($class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         return $this->getDocumentManager($class)->getMetadataFactory()->getMetadataFor($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * Returns the model's metadata holding the fully qualified property, and the last | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * property name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      * @param string $baseClass        The base class of the model holding the fully qualified property | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      * @param string $propertyFullName The name of the fully qualified property (dot ('.') separated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      *                                 property string) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * @return array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      *                \Doctrine\ODM\MongoDB\Mapping\ClassMetadata $parentMetadata, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      *                string $lastPropertyName, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      *                array $parentAssociationMappings | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      *                ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     public function getParentMetadataForProperty($baseClass, $propertyFullName) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $nameElements = explode('.', $propertyFullName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $lastPropertyName = array_pop($nameElements); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $class = $baseClass; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $parentAssociationMappings = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         foreach ($nameElements as $nameElement) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |             $metadata = $this->getMetadata($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             $parentAssociationMappings[] = $metadata->associationMappings[$nameElement]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             $class = $metadata->getAssociationTargetClass($nameElement); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         return [$this->getMetadata($class), $lastPropertyName, $parentAssociationMappings]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     public function hasMetadata($class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         return $this->getDocumentManager($class)->getMetadataFactory()->hasMetadataFor($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     public function getNewFieldDescriptionInstance($class, $name, array $options = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         if (!\is_string($name)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             throw new \RunTimeException('The name argument must be a string'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         if (!isset($options['route']['name'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |             $options['route']['name'] = 'edit'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         if (!isset($options['route']['parameters'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |             $options['route']['parameters'] = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         list($metadata, $propertyName, $parentAssociationMappings) = $this->getParentMetadataForProperty($class, $name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         $fieldDescription = new FieldDescription(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         $fieldDescription->setName($name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         $fieldDescription->setOptions($options); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         $fieldDescription->setParentAssociationMappings($parentAssociationMappings); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         /* @var ClassMetadata */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         if (isset($metadata->associationMappings[$propertyName])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             $fieldDescription->setAssociationMapping($metadata->associationMappings[$propertyName]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         if (isset($metadata->fieldMappings[$propertyName])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |             $fieldDescription->setFieldMapping($metadata->fieldMappings[$propertyName]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         return $fieldDescription; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     public function create($object) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         $documentManager = $this->getDocumentManager($object); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         $documentManager->persist($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         $documentManager->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |     public function update($object) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |         $documentManager = $this->getDocumentManager($object); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |         $documentManager->persist($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         $documentManager->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     public function delete($object) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         $documentManager = $this->getDocumentManager($object); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |         $documentManager->remove($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         $documentManager->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     public function find($class, $id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         if (!isset($id)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |         $documentManager = $this->getDocumentManager($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         if (is_numeric($id)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |             $value = $documentManager->getRepository($class)->find((int) $id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |             if (!empty($value)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |                 return $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         return $documentManager->getRepository($class)->find($id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |     public function findBy($class, array $criteria = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         return $this->getDocumentManager($class)->getRepository($class)->findBy($criteria); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |     public function findOneBy($class, array $criteria = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         return $this->getDocumentManager($class)->getRepository($class)->findOneBy($criteria); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |      * @param string $class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |      * @throw \RuntimeException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |      * @return \Doctrine\ODM\MongoDB\DocumentManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |     public function getDocumentManager($class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         if (\is_object($class)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             $class = \get_class($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         $dm = $this->registry->getManagerForClass($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         if (!$dm) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |             throw new \RuntimeException(sprintf('No document manager defined for class %s', $class)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |         return $dm; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |     public function getParentFieldDescription($parentAssociationMapping, $class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |         $fieldName = $parentAssociationMapping['fieldName']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |         $metadata = $this->getMetadata($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |         $associatingMapping = $metadata->associationMappings[$parentAssociationMapping]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |         $fieldDescription = $this->getNewFieldDescriptionInstance($class, $fieldName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         $fieldDescription->setName($parentAssociationMapping); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         $fieldDescription->setAssociationMapping($associatingMapping); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |         return $fieldDescription; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |     public function createQuery($class, $alias = 'o') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |         $repository = $this->getDocumentManager($class)->getRepository($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |         return new ProxyQuery($repository->createQueryBuilder()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |     public function executeQuery($query) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |         if ($query instanceof Builder) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |             return $query->getQuery()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |         return $query->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |     public function getModelIdentifier($class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |         return $this->getMetadata($class)->identifier; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |     public function getIdentifierValues($document) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |         return [$this->getDocumentManager($document)->getUnitOfWork()->getDocumentIdentifier($document)]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |     public function getIdentifierFieldNames($class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |         return [$this->getMetadata($class)->getIdentifier()]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |     public function getNormalizedIdentifier($document) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         if (is_scalar($document)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |             throw new \RunTimeException('Invalid argument, object or null required'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |         // the document is not managed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |         if (!$document || !$this->getDocumentManager($document)->getUnitOfWork()->isInIdentityMap($document)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |         $values = $this->getIdentifierValues($document); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |         return implode(self::ID_SEPARATOR, $values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |     public function getUrlsafeIdentifier($entity) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |         return $this->getNormalizedIdentifier($entity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |     public function addIdentifiersToQuery($class, ProxyQueryInterface $queryProxy, array $idx) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |         $queryBuilder = $queryProxy->getQueryBuilder(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |         $queryBuilder->field('_id')->in($idx); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |     public function batchDelete($class, ProxyQueryInterface $queryProxy) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |         /** @var Query $queryBuilder */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |         $queryBuilder = $queryProxy->getQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |         $documentManager = $this->getDocumentManager($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |         $i = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |         foreach ($queryBuilder->execute() as $object) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |             $documentManager->remove($object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |             if (0 === (++$i % 20)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |                 $documentManager->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |                 $documentManager->clear(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |         $documentManager->flush(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |         $documentManager->clear(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |     public function getDataSourceIterator(DatagridInterface $datagrid, array $fields, $firstResult = null, $maxResult = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |         $datagrid->buildPager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |         $query = $datagrid->getQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |         $query->setFirstResult($firstResult); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |         $query->setMaxResults($maxResult); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |         return new DoctrineODMQuerySourceIterator($query instanceof ProxyQuery ? $query->getQuery() : $query, $fields); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |     public function getExportFields($class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |         $metadata = $this->getDocumentManager($class)->getClassMetadata($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |         return $metadata->getFieldNames(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |     public function getModelInstance($class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |         return new $class(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 367 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 368 |  |  |     public function getSortParameters(FieldDescriptionInterface $fieldDescription, DatagridInterface $datagrid) | 
            
                                                                        
                            
            
                                    
            
            
                | 369 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 370 |  |  |         $values = $datagrid->getValues(); | 
            
                                                                        
                            
            
                                    
            
            
                | 371 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 372 |  |  |         if (isset($values['_sort_by']) | 
            
                                                                        
                            
            
                                    
            
            
                | 373 |  |  |             && ($fieldDescription->getName() === $values['_sort_by']->getName() | 
            
                                                                        
                            
            
                                    
            
            
                | 374 |  |  |                 || $values['_sort_by']->getName() === $fieldDescription->getOption('sortable')) | 
            
                                                                        
                            
            
                                    
            
            
                | 375 |  |  |         ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 376 |  |  |             if ('ASC' === $values['_sort_order']) { | 
            
                                                                        
                            
            
                                    
            
            
                | 377 |  |  |                 $values['_sort_order'] = 'DESC'; | 
            
                                                                        
                            
            
                                    
            
            
                | 378 |  |  |             } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 379 |  |  |                 $values['_sort_order'] = 'ASC'; | 
            
                                                                        
                            
            
                                    
            
            
                | 380 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 381 |  |  |         } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 382 |  |  |             $values['_sort_order'] = 'ASC'; | 
            
                                                                        
                            
            
                                    
            
            
                | 383 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 384 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 385 |  |  |         $values['_sort_by'] = \is_string($fieldDescription->getOption('sortable')) ? $fieldDescription->getOption('sortable') : $fieldDescription->getName(); | 
            
                                                                        
                            
            
                                    
            
            
                | 386 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 387 |  |  |         return ['filter' => $values]; | 
            
                                                                        
                            
            
                                    
            
            
                | 388 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |     public function getPaginationParameters(DatagridInterface $datagrid, $page) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |         $values = $datagrid->getValues(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |         if (isset($values['_sort_by'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |             $values['_sort_by'] = $values['_sort_by']->getName(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |         $values['_page'] = $page; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |         return ['filter' => $values]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |     public function getDefaultSortValues($class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |             '_sort_order' => 'ASC', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |             '_sort_by' => $this->getModelIdentifier($class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |             '_page' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |             '_per_page' => 25, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |     public function modelTransform($class, $instance) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |         return $instance; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |     public function modelReverseTransform($class, array $array = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |         $instance = $this->getModelInstance($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |         $metadata = $this->getMetadata($class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |         $reflClass = $metadata->reflClass; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |         foreach ($array as $name => $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |             $reflection_property = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |             // property or association ? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |             if (\array_key_exists($name, $metadata->fieldMappings)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |                 $property = $metadata->fieldMappings[$name]['fieldName']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |                 $reflection_property = $metadata->reflFields[$name]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |             } elseif (\array_key_exists($name, $metadata->associationMappings)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |                 $property = $metadata->associationMappings[$name]['fieldName']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |                 $property = $name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |             $setter = 'set'.$this->camelize($name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |             if ($reflClass->hasMethod($setter)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |                 if (!$reflClass->getMethod($setter)->isPublic()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |                     throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $setter, $reflClass->getName())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |                 $instance->$setter($value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |             } elseif ($reflClass->hasMethod('__set')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |                 // needed to support magic method __set | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |                 $instance->$property = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |             } elseif ($reflClass->hasProperty($property)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |                 if (!$reflClass->getProperty($property)->isPublic()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |                     throw new PropertyAccessDeniedException(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "set%s()"?', $property, $reflClass->getName(), ucfirst($property))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |                 $instance->$property = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |             } elseif ($reflection_property) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |                 $reflection_property->setValue($instance, $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |         return $instance; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |     public function getModelCollectionInstance($class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |         return new \Doctrine\Common\Collections\ArrayCollection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |     public function collectionClear(&$collection) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |         return $collection->clear(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |     public function collectionHasElement(&$collection, &$element) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |         return $collection->contains($element); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |     public function collectionAddElement(&$collection, &$element) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |         return $collection->add($element); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |     public function collectionRemoveElement(&$collection, &$element) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |         return $collection->removeElement($element); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |      * method taken from PropertyPath. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |      * @param string $property | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |     protected function camelize($property) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |         return preg_replace(['/(^|_)+(.)/e', '/\.(.)/e'], ["strtoupper('\\2')", "'_'.strtoupper('\\1')"], $property); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 523 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 524 |  |  |  | 
            
                        
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.