Esempio n. 1
0
 /**
  * @throws InvalidStateException
  */
 private function parseProperties()
 {
     $this->properties = [];
     $annotationTypes = ['property', 'property-read'];
     $columns = [];
     foreach ($this->getFamilyLine() as $member) {
         foreach ($annotationTypes as $annotationType) {
             foreach (AnnotationsParser::parseAnnotationValues($annotationType, $member->getDocComment()) as $definition) {
                 $property = PropertyFactory::createFromAnnotation($annotationType, $definition, $member, $this->mapper);
                 // collision check
                 $column = $property->getColumn();
                 if ($column !== null and $property->isWritable()) {
                     if (isset($columns[$column])) {
                         throw new InvalidStateException("Mapping collision in property '{$property->getName()}' (column '{$column}') in entity {$this->getName()}. Please fix mapping or make chosen properties read only (using property-read).");
                     }
                     $columns[$column] = true;
                 }
                 $this->properties[$property->getName()] = $property;
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * Gets name of (main) database table related to entity that repository can handle
  *
  * @return string
  * @throws InvalidStateException
  */
 protected function getTable()
 {
     if ($this->table === null) {
         if (!$this->tableAnnotationChecked) {
             $this->tableAnnotationChecked = true;
             $table = AnnotationsParser::parseSimpleAnnotationValue('table', $this->getDocComment());
             if ($table !== null) {
                 return $this->table = $table;
             }
         }
         $this->table = $this->mapper->getTableByRepositoryClass(get_called_class());
     }
     return $this->table;
 }