• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Tools\ExtendHelper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $defaultFieldOptions = ['multiple' => true];
     $resolver->setDefaults(['enum_code' => null, 'class' => null, 'field_options' => $defaultFieldOptions, 'operator_choices' => [self::TYPE_IN => $this->translator->trans('oro.filter.form.label_type_in'), self::TYPE_NOT_IN => $this->translator->trans('oro.filter.form.label_type_not_in')]]);
     $resolver->setNormalizer('class', function (Options $options, $value) {
         if ($value !== null) {
             return $value;
         }
         if (empty($options['enum_code'])) {
             throw new InvalidOptionsException('Either "class" or "enum_code" must option must be set.');
         }
         $class = ExtendHelper::buildEnumValueClassName($options['enum_code']);
         if (!is_a($class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue', true)) {
             throw new InvalidOptionsException(sprintf('"%s" must be a child of "%s"', $class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue'));
         }
         return $class;
     });
     // this normalizer allows to add/override field_options options outside
     $resolver->setNormalizer('field_options', function (Options $options, $value) use(&$defaultFieldOptions) {
         if (isset($options['class'])) {
             $nullValue = null;
             if ($options->offsetExists('null_value')) {
                 $nullValue = $options->offsetGet('null_value');
             }
             $value['choices'] = $this->getChoices($options['class'], $nullValue);
         } else {
             $value['choices'] = [];
         }
         return array_merge($defaultFieldOptions, $value);
     });
 }
开发者ID:snorchel,项目名称:platform,代码行数:34,代码来源:EnumFilterType.php


示例17: runActivityLists

 /**
  * @param LoggerInterface $logger
  * @param bool            $dryRun
  */
 protected function runActivityLists(LoggerInterface $logger, $dryRun = false)
 {
     // @todo: this workaround should be removed in BAP-9156
     $this->configManager->clear();
     $targetEntities = $this->provider->getTargetEntityClasses(false);
     $toSchema = clone $this->schema;
     $hasSchemaChanges = false;
     foreach ($targetEntities as $targetEntity) {
         $associationName = ExtendHelper::buildAssociationName($targetEntity, ActivityListEntityConfigDumperExtension::ASSOCIATION_KIND);
         $relationTableName = $this->nameGenerator->generateManyToManyJoinTableName(ActivityListEntityConfigDumperExtension::ENTITY_CLASS, $associationName, $targetEntity);
         if (!$toSchema->hasTable($relationTableName)) {
             $hasSchemaChanges = true;
             $this->activityListExtension->addActivityListAssociation($toSchema, $this->metadataHelper->getTableNameByEntityClass($targetEntity));
         }
     }
     if ($hasSchemaChanges) {
         $comparator = new Comparator();
         $platform = $this->connection->getDatabasePlatform();
         $schemaDiff = $comparator->compare($this->schema, $toSchema);
         $queries = $schemaDiff->toSql($platform);
         foreach ($queries as $query) {
             $this->logQuery($logger, $query);
             if (!$dryRun) {
                 $this->connection->executeQuery($query);
             }
         }
     }
 }
开发者ID:woei66,项目名称:platform,代码行数:32,代码来源:ActivityListMigrationQuery.php


示例18: setDefaultOptions

 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $defaultFieldOptions = ['multiple' => true];
     $resolver->setDefaults(['dictionary_code' => null, 'class' => null, 'field_options' => $defaultFieldOptions]);
     $resolver->setNormalizers(['class' => function (Options $options, $value) {
         if ($value !== null) {
             return $value;
         }
         if (empty($options['dictionary_code'])) {
             throw new InvalidOptionsException('Either "class" or "dictionary_code" must option must be set.');
         }
         $class = ExtendHelper::buildEnumValueClassName($options['dictionary_code']);
         if (!is_a($class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue', true)) {
             throw new InvalidOptionsException(sprintf('"%s" must be a child of "%s"', $class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue'));
         }
         return $class;
     }, 'field_options' => function (Options $options, $value) use(&$defaultFieldOptions) {
         if (isset($options['class'])) {
             $nullValue = null;
             if ($options->has('null_value')) {
                 $nullValue = $options->get('null_value');
             }
             $value['choices'] = $this->getChoices($options['class'], $nullValue);
         } else {
             $value['choices'] = [];
         }
         return array_merge($defaultFieldOptions, $value);
     }]);
 }
开发者ID:Maksold,项目名称:platform,代码行数:32,代码来源:DictionaryFilterType.php


示例19: load

 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     /** @var AccountUser[] $accountUsers */
     $accountUsers = $manager->getRepository('OroB2BCustomerBundle:AccountUser')->findAll();
     $internalRatings = $manager->getRepository(ExtendHelper::buildEnumValueClassName(Customer::INTERNAL_RATING_CODE))->findAll();
     $rootCustomer = null;
     $firstLevelCustomer = null;
     // create customer groups
     $rootGroup = $this->createCustomerGroup('Root');
     $firstLevelGroup = $this->createCustomerGroup('First');
     $secondLevelGroup = $this->createCustomerGroup('Second');
     $manager->persist($rootGroup);
     $manager->persist($firstLevelGroup);
     $manager->persist($secondLevelGroup);
     // create customers
     foreach ($accountUsers as $index => $accountUser) {
         $customer = $accountUser->getCustomer();
         switch ($index % 3) {
             case 0:
                 $customer->setGroup($rootGroup);
                 $rootCustomer = $customer;
                 break;
             case 1:
                 $customer->setGroup($firstLevelGroup)->setParent($rootCustomer);
                 $firstLevelCustomer = $customer;
                 break;
             case 2:
                 $customer->setGroup($secondLevelGroup)->setParent($firstLevelCustomer);
                 break;
         }
         $customer->setInternalRating($internalRatings[array_rand($internalRatings)]);
     }
     $manager->flush();
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:37,代码来源:LoadCustomerDemoData.php


示例20: updateEntity

 /**
  * @param EntityConfigEvent $event
  */
 public function updateEntity(EntityConfigEvent $event)
 {
     $className = $event->getClassName();
     $parentClassName = get_parent_class($className);
     if (!$parentClassName) {
         return;
     }
     if (ExtendHelper::isExtendEntityProxy($parentClassName)) {
         // When application is installed parent class will be replaced (via class_alias)
         $extendClass = $parentClassName;
     } else {
         // During install parent class is not replaced (via class_alias)
         $shortClassName = ExtendHelper::getShortClassName($className);
         if (ExtendHelper::getShortClassName($parentClassName) !== 'Extend' . $shortClassName) {
             return;
         }
         $extendClass = ExtendHelper::getExtendEntityProxyClassName($parentClassName);
     }
     $configManager = $event->getConfigManager();
     $config = $configManager->getProvider('extend')->getConfig($className);
     $hasChanges = false;
     if (!$config->is('is_extend')) {
         $config->set('is_extend', true);
         $hasChanges = true;
     }
     if (!$config->is('extend_class', $extendClass)) {
         $config->set('extend_class', $extendClass);
         $hasChanges = true;
     }
     if ($hasChanges) {
         $configManager->persist($config);
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:36,代码来源:EntityConfigListener.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Migration\QueryBag类代码示例发布时间:2022-05-23
下一篇:
PHP Provider\ConfigProvider类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap