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


PHP Tools\ExtendHelper类代码示例

本文整理汇总了PHP中Oro\Bundle\EntityExtendBundle\Tools\ExtendHelper的典型用法代码示例。如果您正苦于以下问题:PHP ExtendHelper类的具体用法?PHP ExtendHelper怎么用?PHP ExtendHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getEntityAlias

 /**
  * {@inheritdoc}
  */
 public function getEntityAlias($entityClass)
 {
     if ($this->configManager->hasConfig($entityClass)) {
         // check for enums
         $enumCode = $this->configManager->getProvider('enum')->getConfig($entityClass)->get('code');
         if ($enumCode) {
             $entityAlias = $this->getEntityAliasFromConfig($entityClass);
             if (null !== $entityAlias) {
                 return $entityAlias;
             }
             return $this->createEntityAlias(str_replace('_', '', $enumCode));
         }
         // check for dictionaries
         $groups = $this->configManager->getProvider('grouping')->getConfig($entityClass)->get('groups');
         if (!empty($groups) && in_array(GroupingScope::GROUP_DICTIONARY, $groups, true)) {
             // delegate aliases generation to default provider
             return null;
         }
         // exclude hidden entities
         if ($this->configManager->isHiddenModel($entityClass)) {
             return false;
         }
         // check for custom entities
         if (ExtendHelper::isCustomEntity($entityClass)) {
             $entityAlias = $this->getEntityAliasFromConfig($entityClass);
             if (null !== $entityAlias) {
                 return $entityAlias;
             }
             return $this->createEntityAlias('Extend' . ExtendHelper::getShortClassName($entityClass));
         }
     }
     return null;
 }
开发者ID:antrampa,项目名称:platform,代码行数:36,代码来源:ExtendEntityAliasProvider.php

示例2: getEntityChoiceList

 /**
  * @param string $entityClassName
  * @param string $relationType
  *
  * @return array
  */
 protected function getEntityChoiceList($entityClassName, $relationType)
 {
     /** @var EntityConfigId[] $entityIds */
     $entityIds = $this->targetEntityClass ? [$this->configManager->getId('extend', $this->targetEntityClass)] : $this->configManager->getIds('extend');
     if (in_array($relationType, [RelationTypeBase::ONE_TO_MANY, RelationTypeBase::MANY_TO_MANY], true)) {
         $entityIds = array_filter($entityIds, function (EntityConfigId $configId) {
             $config = $this->configManager->getConfig($configId);
             return $config->is('is_extend');
         });
     }
     $entityIds = array_filter($entityIds, function (EntityConfigId $configId) {
         $config = $this->configManager->getConfig($configId);
         return !$config->is('state', ExtendScope::STATE_NEW) && ($this->targetEntityClass || !$config->is('is_deleted'));
     });
     $choices = [];
     foreach ($entityIds as $entityId) {
         $className = $entityId->getClassName();
         if (!$this->configManager->hasConfig($className, 'id') && !ExtendHelper::isCustomEntity($className)) {
             // @todo: temporary ignore entities that don't have PK with name 'id'
             // remove this in https://magecore.atlassian.net/browse/BAP-9713
             continue;
         }
         if ($className !== $entityClassName) {
             $entityConfig = $this->configManager->getProvider('entity')->getConfig($className);
             $choices[$className] = $entityConfig->get('label');
         }
     }
     return $choices;
 }
开发者ID:snorchel,项目名称:platform,代码行数:35,代码来源:TargetType.php

示例3: isReadOnly

 /**
  * Checks if the form type should be read-only or not
  *
  * @param Options $options
  *
  * @return bool
  */
 protected function isReadOnly($options)
 {
     /** @var ConfigIdInterface $configId */
     $configId = $options['config_id'];
     $className = $configId->getClassName();
     if (empty($className)) {
         return false;
     }
     $fieldName = $this->typeHelper->getFieldName($configId);
     if (empty($fieldName)) {
         return false;
     }
     if ($this->typeHelper->isSystem($className, $fieldName)) {
         // it is a system field
         return true;
     }
     $enumCode = $this->typeHelper->getEnumCode($className, $fieldName);
     if (!empty($enumCode)) {
         if ($options['config_is_new']) {
             // a new field reuses public enum
             return true;
         }
         $enumValueClassName = ExtendHelper::buildEnumValueClassName($enumCode);
         if ($this->typeHelper->isImmutable('enum', $enumValueClassName, null, 'public')) {
             // is immutable
             return true;
         }
         if ($this->typeHelper->hasOtherReferences($enumCode, $className, $fieldName)) {
             // an enum is reused by other fields
             return true;
         }
     }
     return false;
 }
