当前位置: 首页>>代码示例>>PHP>>正文


PHP ReflectionService::getPropertyNamesByTag方法代码示例

本文整理汇总了PHP中TYPO3\Flow\Reflection\ReflectionService::getPropertyNamesByTag方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionService::getPropertyNamesByTag方法的具体用法?PHP ReflectionService::getPropertyNamesByTag怎么用?PHP ReflectionService::getPropertyNamesByTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\Flow\Reflection\ReflectionService的用法示例。


在下文中一共展示了ReflectionService::getPropertyNamesByTag方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildJoinColumnsIfNeeded

 /**
  * 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 = $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;
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:36,代码来源:FlowAnnotationDriver.php

示例2: buildJoinColumnsIfNeeded

 /**
  * 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\Flow\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('Persistence_Object_Identifier');
             } elseif (count($idProperties) === 1) {
                 $joinColumn['name'] = $joinColumn['name'] === NULL ? $joinColumnName : $joinColumn['name'];
                 $joinColumn['referencedColumnName'] = strtolower(current($idProperties));
             }
         }
     }
     return $joinColumns;
 }
开发者ID:animaltool,项目名称:webinterface,代码行数:36,代码来源:FlowAnnotationDriver.php

示例3: getIdentifierByObject

 /**
  * 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\Flow\Reflection\ObjectAccess::getProperty($object, $idPropertyName, true);
     } elseif (property_exists($object, 'Persistence_Object_Identifier')) {
         return \TYPO3\Flow\Reflection\ObjectAccess::getProperty($object, 'Persistence_Object_Identifier', true);
     }
     return null;
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:28,代码来源:Session.php

示例4: buildSerializeRelatedEntitiesCode

 /**
  * 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, 'TYPO3\\Flow\\Annotations\\Transient');
         $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 = "\t\t\$this->Flow_Object_PropertiesToSerialize = array();\n\n\t\$transientProperties = " . var_export($transientProperties, true) . ";\n\t\$propertyVarTags = " . var_export($propertyVarTags, true) . ";\n\t\$reflectedClass = new \\ReflectionClass('" . $className . "');\n\t\$allReflectedProperties = \$reflectedClass->getProperties();\n\tforeach (\$allReflectedProperties as \$reflectionProperty) {\n\t\t\$propertyName = \$reflectionProperty->name;\n\t\tif (in_array(\$propertyName, array('Flow_Aop_Proxy_targetMethodsAndGroupedAdvices', 'Flow_Aop_Proxy_groupedAdviceChains', 'Flow_Aop_Proxy_methodIsInAdviceMode'))) continue;\n\t\tif (isset(\$this->Flow_Injected_Properties) && is_array(\$this->Flow_Injected_Properties) && in_array(\$propertyName, \$this->Flow_Injected_Properties)) continue;\n\t\tif (\$reflectionProperty->isStatic() || in_array(\$propertyName, \$transientProperties)) continue;\n\t\tif (is_array(\$this->\$propertyName) || (is_object(\$this->\$propertyName) && (\$this->\$propertyName instanceof \\ArrayObject || \$this->\$propertyName instanceof \\SplObjectStorage ||\$this->\$propertyName instanceof \\Doctrine\\Common\\Collections\\Collection))) {\n\t\t\tif (count(\$this->\$propertyName) > 0) {\n\t\t\t\tforeach (\$this->\$propertyName as \$key => \$value) {\n\t\t\t\t\t\$this->searchForEntitiesAndStoreIdentifierArray((string)\$key, \$value, \$propertyName);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (is_object(\$this->\$propertyName) && !\$this->\$propertyName instanceof \\Doctrine\\Common\\Collections\\Collection) {\n\t\t\tif (\$this->\$propertyName instanceof \\Doctrine\\ORM\\Proxy\\Proxy) {\n\t\t\t\t\$className = get_parent_class(\$this->\$propertyName);\n\t\t\t} else {\n\t\t\t\tif (isset(\$propertyVarTags[\$propertyName])) {\n\t\t\t\t\t\$className = trim(\$propertyVarTags[\$propertyName], '\\\\');\n\t\t\t\t}\n\t\t\t\tif (\\TYPO3\\Flow\\Core\\Bootstrap::\$staticObjectManager->isRegistered(\$className) === FALSE) {\n\t\t\t\t\t\$className = \\TYPO3\\Flow\\Core\\Bootstrap::\$staticObjectManager->getObjectNameByClassName(get_class(\$this->\$propertyName));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\$this->\$propertyName instanceof \\TYPO3\\Flow\\Persistence\\Aspect\\PersistenceMagicInterface && !\\TYPO3\\Flow\\Core\\Bootstrap::\$staticObjectManager->get(\\TYPO3\\Flow\\Persistence\\PersistenceManagerInterface::class)->isNewObject(\$this->\$propertyName) || \$this->\$propertyName instanceof \\Doctrine\\ORM\\Proxy\\Proxy) {\n\t\t\t\tif (!property_exists(\$this, 'Flow_Persistence_RelatedEntities') || !is_array(\$this->Flow_Persistence_RelatedEntities)) {\n\t\t\t\t\t\$this->Flow_Persistence_RelatedEntities = array();\n\t\t\t\t\t\$this->Flow_Object_PropertiesToSerialize[] = 'Flow_Persistence_RelatedEntities';\n\t\t\t\t}\n\t\t\t\t\$identifier = \\TYPO3\\Flow\\Core\\Bootstrap::\$staticObjectManager->get(\\TYPO3\\Flow\\Persistence\\PersistenceManagerInterface::class)->getIdentifierByObject(\$this->\$propertyName);\n\t\t\t\tif (!\$identifier && \$this->\$propertyName instanceof \\Doctrine\\ORM\\Proxy\\Proxy) {\n\t\t\t\t\t\$identifier = current(\\TYPO3\\Flow\\Reflection\\ObjectAccess::getProperty(\$this->\$propertyName, '_identifier', TRUE));\n\t\t\t\t}\n\t\t\t\t\$this->Flow_Persistence_RelatedEntities[\$propertyName] = array(\n\t\t\t\t\t'propertyName' => \$propertyName,\n\t\t\t\t\t'entityType' => \$className,\n\t\t\t\t\t'identifier' => \$identifier\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (\$className !== FALSE && (\\TYPO3\\Flow\\Core\\Bootstrap::\$staticObjectManager->getScope(\$className) === \\TYPO3\\Flow\\Object\\Configuration\\Configuration::SCOPE_SINGLETON || \$className === \\TYPO3\\Flow\\Object\\DependencyInjection\\DependencyProxy::class)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\t\$this->Flow_Object_PropertiesToSerialize[] = \$propertyName;\n\t}\n\t\$result = \$this->Flow_Object_PropertiesToSerialize;\n";
     }
     return $code;
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:22,代码来源:ProxyClassBuilder.php

示例5: buildSerializeRelatedEntitiesCode

 /**
  * 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, 'TYPO3\\Flow\\Annotations\\Transient');
         $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;
 }
开发者ID:RafaelKa,项目名称:flow-development-collection,代码行数:22,代码来源:ProxyClassBuilder.php


注:本文中的TYPO3\Flow\Reflection\ReflectionService::getPropertyNamesByTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。