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


PHP ConfigProvider::filter方法代码示例

本文整理汇总了PHP中Oro\Bundle\EntityConfigBundle\Provider\ConfigProvider::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigProvider::filter方法的具体用法?PHP ConfigProvider::filter怎么用?PHP ConfigProvider::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Oro\Bundle\EntityConfigBundle\Provider\ConfigProvider的用法示例。


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

示例1: getTemplateVariables

 /**
  * Return available in template variables
  *
  * @param string $entityName
  * @return array
  */
 public function getTemplateVariables($entityName)
 {
     $userClassName = $this->getUser() ? get_class($this->getUser()) : false;
     $allowedData = array('entity' => array(), 'user' => array());
     $ids = $this->configProvider->getIds();
     foreach ($ids as $entityConfigId) {
         // export variables of asked entity and current user entity class
         $className = $entityConfigId->getClassName();
         if ($className == $entityName || $className == $userClassName) {
             $fields = $this->configProvider->filter(function (ConfigInterface $config) {
                 return $config->is('available_in_template');
             }, $className);
             $fields = array_values(array_map(function (ConfigInterface $field) {
                 return $field->getId()->getFieldName();
             }, $fields));
             switch ($className) {
                 case $entityName:
                     $allowedData['entity'] = $fields;
                     break;
                 case $userClassName:
                     $allowedData['user'] = $fields;
                     break;
             }
             if ($entityName == $userClassName) {
                 $allowedData['user'] = $allowedData['entity'];
             }
         }
     }
     return $allowedData;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:36,代码来源:VariablesProvider.php

示例2: resolve

 /**
  * {@inheritdoc}
  */
 public function resolve(Route $route, RouteCollectionAccessor $routes)
 {
     if ($route->getOption('group') !== self::ROUTE_GROUP) {
         return;
     }
     if ($this->hasAttribute($route, self::ACTIVITY_PLACEHOLDER)) {
         $activities = array_map(function (ConfigInterface $config) {
             // convert to entity alias
             return $this->entityAliasResolver->getPluralAlias($config->getId()->getClassName());
         }, $this->groupingConfigProvider->filter(function (ConfigInterface $config) {
             // filter activity entities
             $groups = $config->get('groups');
             return !empty($groups) && in_array(ActivityScope::GROUP_ACTIVITY, $groups, true);
         }));
         if (!empty($activities)) {
             $activities = $this->adjustRoutes($route, $routes, $activities);
             if (!empty($activities)) {
                 $route->setRequirement(self::ACTIVITY_ATTRIBUTE, implode('|', $activities));
             }
         }
         $this->completeRouteRequirements($route);
     } elseif ($this->hasAttribute($route, self::ENTITY_PLACEHOLDER)) {
         $this->completeRouteRequirements($route);
     }
 }
开发者ID:northdakota,项目名称:platform,代码行数:28,代码来源:ActivityAssociationRouteOptionsResolver.php

示例3: getEntityActivityContactFields

 /**
  * @param object $entity
  *
  * @return ConfigInterface[]
  */
 protected function getEntityActivityContactFields($entity)
 {
     $fields = array_keys(ActivityScope::$fieldsConfiguration);
     return $this->extendProvider->filter(function (ConfigInterface $config) use($fields) {
         /** @var FieldConfigId $fieldConfigId */
         $fieldConfigId = $config->getId();
         return in_array($fieldConfigId->getFieldName(), $fields);
     }, ClassUtils::getClass($entity));
 }
开发者ID:antrampa,项目名称:crm,代码行数:14,代码来源:EntityActivityContactDataProvider.php

示例4: getSupportedActivities

 /**
  * @return string[]
  */
 protected function getSupportedActivities()
 {
     if (null === $this->supportedActivities) {
         $this->supportedActivities = array_map(function (ConfigInterface $config) {
             // convert to entity alias
             return $this->entityAliasResolver->getPluralAlias($config->getId()->getClassName());
         }, $this->groupingConfigProvider->filter(function (ConfigInterface $config) {
             // filter activity entities
             $groups = $config->get('groups');
             return !empty($groups) && in_array(ActivityScope::GROUP_ACTIVITY, $groups, true);
         }));
     }
     return $this->supportedActivities;
 }
开发者ID:startupz,项目名称:platform-1,代码行数:17,代码来源:ActivityAssociationRouteOptionsResolver.php

示例5: testFilter

 public function testFilter()
 {
     $this->configManager->expects($this->once())->method('getConfigs')->with('testScope', DemoEntity::ENTITY_NAME, false)->will($this->returnValue(array($this->entityConfig)));
     $this->assertEquals(array(), $this->configProvider->filter(function (ConfigInterface $config) {
         return $config->getId()->getScope() == 'wrongScope';
     }, DemoEntity::ENTITY_NAME));
 }
开发者ID:ramunasd,项目名称:platform,代码行数:7,代码来源:ConfigProviderTest.php

示例6: getPropertyChoiceList

 /**
  * @return array
  */
 protected function getPropertyChoiceList()
 {
     $choices = array();
     if (!$this->entityClass) {
         return $choices;
     }
     $fields = $this->configProvider->filter(function (Config $config) {
         return in_array($config->getId()->getFieldType(), ['integer', 'string', 'smallint', 'decimal', 'bigint', 'text', 'money']) && $config->is('is_deleted', false);
     }, $this->entityClass);
     $entityConfigProvider = $this->configProvider->getConfigManager()->getProvider('entity');
     foreach ($fields as $field) {
         $label = $entityConfigProvider->getConfigById($field->getId())->get('label');
         $choices[$field->getId()->getFieldName()] = $label ?: $field->getId()->getFieldName();
     }
     return $choices;
 }
开发者ID:xamin123,项目名称:platform,代码行数:19,代码来源:TargetFieldType.php

示例7: prepareConfiguration

 /**
  * Prepare configuration from entity config
  *
  * @return array
  */
 private function prepareConfiguration()
 {
     $configuration = array();
     foreach ($this->configProvider->getIds() as $entityConfigId) {
         $className = $entityConfigId->getClassName();
         $fields = $this->configProvider->filter(function (ConfigInterface $fieldConfig) {
             return $fieldConfig->is('available_in_template');
         }, $className);
         if (count($fields)) {
             $configuration[$className] = array();
             foreach ($fields as $fieldConfig) {
                 $configuration[$className][] = 'get' . strtolower($fieldConfig->getId()->getFieldName());
             }
         }
     }
     return $configuration;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:22,代码来源:EmailRenderer.php

示例8: getActivityTypes

 /**
  * Returns the list of FQCN of all activity entities
  *
  * @return string[]
  */
 public function getActivityTypes()
 {
     return array_values(array_map(function (ConfigInterface $config) {
         return $config->getId()->getClassName();
     }, $this->groupingConfigProvider->filter(function (ConfigInterface $config) {
         // filter activity entities
         $groups = $config->get('groups');
         return !empty($groups) && in_array(ActivityScope::GROUP_ACTIVITY, $groups, true);
     })));
 }
开发者ID:northdakota,项目名称:platform,代码行数:15,代码来源:ActivityManager.php

示例9: getFields

 /**
  * @param object      $entity
  * @param null|string $entityClass
  * @return array
  */
 public function getFields($entity, $entityClass = null)
 {
     $dynamicRow = [];
     $priorities = [];
     if (null === $entityClass) {
         $entityClass = ClassUtils::getRealClass($entity);
     }
     $fields = $this->extendProvider->filter([$this, 'filterFields'], $entityClass);
     foreach ($fields as $field) {
         /** @var FieldConfigId $fieldConfigId */
         $fieldConfigId = $field->getId();
         $fieldName = $fieldConfigId->getFieldName();
         $fieldType = $fieldConfigId->getFieldType();
         $value = $this->propertyAccessor->getValue($entity, $fieldName);
         $event = new ValueRenderEvent($entity, $value, $fieldConfigId);
         $this->eventDispatcher->dispatch(EntityExtendEvents::BEFORE_VALUE_RENDER, $event);
         $fieldConfig = $this->entityProvider->getConfigById($fieldConfigId);
         $dynamicRow[$fieldName] = ['type' => $fieldType, 'label' => $fieldConfig->get('label') ?: $fieldName, 'value' => $event->getFieldViewValue()];
         $priorities[] = $this->viewProvider->getConfigById($fieldConfigId)->get('priority', false, 0);
     }
     array_multisort($priorities, SORT_DESC, $dynamicRow);
     return $dynamicRow;
 }
开发者ID:eltrino,项目名称:platform,代码行数:28,代码来源:DynamicFieldsExtension.php

示例10: testGetConfigs

 public function testGetConfigs()
 {
     $this->configManager->expects($this->exactly(4))->method('getIds')->with('testScope', DemoEntity::ENTITY_NAME)->will($this->returnValue(array($this->entityConfig->getId())));
     $this->assertEquals(array($this->entityConfig->getId()), $this->configProvider->getIds(DemoEntity::ENTITY_NAME));
     $this->assertEquals(array($this->entityConfig), $this->configProvider->getConfigs(DemoEntity::ENTITY_NAME));
     $this->assertEquals(array(), $this->configProvider->filter(function (ConfigInterface $config) {
         return $config->getId()->getScope() == 'wrongScope';
     }, DemoEntity::ENTITY_NAME));
     $entityConfig = new Config(new EntityConfigId(DemoEntity::ENTITY_NAME, 'testScope'));
     $entityConfig->set('key', 'value');
     $this->assertEquals(array($entityConfig), $this->configProvider->map(function (ConfigInterface $config) {
         return $config->set('key', 'value');
     }, DemoEntity::ENTITY_NAME));
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:14,代码来源:ConfigProviderTest.php

示例11: checkSchema

 /**
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  *
  * @param ConfigInterface $extendConfig
  * @param array|null $aliases
  * @param array|null $skippedOrigins
  */
 protected function checkSchema(ConfigInterface $extendConfig, $aliases, array $skippedOrigins = null)
 {
     $className = $extendConfig->getId()->getClassName();
     $doctrine = [];
     $entityName = $className;
     if (ExtendHelper::isCustomEntity($className)) {
         $type = 'Custom';
         $tableName = $extendConfig->get('table');
         if (!$tableName) {
             $tableName = $this->nameGenerator->generateCustomEntityTableName($className);
         }
         $doctrine[$entityName] = ['type' => 'entity', 'table' => $tableName];
         // add 'id' field only for Custom entity without inheritance
         if (!$extendConfig->has('inherit')) {
             $doctrine[$entityName]['fields'] = ['id' => ['type' => 'integer', 'id' => true, 'generator' => ['strategy' => 'AUTO']]];
         }
     } else {
         $type = 'Extend';
         $entityName = $extendConfig->get('extend_class');
         $doctrine[$entityName] = ['type' => 'mappedSuperclass', 'fields' => []];
     }
     $schema = $extendConfig->get('schema');
     $properties = [];
     $relationProperties = $schema ? $schema['relation'] : [];
     $defaultProperties = [];
     $addRemoveMethods = [];
     $fieldConfigs = $this->configProvider->filter($this->createOriginFilterCallback($skippedOrigins), $className, true);
     foreach ($fieldConfigs as $fieldConfig) {
         $this->checkFields($entityName, $fieldConfig, $relationProperties, $defaultProperties, $properties, $doctrine);
         $this->configProvider->persist($fieldConfig);
     }
     $relations = $extendConfig->get('relation', false, []);
     foreach ($relations as $relation) {
         /** @var FieldConfigId $fieldId */
         $fieldId = $relation['field_id'];
         if (!$fieldId) {
             continue;
         }
         $fieldName = $fieldId->getFieldName();
         if (!isset($relationProperties[$fieldName])) {
             $relationProperties[$fieldName] = $fieldName;
         }
         if ($fieldId->getFieldType() !== RelationType::MANY_TO_ONE) {
             $addRemoveMethods[$fieldName]['self'] = $fieldName;
             /** @var FieldConfigId $targetFieldId */
             $targetFieldId = $relation['target_field_id'];
             if ($targetFieldId) {
                 $fieldType = $fieldId->getFieldType();
                 $addRemoveMethods[$fieldName]['target'] = $targetFieldId->getFieldName();
                 $addRemoveMethods[$fieldName]['is_target_addremove'] = $fieldType === RelationType::MANY_TO_MANY;
             }
         }
     }
     $schema = ['class' => $className, 'entity' => $entityName, 'type' => $type, 'property' => $properties, 'relation' => $relationProperties, 'default' => $defaultProperties, 'addremove' => $addRemoveMethods, 'doctrine' => $doctrine];
     if ($type === 'Extend') {
         $parentClassName = get_parent_class($className);
         if ($parentClassName === $entityName) {
             $parentClassName = $aliases[$entityName];
         }
         $schema['parent'] = $parentClassName;
         $schema['inherit'] = get_parent_class($parentClassName);
     } elseif ($extendConfig->has('inherit')) {
         $schema['inherit'] = $extendConfig->get('inherit');
     }
     $extendConfig->set('schema', $schema);
     $this->configProvider->persist($extendConfig);
 }
开发者ID:2ndkauboy,项目名称:platform,代码行数:75,代码来源:ExtendConfigDumper.php


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