本文整理汇总了PHP中Drupal\Core\Field\FieldTypePluginManagerInterface类的典型用法代码示例。如果您正苦于以下问题:PHP FieldTypePluginManagerInterface类的具体用法?PHP FieldTypePluginManagerInterface怎么用?PHP FieldTypePluginManagerInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FieldTypePluginManagerInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructs a new DisplayOverviewBase.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager
* The field type manager.
* @param \Drupal\Component\Plugin\PluginManagerBase $plugin_manager
* The widget or formatter plugin manager.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration factory.
*/
public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, PluginManagerBase $plugin_manager, ConfigFactoryInterface $config_factory)
{
parent::__construct($entity_manager);
$this->fieldTypes = $field_type_manager->getDefinitions();
$this->pluginManager = $plugin_manager;
$this->configFactory = $config_factory;
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:19,代码来源:DisplayOverviewBase.php
示例2: __construct
/**
* Constructs a new FieldStorageConfigListBuilder object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager
* The 'field type' plugin manager.
*/
public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, EntityTypeBundleInfoInterface $bundle_info_service)
{
parent::__construct($entity_type, $entity_manager->getStorage($entity_type->id()));
$this->entityManager = $entity_manager;
$this->bundles = $bundle_info_service->getAllBundleInfo();
$this->fieldTypeManager = $field_type_manager;
$this->fieldTypes = $this->fieldTypeManager->getDefinitions();
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:18,代码来源:FieldStorageConfigListBuilder.php
示例3: __construct
/**
* Constructs a new FieldStorageConfigListBuilder object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager
* The 'field type' plugin manager.
*/
public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager)
{
parent::__construct($entity_type, $entity_manager->getStorage($entity_type->id()));
$this->entityManager = $entity_manager;
$this->bundles = entity_get_bundles();
$this->fieldTypeManager = $field_type_manager;
$this->fieldTypes = $this->fieldTypeManager->getDefinitions();
}
开发者ID:anatalsceo,项目名称:en-classe,代码行数:18,代码来源:FieldStorageConfigListBuilder.php
示例4: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
parent::setUp();
$this->entityManager = $this->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
$this->formatterPluginManager = $this->getMockBuilder('Drupal\\Core\\Field\\FormatterPluginManager')->disableOriginalConstructor()->getMock();
$this->fieldTypePluginManager = $this->getMock('Drupal\\Core\\Field\\FieldTypePluginManagerInterface');
$this->fieldTypePluginManager->expects($this->any())->method('getDefaultStorageSettings')->willReturn([]);
$this->fieldTypePluginManager->expects($this->any())->method('getDefaultFieldSettings')->willReturn([]);
$this->languageManager = $this->getMock('Drupal\\Core\\Language\\LanguageManagerInterface');
$this->renderer = $this->getMock('Drupal\\Core\\Render\\RendererInterface');
$this->setupExecutableAndView();
$this->setupViewsData();
$this->display = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')->disableOriginalConstructor()->getMock();
$this->container = new ContainerBuilder();
$this->container->set('plugin.manager.field.field_type', $this->fieldTypePluginManager);
\Drupal::setContainer($this->container);
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:20,代码来源:FieldTest.php
示例5: __construct
/**
* Constructs a new EntityDisplayFormBase.
*
* @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager
* The field type manager.
* @param \Drupal\Component\Plugin\PluginManagerBase $plugin_manager
* The widget or formatter plugin manager.
*/
public function __construct(FieldTypePluginManagerInterface $field_type_manager, PluginManagerBase $plugin_manager)
{
$this->fieldTypes = $field_type_manager->getDefinitions();
$this->pluginManager = $plugin_manager;
}
开发者ID:Greg-Boggs,项目名称:electric-dev,代码行数:13,代码来源:EntityDisplayFormBase.php
示例6: mapToStorageRecord
/**
* {@inheritdoc}
*/
protected function mapToStorageRecord(EntityInterface $entity)
{
$record = parent::mapToStorageRecord($entity);
$class = $this->fieldTypeManager->getPluginClass($record['field_type']);
$record['settings'] = $class::fieldSettingsToConfigData($record['settings']);
return $record;
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:10,代码来源:FieldConfigStorageBase.php
示例7: getDerivativeDefinitions
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition)
{
foreach ($this->fieldTypePluginManager->getDefinitions() as $plugin_id => $definition) {
$definition['definition_class'] = '\\Drupal\\Core\\Field\\TypedData\\FieldItemDataDefinition';
$definition['list_definition_class'] = '\\Drupal\\Core\\Field\\FieldDefinition';
$this->derivatives[$plugin_id] = $definition;
}
return $this->derivatives;
}
开发者ID:anatalsceo,项目名称:en-classe,代码行数:12,代码来源:FieldItemDeriver.php
示例8: calculateDependencies
/**
* {@inheritdoc}
*/
public function calculateDependencies()
{
$this->dependencies = parent::calculateDependencies();
// Add a dependency on the module that provides the field type using the
// source plugin configuration.
$source_configuration = $this->migration->get('source');
if (isset($source_configuration['constants']['type'])) {
$field_type = $this->fieldTypePluginManager->getDefinition($source_configuration['constants']['type']);
$this->addDependency('module', $field_type['provider']);
}
return $this->dependencies;
}
开发者ID:papillon-cendre,项目名称:d8,代码行数:15,代码来源:EntityFieldStorageConfig.php
示例9: processStubRow
/**
* Populates as much of the stub row as possible.
*
* @param \Drupal\migrate\Row $row
* The row of data.
*/
protected function processStubRow(Row $row)
{
$bundle_key = $this->getKey('bundle');
if ($bundle_key && empty($row->getDestinationProperty($bundle_key))) {
if (empty($this->bundles)) {
throw new MigrateException('Stubbing failed, no bundles available for entity type: ' . $this->storage->getEntityTypeId());
}
$row->setDestinationProperty($bundle_key, reset($this->bundles));
}
// Populate any required fields not already populated.
$fields = $this->entityManager->getFieldDefinitions($this->storage->getEntityTypeId(), $bundle_key);
foreach ($fields as $field_name => $field_definition) {
if ($field_definition->isRequired() && is_null($row->getDestinationProperty($field_name))) {
// Use the configured default value for this specific field, if any.
if ($default_value = $field_definition->getDefaultValueLiteral()) {
$values[] = $default_value;
} else {
// Otherwise, ask the field type to generate a sample value.
$field_type = $field_definition->getType();
/** @var \Drupal\Core\Field\FieldItemInterface $field_type_class */
$field_type_class = $this->fieldTypeManager->getPluginClass($field_definition->getType());
$values = $field_type_class::generateSampleValue($field_definition);
if (is_null($values)) {
// Handle failure to generate a sample value.
throw new MigrateException('Stubbing failed, unable to generate value for field ' . $field_name);
}
}
$row->setDestinationProperty($field_name, $values);
}
}
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:37,代码来源:EntityContentBase.php
示例10: getExistingFieldOptions
/**
* Returns an array of existing fields to be added to a bundle.
*
* @return array
* An array of existing fields keyed by field name.
*/
protected function getExistingFieldOptions()
{
$options = array();
// Collect candidate field instances: all instances of fields for this
// entity type that are not already present in the current bundle.
$field_map = \Drupal::entityManager()->getFieldMap();
$instance_ids = array();
if (!empty($field_map[$this->entity_type])) {
foreach ($field_map[$this->entity_type] as $field_name => $data) {
if (!in_array($this->bundle, $data['bundles'])) {
$bundle = reset($data['bundles']);
$instance_ids[] = $this->entity_type . '.' . $bundle . '.' . $field_name;
}
}
}
// Load the instances and build the list of options.
if ($instance_ids) {
$field_types = $this->fieldTypeManager->getDefinitions();
$instances = $this->entityManager->getStorage('field_instance_config')->loadMultiple($instance_ids);
foreach ($instances as $instance) {
// Do not show:
// - locked fields,
// - fields that should not be added via user interface.
$field_type = $instance->getType();
$field_storage = $instance->getFieldStorageDefinition();
if (empty($field_storage->locked) && empty($field_types[$field_type]['no_ui'])) {
$options[$instance->getName()] = array('type' => $field_type, 'type_label' => $field_types[$field_type]['label'], 'field' => $instance->getName(), 'label' => $instance->getLabel());
}
}
}
return $options;
}
开发者ID:anatalsceo,项目名称:en-classe,代码行数:38,代码来源:FieldOverview.php
示例11: testOnDependencyRemoval
/**
* @covers ::onDependencyRemoval
*/
public function testOnDependencyRemoval()
{
$this->fieldTypePluginManager->expects($this->any())->method('getDefinition')->with('test_field')->willReturn(['class' => '\\Drupal\\Tests\\field\\Unit\\DependencyFieldItem']);
$field = new FieldConfig(['field_name' => $this->fieldStorage->getName(), 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle', 'field_type' => 'test_field', 'dependencies' => ['module' => ['fruiter']], 'third_party_settings' => ['fruiter' => ['fruit' => 'apple']]]);
$changed = $field->onDependencyRemoval(['module' => ['fruiter']]);
$this->assertTrue($changed);
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:10,代码来源:FieldConfigEntityUnitTest.php
示例12: testCalculateDependencies
/**
* @covers ::calculateDependencies
*/
public function testCalculateDependencies()
{
// Create a mock entity type for FieldStorageConfig.
$fieldStorageConfigentityType = $this->getMock('\\Drupal\\Core\\Config\\Entity\\ConfigEntityTypeInterface');
$fieldStorageConfigentityType->expects($this->any())->method('getProvider')->will($this->returnValue('field'));
// Create a mock entity type to attach the field to.
$attached_entity_type_id = $this->randomMachineName();
$attached_entity_type = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
$attached_entity_type->expects($this->any())->method('getProvider')->will($this->returnValue('entity_provider_module'));
// Get definition is called three times. Twice in
// ConfigEntityBase::addDependency() to get the provider of the field config
// entity type and once in FieldStorageConfig::calculateDependencies() to
// get the provider of the entity type that field is attached to.
$this->entityManager->expects($this->any())->method('getDefinition')->willReturnMap([['field_storage_config', TRUE, $fieldStorageConfigentityType], [$attached_entity_type_id, TRUE, $attached_entity_type]]);
$this->fieldTypeManager->expects($this->atLeastOnce())->method('getDefinition')->with('test_field_type', FALSE)->willReturn(['class' => TestFieldType::class]);
$field_storage = new FieldStorageConfig(['entity_type' => $attached_entity_type_id, 'field_name' => 'test_field', 'type' => 'test_field_type', 'module' => 'test_module']);
$dependencies = $field_storage->calculateDependencies()->getDependencies();
$this->assertEquals(['entity_provider_module', 'entity_test', 'test_module'], $dependencies['module']);
$this->assertEquals(['stark'], $dependencies['theme']);
}
开发者ID:HakS,项目名称:drupal8_training,代码行数:23,代码来源:FieldStorageConfigEntityUnitTest.php
示例13: testCalculateDependenciesIncorrectBundle
/**
* Test that invalid bundles are handled.
*
* @expectedException \LogicException
* @expectedExceptionMessage Missing bundle entity, entity type bundle_entity_type, entity id test_bundle_not_exists.
*/
public function testCalculateDependenciesIncorrectBundle()
{
$storage = $this->getMock('\\Drupal\\Core\\Config\\Entity\\ConfigEntityStorageInterface');
$storage->expects($this->any())->method('load')->with('test_bundle_not_exists')->will($this->returnValue(NULL));
$this->entityManager->expects($this->any())->method('getStorage')->with('bundle_entity_type')->will($this->returnValue($storage));
$target_entity_type = new EntityType(array('id' => 'test_entity_type', 'bundle_entity_type' => 'bundle_entity_type'));
$this->entityManager->expects($this->at(0))->method('getDefinition')->with($this->entityTypeId)->willReturn($this->entityType);
$this->entityManager->expects($this->at(1))->method('getDefinition')->with($this->entityTypeId)->willReturn($this->entityType);
$this->entityManager->expects($this->at(2))->method('getDefinition')->with($this->entityTypeId)->willReturn($this->entityType);
$this->entityManager->expects($this->at(3))->method('getDefinition')->with('test_entity_type')->willReturn($target_entity_type);
$this->fieldTypePluginManager->expects($this->any())->method('getDefinition')->with('test_field')->willReturn(['provider' => 'test_module', 'config_dependencies' => ['module' => ['test_module2']], 'class' => '\\Drupal\\Tests\\field\\Unit\\DependencyFieldItem']);
$field = new FieldConfig(array('field_name' => $this->fieldStorage->getName(), 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle_not_exists', 'field_type' => 'test_field'), $this->entityTypeId);
$field->calculateDependencies();
}
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:20,代码来源:FieldConfigEntityUnitTest.php
示例14: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $field_config)
{
/** @var \Drupal\field\FieldConfigInterface $field_config */
$field_storage = $field_config->getFieldStorageDefinition();
$route_parameters = array('field_config' => $field_config->id()) + FieldUI::getRouteBundleParameter($this->entityManager->getDefinition($this->targetEntityTypeId), $this->targetBundle);
$row = array('id' => Html::getClass($field_config->getName()), 'data' => array('label' => $field_config->getLabel(), 'field_name' => $field_config->getName(), 'field_type' => array('data' => array('#type' => 'link', '#title' => $this->fieldTypeManager->getDefinitions()[$field_storage->getType()]['label'], '#url' => Url::fromRoute("entity.field_config.{$this->targetEntityTypeId}_storage_edit_form", $route_parameters), '#options' => array('attributes' => array('title' => $this->t('Edit field settings.')))))));
// Add the operations.
$row['data'] = $row['data'] + parent::buildRow($field_config);
if ($field_storage->isLocked()) {
$row['data']['operations'] = array('data' => array('#markup' => $this->t('Locked')));
$row['class'][] = 'menu-disabled';
}
return $row;
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:17,代码来源:FieldConfigListBuilder.php
示例15: getExistingFieldStorageOptions
/**
* Returns an array of existing field storages that can be added to a bundle.
*
* @return array
* An array of existing field storages keyed by name.
*/
protected function getExistingFieldStorageOptions()
{
$options = array();
// Load the field_storages and build the list of options.
$field_types = $this->fieldTypePluginManager->getDefinitions();
foreach ($this->entityManager->getFieldStorageDefinitions($this->entityTypeId) as $field_name => $field_storage) {
// Do not show:
// - non-configurable field storages,
// - locked field storages,
// - field storages that should not be added via user interface,
// - field storages that already have a field in the bundle.
$field_type = $field_storage->getType();
if ($field_storage instanceof FieldStorageConfigInterface && !$field_storage->isLocked() && empty($field_types[$field_type]['no_ui']) && !in_array($this->bundle, $field_storage->getBundles(), TRUE)) {
$options[$field_name] = $this->t('@type: @field', array('@type' => $field_types[$field_type]['label'], '@field' => $field_name));
}
}
asort($options);
return $options;
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:25,代码来源:FieldStorageAddForm.php
示例16: getOptions
/**
* Returns an array of widget type options for a field type.
*
* @param string|null $field_type
* (optional) The name of a field type, or NULL to retrieve all widget
* options. Defaults to NULL.
*
* @return array
* If no field type is provided, returns a nested array of all widget types,
* keyed by field type human name.
*/
public function getOptions($field_type = NULL)
{
if (!isset($this->widgetOptions)) {
$options = array();
$field_types = $this->fieldTypeManager->getDefinitions();
$widget_types = $this->getDefinitions();
uasort($widget_types, array('Drupal\\Component\\Utility\\SortArray', 'sortByWeightElement'));
foreach ($widget_types as $name => $widget_type) {
foreach ($widget_type['field_types'] as $widget_field_type) {
// Check that the field type exists.
if (isset($field_types[$widget_field_type])) {
$options[$widget_field_type][$name] = $widget_type['label'];
}
}
}
$this->widgetOptions = $options;
}
if (isset($field_type)) {
return !empty($this->widgetOptions[$field_type]) ? $this->widgetOptions[$field_type] : array();
}
return $this->widgetOptions;
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:33,代码来源:WidgetPluginManager.php
示例17: testCalculateDependencies
/**
* @covers ::calculateDependencies
*/
public function testCalculateDependencies()
{
// Mock the interfaces necessary to create a dependency on a bundle entity.
$bundle_entity = $this->getMock('Drupal\\Core\\Config\\Entity\\ConfigEntityInterface');
$bundle_entity->expects($this->any())->method('getConfigDependencyName')->will($this->returnValue('test.test_entity_type.id'));
$storage = $this->getMock('\\Drupal\\Core\\Config\\Entity\\ConfigEntityStorageInterface');
$storage->expects($this->any())->method('load')->with('test_bundle')->will($this->returnValue($bundle_entity));
$this->entityManager->expects($this->any())->method('getStorage')->with('bundle_entity_type')->will($this->returnValue($storage));
$target_entity_type = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
$target_entity_type->expects($this->any())->method('getBundleEntityType')->will($this->returnValue('bundle_entity_type'));
$this->entityManager->expects($this->at(0))->method('getDefinition')->with($this->entityTypeId)->willReturn($this->entityType);
$this->entityManager->expects($this->at(1))->method('getDefinition')->with($this->entityTypeId)->willReturn($this->entityType);
$this->entityManager->expects($this->at(2))->method('getDefinition')->with($this->entityTypeId)->willReturn($this->entityType);
$this->entityManager->expects($this->at(3))->method('getDefinition')->with('test_entity_type')->willReturn($target_entity_type);
$this->fieldTypePluginManager->expects($this->any())->method('getDefinition')->with('test_field')->willReturn(['provider' => 'test_module', 'config_dependencies' => ['module' => ['test_module2']], 'class' => '\\Drupal\\Tests\\field\\Unit\\DependencyFieldItem']);
$this->fieldStorage->expects($this->once())->method('getConfigDependencyName')->will($this->returnValue('field.storage.test_entity_type.test_field'));
$field = new FieldConfig(array('field_name' => $this->fieldStorage->getName(), 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle', 'field_type' => 'test_field'), $this->entityTypeId);
$dependencies = $field->calculateDependencies();
$this->assertContains('field.storage.test_entity_type.test_field', $dependencies['config']);
$this->assertContains('test.test_entity_type.id', $dependencies['config']);
$this->assertEquals(['test_module', 'test_module2', 'test_module3'], $dependencies['module']);
}
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:25,代码来源:FieldConfigEntityUnitTest.php
示例18: getFieldTypeDefinition
/**
* Gets field type definition.
*
* @return array
* The field type definition.
*/
protected function getFieldTypeDefinition()
{
return $this->fieldTypeManager->getDefinition($this->getFieldStorageDefinition()->getType());
}
开发者ID:Wylbur,项目名称:gj,代码行数:10,代码来源:EntityField.php
示例19: getFieldTypeLabel
/**
* Returns the label for a specified field type.
*
* @param string $field_type
* The field type.
*
* @return string
* The field type label.
*/
protected function getFieldTypeLabel($field_type)
{
return $this->fieldTypeManager->getDefinitions()[$field_type]['label'];
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:13,代码来源:FieldUninstallValidator.php
示例20: getEntityRevisionDestination
/**
* Helper method to create an entity revision destination with mock services.
*
* @see \Drupal\Tests\migrate\Unit\Destination\EntityRevision
*
* @param $configuration
* Configuration for the destination.
* @param string $plugin_id
* The plugin id.
* @param array $plugin_definition
* The plugin definition.
*
* @return \Drupal\Tests\migrate\Unit\destination\EntityRevision
* Mocked destination.
*/
protected function getEntityRevisionDestination(array $configuration = [], $plugin_id = 'entity_revision', array $plugin_definition = [])
{
return new EntityRevision($configuration, $plugin_id, $plugin_definition, $this->migration->reveal(), $this->storage->reveal(), [], $this->entityManager->reveal(), $this->fieldTypeManager->reveal());
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:19,代码来源:EntityRevisionTest.php
注:本文中的Drupal\Core\Field\FieldTypePluginManagerInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论