本文整理匯總了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;
}
}
示例2: testNewReflectionClass
/**
* @dataProvider dataGetClass
*/
public function testNewReflectionClass($className, $expectedClassName)
{
$reflClass = ClassUtils::newReflectionClass($className);
$this->assertEquals($expectedClassName, $reflClass->getName());
}