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


PHP ClassUtils::newReflectionClass方法代码示例

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


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

示例1: onPreSerialize

 /**
  * On pre serialize
  *
  * @param ObjectEvent $event Event
  */
 public function onPreSerialize(ObjectEvent $event)
 {
     $object = $event->getObject();
     if ($object instanceof Proxy && !$object->__isInitialized()) {
         $object->__load();
     }
     $objectUid = spl_object_hash($object);
     if (in_array($objectUid, $this->serializedObjects)) {
         return;
     }
     $classAnnotation = $this->annotationReader->getClassAnnotation(new \ReflectionClass(ClassUtils::getClass($object)), VichSerializableClass::class);
     if ($classAnnotation instanceof VichSerializableClass) {
         $reflectionClass = ClassUtils::newReflectionClass(get_class($object));
         $this->logger->debug(sprintf('Found @VichSerializableClass annotation for the class "%s"', $reflectionClass->getName()));
         foreach ($reflectionClass->getProperties() as $property) {
             $vichSerializableAnnotation = $this->annotationReader->getPropertyAnnotation($property, VichSerializableField::class);
             if ($vichSerializableAnnotation instanceof VichSerializableField) {
                 $vichUploadableFileAnnotation = $this->annotationReader->getPropertyAnnotation($property, UploadableField::class);
                 if ($vichUploadableFileAnnotation instanceof UploadableField) {
                     throw new IncompatibleUploadableAndSerializableFieldAnnotationException(sprintf('The field "%s" in the class "%s" cannot have @UploadableField and @VichSerializableField annotations at the same moment.', $property->getName(), $reflectionClass->getName()));
                 }
                 $this->logger->debug(sprintf('Found @VichSerializableField annotation for the field "%s" in the class "%s"', $property->getName(), $reflectionClass->getName()));
                 $uri = null;
                 $property->setAccessible(true);
                 if ($property->getValue($event->getObject())) {
                     $uri = $this->storage->resolveUri($object, $vichSerializableAnnotation->getField());
                     if ($vichSerializableAnnotation->isIncludeHost()) {
                         $uri = $this->getHostUrl() . $uri;
                     }
                 }
                 $property->setValue($object, $uri);
             }
         }
         $this->serializedObjects[$objectUid] = $objectUid;
     }
 }
开发者ID:Bukashk0zzz,项目名称:VichUploaderSerializationBundle,代码行数:41,代码来源:JmsPreSerializeListener.php

示例2: testNewReflectionClass

 /**
  * @dataProvider dataGetClass
  */
 public function testNewReflectionClass($className, $expectedClassName)
 {
     $reflClass = ClassUtils::newReflectionClass($className);
     $this->assertEquals($expectedClassName, $reflClass->getName());
 }
开发者ID:manhvu1212,项目名称:videoplatform,代码行数:8,代码来源:ClassUtilsTest.php


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