本文整理汇总了PHP中Oro\Bundle\EntityBundle\ORM\DoctrineHelper::getEntityMetadata方法的典型用法代码示例。如果您正苦于以下问题:PHP DoctrineHelper::getEntityMetadata方法的具体用法?PHP DoctrineHelper::getEntityMetadata怎么用?PHP DoctrineHelper::getEntityMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EntityBundle\ORM\DoctrineHelper
的用法示例。
在下文中一共展示了DoctrineHelper::getEntityMetadata方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDirection
/**
* {@inheritdoc}
*/
public function getDirection($activity, $target)
{
//check if target is entity created from admin part
if (!$target instanceof EmailHolderInterface) {
$metadata = $this->doctrineHelper->getEntityMetadata($target);
$columns = $metadata->getColumnNames();
$className = get_class($target);
foreach ($columns as $column) {
//check only columns with 'contact_information'
if ($this->isEmailType($className, $column)) {
$getMethodName = "get" . Inflector::classify($column);
/** @var $activity Email */
if ($activity->getFromEmailAddress()->getEmail() === $target->{$getMethodName}()) {
return DirectionProviderInterface::DIRECTION_OUTGOING;
} else {
foreach ($activity->getTo() as $recipient) {
if ($recipient->getEmailAddress()->getEmail() === $target->{$getMethodName}()) {
return DirectionProviderInterface::DIRECTION_INCOMING;
}
}
}
}
}
return DirectionProviderInterface::DIRECTION_UNKNOWN;
}
/** @var $activity Email */
/** @var $target EmailHolderInterface */
if ($activity->getFromEmailAddress()->getEmail() === $target->getEmail()) {
return DirectionProviderInterface::DIRECTION_OUTGOING;
}
return DirectionProviderInterface::DIRECTION_INCOMING;
}
示例2: getEntityName
/**
* @param DatagridInterface $dataGrid
* @return string
*/
protected function getEntityName(DatagridInterface $dataGrid)
{
/** @var OrmDatasource $dataSource */
$dataSource = $dataGrid->getDatasource();
$queryBuilder = $dataSource->getQueryBuilder();
$entityName = $queryBuilder->getRootEntities()[0];
return $this->doctrineHelper->getEntityMetadata($entityName)->getName();
}
示例3: getEntityContactInformationColumns
/**
* Get entity contact information fields.
*
* @param string|object $entity
* @return array
*/
public function getEntityContactInformationColumns($entity)
{
$metadata = $this->doctrineHelper->getEntityMetadata($entity);
$columns = $metadata->getColumnNames();
$contactInformationColumns = array();
foreach ($columns as $column) {
if ($type = $this->getContactInformationFieldType($entity, $column)) {
$contactInformationColumns[$column] = $type;
}
}
return array_merge($contactInformationColumns, $this->getEntityLevelContactInfoColumns($entity));
}
示例4: getMetadata
/**
* @return ClassMetadata
*/
protected function getMetadata()
{
if (!$this->metadata) {
$this->metadata = $this->doctrineHelper->getEntityMetadata(self::CALENDAR_PROPERTY_CLASS);
}
return $this->metadata;
}
示例5: testGetEntityMetadataNotManageableEntity
public function testGetEntityMetadataNotManageableEntity()
{
$class = 'ItemStubProxy';
$this->setExpectedException('Oro\\Bundle\\EntityBundle\\Exception\\NotManageableEntityException', sprintf('Entity class "%s" is not manageable', $class));
$this->registry->expects($this->once())->method('getManagerForClass')->with($class)->will($this->returnValue(null));
$this->doctrineHelper->getEntityMetadata($class);
}
示例6: postSubmit
/**
* @param FormEvent $event
*/
public function postSubmit(FormEvent $event)
{
$form = $event->getForm();
$added = $form->get('added')->getData();
$removed = $form->get('removed')->getData();
$parentData = $form->getParent()->getData();
/** @var ClassMetadata $parentMetadata */
$parentMetadata = $this->doctrineHelper->getEntityMetadata(ClassUtils::getClass($parentData));
/** @var Collection $collection */
$collection = $form->getData();
foreach ($added as $relation) {
$this->processRelation($parentMetadata, $relation, $parentData);
$collection->add($relation);
}
foreach ($removed as $relation) {
$this->processRelation($parentMetadata, $relation, null);
$collection->removeElement($relation);
}
}
示例7: addRFMTypes
/**
* @param FormInterface $form
* @param array $categories
*/
protected function addRFMTypes(FormInterface $form, array $categories)
{
foreach (RFMMetricCategory::$types as $type) {
$typeCategories = array_filter($categories, function (RFMMetricCategory $category) use($type) {
return $category->getCategoryType() === $type;
});
$collection = new PersistentCollection($this->doctrineHelper->getEntityManager($this->rfmCategoryClass), $this->doctrineHelper->getEntityMetadata($this->rfmCategoryClass), new ArrayCollection($typeCategories));
$collection->takeSnapshot();
$constraint = new CategoriesConstraint();
$constraint->setType($type);
$form->add($type, RFMCategorySettingsType::NAME, [RFMCategorySettingsType::TYPE_OPTION => $type, 'label' => sprintf('orocrm.analytics.form.%s.label', $type), 'tooltip' => sprintf('orocrm.analytics.%s.tooltip', $type), 'mapped' => false, 'required' => false, 'error_bubbling' => false, 'is_increasing' => $type === RFMMetricCategory::TYPE_RECENCY, 'constraints' => [$constraint], 'data' => $collection]);
}
}
示例8: fillEntityData
/**
* @param object $entity
* @param array $data
*/
protected function fillEntityData($entity, array $data = [])
{
if (!$data) {
return;
}
if (!$this->propertyAccessor) {
$this->propertyAccessor = PropertyAccess::createPropertyAccessor();
}
$metadata = $this->doctrineHelper->getEntityMetadata($entity);
foreach ($data as $property => $value) {
try {
if ($metadata->hasAssociation($property)) {
$value = $this->doctrineHelper->getEntityReference($metadata->getAssociationTargetClass($property), $value);
}
$this->propertyAccessor->setValue($entity, $property, $value);
} catch (NoSuchPropertyException $e) {
}
}
}
示例9: replaceActivityTargetWithPlainQuery
/**
* This method should be used for fast changing data in 'relation' tables, because
* it uses Plain SQL for updating data in tables.
* Currently there is no another way for updating big amount of data: with Doctrine way
* it takes a lot of time(because of big amount of operations with objects, event listeners etc.);
* with DQL currently it impossible to build query, because DQL works only with entities, but
* 'relation' tables are not entities. For example: there is 'relation'
* table 'oro_rel_c3990ba6b28b6f38c460bc' and it has activitylist_id and account_id columns,
* in fact to solve initial issue with big amount of data we need update only account_id column
* with new values.
*
* @param array $activityIds
* @param string $targetClass
* @param integer $oldTargetId
* @param integer $newTargetId
* @param null|string $activityClass
*
* @return $this
*
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\ORM\Mapping\MappingException
*/
public function replaceActivityTargetWithPlainQuery(array $activityIds, $targetClass, $oldTargetId, $newTargetId, $activityClass = null)
{
if (is_null($activityClass)) {
$associationName = $this->getActivityListAssociationName($targetClass);
$entityClass = ActivityList::ENTITY_NAME;
} else {
$associationName = $this->getActivityAssociationName($targetClass);
$entityClass = $activityClass;
}
$entityMetadata = $this->doctrineHelper->getEntityMetadata($entityClass);
if (!empty($activityIds) && $entityMetadata->hasAssociation($associationName)) {
$association = $entityMetadata->getAssociationMapping($associationName);
$tableName = $association['joinTable']['name'];
$activityField = current(array_keys($association['relationToSourceKeyColumns']));
$targetField = current(array_keys($association['relationToTargetKeyColumns']));
$where = "WHERE {$targetField} = :sourceEntityId AND {$activityField} IN(" . implode(',', $activityIds) . ")";
$dbConnection = $this->doctrineHelper->getEntityManager(ActivityList::ENTITY_NAME)->getConnection()->prepare("UPDATE {$tableName} SET {$targetField} = :masterEntityId {$where}");
$dbConnection->bindValue('masterEntityId', $newTargetId);
$dbConnection->bindValue('sourceEntityId', $oldTargetId);
$dbConnection->execute();
}
return $this;
}
示例10: getSupportedFields
/**
* @param string $className
*
* @return array
*/
protected function getSupportedFields($className)
{
$classMetadata = $this->doctrineHelper->getEntityMetadata($className);
return $classMetadata->fieldNames;
}
示例11: getEntityName
/**
* @param OrmDatasource $dataSource
* @return string
*/
protected function getEntityName(OrmDatasource $dataSource)
{
$queryBuilder = $dataSource->getQueryBuilder();
$entityName = $queryBuilder->getRootEntities()[0];
return $this->doctrineHelper->getEntityMetadata($entityName)->getName();
}
示例12: testGetEntityMetadataNotManageableEntity
/**
* @expectedException \Oro\Bundle\EntityBundle\Exception\NotManageableEntityException
* @expectedExceptionMessage Entity class "ItemStubProxy" is not manageable
*/
public function testGetEntityMetadataNotManageableEntity()
{
$class = 'ItemStubProxy';
$this->registry->expects($this->once())->method('getManagerForClass')->with($class)->will($this->returnValue(null));
$this->doctrineHelper->getEntityMetadata($class);
}
示例13: testGetEntityMetadataNotManageableEntityWithoutThrowException
public function testGetEntityMetadataNotManageableEntityWithoutThrowException()
{
$class = 'ItemStub';
$this->registry->expects($this->once())->method('getManagerForClass')->with($class)->will($this->returnValue(null));
$this->assertNull($this->doctrineHelper->getEntityMetadata($class, false));
}