本文整理汇总了PHP中Oro\Bundle\EntityBundle\ORM\DoctrineHelper::getEntityClass方法的典型用法代码示例。如果您正苦于以下问题:PHP DoctrineHelper::getEntityClass方法的具体用法?PHP DoctrineHelper::getEntityClass怎么用?PHP DoctrineHelper::getEntityClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EntityBundle\ORM\DoctrineHelper
的用法示例。
在下文中一共展示了DoctrineHelper::getEntityClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onFlush
/**
* Collect activities changes
*
* @param OnFlushEventArgs $args
*/
public function onFlush(OnFlushEventArgs $args)
{
$entitiesToDelete = $args->getEntityManager()->getUnitOfWork()->getScheduledEntityDeletions();
$entitiesToUpdate = $args->getEntityManager()->getUnitOfWork()->getScheduledEntityUpdates();
if (!empty($entitiesToDelete) || !empty($entitiesToUpdate)) {
foreach ($entitiesToDelete as $entity) {
$class = $this->doctrineHelper->getEntityClass($entity);
$id = $this->doctrineHelper->getSingleEntityIdentifier($entity);
$key = $class . '_' . $id;
if ($this->activityContactProvider->isSupportedEntity($class) && !isset($this->deletedEntities[$key])) {
$targets = $entity->getActivityTargetEntities();
$targetsInfo = [];
foreach ($targets as $target) {
$targetsInfo[] = ['class' => $this->doctrineHelper->getEntityClass($target), 'id' => $this->doctrineHelper->getSingleEntityIdentifier($target), 'direction' => $this->activityContactProvider->getActivityDirection($entity, $target)];
}
$this->deletedEntities[$key] = ['class' => $class, 'id' => $id, 'contactDate' => $this->activityContactProvider->getActivityDate($entity), 'targets' => $targetsInfo];
}
}
foreach ($entitiesToUpdate as $entity) {
$class = $this->doctrineHelper->getEntityClass($entity);
$id = $this->doctrineHelper->getSingleEntityIdentifier($entity);
$key = $class . '_' . $id;
if ($this->activityContactProvider->isSupportedEntity($class) && !isset($this->updatedEntities[$key])) {
$changes = $args->getEntityManager()->getUnitOfWork()->getEntityChangeSet($entity);
$isDirectionChanged = $this->activityContactProvider->getActivityDirectionProvider($entity)->isDirectionChanged($changes);
$targets = $entity->getActivityTargetEntities();
$targetsInfo = [];
foreach ($targets as $target) {
$targetsInfo[] = ['class' => $this->doctrineHelper->getEntityClass($target), 'id' => $this->doctrineHelper->getSingleEntityIdentifier($target), 'direction' => $this->activityContactProvider->getActivityDirection($entity, $target), 'is_direction_changed' => $isDirectionChanged];
}
$this->updatedEntities[$key] = ['class' => $class, 'id' => $id, 'contactDate' => $this->activityContactProvider->getActivityDate($entity), 'targets' => $targetsInfo];
}
}
}
}
示例2: validate
/**
* {@inheritdoc}
*/
public function validate($entity, Constraint $constraint)
{
$className = $this->doctrineHelper->getEntityClass($entity);
$organizationField = $this->metadataProvider->getMetadata($className)->getGlobalOwnerFieldName();
if ($organizationField) {
$constraint->fields = array_merge((array) $constraint->fields, [$organizationField]);
}
parent::validate($entity, $constraint);
}
示例3: isApplicable
/**
* Checks if the entity can have activities
*
* @param object|null $entity
* @return bool
*/
public function isApplicable($entity = null)
{
if (null === $entity || !is_object($entity)) {
return false;
}
$entityClass = $this->doctrineHelper->getEntityClass($entity);
$id = $this->doctrineHelper->getSingleEntityIdentifier($entity);
$activityListRepo = $this->doctrine->getRepository('OroActivityListBundle:ActivityList');
return in_array($entityClass, $this->activityListProvider->getTargetEntityClasses()) || (bool) $activityListRepo->getRecordsCountForTargetClassAndId($entityClass, $id);
}
示例4: collectDeletedEntities
/**
* We should collect here id's because after flush, object has no id
*
* @param $entities
*/
protected function collectDeletedEntities($entities)
{
if (!empty($entities)) {
foreach ($entities as $hash => $entity) {
if ($this->activityListManager->isSupportedEntity($entity) && empty($this->deletedEntities[$hash])) {
$this->deletedEntities[$hash] = ['class' => $this->doctrineHelper->getEntityClass($entity), 'id' => $this->doctrineHelper->getSingleEntityIdentifier($entity)];
}
}
}
}
示例5: isApplicable
/**
* Checks if the entity can have activities
*
* @param object|null $entity
* @param int|null $pageType
* @return bool
*/
public function isApplicable($entity = null, $pageType = null)
{
if ($pageType === null || !is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || $this->doctrineHelper->isNewEntity($entity)) {
return false;
}
$pageType = (int) $pageType;
$id = $this->doctrineHelper->getSingleEntityIdentifier($entity);
$entityClass = $this->doctrineHelper->getEntityClass($entity);
$activityListRepo = $this->doctrine->getRepository('OroActivityListBundle:ActivityList');
return $this->isAllowedOnPage($entity, $pageType) && (in_array($entityClass, $this->activityListProvider->getTargetEntityClasses()) || (bool) $activityListRepo->getRecordsCountForTargetClassAndId($entityClass, $id));
}
示例6: isConditionAllowed
/**
* Check ACL for resource.
*
* @param mixed $context
* @return boolean
*/
protected function isConditionAllowed($context)
{
$attributes = $this->contextAccessor->getValue($context, $this->attributes);
$objectOrClass = $this->contextAccessor->getValue($context, $this->objectOrClass);
if (is_object($objectOrClass)) {
$unitOfWork = $this->doctrineHelper->getEntityManager($objectOrClass)->getUnitOfWork();
if (!$unitOfWork->isInIdentityMap($objectOrClass) || $unitOfWork->isScheduledForInsert($objectOrClass)) {
$objectOrClass = 'Entity:' . $this->doctrineHelper->getEntityClass($objectOrClass);
}
}
return $this->securityFacade->isGranted($attributes, $objectOrClass);
}
示例7: getOrCreateFieldsChanges
/**
* @param object $entity
* @param bool $allowCreate
*
* @return FieldsChanges
*/
protected function getOrCreateFieldsChanges($entity, $allowCreate = true)
{
$className = $this->doctrineHelper->getEntityClass($entity);
$identifier = $this->doctrineHelper->getSingleEntityIdentifier($entity);
$em = $this->doctrineHelper->getEntityManager($this->className);
$fieldChanges = $em->getRepository($this->className)->findOneBy(['entityClass' => $className, 'entityId' => $identifier]);
if ($fieldChanges || !$fieldChanges && !$allowCreate) {
return $fieldChanges;
}
$fieldChanges = $this->doctrineHelper->createEntityInstance($this->className)->setEntityClass($className)->setEntityId($identifier);
$em->persist($fieldChanges);
return $fieldChanges;
}
示例8: doCompare
/**
* Compare two values for equality
*
* @param mixed $left
* @param mixed $right
* @return boolean
*/
protected function doCompare($left, $right)
{
if (is_object($left) && is_object($right)) {
$leftClass = $this->doctrineHelper->getEntityClass($left);
$rightClass = $this->doctrineHelper->getEntityClass($right);
if ($leftClass == $rightClass && $this->doctrineHelper->isManageableEntity($left) && $this->doctrineHelper->isManageableEntity($right)) {
$leftIdentifier = $this->doctrineHelper->getEntityIdentifier($left);
$rightIdentifier = $this->doctrineHelper->getEntityIdentifier($right);
return $leftIdentifier == $rightIdentifier;
}
}
return $left == $right;
}
示例9: isApplicable
/**
* {@inheritdoc}
*/
public function isApplicable($entity)
{
if (is_object($entity)) {
$entity = $this->doctrineHelper->getEntityClass($entity);
}
return $entity == self::ACTIVITY_CLASS;
}
开发者ID:rodolfobandeira,项目名称:training-crm-application,代码行数:10,代码来源:GitHubIssueActivityListProvider.php
示例10: getActivityListEntityForEntity
/**
* @param object $entity
* @param ActivityListProviderInterface $provider
* @param string $verb
* @param ActivityList|null $list
*
* @return ActivityList
*/
protected function getActivityListEntityForEntity($entity, ActivityListProviderInterface $provider, $verb = ActivityList::VERB_CREATE, $list = null)
{
if ($provider->isApplicable($entity)) {
if (!$list) {
$list = new ActivityList();
}
$list->setSubject($provider->getSubject($entity));
$list->setDescription($this->htmlTagHelper->stripTags($this->htmlTagHelper->purify($provider->getDescription($entity))));
$this->setDate($entity, $provider, $list);
if ($this->hasGrouping($provider)) {
$list->setHead($provider->isHead($entity));
}
$list->setVerb($verb);
if ($verb === ActivityList::VERB_UPDATE) {
$activityListTargets = $list->getActivityListTargetEntities();
foreach ($activityListTargets as $target) {
$list->removeActivityListTarget($target);
}
} else {
$className = $this->doctrineHelper->getEntityClass($entity);
$list->setRelatedActivityClass($className);
$list->setRelatedActivityId($this->doctrineHelper->getSingleEntityIdentifier($entity));
$list->setOrganization($provider->getOrganization($entity));
}
$targets = $provider->getTargetEntities($entity);
foreach ($targets as $target) {
if ($list->supportActivityListTarget($this->doctrineHelper->getEntityClass($target))) {
$list->addActivityListTarget($target);
}
}
return $list;
}
return null;
}
示例11: getWorkflowItemByEntity
/**
* @param object $entity
* @return WorkflowItem|null
*/
public function getWorkflowItemByEntity($entity)
{
$entityClass = $this->doctrineHelper->getEntityClass($entity);
$entityIdentifier = $this->doctrineHelper->getSingleEntityIdentifier($entity);
if (false === filter_var($entityIdentifier, FILTER_VALIDATE_INT)) {
return null;
}
return $this->getWorkflowItemRepository()->findByEntityMetadata($entityClass, $entityIdentifier);
}
示例12: getEntityClass
/**
* @param object $object
* @return string
*/
protected function getEntityClass($object)
{
if ($object instanceof ObjectIdentityInterface) {
$class = $object->getType();
} else {
$class = $this->doctrineHelper->getEntityClass($object);
}
return ClassUtils::getRealClass($class);
}
示例13: isAllowedButton
/**
* @param BeforeGroupingChainWidgetEvent $event
*/
public function isAllowedButton(BeforeGroupingChainWidgetEvent $event)
{
$entity = $event->getEntity();
$pageType = $event->getPageType();
if ($pageType === null || !is_object($entity) || !$this->configManager->hasConfig($this->doctrineHelper->getEntityClass($entity)) || !$this->isAllowedOnPage($this->doctrineHelper->getEntityClass($entity), $pageType)) {
// Clear allowed widgets
$event->setWidgets([]);
}
}
示例14: testGetEntityRepositoryByEntity
public function testGetEntityRepositoryByEntity()
{
$entity = new ItemStubProxy();
$entityClass = $this->doctrineHelper->getEntityClass($entity);
$repo = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository');
$this->registry->expects($this->once())->method('getManagerForClass')->with($entityClass)->will($this->returnValue($this->em));
$this->em->expects($this->once())->method('getRepository')->with($entityClass)->will($this->returnValue($repo));
$this->assertSame($repo, $this->doctrineHelper->getEntityRepository($entity));
}
示例15: getEntityClass
/**
* @param object $object
* @return string
*/
protected function getEntityClass($object)
{
if ($object instanceof ObjectIdentityInterface) {
$class = $object->getType();
$delim = strpos($class, '@');
if ($delim) {
$class = ltrim(substr($class, $delim + 1), ' ');
}
} else {
$class = $this->doctrineHelper->getEntityClass($object);
}
return ClassUtils::getRealClass($class);
}