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


PHP ClassUtils::getClass方法代码示例

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


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

示例1: getForm

 public function getForm(ResourceInterface $resource)
 {
     $resourceClassName = \Doctrine\Common\Util\ClassUtils::getClass($resource);
     $resourceParts = explode("\\", $resourceClassName);
     $resourceParts[count($resourceParts) - 2] = 'Form';
     $resourceParts[count($resourceParts) - 1] .= 'Type';
     $formType = implode("\\", $resourceParts);
     if (class_exists($formType)) {
         return $this->formFactory->create(new $formType(), $resource);
     }
     $options = array('data_class' => $resourceClassName);
     $builder = $this->formFactory->createBuilder('form', $resource, $options);
     $reflectionClass = new \ReflectionClass($resourceClassName);
     $annotationClass = 'uebb\\HateoasBundle\\Annotation\\FormField';
     foreach ($reflectionClass->getProperties() as $propertyReflection) {
         /**
          * @var \uebb\HateoasBundle\Annotation\FormField $annotation
          */
         $annotation = $this->annotationReader->getPropertyAnnotation($propertyReflection, $annotationClass);
         if ($annotation) {
             $builder->add($propertyReflection->getName(), $annotation->type, is_array($annotation->options) ? $annotation->options : array());
         }
     }
     $form = $builder->getForm();
     return $form;
 }
开发者ID:uebb,项目名称:hateoas-bundle,代码行数:26,代码来源:FormResolver.php

示例2: handleOnFlush

 /**
  * Handle onFlush event
  *
  * @param OnFlushEventArgs $event
  */
 public function handleOnFlush(OnFlushEventArgs $event)
 {
     $em = $event->getEntityManager();
     $uow = $em->getUnitOfWork();
     $newEntities = $uow->getScheduledEntityInsertions();
     foreach ($newEntities as $entity) {
         if ($entity instanceof Call) {
             $hasChanges = $this->activityManager->addActivityTarget($entity, $entity->getOwner());
             // recompute change set if needed
             if ($hasChanges) {
                 $uow->computeChangeSet($em->getClassMetadata(ClassUtils::getClass($entity)), $entity);
             }
         }
     }
     $changedEntities = $uow->getScheduledEntityUpdates();
     foreach ($changedEntities as $entity) {
         if ($entity instanceof Call) {
             $hasChanges = false;
             $changeSet = $uow->getEntityChangeSet($entity);
             foreach ($changeSet as $field => $values) {
                 if ($field === 'owner') {
                     list($oldValue, $newValue) = $values;
                     if ($oldValue !== $newValue) {
                         $hasChanges |= $this->activityManager->replaceActivityTarget($entity, $oldValue, $newValue);
                     }
                     break;
                 }
             }
             // recompute change set if needed
             if ($hasChanges) {
                 $uow->computeChangeSet($em->getClassMetadata(ClassUtils::getClass($entity)), $entity);
             }
         }
     }
 }
开发者ID:antrampa,项目名称:crm,代码行数:40,代码来源:CallActivityManager.php

示例3: transform

 /**
  * {@inheritdoc}
  */
 public function transform($value)
 {
     if (!$value) {
         return '';
     }
     if (is_array($value)) {
         $result = [];
         $user = $this->securityFacade->getToken()->getUser();
         foreach ($value as $target) {
             if (ClassUtils::getClass($user) === ClassUtils::getClass($target) && $user->getId() === $target->getId()) {
                 continue;
             }
             if ($fields = $this->mapper->getEntityMapParameter(ClassUtils::getClass($target), 'title_fields')) {
                 $text = [];
                 foreach ($fields as $field) {
                     $text[] = $this->mapper->getFieldValue($target, $field);
                 }
             } else {
                 $text = [(string) $target];
             }
             $text = implode(' ', $text);
             if ($label = $this->getClassLabel(ClassUtils::getClass($target))) {
                 $text .= ' (' . $label . ')';
             }
             $result[] = json_encode(['text' => $text, 'id' => json_encode(['entityClass' => ClassUtils::getClass($target), 'entityId' => $target->getId()])]);
         }
         $value = implode(';', $result);
     }
     return $value;
 }