开发者ID:Maksold,项目名称:platform,代码行数:41,代码来源:EnumPublicType.php

示例4: up

 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $relationTableName = $this->nameGenerator->generateManyToManyJoinTableName('Oro\\Bundle\\EmailBundle\\Entity\\Email', ExtendHelper::buildAssociationName('OroCRM\\Bundle\\SalesBundle\\Entity\\B2bCustomer', ActivityScope::ASSOCIATION_KIND), 'OroCRM\\Bundle\\SalesBundle\\Entity\\B2bCustomer');
     if (!$schema->hasTable($relationTableName)) {
         $this->activityExtension->addActivityAssociation($schema, 'oro_email', 'orocrm_sales_b2bcustomer');
     }
 }
开发者ID:antrampa,项目名称:crm,代码行数:10,代码来源:OroCRMSalesBundle.php

示例5: load

 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $internalRatings = $manager->getRepository(ExtendHelper::buildEnumValueClassName(Account::INTERNAL_RATING_CODE))->findAll();
     /** @var \Oro\Bundle\UserBundle\Entity\User $accountOwner */
     $accountOwner = $manager->getRepository('OroUserBundle:User')->findOneBy([]);
     foreach ($this->accounts as $accountName => $accountData) {
         /** @var \OroB2B\Bundle\AccountBundle\Entity\AccountGroup $accountGroup */
         $accountGroup = $this->getReference(LoadAccountGroupDemoData::ACCOUNT_GROUP_REFERENCE_PREFIX . $accountData['group']);
         $account = new Account();
         $account->setName($accountName)->setGroup($accountGroup)->setParent(null)->setOrganization($accountOwner->getOrganization())->setOwner($accountOwner)->setInternalRating($internalRatings[array_rand($internalRatings)]);
         $manager->persist($account);
         $this->addReference(static::ACCOUNT_REFERENCE_PREFIX . $account->getName(), $account);
         if (isset($accountData['subsidiaries'])) {
             foreach ($accountData['subsidiaries'] as $subsidiaryName => $subsidiaryData) {
                 /** @var \OroB2B\Bundle\AccountBundle\Entity\AccountGroup $subsidiaryGroup */
                 $subsidiaryGroup = $this->getReference(LoadAccountGroupDemoData::ACCOUNT_GROUP_REFERENCE_PREFIX . $subsidiaryData['group']);
                 $subsidiary = new Account();
                 $subsidiary->setName($subsidiaryName)->setGroup($subsidiaryGroup)->setParent($account)->setOrganization($accountOwner->getOrganization())->setOwner($accountOwner)->setInternalRating($internalRatings[array_rand($internalRatings)]);
                 $manager->persist($subsidiary);
                 $this->addReference(static::ACCOUNT_REFERENCE_PREFIX . $subsidiary->getName(), $subsidiary);
             }
         }
     }
     $manager->flush();
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:28,代码来源:LoadAccountDemoData.php

示例6: getBaseAssociatedNotesQB

 /**
  * @param $entityClassName
  * @param $entityId
  * @return QueryBuilder
  */
 public function getBaseAssociatedNotesQB($entityClassName, $entityId)
 {
     $ids = is_array($entityId) ? $entityId : [$entityId];
     $queryBuilder = $this->createQueryBuilder('note')->innerJoin($entityClassName, 'e', 'WITH', sprintf('note.%s = e', ExtendHelper::buildAssociationName($entityClassName)));
     $queryBuilder->where($queryBuilder->expr()->in('e.id', $ids));
     return $queryBuilder;
 }
开发者ID:Maksold,项目名称:platform,代码行数:12,代码来源:NoteRepository.php

示例7: updateEntityConfig

 /**
  * @param EntityConfigEvent $event
  */
 public function updateEntityConfig(EntityConfigEvent $event)
 {
     $parentClassName = get_parent_class($event->getClassName());
     if (!$parentClassName) {
         return;
     }
     $shortClassName = ExtendHelper::getShortClassName($event->getClassName());
     if (ExtendHelper::getShortClassName($parentClassName) !== 'Extend' . $shortClassName) {
         return;
     }
     $config = $event->getConfigManager()->getProvider('extend')->getConfig($event->getClassName());
     $hasChanges = false;
     if (!$config->is('is_extend')) {
         $config->set('is_extend', true);
         $hasChanges = true;
     }
     $extendClass = ExtendHelper::getExtendEntityProxyClassName($parentClassName);
     if (!$config->is('extend_class', $extendClass)) {
         $config->set('extend_class', $extendClass);
         $hasChanges = true;
     }
     if ($hasChanges) {
         $event->getConfigManager()->persist($config);
     }
 }
