本文整理汇总了PHP中Oro\Bundle\EntityConfigBundle\Provider\ConfigProvider::getIds方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigProvider::getIds方法的具体用法?PHP ConfigProvider::getIds怎么用?PHP ConfigProvider::getIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EntityConfigBundle\Provider\ConfigProvider
的用法示例。
在下文中一共展示了ConfigProvider::getIds方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$fields = [];
$className = $options['className'];
$fieldConfigIds = $this->entityProvider->getIds($className);
/** @var FieldConfigId $fieldConfigId */
foreach ($fieldConfigIds as $fieldConfigId) {
if ($fieldConfigId->getFieldType() === RelationTypeBase::TO_MANY) {
continue;
}
$fieldName = $fieldConfigId->getFieldName();
$fields[$fieldName] = $this->entityProvider->getConfig($className, $fieldName)->get('label', false, ucfirst($fieldName));
}
$builder->add('keys', 'collection', array('required' => true, 'type' => new UniqueKeyType($fields), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'prototype_name' => 'tag__name__', 'label' => false, 'constraints' => [new UniqueKeys()]));
}
示例3: getMetadata
/**
* {@inheritdoc}
*/
public function getMetadata()
{
$metadata = parent::getMetadata();
$entityIds = [];
$configIds = $this->entityConfigProvider->getIds();
foreach ($configIds as $configId) {
$className = $configId->getClassName();
if ($this->extendConfigProvider->getConfig($className)->in('state', [ExtendScope::STATE_ACTIVE, ExtendScope::STATE_UPDATE])) {
$classMetadata = $this->doctrine->getManagerForClass($className)->getClassMetadata($className);
$identifiers = $classMetadata->getIdentifier();
$entityIds[$className] = array_shift($identifiers);
}
}
$metadata['entity_ids'] = $entityIds;
return $metadata;
}
示例4: preSetData
/**
* @param FormEvent $event
*/
public function preSetData(FormEvent $event)
{
$form = $event->getForm();
$entityClass = $form->getConfig()->getDataClass();
/** @var FieldConfigId[] $fieldConfigIds */
$fieldConfigIds = $this->extendConfigProvider->getIds($entityClass);
foreach ($fieldConfigIds as $fieldConfigId) {
if ($fieldConfigId->getFieldType() === 'manyToOne') {
$fieldEntityConfig = $this->entityConfigProvider->getConfigById($fieldConfigId);
$fieldExtendConfig = $this->extendConfigProvider->getConfigById($fieldConfigId);
if (!$fieldExtendConfig->is('state', ExtendScope::STATE_ACTIVE)) {
continue;
}
$form->add($fieldConfigId->getFieldName(), 'entity', ['required' => false, 'class' => $fieldExtendConfig->get('target_entity'), 'property' => $fieldExtendConfig->get('target_field'), 'label' => $fieldEntityConfig->get('label')]);
}
}
}
示例5: 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;
}
示例6: getVariableGetters
/**
* {@inheritdoc}
*/
public function getVariableGetters($entityClass = null)
{
if ($entityClass) {
// process the specified entity only
return $this->getEntityVariableGetters($entityClass);
}
// process all entities
$result = [];
$entityIds = $this->entityConfigProvider->getIds();
foreach ($entityIds as $entityId) {
$className = $entityId->getClassName();
$entityData = $this->getEntityVariableGetters($className);
if (!empty($entityData)) {
$result[$className] = $entityData;
}
}
return $result;
}
示例7: 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));
}
示例8: getUnidirectionalRelations
/**
* Return mapping data for entities that has one-way link to $className entity
*
* @param string $className
*
* @return array
*/
protected function getUnidirectionalRelations($className)
{
$relations = [];
/** @var EntityConfigId[] $entityConfigIds */
$entityConfigIds = $this->entityConfigProvider->getIds();
foreach ($entityConfigIds as $entityConfigId) {
if ($this->isIgnoredEntity($entityConfigId)) {
continue;
}
$metadata = $this->getMetadataFor($entityConfigId->getClassName());
$targetMappings = $metadata->getAssociationMappings();
if (empty($targetMappings)) {
continue;
}
foreach ($targetMappings as $mapping) {
if ($mapping['isOwningSide'] && empty($mapping['inversedBy']) && $mapping['targetEntity'] === $className) {
$relations[$mapping['sourceEntity'] . '::' . $mapping['fieldName']] = $mapping;
}
}
}
return $relations;
}
示例9: testGetIdsWithHidden
public function testGetIdsWithHidden()
{
$this->configManager->expects($this->once())->method('getIds')->with('testScope', DemoEntity::ENTITY_NAME, true)->will($this->returnValue(array($this->entityConfig->getId())));
$this->assertEquals(array($this->entityConfig->getId()), $this->configProvider->getIds(DemoEntity::ENTITY_NAME, true));
}