getPropertyNamesByTag() public method

If no properties were found, an empty array is returned.
public getPropertyNamesByTag ( string $className, string $tag ) : array
$className string Name of the class containing the properties
$tag string Tag to search for
return array An array of property names tagged by the tag
Beispiel #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 === []) {
         $joinColumns[] = ['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 = $this->getUnproxiedClassName($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('Persistence_Object_Identifier');
             } elseif (count($idProperties) === 1) {
                 $joinColumn['name'] = $joinColumn['name'] === null ? $joinColumnName : $joinColumn['name'];
                 $joinColumn['referencedColumnName'] = strtolower(current($idProperties));
             }
         }
     }
     return $joinColumns;
 }
 /**
  * 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 ObjectAccess::getProperty($object, $idPropertyName, true);
     } elseif (property_exists($object, 'Persistence_Object_Identifier')) {
         return ObjectAccess::getProperty($object, 'Persistence_Object_Identifier', true);
     }
     return null;
 }
 /**
  * Renders code to create identifier/type information from related entities in an object.
  * Used in sleep methods.
  *
  * @param Configuration $objectConfiguration
  * @return string
  */
 protected function buildSerializeRelatedEntitiesCode(Configuration $objectConfiguration)
 {
     $className = $objectConfiguration->getClassName();
     $code = '';
     if ($this->reflectionService->hasMethod($className, '__sleep') === false) {
         $transientProperties = $this->reflectionService->getPropertyNamesByAnnotation($className, Flow\Transient::class);
         $propertyVarTags = [];
         foreach ($this->reflectionService->getPropertyNamesByTag($className, 'var') as $propertyName) {
             $varTagValues = $this->reflectionService->getPropertyTagValues($className, $propertyName, 'var');
             $propertyVarTags[$propertyName] = isset($varTagValues[0]) ? $varTagValues[0] : null;
         }
         $code = "        \$this->Flow_Object_PropertiesToSerialize = array();\n\n        \$transientProperties = " . var_export($transientProperties, true) . ";\n        \$propertyVarTags = " . var_export($propertyVarTags, true) . ";\n        \$result = \$this->Flow_serializeRelatedEntities(\$transientProperties, \$propertyVarTags);\n";
     }
     return $code;
 }