开发者ID:xamin123,项目名称:platform,代码行数:28,代码来源:ConfigSubscriber.php

示例8: getAssociationTableName

 /**
  * Gets a table name for many-to-many relation
  *
  * @param string $activityTableName Activity entity table name. It is owning side of the association.
  * @param string $targetTableName   Target entity table name.
  *
  * @return string
  */
 public function getAssociationTableName($activityTableName, $targetTableName)
 {
     $sourceClassName = $this->extendExtension->getEntityClassByTableName($activityTableName);
     $targetClassName = $this->extendExtension->getEntityClassByTableName($targetTableName);
     $associationName = ExtendHelper::buildAssociationName($targetClassName, ActivityScope::ASSOCIATION_KIND);
     return $this->nameGenerator->generateManyToManyJoinTableName($sourceClassName, $associationName, $targetClassName);
 }
开发者ID:woei66,项目名称:platform,代码行数:15,代码来源:ActivityExtension.php

示例9: load

 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     /** @var UserManager $userManager */
     $userManager = $this->container->get('oro_user.manager');
     $admin = $userManager->findUserByEmail(LoadAdminUserData::DEFAULT_ADMIN_EMAIL);
     $organization = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst();
     /** @var Store $store */
     $store = $this->getReference('store');
     /** @var Channel $channel */
     $channel = $this->getReference('default_channel');
     /** @var Integration $integration */
     $integration = $this->getReference('integration');
     $className = ExtendHelper::buildEnumValueClassName('mage_subscr_status');
     $enumRepo = $manager->getRepository($className);
     foreach ($this->subscriberData as $data) {
         $subscriber = new NewsletterSubscriber();
         $date = new \DateTime();
         $date->modify('-1 day');
         /** @var AbstractEnumValue $status */
         $status = $enumRepo->find($data['status']);
         $subscriber->setEmail($data['email'])->setStatus($status)->setConfirmCode(uniqid())->setStore($store)->setOwner($admin)->setOrganization($organization)->setOriginId($data['originId'])->setChangeStatusAt($date)->setCreatedAt($date)->setUpdatedAt($date)->setChannel($integration)->setDataChannel($channel);
         if (!empty($data['customer'])) {
             /** @var Customer $customer */
             $customer = $this->getReference($data['customer']);
             $subscriber->setCustomer($customer);
         }
         $this->setReference($data['reference'], $subscriber);
         $manager->persist($subscriber);
     }
     $manager->flush();
 }
开发者ID:antrampa,项目名称:crm,代码行数:34,代码来源:LoadNewsletterSubscriberData.php

示例10: createOwnerRelation

 /**
  * @param ConfigInterface $entityConfig
  * @param string          $targetEntityClassName
  * @param string          $relationName
  */
 protected function createOwnerRelation(ConfigInterface $entityConfig, $targetEntityClassName, $relationName)
 {
     $relationKey = ExtendHelper::buildRelationKey($entityConfig->getId()->getClassName(), $relationName, 'manyToOne', $this->ownershipMetadataProvider->getOrganizationClass());
     if (!isset($entityConfig->get('relation')[$relationKey])) {
         $this->relationBuilder->addManyToOneRelation($entityConfig, $targetEntityClassName, $relationName, 'id', ['entity' => ['label' => 'oro.custom_entity.' . $relationName . '.label', 'description' => 'oro.custom_entity.' . $relationName . '.description'], 'view' => ['is_displayable' => false], 'form' => ['is_enabled' => false], 'dataaudit' => ['auditable' => true]]);
     }
 }
开发者ID:northdakota,项目名称:platform,代码行数:12,代码来源:OwnershipEntityConfigDumperExtension.php

