/** * Checks if the entity can has notes * * @param object $entity * @return bool */ public function isNoteAssociationEnabled($entity) { if (!is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || $this->doctrineHelper->isNewEntity($entity)) { return false; } return $this->noteAssociationHelper->isNoteAssociationEnabled(ClassUtils::getClass($entity)); }
/** * Delegated method * * @param object $entity * @return bool */ public function isAttachmentAssociationEnabled($entity) { if (!is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || $this->doctrineHelper->isNewEntity($entity)) { return false; } return $this->config->isAttachmentAssociationEnabled($entity); }
/** * Checks if the entity can has notes * * @param object $entity * @return bool */ public function isNoteAssociationEnabled($entity) { if (!is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || $this->doctrineHelper->isNewEntity($entity)) { return false; } $className = ClassUtils::getClass($entity); return $this->noteConfigProvider->hasConfig($className) && $this->noteConfigProvider->getConfig($className)->is('enabled') && $this->entityConfigProvider->hasConfig(Note::ENTITY_NAME, ExtendHelper::buildAssociationName($className)); }
/** * 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)); }
/** * 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 (null === $pageType || !is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || $this->doctrineHelper->isNewEntity($entity)) { return false; } $entityClass = $this->doctrineHelper->getEntityClass($entity); if (isset($this->applicableCache[$entityClass])) { return $this->applicableCache[$entityClass]; } $result = false; if ($this->configManager->hasConfig($entityClass) && $this->isAllowedOnPage($entityClass, $pageType) && $this->hasApplicableActivityAssociations($entityClass)) { $result = in_array($entityClass, $this->activityListProvider->getTargetEntityClasses(), true) || !$this->isActivityListEmpty($entityClass, $this->doctrineHelper->getSingleEntityIdentifier($entity)); } $this->applicableCache[$entityClass] = $result; return $result; }
/** * * @param object $entity * @return bool */ public function isApplicable($entity) { if (!is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || $this->doctrineHelper->isNewEntity($entity)) { return false; } //$allowedValues = $this->configProvider->getAllowed(); $allowedSection = $this->getAllowedSection(); $className = ClassUtils::getClass($entity); $allowedSection = $allowedSection['allowed']; foreach ($allowedSection as $allowedValue) { if ($allowedValue == $className) { return true; } } //echo $className;die(); return false; }
/** * @param object $entity * @param string $class * @param array $identifiers * @param bool $expected * @dataProvider testIsNewEntityDataProvider */ public function testIsNewEntity($entity, $class, array $identifiers, $expected) { $this->classMetadata->expects($this->once())->method('getIdentifierValues')->with($entity)->will($this->returnCallback(function ($entity) use($identifiers) { $res = []; foreach ($identifiers as $identifier) { if (isset($entity->{$identifier})) { $res[$identifier] = $entity->{$identifier}; } } return $res; })); $this->em->expects($this->once())->method('getClassMetadata')->with($class)->will($this->returnValue($this->classMetadata)); $this->registry->expects($this->once())->method('getManagerForClass')->with($class)->will($this->returnValue($this->em)); $this->assertEquals($expected, $this->doctrineHelper->isNewEntity($entity)); }