本文整理汇总了PHP中Oro\Bundle\EntityConfigBundle\Config\ConfigManager类的典型用法代码示例。如果您正苦于以下问题:PHP ConfigManager类的具体用法?PHP ConfigManager怎么用?PHP ConfigManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: onBuildBefore
/**
* @param BuildBefore $event
* @return bool
*/
public function onBuildBefore(BuildBefore $event)
{
$datagrid = $event->getDatagrid();
$config = $event->getConfig();
$entityClassName = $datagrid->getParameters()->get('class_name');
$fieldName = $datagrid->getParameters()->get('field_name');
$entityId = $datagrid->getParameters()->get('id');
$extendConfigProvider = $this->configManager->getProvider('extend');
$extendFieldConfig = $extendConfigProvider->getConfig($entityClassName, $fieldName);
$targetEntityName = $extendFieldConfig->get('target_entity');
$targetFieldNames = $extendFieldConfig->get('target_grid');
// build 'assigned' field expression
if ($entityId) {
$extendEntityConfig = $extendConfigProvider->getConfig($entityClassName);
$relations = $extendEntityConfig->get('relation');
$relation = $relations[$extendFieldConfig->get('relation_key')];
$targetFieldName = $relation['target_field_id']->getFieldName();
$fieldType = $extendFieldConfig->getId()->getFieldType();
$operator = $fieldType == 'oneToMany' ? '=' : 'MEMBER OF';
$whenExpr = '(:relation ' . $operator . ' o.' . $targetFieldName . ' OR o.id IN (:data_in))' . ' AND o.id NOT IN (:data_not_in)';
} else {
$whenExpr = 'o.id IN (:data_in) AND o.id NOT IN (:data_not_in)';
}
$assignedExpr = "CASE WHEN " . $whenExpr . " THEN true ELSE false END";
// build a query skeleton
$query = ['select' => ['o.id', $assignedExpr . ' as assigned'], 'from' => [['table' => $targetEntityName, 'alias' => 'o']]];
$config->offsetSetByPath('[source][query]', $query);
// enable AdditionalFieldsExtension to add all other fields
$config->offsetSetByPath('[options][entity_name]', $targetEntityName);
$config->offsetSetByPath('[options][additional_fields]', $targetFieldNames);
}
开发者ID:xamin123,项目名称:platform,代码行数:35,代码来源:EntityRelationGridListener.php
示例2: 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
示例3: setDefaultOptions
/**
* Options:
* - grid_name - name of grid that will be used for entity selection
* - grid_parameters - parameters need to be passed to grid request
* - grid_render_parameters - render parameters need to be set for grid rendering
* - existing_entity_grid_id - grid row field name used as entity identifier
* - create_enabled - enables new entity creation
* - create_acl - ACL resource used to determine that create is allowed, by default CREATE for entity used
* - create_form_route - route name for creation form
* - create_form_route_parameters - route parameters for create_form_route_parameters
*
* {@inheritDoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(['existing_entity_grid_id' => 'id', 'create_enabled' => true, 'create_acl' => null, 'create_form_route' => null, 'create_form_route_parameters' => [], 'grid_name' => null, 'grid_parameters' => [], 'grid_render_parameters' => []]);
$resolver->setNormalizers(['create_enabled' => function (Options $options, $createEnabled) {
$createRouteName = $options->get('create_form_route');
$createEnabled = $createEnabled && !empty($createRouteName);
if ($createEnabled) {
$aclName = $options->get('create_acl');
if (empty($aclName)) {
$aclObjectName = 'Entity:' . $options->get('entity_class');
$createEnabled = $this->securityFacade->isGranted('CREATE', $aclObjectName);
} else {
$createEnabled = $this->securityFacade->isGranted($aclName);
}
}
return $createEnabled;
}, 'grid_name' => function (Options $options, $gridName) {
if (!empty($gridName)) {
return $gridName;
}
$formConfig = $this->configManager->getProvider('form')->getConfig($options->get('entity_class'));
if ($formConfig->has('grid_name')) {
return $formConfig->get('grid_name');
}
throw new InvalidConfigurationException('The option "grid_name" must be set.');
}]);
}
开发者ID:xamin123,项目名称:platform,代码行数:40,代码来源:OroEntitySelectOrCreateInlineType.php
示例4: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$configModel = $options['config_model'];
$data = array();
if ($configModel instanceof FieldConfigModel) {
$className = $configModel->getEntity()->getClassName();
$fieldName = $configModel->getFieldName();
$fieldType = $configModel->getType();
$configType = PropertyConfigContainer::TYPE_FIELD;
} else {
$className = $configModel->getClassName();
$fieldName = null;
$fieldType = null;
$configType = PropertyConfigContainer::TYPE_ENTITY;
}
foreach ($this->configManager->getProviders() as $provider) {
if ($provider->getPropertyConfig()->hasForm($configType, $fieldType)) {
$config = $provider->getConfig($className, $fieldName);
$builder->add($provider->getScope(), new ConfigScopeType($provider->getPropertyConfig()->getFormItems($configType, $fieldType), $config, $this->configManager, $configModel), array('block_config' => (array) $provider->getPropertyConfig()->getFormBlockConfig($configType)));
$data[$provider->getScope()] = $config->all();
}
}
if ($fieldType == 'optionSet') {
$data['extend']['set_options'] = $this->configManager->getEntityManager()->getRepository(OptionSet::ENTITY_NAME)->findOptionsByField($configModel->getId());
}
$builder->setData($data);
$builder->addEventSubscriber(new ConfigSubscriber($this->configManager));
}
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:31,代码来源:ConfigType.php
示例5: getEntityChoiceList
protected function getEntityChoiceList($entityClassName, $relationType)
{
$choices = array();
$extendEntityConfig = $this->configManager->getProvider('extend');
/** @var EntityConfigId[] $entityIds */
$entityIds = $this->targetEntity ? array($extendEntityConfig->getId($this->targetEntity)) : $extendEntityConfig->getIds();
if (in_array($relationType, array(RelationTypeBase::ONE_TO_MANY, RelationTypeBase::MANY_TO_MANY))) {
$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('is_extend', false) || !$config->is('state', ExtendScope::STATE_NEW);
});
foreach ($entityIds as $entityId) {
$className = $entityId->getClassName();
if ($className != $entityClassName) {
$entityConfig = $this->configManager->getProvider('entity')->getConfig($className);
$choices[$className] = new ChoiceListItem($entityConfig->get('label'), array('data-icon' => $entityConfig->get('icon')));
}
}
return $choices;
}
开发者ID:nmallare,项目名称:platform,代码行数:25,代码来源:TargetType.php
示例6: testFlush
public function testFlush()
{
$model = new EntityConfigModel(self::ENTITY_CLASS);
$entityConfigId = new EntityConfigId('entity', self::ENTITY_CLASS);
$entityConfig = new Config($entityConfigId);
$entityConfig->set('icon', 'test_icon');
$entityConfig->set('label', 'test_label');
$entityPropertyConfig = new PropertyConfigContainer(['entity' => ['items' => ['icon' => [], 'label' => ['options' => ['indexed' => true]]]]]);
$this->entityConfigProvider->expects($this->once())->method('getPropertyConfig')->will($this->returnValue($entityPropertyConfig));
$testConfigId = new EntityConfigId('test', self::ENTITY_CLASS);
$testConfig = new Config($testConfigId);
$testConfig->set('attr1', 'test_attr1');
$testPropertyConfig = new PropertyConfigContainer(['entity' => ['items' => ['attr1' => []]]]);
$this->testConfigProvider->expects($this->once())->method('getPropertyConfig')->will($this->returnValue($testPropertyConfig));
$this->modelManager->expects($this->once())->method('getEntityModel')->with($entityConfigId->getClassName())->will($this->returnValue($model));
$em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
$this->modelManager->expects($this->any())->method('getEntityManager')->will($this->returnValue($em));
$this->setFlushExpectations($em, [$model]);
$this->eventDispatcher->expects($this->at(2))->method('dispatch')->with(Events::PRE_FLUSH, new PreFlushConfigEvent(['entity' => $entityConfig, 'test' => $testConfig], $this->configManager));
$this->configManager->persist($entityConfig);
$this->configManager->persist($testConfig);
$this->configManager->flush();
$this->assertEquals(['icon' => 'test_icon', 'label' => 'test_label'], $model->toArray('entity'));
$this->assertEquals(['attr1' => 'test_attr1'], $model->toArray('test'));
$this->assertCount(3, $model->getIndexedValues());
$this->assertEquals('entity_config', $model->getIndexedValues()[0]->getScope());
$this->assertEquals('module_name', $model->getIndexedValues()[0]->getCode());
$this->assertEquals('entity_config', $model->getIndexedValues()[1]->getScope());
$this->assertEquals('entity_name', $model->getIndexedValues()[1]->getCode());
$this->assertEquals('entity', $model->getIndexedValues()[2]->getScope());
$this->assertEquals('label', $model->getIndexedValues()[2]->getCode());
}
开发者ID:Maksold,项目名称:platform,代码行数:32,代码来源:FlushConfigManagerTest.php
示例7: getConfiguration
/**
* {@inheritdoc}
*/
public function getConfiguration()
{
$configuration = parent::getConfiguration();
$className = $this->source->getEntity();
$metadata = $this->configManager->getEntityMetadata($className);
if (!$metadata || empty($metadata->routeView)) {
return $configuration;
}
$fromPart = $configuration->offsetGetByPath('[source][query][from]');
$entityAlias = null;
$doctrineMetadata = $this->doctrine->getManagerForClass($className)->getClassMetadata($className);
$identifiers = $doctrineMetadata->getIdentifier();
$primaryKey = array_shift($identifiers);
foreach ($fromPart as $piece) {
if ($piece['table'] == $className) {
$entityAlias = $piece['alias'];
break;
}
}
if (!$entityAlias || !$primaryKey || count($identifiers) > 1 || !$this->isActionSupported($primaryKey)) {
return $configuration;
}
$viewAction = ['view' => ['type' => 'navigate', 'label' => 'oro.report.datagrid.view', 'acl_resource' => 'VIEW;entity:' . $className, 'icon' => 'eye-open', 'link' => 'view_link', 'rowAction' => true]];
$properties = [$primaryKey => null, 'view_link' => ['type' => 'url', 'route' => $metadata->routeView, 'params' => [$primaryKey]]];
$configuration->offsetAddToArrayByPath('[source][query][select]', ["{$entityAlias}.{$primaryKey}"]);
$configuration->offsetAddToArrayByPath('[properties]', $properties);
$configuration->offsetAddToArrayByPath('[actions]', $viewAction);
return $configuration;
}
开发者ID:xamin123,项目名称:platform,代码行数:32,代码来源:BaseReportConfigurationBuilder.php
示例8: generateProxies
/**
* Generate doctrine proxy classes for extended entities
*/
public function generateProxies()
{
$em = $this->configManager->getEntityManager();
$isAutoGenerated = $em->getConfiguration()->getAutoGenerateProxyClasses();
if (!$isAutoGenerated) {
$proxyDir = $em->getConfiguration()->getProxyDir();
if (!empty($this->cacheDir) && $this->kernelCacheDir !== $this->cacheDir && strpos($proxyDir, $this->kernelCacheDir) === 0) {
$proxyDir = $this->cacheDir . substr($proxyDir, strlen($this->kernelCacheDir));
}
$extendConfigProvider = $this->configManager->getProvider('extend');
$extendConfigs = $extendConfigProvider->getConfigs(null, true);
$metadataFactory = $em->getMetadataFactory();
$proxyFactory = $em->getProxyFactory();
foreach ($extendConfigs as $extendConfig) {
if (!$extendConfig->is('is_extend')) {
continue;
}
if ($extendConfig->in('state', [ExtendScope::STATE_NEW])) {
continue;
}
$entityClass = $extendConfig->getId()->getClassName();
$proxyFileName = $proxyDir . DIRECTORY_SEPARATOR . '__CG__' . str_replace('\\', '', $entityClass) . '.php';
$metadata = $metadataFactory->getMetadataFor($entityClass);
$proxyFactory->generateProxyClasses([$metadata], $proxyDir);
clearstatcache(true, $proxyFileName);
}
}
}
开发者ID:northdakota,项目名称:platform,代码行数:31,代码来源:EntityProxyGenerator.php
示例9: getObjects
/**
* Returns objects extracted from simple search
*
* @param User $user
* @param string $entityClass
* @param string $searchString
* @param int $offset
* @param int $maxResults
*
* @return array
*/
protected function getObjects(User $user, $entityClass, $searchString, $offset, $maxResults)
{
$objects = [];
if (!$this->configManager->hasConfig($entityClass)) {
return $objects;
}
$classNames = $this->shareScopeProvider->getClassNamesBySharingScopeConfig($entityClass);
if (!$classNames) {
return $objects;
}
$tables = [];
foreach ($classNames as $className) {
$metadata = $this->em->getClassMetadata($className);
$tables[] = $metadata->getTableName();
}
$searchResults = $this->indexer->simpleSearch($searchString, $offset, $maxResults, $tables);
list($userIds, $buIds, $orgIds) = $this->getIdsByClass($searchResults, $user);
if ($orgIds) {
$organizations = $this->em->getRepository('OroOrganizationBundle:Organization')->getEnabledOrganizations($orgIds);
$objects = array_merge($objects, $organizations);
}
if ($buIds) {
$businessUnits = $this->em->getRepository('OroOrganizationBundle:BusinessUnit')->getBusinessUnits($buIds);
$objects = array_merge($objects, $businessUnits);
}
if ($userIds) {
$users = $this->em->getRepository('OroUserBundle:User')->findUsersByIds($userIds);
$objects = array_merge($objects, $users);
}
return $objects;
}
开发者ID:kstupak,项目名称:platform,代码行数:42,代码来源:SecurityIndexer.php
示例10: getExtendConfigProvider
/**
* @return ConfigProvider
*/
protected function getExtendConfigProvider()
{
if (!$this->extendConfigProvider) {
$this->extendConfigProvider = $this->configManager->getProvider('extend');
}
return $this->extendConfigProvider;
}
开发者ID:Maksold,项目名称:platform,代码行数:10,代码来源:ApplicableEntitiesType.php
示例11: postSubmit
/**
* POST_SUBMIT event handler
*
* @param FormEvent $event
*/
public function postSubmit(FormEvent $event)
{
$form = $event->getForm();
$options = $form->getConfig()->getOptions();
/** @var ConfigIdInterface $configId */
$configId = $options['config_id'];
if (!$form->isValid()) {
return;
}
// change the entity state to "Requires update" if the attribute has "require_schema_update" option
// and the value of the attribute was changed
$configProvider = $this->configManager->getProvider($configId->getScope());
if ($configProvider->getPropertyConfig()->isSchemaUpdateRequired($form->getName(), $configId)) {
$newVal = $form->getData();
$oldVal = $this->configManager->getConfig($configId)->get($form->getName());
if ($this->isSchemaUpdateRequired($newVal, $oldVal)) {
$extendConfigProvider = $this->configManager->getProvider('extend');
$extendConfig = $extendConfigProvider->getConfig($configId->getClassName());
if ($extendConfig->is('state', ExtendScope::STATE_ACTIVE)) {
$extendConfig->set('state', ExtendScope::STATE_UPDATE);
$this->configManager->persist($extendConfig);
}
}
}
}
开发者ID:Maksold,项目名称:platform,代码行数:30,代码来源:AbstractConfigType.php
示例12: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$vars = ['configs' => $options['configs']];
if ($form->getData()) {
$data = $form->getParent()->getData();
$fieldConfig = $this->cm->getProvider('extend')->getConfig($data, $form->getName());
if ($form->getData()) {
/** @var ConverterInterface|EntitySelectHandler $converter */
$converter = $options['converter'];
$result = [];
if ($converter instanceof EntitySelectHandler) {
$converter->initForEntity($fieldConfig->getId()->getClassName(), $fieldConfig->get('target_field'));
}
if (isset($options['configs']['multiple']) && $options['configs']['multiple']) {
foreach ($form->getData() as $item) {
$result[] = $converter->convertItem($item);
}
} else {
$result[] = $converter->convertItem($form->getData());
}
$vars['attr'] = ['data-selected-data' => json_encode($result)];
}
}
$view->vars = array_replace_recursive($view->vars, $vars);
}
开发者ID:ramunasd,项目名称:platform,代码行数:28,代码来源:EntitySelectType.php
示例13: preUpdate
/**
* {@inheritdoc}
*/
public function preUpdate()
{
$extendConfigProvider = $this->configManager->getProvider('extend');
$entityConfigs = $extendConfigProvider->getConfigs();
foreach ($entityConfigs as $entityConfig) {
if (!$entityConfig->is('is_extend')) {
continue;
}
$fieldConfigs = $extendConfigProvider->getConfigs($entityConfig->getId()->getClassName());
foreach ($fieldConfigs as $fieldConfig) {
if (!$fieldConfig->is('state', ExtendScope::STATE_NEW)) {
continue;
}
/** @var FieldConfigId $fieldConfigId */
$fieldConfigId = $fieldConfig->getId();
if (in_array($fieldConfigId->getFieldType(), ['file', 'image'])) {
// create a relation
$relationKey = $this->relationBuilder->addManyToOneRelation($entityConfig, 'Oro\\Bundle\\AttachmentBundle\\Entity\\File', $fieldConfigId->getFieldName(), 'id', ['importexport' => ['process_as_scalar' => true]], $fieldConfigId->getFieldType());
// set cascade persist
$relations = $entityConfig->get('relation');
$cascade = isset($relations[$relationKey]['cascade']) ? $relations[$relationKey]['cascade'] : [];
$cascade[] = 'persist';
$relations[$relationKey]['cascade'] = $cascade;
$entityConfig->set('relation', $relations);
$extendConfigProvider->persist($entityConfig);
}
}
}
}
开发者ID:xamin123,项目名称:platform,代码行数:32,代码来源:FileEntityConfigDumperExtension.php
示例14: 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
示例15: preUpdate
/**
* {@inheritdoc}
*/
public function preUpdate()
{
$extendConfigProvider = $this->configManager->getProvider('extend');
$entityConfigs = $extendConfigProvider->getConfigs();
foreach ($entityConfigs as $entityConfig) {
if (!$entityConfig->is('is_extend')) {
continue;
}
$fieldConfigs = $extendConfigProvider->getConfigs($entityConfig->getId()->getClassName());
foreach ($fieldConfigs as $fieldConfig) {
if (!$fieldConfig->in('state', [ExtendScope::STATE_NEW, ExtendScope::STATE_UPDATE])) {
continue;
}
/** @var FieldConfigId $fieldConfigId */
$fieldConfigId = $fieldConfig->getId();
if (in_array($fieldConfigId->getFieldType(), ['file', 'image'])) {
$cascade = $fieldConfig->get('cascade', false, []);
if (!in_array('persist', $cascade, true)) {
$cascade[] = 'persist';
}
$this->relationBuilder->addManyToOneRelation($entityConfig, 'Oro\\Bundle\\AttachmentBundle\\Entity\\File', $fieldConfigId->getFieldName(), 'id', ['extend' => ['cascade' => $cascade], 'importexport' => ['process_as_scalar' => true]], $fieldConfigId->getFieldType());
}
}
}
}
开发者ID:Maksold,项目名称:platform,代码行数:28,代码来源:FileEntityConfigDumperExtension.php
示例16: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$configModel = $options['config_model'];
$data = array();
if ($configModel instanceof FieldConfigModel) {
$className = $configModel->getEntity()->getClassName();
$fieldName = $configModel->getFieldName();
$fieldType = $configModel->getType();
$configType = PropertyConfigContainer::TYPE_FIELD;
/**
* Add read only field name and field type
*/
$builder->add('fieldName', 'text', array('label' => 'oro.entity_config.form.name.label', 'block' => 'general', 'disabled' => true, 'data' => $fieldName));
$builder->add('type', 'choice', array('label' => 'oro.entity_config.form.type.label', 'choices' => [], 'block' => 'general', 'disabled' => true, 'empty_value' => 'oro.entity_extend.form.data_type.' . $fieldType));
} else {
$className = $configModel->getClassName();
$fieldName = null;
$fieldType = null;
$configType = PropertyConfigContainer::TYPE_ENTITY;
}
foreach ($this->configManager->getProviders() as $provider) {
if ($provider->getPropertyConfig()->hasForm($configType, $fieldType)) {
$config = $this->configManager->getConfig($provider->getId($className, $fieldName, $fieldType));
$builder->add($provider->getScope(), new ConfigScopeType($provider->getPropertyConfig()->getFormItems($configType, $fieldType), $config, $this->configManager, $configModel), array('block_config' => $this->getFormBlockConfig($provider, $configType)));
$data[$provider->getScope()] = $config->all();
}
}
$builder->setData($data);
$builder->addEventSubscriber(new ConfigSubscriber($this->doctrine, $this->configManager, $this->translator, $this->dbTranslationMetadataCache));
}
开发者ID:ramunasd,项目名称:platform,代码行数:33,代码来源:ConfigType.php
示例17: preUpdate
/**
* {@inheritdoc}
*/
public function preUpdate()
{
$ownershipConfigProvider = $this->configManager->getProvider('ownership');
$extendConfigProvider = $this->configManager->getProvider('extend');
$entityConfigs = $extendConfigProvider->getConfigs();
foreach ($entityConfigs as $entityConfig) {
if (!$entityConfig->is('owner', ExtendScope::OWNER_CUSTOM)) {
continue;
}
if (!$entityConfig->is('state', ExtendScope::STATE_NEW)) {
continue;
}
if (!$ownershipConfigProvider->hasConfig($entityConfig->getId()->getClassName())) {
continue;
}
$ownershipConfig = $ownershipConfigProvider->getConfig($entityConfig->getId()->getClassName());
$ownerType = $ownershipConfig->get('owner_type');
if (empty($ownerType)) {
continue;
}
$this->createOwnerRelation($entityConfig, $this->getOwnerTargetEntityClassName($ownerType), $ownershipConfig->get('owner_field_name'));
if (in_array($ownerType, [OwnershipType::OWNER_TYPE_USER, OwnershipType::OWNER_TYPE_BUSINESS_UNIT]) && $ownershipConfig->has('organization_field_name')) {
$this->createOwnerRelation($entityConfig, $this->ownershipMetadataProvider->getOrganizationClass(), $ownershipConfig->get('organization_field_name'));
}
}
}
开发者ID:xamin123,项目名称:platform,代码行数:29,代码来源:OwnershipEntityConfigDumperExtension.php
示例18: onNavigationConfigure
/**
* @param ConfigureMenuEvent $event
*/
public function onNavigationConfigure(ConfigureMenuEvent $event)
{
$menu = $event->getMenu();
$children = array();
$entitiesMenuItem = $menu->getChild('system_tab')->getChild('entities_list');
if ($entitiesMenuItem) {
/** @var ConfigProvider $entityConfigProvider */
$entityConfigProvider = $this->configManager->getProvider('entity');
/** @var ConfigProvider $entityExtendProvider */
$entityExtendProvider = $this->configManager->getProvider('extend');
$extendConfigs = $entityExtendProvider->getConfigs();
foreach ($extendConfigs as $extendConfig) {
if ($this->checkAvailability($extendConfig)) {
$config = $entityConfigProvider->getConfig($extendConfig->getId()->getClassname());
if (!class_exists($config->getId()->getClassName()) || !$this->securityFacade->hasLoggedUser() || !$this->securityFacade->isGranted('VIEW', 'entity:' . $config->getId()->getClassName())) {
continue;
}
$children[$config->get('label')] = array('label' => $this->translator->trans($config->get('label')), 'options' => array('route' => 'oro_entity_index', 'routeParameters' => array('entityName' => str_replace('\\', '_', $config->getId()->getClassName())), 'extras' => array('safe_label' => true, 'routes' => array('oro_entity_*'))));
}
}
sort($children);
foreach ($children as $child) {
$entitiesMenuItem->addChild($child['label'], $child['options']);
}
}
}
开发者ID:ramunasd,项目名称:platform,代码行数:29,代码来源:NavigationListener.php
示例19: getGroupedResults
/**
* Returns grouped search results
*
* @param string $string
* @return array
*/
public function getGroupedResults($string)
{
$search = $this->getResults($string);
// empty key array contains all data
$result = array('' => array('count' => 0, 'class' => '', 'config' => array(), 'icon' => '', 'label' => ''));
/** @var $item Item */
foreach ($search->getElements() as $item) {
$config = $item->getEntityConfig();
$alias = $config['alias'];
if (!isset($result[$alias])) {
$group = array('count' => 0, 'class' => $item->getEntityName(), 'config' => $config, 'icon' => '', 'label' => '');
if (!empty($group['class']) && $this->configManager->hasConfig($group['class'])) {
$entityConfigId = new EntityConfigId('entity', $group['class']);
$entityConfig = $this->configManager->getConfig($entityConfigId);
if ($entityConfig->has('plural_label')) {
$group['label'] = $this->translator->trans($entityConfig->get('plural_label'));
}
if ($entityConfig->has('icon')) {
$group['icon'] = $entityConfig->get('icon');
}
}
$result[$alias] = $group;
}
$result[$alias]['count']++;
$result['']['count']++;
}
uasort($result, function ($first, $second) {
if ($first['label'] == $second['label']) {
return 0;
}
return $first['label'] > $second['label'] ? 1 : -1;
});
return $result;
}
开发者ID:Maksold,项目名称:platform,代码行数:40,代码来源:ResultStatisticsProvider.php
示例20: getObjectName
/**
*
* @param string $scope
* @return array
*/
protected function getObjectName($scope = 'name')
{
if (empty($this->filterChoices[$scope])) {
$alias = 'ce';
$qb = $this->configManager->getEntityManager()->createQueryBuilder();
$qb->select($alias)->from(EntityConfigModel::ENTITY_NAME, $alias)->add('select', $alias . '.className')->distinct($alias . '.className');
$result = $qb->getQuery()->getArrayResult();
$options = ['name' => [], 'module' => []];
foreach ((array) $result as $value) {
$className = explode('\\', $value['className']);
$options['name'][$value['className']] = '';
$options['module'][$value['className']] = '';
if (strpos($value['className'], 'Extend\\Entity') === false) {
foreach ($className as $index => $name) {
if (count($className) - 1 == $index) {
$options['name'][$value['className']] = $name;
} elseif (!in_array($name, array('Bundle', 'Entity'))) {
$options['module'][$value['className']] .= $name;
}
}
} else {
$options['name'][$value['className']] = str_replace('Extend\\Entity\\', '', $value['className']);
$options['module'][$value['className']] = 'System';
}
}
$this->filterChoices = $options;
}
return $this->filterChoices[$scope];
}
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:34,代码来源:EntityConfigGridListener.php
注:本文中的Oro\Bundle\EntityConfigBundle\Config\ConfigManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论