示例11: getFields

 /**
  * {@inheritdoc}
  */
 protected function getFields(DatagridConfiguration $config)
 {
     $entityClassName = $this->entityClassResolver->getEntityClass($this->getEntityName($config));
     if (!$this->configManager->hasConfig($entityClassName)) {
         return [];
     }
     $entityConfigProvider = $this->configManager->getProvider('entity');
     $extendConfigProvider = $this->configManager->getProvider('extend');
     $viewConfigProvider = $this->configManager->getProvider('view');
     $datagridConfigProvider = $this->configManager->getProvider('datagrid');
     $fields = [];
     $fieldIds = $entityConfigProvider->getIds($entityClassName);
     /** @var FieldConfigId $fieldId */
     foreach ($fieldIds as $fieldId) {
         $extendConfig = $extendConfigProvider->getConfigById($fieldId);
         if ($extendConfig->is('owner', ExtendScope::OWNER_CUSTOM) && ExtendHelper::isFieldAccessible($extendConfig) && $datagridConfigProvider->getConfigById($fieldId)->is('is_visible')) {
             $viewConfig = $viewConfigProvider->getConfig($entityClassName, $fieldId->getFieldName());
             $fields[] = ['id' => $fieldId, 'priority' => $viewConfig->get('priority', false, 0)];
         }
     }
     ArrayUtil::sortBy($fields, true);
     return array_map(function ($field) {
         return $field['id'];
     }, $fields);
 }
开发者ID:Maksold,项目名称:platform,代码行数:28,代码来源:DynamicFieldsExtension.php

示例12: detailedAction

 /**
  * @param string $id
  * @param string $entityName
  * @param string $fieldName
  *
  * @return array
  *
  * @Route(
  *      "/detailed/{id}/{entityName}/{fieldName}",
  *      name="oro_entity_detailed",
  *      defaults={"id"=0, "fieldName"=""}
  * )
  * @Template
  */
 public function detailedAction($id, $entityName, $fieldName)
 {
     $entityClass = $this->get('oro_entity.routing_helper')->resolveEntityClass($entityName);
     if (!class_exists($entityClass)) {
         throw $this->createNotFoundException();
     }
     $this->checkAccess('VIEW', $entityClass);
     $entityProvider = $this->get('oro_entity_config.provider.entity');
     $extendProvider = $this->get('oro_entity_config.provider.extend');
     $relationConfig = $extendProvider->getConfig($entityClass, $fieldName);
     $relationTargetEntity = $relationConfig->get('target_entity');
     if (!class_exists($relationTargetEntity)) {
         throw $this->createNotFoundException();
     }
     /** @var ConfigInterface[] $fields */
     $fields = $extendProvider->filter(function (ConfigInterface $config) use($relationConfig) {
         /** @var FieldConfigId $fieldConfigId */
         $fieldConfigId = $config->getId();
         return ExtendHelper::isFieldAccessible($config) && in_array($fieldConfigId->getFieldName(), (array) $relationConfig->get('target_detailed'), true);
     }, $relationConfig->get('target_entity'));
     $entity = $this->getDoctrine()->getRepository($relationTargetEntity)->find($id);
     if (!$entity) {
         return $this->createNotFoundException();
     }
     $dynamicRow = array();
     foreach ($fields as $field) {
         /** @var FieldConfigId $fieldConfigId */
         $fieldConfigId = $field->getId();
         $fieldName = $fieldConfigId->getFieldName();
         $label = $entityProvider->getConfigById($fieldConfigId)->get('label') ?: $fieldName;
         $dynamicRow[$label] = FieldAccessor::getValue($entity, $fieldName);
     }
     return array('dynamic' => $dynamicRow, 'entity' => $entity);
 }
开发者ID:Maksold,项目名称:platform,代码行数:48,代码来源:EntitiesController.php

示例13: setDefaultOptions

 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('constraints' => [new Assert\NotBlank()]));
     $constraintsNormalizer = function (Options $options, $constraints) {
         /** @var FieldConfigId $fieldConfigId */
         $fieldConfigId = $options['config_id'];
         if (!$this->typeHelper->hasEnumCode($fieldConfigId->getClassName(), $fieldConfigId->getFieldName())) {
             // validations of new enum
             $constraints[] = new Assert\Length(['max' => $this->nameGenerator->getMaxEnumCodeSize()]);
             $constraints[] = new Assert\Regex(['pattern' => '/^[\\w- ]*$/', 'message' => self::INVALID_NAME_MESSAGE]);
             $callback = function ($value, ExecutionContext $context) {
                 if (!empty($value)) {
                     $code = ExtendHelper::buildEnumCode($value, false);
                     if (empty($code)) {
                         $context->addViolation(self::INVALID_NAME_MESSAGE, ['{{ value }}' => $value]);
                     }
                 }
             };
             $constraints[] = new Assert\Callback([$callback]);
             $constraints[] = new UniqueEnumName(['entityClassName' => $fieldConfigId->getClassName(), 'fieldName' => $fieldConfigId->getFieldName()]);
         } else {
             // validations of existing enum
             $constraints[] = new Assert\Length(['max' => 255]);
         }
         return $constraints;
     };
     $resolver->setNormalizers(['constraints' => $constraintsNormalizer, 'disabled' => function (Options $options, $value) {
         return $this->isReadOnly($options) ? true : $value;
     }, 'validation_groups' => function (Options $options, $value) {
         return $options['disabled'] ? false : $value;
     }]);
 }