开发者ID:northdakota,项目名称:platform,代码行数:33,代码来源:ContextsToViewTransformer.php

示例4: addOwnerField

 /**
  * Add owner field to forms
  *
  * @param BeforeFormRenderEvent $event
  */
 public function addOwnerField(BeforeFormRenderEvent $event)
 {
     $environment = $event->getTwigEnvironment();
     $data = $event->getFormData();
     $form = $event->getForm();
     $label = false;
     $entityProvider = $this->configManager->getProvider('entity');
     if (is_object($form->vars['value'])) {
         $className = ClassUtils::getClass($form->vars['value']);
         if (class_exists($className) && $entityProvider->hasConfig($className, 'owner')) {
             $config = $entityProvider->getConfig($className, 'owner');
             $label = $config->get('label');
         }
     }
     $ownerField = $environment->render("OroOrganizationBundle::owner.html.twig", array('form' => $form, 'label' => $label));
     /**
      * Setting owner field as first field in first data block
      */
     if (!empty($data['dataBlocks'])) {
         if (isset($data['dataBlocks'][0]['subblocks'])) {
             if (!isset($data['dataBlocks'][0]['subblocks'][0])) {
                 $data['dataBlocks'][0]['subblocks'][0] = ['data' => []];
             }
             array_unshift($data['dataBlocks'][0]['subblocks'][0]['data'], $ownerField);
         }
     }
     $event->setFormData($data);
 }
开发者ID:Maksold,项目名称:platform,代码行数:33,代码来源:FormListener.php

示例5: getActivityContext

 /**
  * Returns the context for the given activity class and id
  *
  * @param string $class The FQCN of the activity entity
  * @param        $id
  *
  * @return array
  */
 public function getActivityContext($class, $id)
 {
     $currentUser = $this->securityTokenStorage->getToken()->getUser();
     $userClass = ClassUtils::getClass($currentUser);
     $entity = $this->doctrineHelper->getEntity($class, $id);
     $result = [];
     if (!$entity || !$entity instanceof ActivityInterface) {
         return $result;
     }
     $targets = $entity->getActivityTargetEntities();
     $entityProvider = $this->configManager->getProvider('entity');
     foreach ($targets as $target) {
         $targetClass = ClassUtils::getClass($target);
         $targetId = $target->getId();
         if ($userClass === $targetClass && $currentUser->getId() === $targetId) {
             continue;
         }
         $item = [];
         $config = $entityProvider->getConfig($targetClass);
         $safeClassName = $this->entityClassNameHelper->getUrlSafeClassName($targetClass);
         $item = $this->prepareItemTitle($item, $targetClass, $target, $targetId);
         $item['activityClassAlias'] = $this->entityAliasResolver->getPluralAlias($class);
         $item['entityId'] = $id;
         $item['targetId'] = $targetId;
         $item['targetClassName'] = $safeClassName;
         $item['icon'] = $config->get('icon');
         $item['link'] = $this->getContextLink($targetClass, $targetId);
         $item = $this->dispatchContextTitle($item, $targetClass);
         $result[] = $item;
     }
     return $result;
 }
开发者ID:woei66,项目名称:platform,代码行数:40,代码来源:ActivityContextApiEntityManager.php

