예제 #1
0
 /**
  * Check if the referenced column name is set (and valid) and if not make sure
  * it is initialized properly.
  *
  * @param array $joinColumns
  * @param array $mapping
  * @param \ReflectionProperty $property
  * @param integer $direction regular or inverse mapping (use is to be coded)
  * @return array
  */
 protected function buildJoinColumnsIfNeeded(array $joinColumns, array $mapping, \ReflectionProperty $property, $direction = self::MAPPING_REGULAR)
 {
     if ($joinColumns === array()) {
         $joinColumns[] = array('name' => strtolower($property->getName()), 'referencedColumnName' => NULL);
     }
     foreach ($joinColumns as &$joinColumn) {
         if ($joinColumn['referencedColumnName'] === NULL || $joinColumn['referencedColumnName'] === 'id') {
             if ($direction === self::MAPPING_REGULAR) {
                 $idProperties = $this->reflectionService->getPropertyNamesByTag($mapping['targetEntity'], 'id');
                 $joinColumnName = $this->buildJoinTableColumnName($mapping['targetEntity']);
             } else {
                 $className = preg_replace('/' . \TYPO3\FLOW3\Object\Proxy\Compiler::ORIGINAL_CLASSNAME_SUFFIX . '$/', '', $property->getDeclaringClass()->getName());
                 $idProperties = $this->reflectionService->getPropertyNamesByTag($className, 'id');
                 $joinColumnName = $this->buildJoinTableColumnName($className);
             }
             if (count($idProperties) === 0) {
                 $joinColumn['name'] = $joinColumn['name'] === NULL ? $joinColumnName : $joinColumn['name'];
                 $joinColumn['referencedColumnName'] = strtolower('FLOW3_Persistence_Identifier');
             } elseif (count($idProperties) === 1) {
                 $joinColumn['name'] = $joinColumn['name'] === NULL ? $joinColumnName : $joinColumn['name'];
                 $joinColumn['referencedColumnName'] = strtolower(current($idProperties));
             }
         }
     }
     return $joinColumns;
 }
예제 #2
0
파일: Session.php 프로젝트: nxpthx/FLOW3
 /**
  * Returns the identifier for the given object either from
  * the session, if the object was registered, or from the object
  * itself using a special uuid property or the internal
  * properties set by AOP.
  *
  * Note: this returns an UUID even if the object has not been persisted
  * in case of AOP-managed entities. Use isNewObject() if you need
  * to distinguish those cases.
  *
  * @param object $object
  * @return string
  * @api
  */
 public function getIdentifierByObject($object)
 {
     if ($this->hasObject($object)) {
         return $this->objectMap[$object];
     }
     $idPropertyNames = $this->reflectionService->getPropertyNamesByTag(get_class($object), 'id');
     if (count($idPropertyNames) === 1) {
         $idPropertyName = $idPropertyNames[0];
         return \TYPO3\FLOW3\Reflection\ObjectAccess::getProperty($object, $idPropertyName, TRUE);
     } elseif (property_exists($object, 'FLOW3_Persistence_Identifier')) {
         return \TYPO3\FLOW3\Reflection\ObjectAccess::getProperty($object, 'FLOW3_Persistence_Identifier', TRUE);
     }
     return NULL;
 }