开发者ID:xamin123,项目名称:platform,代码行数:35,代码来源:EnumNameType.php

示例14: isDisabled

 /**
  * Checks if the given constraint is applied or not
  *
  * @param Options     $options
  * @param string|null $constraintName Can be: null, 'add', 'delete'
  *
  * @return bool
  */
 protected function isDisabled($options, $constraintName = null)
 {
     /** @var ConfigIdInterface $configId */
     $configId = $options['config_id'];
     $className = $configId->getClassName();
     if (empty($className)) {
         return false;
     }
     $fieldName = $this->typeHelper->getFieldName($configId);
     if (empty($fieldName)) {
         return false;
     }
     $enumCode = $this->typeHelper->getEnumCode($className, $fieldName);
     if (!empty($enumCode)) {
         if ($options['config_is_new']) {
             // a new field reuses public enum
             return true;
         }
         if ($constraintName) {
             $enumValueClassName = ExtendHelper::buildEnumValueClassName($enumCode);
             if ($this->typeHelper->isImmutable('enum', $enumValueClassName, null, $constraintName)) {
                 // is immutable
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:Maksold,项目名称:platform,代码行数:36,代码来源:EnumValueCollectionType.php

示例15: addManyToOneRelation

 /**
  * @param ConfigInterface $sourceEntityConfig The 'extend' config of the source entity
  * @param string          $targetEntityName
  * @param string          $relationName
  * @param string          $targetFieldName    A field name is used to show related entity
  * @param array           $options
  * @param string          $fieldType          The field type. By default the field type is manyToOne,
  *                                            but you can specify another type if it is based on manyToOne.
  *                                            In this case this type should be registered
  *                                            in entity_extend.yml under underlying_types section
  *
  * @return string The relation key
  */
 public function addManyToOneRelation(ConfigInterface $sourceEntityConfig, $targetEntityName, $relationName, $targetFieldName, $options = [], $fieldType = 'manyToOne')
 {
     $sourceEntityName = $sourceEntityConfig->getId()->getClassName();
     $relationKey = ExtendHelper::buildRelationKey($sourceEntityName, $relationName, 'manyToOne', $targetEntityName);
     // add a relation field config
     if (!$this->configManager->hasConfigFieldModel($sourceEntityName, $relationName)) {
         $this->configManager->createConfigFieldModel($sourceEntityName, $relationName, $fieldType);
         $options['extend']['state'] = ExtendScope::STATE_NEW;
     } else {
         $configFieldModel = $this->configManager->getConfigFieldModel($sourceEntityName, $relationName);
         if ($configFieldModel->getType() !== $fieldType) {
             $this->configManager->changeFieldType($sourceEntityName, $relationName, $fieldType);
         }
     }
     $options['extend']['is_extend'] = true;
     $options['extend']['relation_key'] = $relationKey;
     $options['extend']['target_entity'] = $targetEntityName;
     $options['extend']['target_field'] = $targetFieldName;
     $this->updateFieldConfigs($sourceEntityName, $relationName, $options);
     // add relation to config
     $relations = $sourceEntityConfig->get('relation', false, []);
     if (!isset($relations[$relationKey])) {
         $relations[$relationKey] = ['assign' => false, 'field_id' => new FieldConfigId('extend', $sourceEntityName, $relationName, 'manyToOne'), 'owner' => true, 'target_entity' => $targetEntityName, 'target_field_id' => false];
         $sourceEntityConfig->set('relation', $relations);
         $extendConfigProvider = $this->configManager->getProvider('extend');
         $extendConfigProvider->persist($sourceEntityConfig);
     }
     return $relationKey;
 }
开发者ID:xamin123,项目名称:platform,代码行数:42,代码来源:RelationBuilder.php


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