示例6: invalidateProcess

 /**
  * @param $entity
  */
 public function invalidateProcess($entity)
 {
     $handler = $this->getHandlerByClass(ClassUtils::getClass($entity));
     if ($handler) {
         $handler->invalidateProcess($entity);
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:10,代码来源:EntityApiHandlerProcessor.php

示例7: isEntity

 /**
  * Check object status is enity
  *
  * @param object|string $entity
  * @return bool
  */
 protected function isEntity($entity)
 {
     if (is_object($entity)) {
         $entity = ClassUtils::getClass($entity);
     }
     return !$this->entityManager->getMetadataFactory()->isTransient($entity);
 }
开发者ID:pecinaon,项目名称:doctrine-mapper,代码行数:13,代码来源:BaseMapper.php

示例8: onFlush

 /**
  * Collect changes that were done
  * Generates tags and store in protected variable
  *
  * @param OnFlushEventArgs $event
  */
 public function onFlush(OnFlushEventArgs $event)
 {
     if (!$this->isApplicationInstalled) {
         return;
     }
     $em = $event->getEntityManager();
     $uow = $em->getUnitOfWork();
     $entities = array_merge($uow->getScheduledEntityDeletions(), $uow->getScheduledEntityInsertions(), $uow->getScheduledEntityUpdates());
     $collections = array_merge($uow->getScheduledCollectionUpdates(), $uow->getScheduledCollectionDeletions());
     foreach ($collections as $collection) {
         $owner = $collection->getOwner();
         if (!in_array($owner, $entities, true)) {
             $entities[] = $owner;
         }
     }
     $generator = $this->sender->getGenerator();
     foreach ($entities as $entity) {
         if (!in_array(ClassUtils::getClass($entity), $this->skipTrackingFor)) {
             // invalidate collection view pages only when entity has been added or removed
             $includeCollectionTag = $uow->isScheduledForInsert($entity) || $uow->isScheduledForDelete($entity);
             $this->collectedTags = array_merge($this->collectedTags, $generator->generate($entity, $includeCollectionTag));
         }
     }
     $this->collectedTags = array_unique($this->collectedTags);
 }
开发者ID:xamin123,项目名称:platform,代码行数:31,代码来源:DoctrineTagEventListener.php

示例9: onFlush

 /**
  * @param OnFlushEventArgs $args
  */
 public function onFlush(OnFlushEventArgs $args)
 {
     $this->initializeFromEventArgs($args);
     $entities = array_merge($this->uow->getScheduledEntityInsertions(), $this->uow->getScheduledEntityDeletions(), $this->uow->getScheduledEntityUpdates());
     /** @var Opportunity[] $entities */
     $entities = array_filter($entities, function ($entity) {
         return 'OroCRM\\Bundle\\SalesBundle\\Entity\\Opportunity' === ClassUtils::getClass($entity);
     });
     foreach ($entities as $entity) {
         if (!$entity->getId() && $this->isValuable($entity)) {
             // handle creation, just add to prev lifetime value and recalculate change set
             $b2bCustomer = $entity->getCustomer();
             $b2bCustomer->setLifetime($b2bCustomer->getLifetime() + $entity->getCloseRevenue());
             $this->scheduleUpdate($b2bCustomer);
             $this->uow->computeChangeSet($this->em->getClassMetadata(ClassUtils::getClass($b2bCustomer)), $b2bCustomer);
         } elseif ($this->uow->isScheduledForDelete($entity) && $this->isValuable($entity)) {
             $this->scheduleUpdate($entity->getCustomer());
         } elseif ($this->uow->isScheduledForUpdate($entity)) {
             // handle update
             $changeSet = $this->uow->getEntityChangeSet($entity);
             if ($this->isChangeSetValuable($changeSet)) {
                 if (!empty($changeSet['customer']) && $changeSet['customer'][0] instanceof B2bCustomer && B2bCustomerRepository::VALUABLE_STATUS === $this->getOldStatus($entity, $changeSet)) {
                     // handle change of b2b customer
                     $this->scheduleUpdate($changeSet['customer'][0]);
                 }
                 if ($this->isValuable($entity, isset($changeSet['closeRevenue'])) || B2bCustomerRepository::VALUABLE_STATUS === $this->getOldStatus($entity, $changeSet) && $entity->getCustomer()) {
                     $this->scheduleUpdate($entity->getCustomer());
                 }
             }
         }
     }
 }
开发者ID:antrampa,项目名称:crm,代码行数:35,代码来源:B2bCustomerLifetimeListener.php

示例10: isApplicable

 /**
  * Checks if the entity can have comments
  *
  * @param object|null $entity
  *
  * @return bool
  */
 public function isApplicable($entity)
 {
     if (!is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || !$this->securityFacade->isGranted('oro_comment_view')) {
         return false;
     }
     return $this->commentAssociationHelper->isCommentAssociationEnabled(ClassUtils::getClass($entity));
 }
开发者ID:olegpopadko,项目名称:platform,代码行数:14,代码来源:CommentPlaceholderFilter.php

示例11: name

 /**
  * {@inheritdoc}
  */
 public function name($objectOrClass)
 {
     $class = is_object($objectOrClass) ? ClassUtils::getClass($objectOrClass) : $objectOrClass;
     if (!isset($this->names[$class])) {
         $nsParts = array_map(function ($nsPart) {
             return explode('_', StringsUtil::toUnderscore($nsPart));
         }, explode('\\', $class));
         $offset = array_search(['entity'], $nsParts);
         if ($offset) {
             $nsParts = array_slice($nsParts, $offset + 1);
         }
         $nsPartsCount = count($nsParts);
         for ($i = 0; $i < $nsPartsCount - 1; $i++) {
             if (array_intersect($nsParts[$i], $nsParts[$i + 1]) === $nsParts[$i]) {
                 unset($nsParts[$i]);
             }
         }
         $parts = [];
         foreach ($nsParts as $nsPart) {
             $parts = array_merge($parts, $nsPart);
         }
         $this->names[$class] = implode('_', $parts);
     }
     return $this->names[$class];
 }
开发者ID:darvinstudio,项目名称:darvin-utils,代码行数:28,代码来源:ObjectNamer.php

示例12: getSnapshotDeleteQueryBuilderByEntities

 /**
  * Returns DELETE query builder with conditions for deleting from snapshot table by entity
  *
  * @param array $entities
  * @throws \InvalidArgumentException
  * @return QueryBuilder|null
  */
 protected function getSnapshotDeleteQueryBuilderByEntities(array $entities)
 {
     if (empty($entities)) {
         throw new \InvalidArgumentException('List of entity can not be empty');
     }
     $deleteParams = array();
     $entityManager = $this->getEntityManager();
     $segmentQB = $entityManager->createQueryBuilder();
     $segmentQB->select('s.id, s.entity')->from('OroSegmentBundle:Segment', 's');
     foreach ($entities as $key => $entity) {
         if (is_array($entity) && array_key_exists('id', $entity)) {
             $entityId = $entity['id'];
             $className = ClassUtils::getClass($entity['entity']);
         } else {
             /** @var object $entity */
             $className = ClassUtils::getClass($entity);
             $metadata = $entityManager->getClassMetadata($className);
             $entityIds = $metadata->getIdentifierValues($entity);
             $entityId = reset($entityIds);
         }
         if (!$entityId) {
             continue;
         }
         if (!isset($deleteParams[$className])) {
             $segmentQB->orWhere('s.entity = :className' . $key)->setParameter('className' . $key, $className);
         }
         $deleteParams[$className]['entityIds'][] = (string) $entityId;
     }
     $segments = $segmentQB->getQuery()->getResult();
     foreach ($segments as $segment) {
         $deleteParams[$segment['entity']]['segmentIds'][] = (string) $segment['id'];
     }
     return $this->getDeleteQueryBuilderByParameters($deleteParams);
 }
开发者ID:xamin123,项目名称:platform,代码行数:41,代码来源:SegmentSnapshotRepository.php

示例13: buildCacheEntry

 /**
  * {@inheritdoc}
  */
 public function buildCacheEntry(ClassMetadata $metadata, EntityCacheKey $key, $entity)
 {
     $data = $this->uow->getOriginalEntityData($entity);
     $data = array_merge($data, $key->identifier);
     // why update has no identifier values ?
     foreach ($metadata->associationMappings as $name => $assoc) {
         if (!isset($data[$name])) {
             continue;
         }
         if (!isset($assoc['cache']) || !($assoc['type'] & ClassMetadata::TO_ONE)) {
             unset($data[$name]);
             continue;
         }
         if (!isset($assoc['id'])) {
             $targetClass = ClassUtils::getClass($data[$name]);
             $targetId = $this->uow->getEntityIdentifier($data[$name]);
             $data[$name] = new AssociationCacheEntry($targetClass, $targetId);
             continue;
         }
         // handle association identifier
         $targetId = is_object($data[$name]) && $this->uow->isInIdentityMap($data[$name]) ? $this->uow->getEntityIdentifier($data[$name]) : $data[$name];
         // @TODO - fix it !
         // handle UnitOfWork#createEntity hash generation
         if (!is_array($targetId)) {
             $data[reset($assoc['joinColumnFieldNames'])] = $targetId;
             $targetEntity = $this->em->getClassMetadata($assoc['targetEntity']);
             $targetId = array($targetEntity->identifier[0] => $targetId);
         }
         $data[$name] = new AssociationCacheEntry($assoc['targetEntity'], $targetId);
     }
     return new EntityCacheEntry($metadata->name, $data);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:35,代码来源:DefaultEntityHydrator.php

示例14: setDefaults

 /**
  * {@inheritdoc}
  */
 public function setDefaults(MediaInterface $media, $parentPath = null)
 {
     $class = ClassUtils::getClass($media);
     // check and add name if possible
     if (!$media->getName()) {
         if ($media->getId()) {
             $media->setName(PathHelper::getNodeName($media->getId()));
         } else {
             throw new \RuntimeException(sprintf('Unable to set defaults, Media of type "%s" does not have a name or id.', $class));
         }
     }
     $rootPath = is_null($parentPath) ? $this->rootPath : $parentPath;
     $path = ($rootPath === '/' ? $rootPath : $rootPath . '/') . $media->getName();
     /** @var DocumentManager $dm */
     $dm = $this->getObjectManager();
     // TODO use PHPCR autoname once this is done: http://www.doctrine-project.org/jira/browse/PHPCR-103
     if ($dm->find($class, $path)) {
         // path already exists
         $media->setName($media->getName() . '_' . time() . '_' . rand());
     }
     if (!$media->getParent()) {
         $parent = $dm->find(null, PathHelper::getParentPath($path));
         $media->setParent($parent);
     }
 }
开发者ID:vespolina,项目名称:media,代码行数:28,代码来源:MediaManager.php

示例15: save

 /**
  * {@inheritdoc}
  */
 public function save($group, array $options = [])
 {
     /* @var GroupInterface */
     if (!$group instanceof GroupInterface) {
         throw new \InvalidArgumentException(sprintf('Expects a "Pim\\Bundle\\CatalogBundle\\Model\\GroupInterface", "%s" provided.', ClassUtils::getClass($group)));
     }
     $this->eventDispatcher->dispatch(GroupEvents::PRE_SAVE, new GenericEvent($group));
     $options = $this->optionsResolver->resolveSaveOptions($options);
     $this->versionContext->addContextInfo(sprintf('Comes from variant group %s', $group->getCode()), $this->productClassName);
     if ($group->getType()->isVariant()) {
         $template = $group->getProductTemplate();
         if (null !== $template) {
             $this->templateMediaManager->handleProductTemplateMedia($template);
         }
     }
     $this->objectManager->persist($group);
     if (true === $options['flush']) {
         $this->objectManager->flush();
     }
     if (count($options['add_products']) > 0) {
         $this->addProducts($options['add_products']);
     }
     if (count($options['remove_products']) > 0) {
         $this->removeProducts($options['remove_products']);
     }
     if ($group->getType()->isVariant() && true === $options['copy_values_to_products']) {
         $this->copyVariantGroupValues($group);
     }
     $this->eventDispatcher->dispatch(GroupEvents::POST_SAVE, new GenericEvent($group));
 }
开发者ID:umpirsky,项目名称:pim-community-dev,代码行数:33,代码来源:GroupSaver.php


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