diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 48ee728..21a4a4f 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -41,50 +41,7 @@ function entity_get_info($entity_type = NULL) { $entity_info = $cache->data; } else { - $entity_info = module_invoke_all('entity_info'); - // Merge in default values. - foreach ($entity_info as $name => $data) { - $entity_info[$name] += array( - 'fieldable' => FALSE, - 'entity class' => 'Drupal\Core\Entity\Entity', - 'controller class' => 'Drupal\Core\Entity\DatabaseStorageController', - 'list controller class' => 'Drupal\Core\Entity\EntityListController', - 'render controller class' => 'Drupal\Core\Entity\EntityRenderController', - 'form controller class' => array( - 'default' => 'Drupal\Core\Entity\EntityFormController', - ), - 'static cache' => TRUE, - 'field cache' => TRUE, - 'bundles' => array(), - 'view modes' => array(), - 'entity keys' => array(), - 'translation' => array(), - ); - $entity_info[$name]['entity keys'] += array( - 'revision' => '', - 'bundle' => '', - ); - foreach ($entity_info[$name]['view modes'] as $view_mode => $view_mode_info) { - $entity_info[$name]['view modes'][$view_mode] += array( - 'custom settings' => FALSE, - ); - } - // If no bundle key is provided, assume a single bundle, named after - // the entity type. - if (empty($entity_info[$name]['entity keys']['bundle']) && empty($entity_info[$name]['bundles'])) { - $entity_info[$name]['bundles'] = array($name => array('label' => $entity_info[$name]['label'])); - } - // Prepare entity schema fields SQL info for - // Drupal\Core\Entity\DatabaseStorageControllerInterface::buildQuery(). - if (isset($entity_info[$name]['base table'])) { - $entity_info[$name]['schema_fields_sql']['base table'] = drupal_schema_fields_sql($entity_info[$name]['base table']); - if (isset($entity_info[$name]['revision table'])) { - $entity_info[$name]['schema_fields_sql']['revision table'] = drupal_schema_fields_sql($entity_info[$name]['revision table']); - } - } - } - // Let other modules alter the entity info. - drupal_alter('entity_info', $entity_info); + $entity_info = drupal_container()->get('plugin.manager.entity')->getDefinitions(); cache()->set("entity_info:$langcode", $entity_info, CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE)); } } diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php index f1e43d6..2ad563b 100644 --- a/core/lib/Drupal/Core/CoreBundle.php +++ b/core/lib/Drupal/Core/CoreBundle.php @@ -66,6 +66,8 @@ public function build(ContainerBuilder $container) { $container->register('router.builder', 'Drupal\Core\Routing\RouteBuilder') ->addArgument(new Reference('router.dumper')); + $container->register('plugin.manager.entity', 'Drupal\Core\Plugin\Type\EntityManager'); + // @todo Replace below lines with the commented out block below it when it's // performant to do so: http://drupal.org/node/1706064. $dispatcher = $container->get('dispatcher'); diff --git a/core/lib/Drupal/Core/Plugin/Discovery/ModuleDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/ModuleDecorator.php new file mode 100644 index 0000000..8b7f475 --- /dev/null +++ b/core/lib/Drupal/Core/Plugin/Discovery/ModuleDecorator.php @@ -0,0 +1,68 @@ +decorated = $decorated; + } + + /** + * Implements Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinition(). + */ + public function getDefinition($plugin_id) { + $definitions = $this->getDefinitions(); + return isset($definitions[$plugin_id]) ? $definitions[$plugin_id] : NULL; + } + + + /** + * Implements Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinitions(). + * + * Loop through each definition, look for a 'module' key, and check it with + * module_exists(). + */ + public function getDefinitions() { + $definitions = array(); + foreach ($this->decorated->getDefinitions() as $plugin_id => $definition) { + if (isset($definition['module']) && module_exists($definition['module'])) { + $definitions[$plugin_id] = $definition; + } + } + return $definitions; + } + + /** + * Passes through all unknown calls onto the decorated object. + */ + public function __call($method, $args) { + return call_user_func_array(array($this->decorated, $method), $args); + } + +} diff --git a/core/lib/Drupal/Core/Plugin/Type/EntityManager.php b/core/lib/Drupal/Core/Plugin/Type/EntityManager.php new file mode 100644 index 0000000..710c56e --- /dev/null +++ b/core/lib/Drupal/Core/Plugin/Type/EntityManager.php @@ -0,0 +1,86 @@ +discovery = new ModuleDecorator(new AlterDecorator(new DerivativeDiscoveryDecorator(new AnnotatedClassDiscovery('Core', 'Entity')), 'entity_info')); + $this->factory = new DefaultFactory($this); + + $this->defaults = array( + 'fieldable' => FALSE, + 'entity class' => 'Drupal\Core\Entity\Entity', + 'controller class' => 'Drupal\Core\Entity\DatabaseStorageController', + 'list controller class' => 'Drupal\Core\Entity\EntityListController', + 'render controller class' => 'Drupal\Core\Entity\EntityRenderController', + 'form controller class' => array( + 'default' => 'Drupal\Core\Entity\EntityFormController', + ), + 'static cache' => TRUE, + 'field cache' => TRUE, + 'bundles' => array(), + 'view modes' => array(), + 'entity keys' => array(), + 'translation' => array(), + ); + } + + /** + * Overrides Drupal\Component\Plugin\PluginManagerBase::processDefinition(). + */ + protected function processDefinition(&$definition, $plugin_id) { + parent::processDefinition($definition, $plugin_id); + + foreach ($definition as $key => $value) { + if (strpos($key, '_') !== FALSE) { + $new_key = str_replace('_', ' ', $key); + $definition[$new_key] = $value; + } + } + if (isset($definition['class'])) { + $definition['entity class'] = $definition['class']; + } + + $definition['entity keys'] += array( + 'revision' => '', + 'bundle' => '', + ); + + foreach ($definition['view modes'] as $view_mode => $view_mode_info) { + $definition['view modes'][$view_mode] += array( + 'custom settings' => FALSE, + ); + } + + // If no bundle key is provided, assume a single bundle, named after + // the entity type. + if (empty($definition['entity keys']['bundle']) && empty($definition['bundles'])) { + $definition['bundles'] = array($plugin_id => array('label' => $definition['label'])); + } + // Prepare entity schema fields SQL info for + // Drupal\Core\Entity\DatabaseStorageControllerInterface::buildQuery(). + if (isset($definition['base table'])) { + $definition['schema_fields_sql']['base table'] = drupal_schema_fields_sql($definition['base table']); + if (isset($definition['revision table'])) { + $definition['schema_fields_sql']['revision table'] = drupal_schema_fields_sql($definition['revision table']); + } + } + } + +} diff --git a/core/modules/book/book.admin.inc b/core/modules/book/book.admin.inc index fbd8dda..27f5cae 100644 --- a/core/modules/book/book.admin.inc +++ b/core/modules/book/book.admin.inc @@ -5,7 +5,7 @@ * Admin page callbacks for the book module. */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; /** * Page callback: Returns an administrative overview of all books. diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 7c43e28..b0922aa 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -5,7 +5,7 @@ * Allows users to create and organize related content in an outline. */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\Core\Template\Attribute; /** @@ -253,6 +253,9 @@ function book_admin_paths() { */ function book_entity_info_alter(&$info) { // Add the 'Print' view mode for nodes. + if (!isset($info['node']['view modes'])) { + $info['node']['view modes'] = array(); + } $info['node']['view modes'] += array( 'print' => array( 'label' => t('Print'), diff --git a/core/modules/book/book.pages.inc b/core/modules/book/book.pages.inc index 90b2192..ae79318 100644 --- a/core/modules/book/book.pages.inc +++ b/core/modules/book/book.pages.inc @@ -5,7 +5,7 @@ * User page callbacks for the book module. */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; diff --git a/core/modules/book/lib/Drupal/book/Tests/BookTest.php b/core/modules/book/lib/Drupal/book/Tests/BookTest.php index a1a88c4..5f50fe8 100644 --- a/core/modules/book/lib/Drupal/book/Tests/BookTest.php +++ b/core/modules/book/lib/Drupal/book/Tests/BookTest.php @@ -7,7 +7,7 @@ namespace Drupal\book\Tests; -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\simpletest\WebTestBase; class BookTest extends WebTestBase { diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc index dcbd1bc..26e9c8b 100644 --- a/core/modules/comment/comment.admin.inc +++ b/core/modules/comment/comment.admin.inc @@ -5,7 +5,7 @@ * Admin page callbacks for the Comment module. */ -use Drupal\comment\Comment; +use Drupal\comment\Plugin\Core\Entity\Comment; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index df0a33a..cbaee66 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -9,8 +9,8 @@ * book page, etc. */ -use Drupal\node\Node; -use Drupal\file\File; +use Drupal\node\Plugin\Core\Entity\Node; +use Drupal\file\Plugin\Core\Entity\File; use Drupal\Core\Entity\EntityInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -76,7 +76,7 @@ */ const COMMENT_NODE_OPEN = 2; -use Drupal\comment\Comment; +use Drupal\comment\Plugin\Core\Entity\Comment; /** * Implements hook_help(). @@ -98,40 +98,18 @@ function comment_help($path, $arg) { } /** - * Implements hook_entity_info(). + * Implements hook_entity_info_alter(). */ -function comment_entity_info() { - $return = array( - 'comment' => array( - 'label' => t('Comment'), - 'base table' => 'comment', - 'uri callback' => 'comment_uri', - 'fieldable' => TRUE, - 'controller class' => 'Drupal\comment\CommentStorageController', - 'form controller class' => array( - 'default' => 'Drupal\comment\CommentFormController', - ), - 'entity class' => 'Drupal\comment\Comment', - 'entity keys' => array( - 'id' => 'cid', - 'bundle' => 'node_type', - 'label' => 'subject', - 'uuid' => 'uuid', - ), - 'bundles' => array(), - 'render controller class' => 'Drupal\comment\CommentRenderController', - 'view modes' => array( - 'full' => array( - 'label' => t('Full comment'), - 'custom settings' => FALSE, - ), - ), - 'static cache' => FALSE, +function comment_entity_info_alter(&$info) { + $info['comment']['view modes'] = array( + 'full' => array( + 'label' => t('Full comment'), + 'custom settings' => FALSE, ), ); foreach (node_type_get_names() as $type => $name) { - $return['comment']['bundles']['comment_node_' . $type] = array( + $info['comment']['bundles']['comment_node_' . $type] = array( 'label' => t('@node_type comment', array('@node_type' => $name)), // Provide the node type/bundle name for other modules, so it does not // have to be extracted manually from the bundle name. @@ -150,8 +128,6 @@ function comment_entity_info() { ), ); } - - return $return; } /** diff --git a/core/modules/comment/comment.pages.inc b/core/modules/comment/comment.pages.inc index 3d1ecb9..6263660 100644 --- a/core/modules/comment/comment.pages.inc +++ b/core/modules/comment/comment.pages.inc @@ -5,7 +5,7 @@ * User page callbacks for the Comment module. */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; diff --git a/core/modules/comment/lib/Drupal/comment/Comment.php b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php similarity index 67% rename from core/modules/comment/lib/Drupal/comment/Comment.php rename to core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php index ef6c16a..c2dd9f2 100644 --- a/core/modules/comment/lib/Drupal/comment/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php @@ -2,16 +2,39 @@ /** * @file - * Definition of Drupal\comment\Comment. + * Definition of Drupal\comment\Plugin\Core\Entity\Comment. */ -namespace Drupal\comment; +namespace Drupal\comment\Plugin\Core\Entity; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\Entity; +use Drupal\Core\Annotation\Plugin; +use Drupal\Core\Annotation\Translation; /** * Defines the comment entity class. + * + * @Plugin( + * id = "comment", + * label = @Translation("Comment"), + * module = "comment", + * controller_class = "Drupal\comment\CommentStorageController", + * render_controller_class = "Drupal\comment\CommentRenderController", + * form_controller_class = { + * "default" = "Drupal\comment\CommentFormController" + * }, + * base_table = "comment", + * uri_callback = "comment_uri", + * fieldable = TRUE, + * static_cache = FALSE, + * entity_keys = { + * "id" = "cid", + * "bundle" = "node_type", + * "label" = "subject", + * "uuid" = "uuid" + * } + * ) */ class Comment extends Entity implements ContentEntityInterface { diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php index deb2e40..adb3de9 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php @@ -7,7 +7,7 @@ namespace Drupal\comment\Tests; -use Drupal\comment\Comment; +use Drupal\comment\Plugin\Core\Entity\Comment; use Drupal\simpletest\WebTestBase; /** diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php index cd48f71..80698c1 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php @@ -8,7 +8,7 @@ namespace Drupal\config\Tests; use Drupal\simpletest\WebTestBase; -use Drupal\config_test\ConfigTest; +use Drupal\config_test\Plugin\Core\Entity\ConfigTest; use Drupal\Core\Entity\EntityStorageControllerInterface; /** diff --git a/core/modules/config/tests/config_test/config_test.module b/core/modules/config/tests/config_test/config_test.module index 44df4da..1ff2579 100644 --- a/core/modules/config/tests/config_test/config_test.module +++ b/core/modules/config/tests/config_test/config_test.module @@ -5,7 +5,7 @@ * Provides Config module hook implementations for testing purposes. */ -use Drupal\config_test\ConfigTest; +use Drupal\config_test\Plugin\Core\Entity\ConfigTest; require_once dirname(__FILE__) . '/config_test.hooks.inc'; @@ -75,29 +75,9 @@ function config_test_config_import_delete($name, $new_config, $old_config) { } /** - * Implements hook_entity_info(). - */ -function config_test_entity_info() { - $types['config_test'] = array( - 'label' => 'Test configuration', - 'controller class' => 'Drupal\Core\Config\Entity\ConfigStorageController', - 'entity class' => 'Drupal\config_test\ConfigTest', - 'list controller class' => 'Drupal\Core\Config\Entity\ConfigEntityListController', - 'uri callback' => 'config_test_uri', - 'config prefix' => 'config_test.dynamic', - 'entity keys' => array( - 'id' => 'id', - 'label' => 'label', - 'uuid' => 'uuid', - ), - ); - return $types; -} - -/** * Entity URI callback. * - * @param Drupal\config_test\ConfigTest $config_test + * @param Drupal\config_test\Plugin\Core\Entity\ConfigTest $config_test * A ConfigTest entity. */ function config_test_uri(ConfigTest $config_test) { @@ -156,7 +136,7 @@ function config_test_load($id) { /** * Saves a ConfigTest object. * - * @param Drupal\config_test\ConfigTest $config_test + * @param Drupal\config_test\Plugin\Core\Entity\ConfigTest $config_test * The ConfigTest object to save. */ function config_test_save(ConfigTest $config_test) { @@ -184,7 +164,7 @@ function config_test_list_page() { /** * Form constructor to add or edit a ConfigTest object. * - * @param Drupal\config_test\ConfigTest $config_test + * @param Drupal\config_test\Plugin\Core\Entity\ConfigTest $config_test * (optional) An existing ConfigTest object to edit. If omitted, the form * creates a new ConfigTest. */ @@ -260,7 +240,7 @@ function config_test_form_submit($form, &$form_state) { /** * Form constructor to delete a ConfigTest object. * - * @param Drupal\config_test\ConfigTest $config_test + * @param Drupal\config_test\Plugin\Core\Entity\ConfigTest $config_test * The ConfigTest object to delete. */ function config_test_delete_form($form, &$form_state, ConfigTest $config_test) { diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTest.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTest.php deleted file mode 100644 index e1df5c4..0000000 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTest.php +++ /dev/null @@ -1,45 +0,0 @@ - $entity->ftid, 'revision_id' => $entity->ftvid, 'bundle' => $entity->fttype, - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', ); $partial_entities[$id] = _field_create_entity_from_ids($ids); $partial_entities[$id]->$field_name = $entity->$field_name; @@ -116,7 +116,7 @@ function setUp() { // For each bundle, create an instance of each field, and 10 // entities with values for each field. $id = 0; - $this->entity_type = 'test_entity'; + $this->entity_type = 'test_entity:test_entity'; foreach ($this->bundles as $bundle) { foreach ($this->fields as $field) { $instance = array( @@ -164,7 +164,7 @@ function testDeleteFieldInstance() { ->fieldCondition($field) ->entityCondition('bundle', $bundle) ->execute(); - $this->assertEqual(count($found['test_entity']), 10, 'Correct number of entities found before deleting'); + $this->assertEqual(count($found['test_entity:test_entity']), 10, 'Correct number of entities found before deleting'); // Delete the instance. $instance = field_info_instance($this->entity_type, $field['field_name'], $bundle); @@ -181,7 +181,7 @@ function testDeleteFieldInstance() { ->fieldCondition($field) ->entityCondition('bundle', $bundle) ->execute(); - $this->assertTrue(!isset($found['test_entity']), 'No entities found after deleting'); + $this->assertTrue(!isset($found['test_entity:test_entity']), 'No entities found after deleting'); // There are 10 entities of this bundle when deleted fields are allowed, and // their values are correct. @@ -196,7 +196,7 @@ function testDeleteFieldInstance() { $entities[$ids->entity_id] = _field_create_entity_from_ids($ids); } field_attach_load($this->entity_type, $entities, FIELD_LOAD_CURRENT, array('field_id' => $field['id'], 'deleted' => 1)); - $this->assertEqual(count($found['test_entity']), 10, 'Correct number of entities found after deleting'); + $this->assertEqual(count($found['test_entity:test_entity']), 10, 'Correct number of entities found after deleting'); foreach ($entities as $id => $entity) { $this->assertEqual($this->entities[$id]->{$field['field_name']}, $entity->{$field['field_name']}, "Entity $id with deleted data loaded correctly"); } @@ -233,7 +233,7 @@ function testPurgeInstance() { ->entityCondition('bundle', $bundle) ->deleted(TRUE) ->execute(); - $this->assertEqual($count ? count($found['test_entity']) : count($found), $count, 'Correct number of entities found after purging 2'); + $this->assertEqual($count ? count($found['test_entity:test_entity']) : count($found), $count, 'Correct number of entities found after purging 2'); } // Check hooks invocations. diff --git a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php index 5ca210c..122c9ac 100644 --- a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php @@ -250,7 +250,7 @@ function testDeleteField() { // Create instances for each. $this->instance_definition = array( 'field_name' => $this->field['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'widget' => array( 'type' => 'test_field_widget', @@ -273,7 +273,7 @@ function testDeleteField() { // Make sure that this field's instance is marked as deleted when it is // specifically loaded. - $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE)); + $instance = field_read_instance('test_entity:test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE)); $this->assertTrue(!empty($instance['deleted']), 'An instance for a deleted field is marked for deletion.'); // Try to load the field normally and make sure it does not show up. @@ -281,13 +281,13 @@ function testDeleteField() { $this->assertTrue(empty($field), 'A deleted field is not loaded by default.'); // Try to load the instance normally and make sure it does not show up. - $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); + $instance = field_read_instance('test_entity:test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); $this->assertTrue(empty($instance), 'An instance for a deleted field is not loaded by default.'); // Make sure the other field (and its field instance) are not deleted. $another_field = field_read_field($this->another_field['field_name']); $this->assertTrue(!empty($another_field) && empty($another_field['deleted']), 'A non-deleted field is not marked for deletion.'); - $another_instance = field_read_instance('test_entity', $this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']); + $another_instance = field_read_instance('test_entity:test_entity', $this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']); $this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), 'An instance of a non-deleted field is not marked for deletion.'); // Try to create a new field the same name as a deleted field and @@ -296,7 +296,7 @@ function testDeleteField() { field_create_instance($this->instance_definition); $field = field_read_field($this->field['field_name']); $this->assertTrue(!empty($field) && empty($field['deleted']), 'A new field with a previously used name is created.'); - $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); + $instance = field_read_instance('test_entity:test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); $this->assertTrue(!empty($instance) && empty($instance['deleted']), 'A new instance for a previously used field name is created.'); // Save an entity with data for the field @@ -304,8 +304,8 @@ function testDeleteField() { $langcode = LANGUAGE_NOT_SPECIFIED; $values[0]['value'] = mt_rand(1, 127); $entity->{$field['field_name']}[$langcode] = $values; - $entity_type = 'test_entity'; - field_attach_insert('test_entity', $entity); + $entity_type = 'test_entity:test_entity'; + field_attach_insert('test_entity:test_entity', $entity); // Verify the field is present on load $entity = field_test_create_entity(0, 0, $this->instance_definition['bundle']); @@ -357,7 +357,7 @@ function testUpdateField() { $field_definition = field_create_field($field_definition); $instance = array( 'field_name' => 'field_update', - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', ); $instance = field_create_instance($instance); @@ -371,10 +371,10 @@ function testUpdateField() { $entity->field_update[LANGUAGE_NOT_SPECIFIED][$i]['value'] = $i; } // Save the entity. - field_attach_insert('test_entity', $entity); + field_attach_insert('test_entity:test_entity', $entity); // Load back and assert there are $cardinality number of values. $entity = field_test_create_entity($id, $id, $instance['bundle']); - field_attach_load('test_entity', array($id => $entity)); + field_attach_load('test_entity:test_entity', array($id => $entity)); $this->assertEqual(count($entity->field_update[LANGUAGE_NOT_SPECIFIED]), $field_definition['cardinality'], 'Cardinality is kept'); // Now check the values themselves. for ($delta = 0; $delta < $cardinality; $delta++) { diff --git a/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php b/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php index fdf5e88..f48923d 100644 --- a/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php @@ -39,7 +39,7 @@ function setUp() { ); $this->instance = array( 'field_name' => $this->field_name, - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'label' => $this->label, 'display' => array( @@ -73,7 +73,7 @@ function setUp() { */ function testFieldViewField() { // No display settings: check that default display settings are used. - $output = field_view_field('test_entity', $this->entity, $this->field_name); + $output = field_view_field('test_entity:test_entity', $this->entity, $this->field_name); $this->drupalSetContent(drupal_render($output)); $settings = field_info_formatter_settings('field_test_default'); $setting = $settings['test_formatter_setting']; @@ -91,7 +91,7 @@ function testFieldViewField() { 'alter' => TRUE, ), ); - $output = field_view_field('test_entity', $this->entity, $this->field_name, $display); + $output = field_view_field('test_entity:test_entity', $this->entity, $this->field_name, $display); $this->drupalSetContent(drupal_render($output)); $setting = $display['settings']['test_formatter_setting_multiple']; $this->assertNoText($this->label, 'Label was not displayed.'); @@ -110,7 +110,7 @@ function testFieldViewField() { 'test_formatter_setting_additional' => $this->randomName(), ), ); - $output = field_view_field('test_entity', $this->entity, $this->field_name, $display); + $output = field_view_field('test_entity:test_entity', $this->entity, $this->field_name, $display); $view = drupal_render($output); $this->drupalSetContent($view); $setting = $display['settings']['test_formatter_setting_additional']; @@ -122,7 +122,7 @@ function testFieldViewField() { // View mode: check that display settings specified in the instance are // used. - $output = field_view_field('test_entity', $this->entity, $this->field_name, 'teaser'); + $output = field_view_field('test_entity:test_entity', $this->entity, $this->field_name, 'teaser'); $this->drupalSetContent(drupal_render($output)); $setting = $this->instance['display']['teaser']['settings']['test_formatter_setting']; $this->assertText($this->label, 'Label was displayed.'); @@ -132,7 +132,7 @@ function testFieldViewField() { // Unknown view mode: check that display settings for 'default' view mode // are used. - $output = field_view_field('test_entity', $this->entity, $this->field_name, 'unknown_view_mode'); + $output = field_view_field('test_entity:test_entity', $this->entity, $this->field_name, 'unknown_view_mode'); $this->drupalSetContent(drupal_render($output)); $setting = $this->instance['display']['default']['settings']['test_formatter_setting']; $this->assertText($this->label, 'Label was displayed.'); @@ -150,7 +150,7 @@ function testFieldViewValue() { $setting = $settings['test_formatter_setting']; foreach ($this->values as $delta => $value) { $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta]; - $output = field_view_value('test_entity', $this->entity, $this->field_name, $item); + $output = field_view_value('test_entity:test_entity', $this->entity, $this->field_name, $item); $this->drupalSetContent(drupal_render($output)); $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } @@ -166,7 +166,7 @@ function testFieldViewValue() { $array = array(); foreach ($this->values as $delta => $value) { $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta]; - $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, $display); + $output = field_view_value('test_entity:test_entity', $this->entity, $this->field_name, $item, $display); $this->drupalSetContent(drupal_render($output)); $this->assertText($setting . '|0:' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } @@ -182,7 +182,7 @@ function testFieldViewValue() { $array = array(); foreach ($this->values as $delta => $value) { $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta]; - $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, $display); + $output = field_view_value('test_entity:test_entity', $this->entity, $this->field_name, $item, $display); $this->drupalSetContent(drupal_render($output)); $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } @@ -192,7 +192,7 @@ function testFieldViewValue() { $setting = $this->instance['display']['teaser']['settings']['test_formatter_setting']; foreach ($this->values as $delta => $value) { $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta]; - $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, 'teaser'); + $output = field_view_value('test_entity:test_entity', $this->entity, $this->field_name, $item, 'teaser'); $this->drupalSetContent(drupal_render($output)); $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } @@ -202,7 +202,7 @@ function testFieldViewValue() { $setting = $this->instance['display']['default']['settings']['test_formatter_setting']; foreach ($this->values as $delta => $value) { $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta]; - $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, 'unknown_view_mode'); + $output = field_view_value('test_entity:test_entity', $this->entity, $this->field_name, $item, 'unknown_view_mode'); $this->drupalSetContent(drupal_render($output)); $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } diff --git a/core/modules/field/lib/Drupal/field/Tests/EntityPropertiesTest.php b/core/modules/field/lib/Drupal/field/Tests/EntityPropertiesTest.php index 85b3d39..2befa41 100644 --- a/core/modules/field/lib/Drupal/field/Tests/EntityPropertiesTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/EntityPropertiesTest.php @@ -32,9 +32,9 @@ public static function getInfo() { */ function testEntityLabel() { $entity_types = array( - 'test_entity_no_label', - 'test_entity_label', - 'test_entity_label_callback', + 'test_entity:test_entity_no_label', + 'test_entity:test_entity_label', + 'test_entity:test_entity_label_callback', ); // @todo Remove once test_entity entity has been merged with entity_test. @@ -47,15 +47,15 @@ function testEntityLabel() { $label = $entity->label(); switch ($entity_type) { - case 'test_entity_no_label': + case 'test_entity:test_entity_no_label': $this->assertFalse($label, 'Entity with no label property or callback returned FALSE.'); break; - case 'test_entity_label': + case 'test_entity:test_entity_label': $this->assertEqual($label, $entity->ftlabel, 'Entity with label key returned correct label.'); break; - case 'test_entity_label_callback': + case 'test_entity:test_entity_label_callback': $this->assertEqual($label, 'label callback ' . $entity->ftlabel, 'Entity with label callback returned correct label.'); break; } diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php index 9bf4b2e..acaa84f 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php @@ -25,7 +25,7 @@ public static function getInfo() { * Test field_attach_view() and field_attach_prepare_view(). */ function testFieldAttachView() { - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $entity_init = field_test_create_entity(); $langcode = LANGUAGE_NOT_SPECIFIED; @@ -150,7 +150,7 @@ function testFieldAttachView() { * Tests the 'multiple entity' behavior of field_attach_prepare_view(). */ function testFieldAttachPrepareViewMultiple() { - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $langcode = LANGUAGE_NOT_SPECIFIED; // Set the instance to be hidden. @@ -205,7 +205,7 @@ function testFieldAttachCache() { $values = $this->_generateTestFieldValues($this->field['cardinality']); // Non-cacheable entity type. - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $cid = "field:$entity_type:{$entity_init->ftid}"; // Check that no initial cache entry is present. @@ -224,7 +224,7 @@ function testFieldAttachCache() { // Cacheable entity type. - $entity_type = 'test_cacheable_entity'; + $entity_type = 'test_entity:test_cacheable_entity'; $cid = "field:$entity_type:{$entity_init->ftid}"; $instance = $this->instance; $instance['entity_type'] = $entity_type; @@ -291,7 +291,7 @@ function testFieldAttachCache() { * hook_field_validate. */ function testFieldAttachValidate() { - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $entity = field_test_create_entity(0, 0, $this->instance['bundle']); $langcode = LANGUAGE_NOT_SPECIFIED; @@ -342,7 +342,7 @@ function testFieldAttachValidate() { * widgets show up. */ function testFieldAttachForm() { - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $entity = field_test_create_entity(0, 0, $this->instance['bundle']); $form = array(); @@ -361,7 +361,7 @@ function testFieldAttachForm() { * Test field_attach_submit(). */ function testFieldAttachSubmit() { - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $entity = field_test_create_entity(0, 0, $this->instance['bundle']); // Build the form. diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php index 501d001..cb31731 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php @@ -35,7 +35,7 @@ function testFieldAttachSaveLoad() { field_update_instance($this->instance); $langcode = LANGUAGE_NOT_SPECIFIED; - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $values = array(); // TODO : test empty values filtering and "compression" (store consecutive deltas). @@ -89,7 +89,7 @@ function testFieldAttachSaveLoad() { * Test the 'multiple' load feature. */ function testFieldAttachLoadMultiple() { - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $langcode = LANGUAGE_NOT_SPECIFIED; // Define 2 bundles. @@ -116,7 +116,7 @@ function testFieldAttachLoadMultiple() { foreach ($field_bundles_map[$i] as $bundle) { $instance = array( 'field_name' => $field_names[$i], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => $bundles[$bundle], 'settings' => array( // Configure the instance so that we test hook_field_load() @@ -132,7 +132,7 @@ function testFieldAttachLoadMultiple() { foreach ($bundles as $index => $bundle) { $entities[$index] = field_test_create_entity($index, $index, $bundle); $entity = clone($entities[$index]); - $instances = field_info_instances('test_entity', $bundle); + $instances = field_info_instances('test_entity:test_entity', $bundle); foreach ($instances as $field_name => $instance) { $values[$index][$field_name] = mt_rand(1, 127); $entity->$field_name = array($langcode => array(array('value' => $values[$index][$field_name]))); @@ -165,7 +165,7 @@ function testFieldAttachLoadMultiple() { * Test saving and loading fields using different storage backends. */ function testFieldAttachSaveLoadDifferentStorage() { - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $langcode = LANGUAGE_NOT_SPECIFIED; // Create two fields using different storage backends, and their instances. @@ -187,7 +187,7 @@ function testFieldAttachSaveLoadDifferentStorage() { field_create_field($field); $instance = array( 'field_name' => $field['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', ); field_create_instance($instance); @@ -228,7 +228,7 @@ function testFieldStorageDetailsAlter() { $field = field_create_field($field); $instance = array( 'field_name' => $field_name, - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', ); field_create_instance($instance); @@ -258,7 +258,7 @@ function testFieldStorageDetailsAlter() { * Tests insert and update with missing or NULL fields. */ function testFieldAttachSaveMissingData() { - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $entity_init = field_test_create_entity(); $langcode = LANGUAGE_NOT_SPECIFIED; @@ -340,7 +340,7 @@ function testFieldAttachSaveMissingDataDefaultValue() { $this->instance['default_value_function'] = 'field_test_default_value'; field_update_instance($this->instance); - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $entity_init = field_test_create_entity(); $langcode = LANGUAGE_NOT_SPECIFIED; @@ -368,7 +368,7 @@ function testFieldAttachSaveMissingDataDefaultValue() { * Test field_attach_delete(). */ function testFieldAttachDelete() { - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $langcode = LANGUAGE_NOT_SPECIFIED; $rev[0] = field_test_create_entity(0, 0, $this->instance['bundle']); @@ -437,7 +437,7 @@ function testFieldAttachCreateRenameBundle() { $langcode = LANGUAGE_NOT_SPECIFIED; $values = $this->_generateTestFieldValues($this->field['cardinality']); $entity->{$this->field_name}[$langcode] = $values; - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; field_attach_insert($entity_type, $entity); // Verify the field data is present on load. @@ -479,7 +479,7 @@ function testFieldAttachDeleteBundle() { field_create_field($field); $instance = array( 'field_name' => $field_name, - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => $this->instance['bundle'], 'label' => $this->randomName() . '_label', 'description' => $this->randomName() . '_description', @@ -497,11 +497,11 @@ function testFieldAttachDeleteBundle() { $values = $this->_generateTestFieldValues($this->field['cardinality']); $entity->{$this->field_name}[$langcode] = $values; $entity->{$field_name}[$langcode] = $this->_generateTestFieldValues(1); - field_attach_insert('test_entity', $entity); + field_attach_insert('test_entity:test_entity', $entity); // Verify the fields are present on load $entity = field_test_create_entity(0, 0, $this->instance['bundle']); - field_attach_load('test_entity', array(0 => $entity)); + field_attach_load('test_entity:test_entity', array(0 => $entity)); $this->assertEqual(count($entity->{$this->field_name}[$langcode]), 4, 'First field got loaded'); $this->assertEqual(count($entity->{$field_name}[$langcode]), 1, 'Second field got loaded'); @@ -511,12 +511,12 @@ function testFieldAttachDeleteBundle() { // Verify no data gets loaded $entity = field_test_create_entity(0, 0, $this->instance['bundle']); - field_attach_load('test_entity', array(0 => $entity)); + field_attach_load('test_entity:test_entity', array(0 => $entity)); $this->assertFalse(isset($entity->{$this->field_name}[$langcode]), 'No data for first field'); $this->assertFalse(isset($entity->{$field_name}[$langcode]), 'No data for second field'); // Verify that the instances are gone - $this->assertFalse(field_read_instance('test_entity', $this->field_name, $this->instance['bundle']), "First field is deleted"); - $this->assertFalse(field_read_instance('test_entity', $field_name, $instance['bundle']), "Second field is deleted"); + $this->assertFalse(field_read_instance('test_entity:test_entity', $this->field_name, $this->instance['bundle']), "First field is deleted"); + $this->assertFalse(field_read_instance('test_entity:test_entity', $field_name, $instance['bundle']), "Second field is deleted"); } } diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachTestBase.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachTestBase.php index 17c7a3b..095bc51 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachTestBase.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachTestBase.php @@ -25,7 +25,7 @@ function setUp() { $this->field_id = $this->field['id']; $this->instance = array( 'field_name' => $this->field_name, - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'label' => $this->randomName() . '_label', 'description' => $this->randomName() . '_description', diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php index dc4397f..8587522 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php @@ -53,11 +53,11 @@ function testFieldInfo() { } // Verify that no unexpected instances exist. - $instances = field_info_instances('test_entity'); + $instances = field_info_instances('test_entity:test_entity'); $expected = array(); - $this->assertIdentical($instances, $expected, "field_info_instances('test_entity') returns " . var_export($expected, TRUE) . '.'); - $instances = field_info_instances('test_entity', 'test_bundle'); - $this->assertIdentical($instances, array(), "field_info_instances('test_entity', 'test_bundle') returns an empty array."); + $this->assertIdentical($instances, $expected, "field_info_instances('test_entity:test_entity') returns " . var_export($expected, TRUE) . '.'); + $instances = field_info_instances('test_entity:test_entity', 'test_bundle'); + $this->assertIdentical($instances, array(), "field_info_instances('test_entity:test_entity', 'test_bundle') returns an empty array."); // Create a field, verify it shows up. $core_fields = field_info_fields(); @@ -81,7 +81,7 @@ function testFieldInfo() { // Create an instance, verify that it shows up $instance = array( 'field_name' => $field['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'label' => $this->randomName(), 'description' => $this->randomName(), @@ -93,13 +93,13 @@ function testFieldInfo() { 'test_setting' => 999))); field_create_instance($instance); - $instances = field_info_instances('test_entity', $instance['bundle']); + $instances = field_info_instances('test_entity:test_entity', $instance['bundle']); $this->assertEqual(count($instances), 1, 'One instance shows up in info when attached to a bundle.'); $this->assertTrue($instance < $instances[$instance['field_name']], 'Instance appears in info correctly'); // Test a valid entity type but an invalid bundle. - $instances = field_info_instances('test_entity', 'invalid_bundle'); - $this->assertIdentical($instances, array(), "field_info_instances('test_entity', 'invalid_bundle') returns an empty array."); + $instances = field_info_instances('test_entity:test_entity', 'invalid_bundle'); + $this->assertIdentical($instances, array(), "field_info_instances('test_entity:test_entity', 'invalid_bundle') returns an empty array."); // Test invalid entity type and bundle. $instances = field_info_instances('invalid_entity', $instance['bundle']); @@ -159,7 +159,7 @@ function testInstancePrepare() { field_create_field($field_definition); $instance_definition = array( 'field_name' => $field_definition['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', ); field_create_instance($instance_definition); @@ -233,7 +233,7 @@ function testFieldMap() { // We will overlook fields created by the 'standard' installation profile. $exclude = field_info_field_map(); - // Create a new bundle for 'test_entity' entity type. + // Create a new bundle for 'test_entity:test_entity' entity type. field_test_create_bundle('test_bundle_2'); // Create a couple fields. @@ -255,22 +255,22 @@ function testFieldMap() { $instances = array( array( 'field_name' => 'field_1', - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', ), array( 'field_name' => 'field_1', - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle_2', ), array( 'field_name' => 'field_2', - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', ), array( 'field_name' => 'field_2', - 'entity_type' => 'test_cacheable_entity', + 'entity_type' => 'test_entity:test_cacheable_entity', 'bundle' => 'test_bundle', ), ); @@ -282,14 +282,14 @@ function testFieldMap() { 'field_1' => array( 'type' => 'test_field', 'bundles' => array( - 'test_entity' => array('test_bundle', 'test_bundle_2'), + 'test_entity:test_entity' => array('test_bundle', 'test_bundle_2'), ), ), 'field_2' => array( 'type' => 'hidden_test_field', 'bundles' => array( - 'test_entity' => array('test_bundle'), - 'test_cacheable_entity' => array('test_bundle'), + 'test_entity:test_entity' => array('test_bundle'), + 'test_entity:test_cacheable_entity' => array('test_bundle'), ), ), ); diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php index 84cee72..76e1765 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php @@ -38,7 +38,7 @@ function setUp() { field_create_field($this->field); $this->instance_definition = array( 'field_name' => $this->field['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', ); } @@ -103,7 +103,7 @@ function testCreateFieldInstance() { $field_restricted = array( 'field_name' => drupal_strtolower($this->randomName()), 'type' => 'test_field', - 'entity_types' => array('test_cacheable_entity'), + 'entity_types' => array('test_entity:test_cacheable_entity'), ); field_create_field($field_restricted); @@ -112,7 +112,7 @@ function testCreateFieldInstance() { try { $instance = $this->instance_definition; $instance['field_name'] = $field_restricted['field_name']; - $instance['entity_type'] = 'test_cacheable_entity'; + $instance['entity_type'] = 'test_entity:test_cacheable_entity'; field_create_instance($instance); $this->pass(t('Can create an instance on an entity type allowed by the field.')); } @@ -142,7 +142,7 @@ function testReadFieldInstance() { field_create_instance($this->instance_definition); // Read the instance back. - $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); + $instance = field_read_instance('test_entity:test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); $this->assertTrue($this->instance_definition == $instance, 'The field was properly read.'); } @@ -154,7 +154,7 @@ function testUpdateFieldInstance() { $field_type = field_info_field_types($this->field['type']); // Check that basic changes are saved. - $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); + $instance = field_read_instance('test_entity:test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); $instance['required'] = !$instance['required']; $instance['label'] = $this->randomName(); $instance['description'] = $this->randomName(); @@ -165,7 +165,7 @@ function testUpdateFieldInstance() { $instance['display']['default']['weight']++; field_update_instance($instance); - $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); + $instance_new = field_read_instance('test_entity:test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); $this->assertEqual($instance['required'], $instance_new['required'], '"required" change is saved'); $this->assertEqual($instance['label'], $instance_new['label'], '"label" change is saved'); $this->assertEqual($instance['description'], $instance_new['description'], '"description" change is saved'); @@ -175,12 +175,12 @@ function testUpdateFieldInstance() { $this->assertEqual($instance['display']['default']['weight'], $instance_new['display']['default']['weight'], 'Widget weight change is saved'); // Check that changing widget and formatter types updates the default settings. - $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); + $instance = field_read_instance('test_entity:test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); $instance['widget']['type'] = 'test_field_widget_multiple'; $instance['display']['default']['type'] = 'field_test_multiple'; field_update_instance($instance); - $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); + $instance_new = field_read_instance('test_entity:test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); $this->assertEqual($instance['widget']['type'], $instance_new['widget']['type'] , 'Widget type change is saved.'); $settings = field_info_widget_settings($instance_new['widget']['type']); $this->assertIdentical($settings, array_intersect_key($instance_new['widget']['settings'], $settings) , 'Widget type change updates default settings.'); @@ -190,11 +190,11 @@ function testUpdateFieldInstance() { $this->assertIdentical($settings, array_intersect_key($instance_new['display']['default']['settings'], $settings) , 'Changing formatter type updates default settings.'); // Check that adding a new view mode is saved and gets default settings. - $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); + $instance = field_read_instance('test_entity:test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); $instance['display']['teaser'] = array(); field_update_instance($instance); - $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); + $instance_new = field_read_instance('test_entity:test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); $this->assertTrue(isset($instance_new['display']['teaser']), 'Display for the new view_mode has been written.'); $this->assertIdentical($instance_new['display']['teaser']['type'], $field_type['default_formatter'], 'Default formatter for the new view_mode has been written.'); $info = field_info_formatter_types($instance_new['display']['teaser']['type']); @@ -220,21 +220,21 @@ function testDeleteFieldInstance() { $instance = field_create_instance($this->another_instance_definition); // Test that the first instance is not deleted, and then delete it. - $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE)); + $instance = field_read_instance('test_entity:test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE)); $this->assertTrue(!empty($instance) && empty($instance['deleted']), 'A new field instance is not marked for deletion.'); field_delete_instance($instance); // Make sure the instance is marked as deleted when the instance is // specifically loaded. - $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE)); + $instance = field_read_instance('test_entity:test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE)); $this->assertTrue(!empty($instance['deleted']), 'A deleted field instance is marked for deletion.'); // Try to load the instance normally and make sure it does not show up. - $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); + $instance = field_read_instance('test_entity:test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); $this->assertTrue(empty($instance), 'A deleted field instance is not loaded by default.'); // Make sure the other field instance is not deleted. - $another_instance = field_read_instance('test_entity', $this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']); + $another_instance = field_read_instance('test_entity:test_entity', $this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']); $this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), 'A non-deleted field instance is not marked for deletion.'); // Make sure the field is deleted when its last instance is deleted. diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php b/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php index fc5cac0..29340d7 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php @@ -60,7 +60,7 @@ function _generateTestFieldValues($cardinality) { */ function assertFieldValues($entity, $field_name, $langcode, $expected_values, $column = 'value') { $e = clone $entity; - field_attach_load('test_entity', array($e->ftid => $e)); + field_attach_load('test_entity:test_entity', array($e->ftid => $e)); $values = isset($e->{$field_name}[$langcode]) ? $e->{$field_name}[$langcode] : array(); $this->assertEqual(count($values), count($expected_values), 'Expected number of values were saved.'); foreach ($expected_values as $key => $value) { diff --git a/core/modules/field/lib/Drupal/field/Tests/FormTest.php b/core/modules/field/lib/Drupal/field/Tests/FormTest.php index 1cc5616..a3b344f 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FormTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FormTest.php @@ -35,7 +35,7 @@ function setUp() { $this->field_unlimited = array('field_name' => 'field_unlimited', 'type' => 'test_field', 'cardinality' => FIELD_CARDINALITY_UNLIMITED); $this->instance = array( - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'label' => $this->randomName() . '_label', 'description' => $this->randomName() . '_description', @@ -83,7 +83,7 @@ function testFieldFormSingle() { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); + $this->assertRaw(t('test_entity:test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); $entity = field_test_entity_test_load($id); $this->assertEqual($entity->{$this->field_name}[$langcode][0]['value'], $value, 'Field value was saved'); @@ -96,8 +96,8 @@ function testFieldFormSingle() { $value = mt_rand(1, 127); $edit = array("{$this->field_name}[$langcode][0][value]" => $value); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated'); - entity_get_controller('test_entity')->resetCache(array($id)); + $this->assertRaw(t('test_entity:test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated'); + entity_get_controller('test_entity:test_entity')->resetCache(array($id)); $entity = field_test_entity_test_load($id); $this->assertEqual($entity->{$this->field_name}[$langcode][0]['value'], $value, 'Field value was updated'); @@ -105,8 +105,8 @@ function testFieldFormSingle() { $value = ''; $edit = array("{$this->field_name}[$langcode][0][value]" => $value); $this->drupalPost('test-entity/manage/' . $id . '/edit', $edit, t('Save')); - $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated'); - entity_get_controller('test_entity')->resetCache(array($id)); + $this->assertRaw(t('test_entity:test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated'); + entity_get_controller('test_entity:test_entity')->resetCache(array($id)); $entity = field_test_entity_test_load($id); $this->assertIdentical($entity->{$this->field_name}, array(), 'Field was emptied'); @@ -132,7 +132,7 @@ function testFieldFormSingleRequired() { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); + $this->assertRaw(t('test_entity:test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); $entity = field_test_entity_test_load($id); $this->assertEqual($entity->{$this->field_name}[$langcode][0]['value'], $value, 'Field value was saved'); @@ -212,7 +212,7 @@ function testFieldFormUnlimited() { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); + $this->assertRaw(t('test_entity:test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); $entity = field_test_entity_test_load($id); ksort($field_values); $field_values = array_values($field_values); @@ -249,7 +249,7 @@ function testFieldFormMultivalueWithRequiredRadio() { )); $instance = array( 'field_name' => 'required_radio_test', - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'required' => TRUE, 'widget' => array( @@ -387,7 +387,7 @@ function testFieldFormAccess() { $field_name_no_access = $field_no_access['field_name']; $instance_no_access = array( 'field_name' => $field_name_no_access, - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'default_value' => array(0 => array('value' => 99)), ); @@ -398,7 +398,7 @@ function testFieldFormAccess() { // Test that the form structure includes full information for each delta // apart from #access. - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $entity = field_test_create_entity(0, 0, $this->instance['bundle']); $form = array(); @@ -428,7 +428,7 @@ function testFieldFormAccess() { $this->drupalPost('test-entity/manage/' . $id . '/edit', $edit, t('Save')); // Check that the new revision has the expected values. - entity_get_controller('test_entity')->resetCache(array($id)); + entity_get_controller('test_entity:test_entity')->resetCache(array($id)); $entity = field_test_entity_test_load($id); $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, 'New revision has the expected value for the field with no edit access.'); $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, 'New revision has the expected value for the field with edit access.'); diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php index 8e720b0..84845c9 100644 --- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php @@ -37,7 +37,7 @@ function setUp() { $this->field_name = drupal_strtolower($this->randomName() . '_field_name'); - $this->entity_type = 'test_entity'; + $this->entity_type = 'test_entity:test_entity'; $field = array( 'field_name' => $this->field_name, @@ -54,7 +54,7 @@ function setUp() { 'bundle' => 'test_bundle', ); field_create_instance($instance); - $this->instance = field_read_instance('test_entity', $this->field_name, 'test_bundle'); + $this->instance = field_read_instance('test_entity:test_entity', $this->field_name, 'test_bundle'); for ($i = 0; $i < 3; ++$i) { $language = new Language(array( @@ -70,12 +70,12 @@ function setUp() { */ function testFieldAvailableLanguages() { // Test 'translatable' fieldable info. - field_test_entity_info_translatable('test_entity', FALSE); + field_test_entity_info_translatable('test_entity:test_entity', FALSE); $field = $this->field; $field['field_name'] .= '_untranslatable'; // Enable field translations for the entity. - field_test_entity_info_translatable('test_entity', TRUE); + field_test_entity_info_translatable('test_entity:test_entity', TRUE); // Test hook_field_languages() invocation on a translatable field. variable_set('field_test_field_available_languages_alter', TRUE); @@ -101,9 +101,9 @@ function testFieldAvailableLanguages() { */ function testFieldInvoke() { // Enable field translations for the entity. - field_test_entity_info_translatable('test_entity', TRUE); + field_test_entity_info_translatable('test_entity:test_entity', TRUE); - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $entity = field_test_create_entity(0, 0, $this->instance['bundle']); // Populate some extra languages to check if _field_invoke() correctly uses @@ -139,12 +139,12 @@ function testFieldInvoke() { */ function testFieldInvokeMultiple() { // Enable field translations for the entity. - field_test_entity_info_translatable('test_entity', TRUE); + field_test_entity_info_translatable('test_entity:test_entity', TRUE); $values = array(); $options = array(); $entities = array(); - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $entity_count = 5; $available_langcodes = field_available_languages($this->entity_type, $this->field); @@ -217,9 +217,9 @@ function testTranslatableFieldSaveLoad() { $this->assertTrue(count($entity_info['translation']), 'Nodes are translatable.'); // Prepare the field translations. - field_test_entity_info_translatable('test_entity', TRUE); + field_test_entity_info_translatable('test_entity:test_entity', TRUE); $eid = $evid = 1; - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $entity = field_test_create_entity($eid, $evid, $this->instance['bundle']); $field_translations = array(); $available_langcodes = field_available_languages($entity_type, $this->field); @@ -249,7 +249,7 @@ function testTranslatableFieldSaveLoad() { */ function testFieldDisplayLanguage() { $field_name = drupal_strtolower($this->randomName() . '_field_name'); - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; // We need an additional field here to properly test display language // suggestions. diff --git a/core/modules/field/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php b/core/modules/field/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php index 932708e..7d792e9 100644 --- a/core/modules/field/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php +++ b/core/modules/field/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php @@ -52,7 +52,7 @@ function testEmailField() { field_create_field($this->field); $this->instance = array( 'field_name' => $this->field['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'widget' => array( 'type' => 'email_default', @@ -78,12 +78,12 @@ function testEmailField() { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id))); + $this->assertRaw(t('test_entity:test_entity @id has been created.', array('@id' => $id))); $this->assertRaw($value); // Verify that a mailto link is displayed. $entity = field_test_entity_test_load($id); - $entity->content = field_attach_view('test_entity', $entity, 'full'); + $entity->content = field_attach_view('test_entity:test_entity', $entity, 'full'); $this->drupalSetContent(drupal_render($entity->content)); $this->assertLinkByHref('mailto:test@example.com'); } diff --git a/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php b/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php index 3cabd58..9eb7016 100644 --- a/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php +++ b/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php @@ -43,7 +43,7 @@ function setUp() { $this->field = field_create_field($this->field); $this->instance = array( 'field_name' => $this->field_name, - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle' ); $this->instance = field_create_instance($this->instance); @@ -57,7 +57,7 @@ function setUp() { * field_load_revision works correctly. */ function testFieldAttachLoad() { - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $eid = 0; $langcode = LANGUAGE_NOT_SPECIFIED; @@ -126,7 +126,7 @@ function testFieldAttachLoad() { * written when using insert and update. */ function testFieldAttachInsertAndUpdate() { - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $entity = field_test_create_entity(0, 0, $this->instance['bundle']); $langcode = LANGUAGE_NOT_SPECIFIED; @@ -207,7 +207,7 @@ function testFieldAttachInsertAndUpdate() { * Tests insert and update with missing or NULL fields. */ function testFieldAttachSaveMissingData() { - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $entity = field_test_create_entity(0, 0, $this->instance['bundle']); $langcode = LANGUAGE_NOT_SPECIFIED; @@ -305,11 +305,11 @@ function testUpdateFieldSchemaWithData() { // Create a decimal 5.2 field and add some data. $field = array('field_name' => 'decimal52', 'type' => 'number_decimal', 'settings' => array('precision' => 5, 'scale' => 2)); $field = field_create_field($field); - $instance = array('field_name' => 'decimal52', 'entity_type' => 'test_entity', 'bundle' => 'test_bundle'); + $instance = array('field_name' => 'decimal52', 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle'); $instance = field_create_instance($instance); $entity = field_test_create_entity(0, 0, $instance['bundle']); $entity->decimal52[LANGUAGE_NOT_SPECIFIED][0]['value'] = '1.235'; - field_attach_insert('test_entity', $entity); + field_attach_insert('test_entity:test_entity', $entity); // Attempt to update the field in a way that would work without data. $field['settings']['scale'] = 3; @@ -356,7 +356,7 @@ function testFieldUpdateIndexesWithData() { $field_name = 'testfield'; $field = array('field_name' => $field_name, 'type' => 'text'); $field = field_create_field($field); - $instance = array('field_name' => $field_name, 'entity_type' => 'test_entity', 'bundle' => 'test_bundle'); + $instance = array('field_name' => $field_name, 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle'); $instance = field_create_instance($instance); $tables = array(_field_sql_storage_tablename($field), _field_sql_storage_revision_tablename($field)); @@ -369,7 +369,7 @@ function testFieldUpdateIndexesWithData() { // Add data so the table cannot be dropped. $entity = field_test_create_entity(0, 0, $instance['bundle']); $entity->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['value'] = 'field data'; - field_attach_insert('test_entity', $entity); + field_attach_insert('test_entity:test_entity', $entity); // Add an index $field = array('field_name' => $field_name, 'indexes' => array('value' => array(array('value', 255)))); @@ -388,7 +388,7 @@ function testFieldUpdateIndexesWithData() { // Verify that the tables were not dropped. $entity = field_test_create_entity(0, 0, $instance['bundle']); - field_attach_load('test_entity', array(0 => $entity)); + field_attach_load('test_entity:test_entity', array(0 => $entity)); $this->assertEqual($entity->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['value'], 'field data', t("Index changes performed without dropping the tables")); } diff --git a/core/modules/field/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php b/core/modules/field/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php index acca988..5814431 100644 --- a/core/modules/field/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php +++ b/core/modules/field/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php @@ -51,7 +51,7 @@ function testURLValidation() { field_create_field($this->field); $this->instance = array( 'field_name' => $this->field['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'settings' => array( 'title' => DRUPAL_DISABLED, @@ -80,7 +80,7 @@ function testURLValidation() { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id))); + $this->assertRaw(t('test_entity:test_entity @id has been created.', array('@id' => $id))); $this->assertRaw($value); // Verify that invalid URLs cannot be submitted. @@ -114,7 +114,7 @@ function testLinkTitle() { field_create_field($this->field); $this->instance = array( 'field_name' => $this->field['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'settings' => array( 'title' => DRUPAL_OPTIONAL, @@ -183,7 +183,7 @@ function testLinkTitle() { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id))); + $this->assertRaw(t('test_entity:test_entity @id has been created.', array('@id' => $id))); $this->renderTestEntity($id); $expected_link = l($value, $value); @@ -195,7 +195,7 @@ function testLinkTitle() { "{$this->field['field_name']}[$langcode][0][title]" => $title, ); $this->drupalPost("test-entity/manage/$id/edit", $edit, t('Save')); - $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id))); + $this->assertRaw(t('test_entity:test_entity @id has been updated.', array('@id' => $id))); $this->renderTestEntity($id); $expected_link = l($title, $value); @@ -215,7 +215,7 @@ function testLinkFormatter() { field_create_field($this->field); $this->instance = array( 'field_name' => $this->field['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'settings' => array( 'title' => DRUPAL_OPTIONAL, @@ -254,7 +254,7 @@ function testLinkFormatter() { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id))); + $this->assertRaw(t('test_entity:test_entity @id has been created.', array('@id' => $id))); // Verify that the link is output according to the formatter settings. // Not using generatePermutations(), since that leads to 32 cases, which @@ -347,7 +347,7 @@ function testLinkSeparateFormatter() { field_create_field($this->field); $this->instance = array( 'field_name' => $this->field['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'settings' => array( 'title' => DRUPAL_OPTIONAL, @@ -383,7 +383,7 @@ function testLinkSeparateFormatter() { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id))); + $this->assertRaw(t('test_entity:test_entity @id has been created.', array('@id' => $id))); // Verify that the link is output according to the formatter settings. $options = array( @@ -446,11 +446,11 @@ function testLinkSeparateFormatter() { */ protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) { if ($reset) { - entity_get_controller('test_entity')->resetCache(array($id)); + entity_get_controller('test_entity:test_entity')->resetCache(array($id)); } $entity = field_test_entity_test_load($id); - field_attach_prepare_view('test_entity', array($entity->id() => $entity), $view_mode); - $entity->content = field_attach_view('test_entity', $entity, $view_mode); + field_attach_prepare_view('test_entity:test_entity', array($entity->id() => $entity), $view_mode); + $entity->content = field_attach_view('test_entity:test_entity', $entity, $view_mode); $output = drupal_render($entity->content); $this->drupalSetContent($output); diff --git a/core/modules/field/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php b/core/modules/field/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php index 63bef1f..3da7f58 100644 --- a/core/modules/field/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php +++ b/core/modules/field/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php @@ -55,7 +55,7 @@ function testNumberDecimalField() { field_create_field($this->field); $this->instance = array( 'field_name' => $this->field['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'widget' => array( 'type' => 'number', @@ -81,7 +81,7 @@ function testNumberDecimalField() { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); + $this->assertRaw(t('test_entity:test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); $this->assertRaw(round($value, 2), 'Value is displayed.'); // Try to create entries with more than one decimal separator; assert fail. diff --git a/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php b/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php index 4065b7d..354375e 100644 --- a/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php +++ b/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php @@ -37,7 +37,7 @@ function setUp() { $this->instance = array( 'field_name' => $this->field_name, - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'required' => TRUE, 'widget' => array( diff --git a/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php b/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php index 0fa0763..3abe518 100644 --- a/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php +++ b/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php @@ -29,7 +29,7 @@ function testDynamicAllowedValues() { foreach ($this->test as $key => $value) { $this->entity->test_options[LANGUAGE_NOT_SPECIFIED][0]['value'] = $value; try { - field_attach_validate('test_entity', $this->entity); + field_attach_validate('test_entity:test_entity', $this->entity); $this->pass("$key should pass"); } catch (FieldValidationException $e) { @@ -42,7 +42,7 @@ function testDynamicAllowedValues() { $this->entity->test_options[LANGUAGE_NOT_SPECIFIED][0]['value'] = is_numeric($value) ? (100 - $value) : ('X' . $value); $pass = FALSE; try { - field_attach_validate('test_entity', $this->entity); + field_attach_validate('test_entity:test_entity', $this->entity); } catch (FieldValidationException $e) { $pass = TRUE; diff --git a/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php b/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php index 1027eb1..a85f900 100644 --- a/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php +++ b/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php @@ -46,7 +46,7 @@ function setUp() { $this->instance = array( 'field_name' => $this->field_name, - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'widget' => array( 'type' => 'options_buttons', @@ -111,7 +111,7 @@ function testUpdateAllowedValues() { $this->field = field_create_field($this->field); $this->instance = array( 'field_name' => $this->field_name, - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'widget' => array( 'type' => 'options_buttons', diff --git a/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php b/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php index d61eebb..c800e29 100644 --- a/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php +++ b/core/modules/field/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php @@ -80,7 +80,7 @@ function testRadioButtons() { // Create an instance of the 'single value' field. $instance = array( 'field_name' => $this->card_1['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'widget' => array( 'type' => 'options_buttons', @@ -134,7 +134,7 @@ function testCheckBoxes() { // Create an instance of the 'multiple values' field. $instance = array( 'field_name' => $this->card_2['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'widget' => array( 'type' => 'options_buttons', @@ -221,7 +221,7 @@ function testSelectListSingle() { // Create an instance of the 'single value' field. $instance = array( 'field_name' => $this->card_1['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'required' => TRUE, 'widget' => array( @@ -318,7 +318,7 @@ function testSelectListMultiple() { // Create an instance of the 'multiple values' field. $instance = array( 'field_name' => $this->card_2['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'widget' => array( 'type' => 'options_select', @@ -435,7 +435,7 @@ function testOnOffCheckbox() { // Create an instance of the 'boolean' field. $instance = array( 'field_name' => $this->bool['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'widget' => array( 'type' => 'options_onoff', diff --git a/core/modules/field/modules/text/lib/Drupal/text/Tests/TextFieldTest.php b/core/modules/field/modules/text/lib/Drupal/text/Tests/TextFieldTest.php index 1a41523..3a421a8 100644 --- a/core/modules/field/modules/text/lib/Drupal/text/Tests/TextFieldTest.php +++ b/core/modules/field/modules/text/lib/Drupal/text/Tests/TextFieldTest.php @@ -60,7 +60,7 @@ function testTextFieldValidation() { field_create_field($this->field); $this->instance = array( 'field_name' => $this->field['field_name'], - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'widget' => array( 'type' => 'text_textfield', @@ -78,7 +78,7 @@ function testTextFieldValidation() { for ($i = 0; $i <= $max_length + 2; $i++) { $entity->{$this->field['field_name']}[$langcode][0]['value'] = str_repeat('x', $i); try { - field_attach_validate('test_entity', $entity); + field_attach_validate('test_entity:test_entity', $entity); $this->assertTrue($i <= $max_length, "Length $i does not cause validation error when max_length is $max_length"); } catch (FieldValidationException $e) { @@ -100,13 +100,13 @@ function testTextfieldWidgets() { */ function _testTextfieldWidgets($field_type, $widget_type) { // Setup a field and instance - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $this->field_name = drupal_strtolower($this->randomName()); $this->field = array('field_name' => $this->field_name, 'type' => $field_type); field_create_field($this->field); $this->instance = array( 'field_name' => $this->field_name, - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'label' => $this->randomName() . '_label', 'settings' => array( @@ -137,7 +137,7 @@ function _testTextfieldWidgets($field_type, $widget_type) { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); + $this->assertRaw(t('test_entity:test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); // Display the entity. $entity = field_test_entity_test_load($id); @@ -159,13 +159,13 @@ function testTextfieldWidgetsFormatted() { */ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { // Setup a field and instance - $entity_type = 'test_entity'; + $entity_type = 'test_entity:test_entity'; $this->field_name = drupal_strtolower($this->randomName()); $this->field = array('field_name' => $this->field_name, 'type' => $field_type); field_create_field($this->field); $this->instance = array( 'field_name' => $this->field_name, - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'label' => $this->randomName() . '_label', 'settings' => array( @@ -206,7 +206,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); + $this->assertRaw(t('test_entity:test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); // Display the entity. $entity = field_test_entity_test_load($id); @@ -245,10 +245,10 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { "{$this->field_name}[$langcode][0][format]" => $format_id, ); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated'); + $this->assertRaw(t('test_entity:test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated'); // Display the entity. - entity_get_controller('test_entity')->resetCache(array($id)); + entity_get_controller('test_entity:test_entity')->resetCache(array($id)); $entity = field_test_entity_test_load($id); $entity->content = field_attach_view($entity_type, $entity, 'full'); $this->content = drupal_render($entity->content); diff --git a/core/modules/field/tests/modules/field_test/field_test.entity.inc b/core/modules/field/tests/modules/field_test/field_test.entity.inc index 431ac11..d7d8c46 100644 --- a/core/modules/field/tests/modules/field_test/field_test.entity.inc +++ b/core/modules/field/tests/modules/field_test/field_test.entity.inc @@ -6,141 +6,7 @@ */ use Drupal\Core\Entity\EntityInterface; -use Drupal\field_test\TestEntity; - -/** - * Implements hook_entity_info(). - */ -function field_test_entity_info() { - $bundles = variable_get('field_test_bundles', array('test_bundle' => array('label' => 'Test Bundle'))); - $test_entity_modes = array( - 'full' => array( - 'label' => t('Full object'), - 'custom settings' => TRUE, - ), - 'teaser' => array( - 'label' => t('Teaser'), - 'custom settings' => TRUE, - ), - ); - - return array( - 'test_entity' => array( - 'name' => t('Test Entity'), - 'entity class' => 'Drupal\field_test\TestEntity', - 'controller class' => 'Drupal\field_test\TestEntityController', - 'form controller class' => array( - 'default' => 'Drupal\field_test\TestEntityFormController', - ), - 'fieldable' => TRUE, - 'field cache' => FALSE, - 'base table' => 'test_entity', - 'revision table' => 'test_entity_revision', - 'entity keys' => array( - 'id' => 'ftid', - 'revision' => 'ftvid', - 'bundle' => 'fttype', - ), - 'bundles' => $bundles, - 'view modes' => $test_entity_modes, - ), - // This entity type doesn't get form handling for now... - 'test_cacheable_entity' => array( - 'name' => t('Test Entity, cacheable'), - 'entity class' => 'Drupal\field_test\TestEntity', - 'controller class' => 'Drupal\field_test\TestEntityController', - 'fieldable' => TRUE, - 'field cache' => TRUE, - 'entity keys' => array( - 'id' => 'ftid', - 'revision' => 'ftvid', - 'bundle' => 'fttype', - ), - 'bundles' => $bundles, - 'view modes' => $test_entity_modes, - ), - 'test_entity_bundle_key' => array( - 'entity class' => 'Drupal\field_test\TestEntity', - 'controller class' => 'Drupal\field_test\TestEntityController', - 'name' => t('Test Entity with a bundle key.'), - 'base table' => 'test_entity_bundle_key', - 'fieldable' => TRUE, - 'field cache' => FALSE, - 'entity keys' => array( - 'id' => 'ftid', - 'bundle' => 'fttype', - ), - 'bundles' => array('bundle1' => array('label' => 'Bundle1'), 'bundle2' => array('label' => 'Bundle2')) + $bundles, - 'view modes' => $test_entity_modes, - ), - // In this case, the bundle key is not stored in the database. - 'test_entity_bundle' => array( - 'name' => t('Test Entity with a specified bundle.'), - 'entity class' => 'Drupal\field_test\TestEntity', - 'controller class' => 'Drupal\field_test\TestEntityController', - 'base table' => 'test_entity_bundle', - 'fieldable' => TRUE, - 'field cache' => FALSE, - 'entity keys' => array( - 'id' => 'ftid', - 'bundle' => 'fttype', - ), - 'bundles' => array('test_entity_2' => array('label' => 'Test entity 2')) + $bundles, - 'view modes' => $test_entity_modes, - ), - // @see EntityPropertiesTestCase::testEntityLabel() - 'test_entity_no_label' => array( - 'name' => t('Test entity without label'), - 'entity class' => 'Drupal\field_test\TestEntity', - 'controller class' => 'Drupal\field_test\TestEntityController', - 'fieldable' => TRUE, - 'field cache' => FALSE, - 'base table' => 'test_entity', - 'revision table' => 'test_entity_revision', - 'entity keys' => array( - 'id' => 'ftid', - 'revision' => 'ftvid', - 'bundle' => 'fttype', - ), - 'bundles' => $bundles, - 'view modes' => $test_entity_modes, - ), - 'test_entity_label' => array( - 'name' => t('Test entity label'), - 'entity class' => 'Drupal\field_test\TestEntity', - 'controller class' => 'Drupal\field_test\TestEntityController', - 'fieldable' => TRUE, - 'field cache' => FALSE, - 'base table' => 'test_entity', - 'revision table' => 'test_entity_revision', - 'entity keys' => array( - 'id' => 'ftid', - 'revision' => 'ftvid', - 'bundle' => 'fttype', - 'label' => 'ftlabel', - ), - 'bundles' => $bundles, - 'view modes' => $test_entity_modes, - ), - 'test_entity_label_callback' => array( - 'name' => t('Test entity label callback'), - 'entity class' => 'Drupal\field_test\TestEntity', - 'controller class' => 'Drupal\field_test\TestEntityController', - 'fieldable' => TRUE, - 'field cache' => FALSE, - 'base table' => 'test_entity', - 'revision table' => 'test_entity_revision', - 'label callback' => 'field_test_entity_label_callback', - 'entity keys' => array( - 'id' => 'ftid', - 'revision' => 'ftvid', - 'bundle' => 'fttype', - ), - 'bundles' => $bundles, - 'view modes' => $test_entity_modes, - ), - ); -} +use Drupal\field_test\Plugin\Core\Entity\TestEntity; /** * Implements hook_entity_info_alter(). @@ -183,9 +49,11 @@ function field_test_create_bundle($bundle, $text = NULL) { $bundles += array($bundle => array('label' => $text ? $text : $bundle)); variable_set('field_test_bundles', $bundles); - $info = field_test_entity_info(); + $info = drupal_container()->get('plugin.manager.entity')->getDefinitions(); foreach ($info as $type => $type_info) { - field_attach_create_bundle($type, $bundle); + if ($type_info['module'] == 'field_test') { + field_attach_create_bundle($type, $bundle); + } } } @@ -203,9 +71,11 @@ function field_test_rename_bundle($bundle_old, $bundle_new) { unset($bundles[$bundle_old]); variable_set('field_test_bundles', $bundles); - $info = field_test_entity_info(); + $info = drupal_container()->get('plugin.manager.entity')->getDefinitions(); foreach ($info as $type => $type_info) { - field_attach_rename_bundle($type, $bundle_old, $bundle_new); + if ($type_info['module'] == 'field_test') { + field_attach_rename_bundle($type, $bundle_old, $bundle_new); + } } } @@ -220,9 +90,11 @@ function field_test_delete_bundle($bundle) { unset($bundles[$bundle]); variable_set('field_test_bundles', $bundles); - $info = field_test_entity_info(); + $info = drupal_container()->get('plugin.manager.entity')->getDefinitions(); foreach ($info as $type => $type_info) { - field_attach_delete_bundle($type, $bundle); + if ($type_info['module'] == 'field_test') { + field_attach_delete_bundle($type, $bundle); + } } } @@ -230,7 +102,7 @@ function field_test_delete_bundle($bundle) { * Creates a basic test_entity entity. */ function field_test_create_entity($id = 1, $vid = 1, $bundle = 'test_bundle', $label = '') { - $entity = entity_create('test_entity', array()); + $entity = entity_create('test_entity:test_entity', array()); // Only set id and vid properties if they don't come as NULL (creation form). if (isset($id)) { $entity->ftid = $id; @@ -264,7 +136,7 @@ function field_test_create_entity($id = 1, $vid = 1, $bundle = 'test_bundle', $l function field_test_entity_test_load($ftid, $ftvid = NULL) { $ids = (isset($ftid) ? array($ftid) : array()); $conditions = (isset($ftvid) ? array('ftvid' => $ftvid) : array()); - $test_entity = entity_load_multiple('test_entity', $ids, $conditions); + $test_entity = entity_load_multiple('test_entity:test_entity', $ids, $conditions); return $test_entity ? reset($test_entity) : FALSE; } @@ -292,7 +164,7 @@ function field_test_entity_add($fttype) { * Menu callback: displays the 'Edit exiisting test_entity' form. */ function field_test_entity_edit(TestEntity $entity) { - drupal_set_title(t('test_entity @ftid revision @ftvid', array('@ftid' => $entity->ftid, '@ftvid' => $entity->ftvid)), PASS_THROUGH); + drupal_set_title(t('test_entity:test_entity @ftid revision @ftvid', array('@ftid' => $entity->ftid, '@ftvid' => $entity->ftvid)), PASS_THROUGH); return entity_get_form($entity); } @@ -307,7 +179,7 @@ function field_test_entity_nested_form($form, &$form_state, $entity_1, $entity_2 '#value' => $entity_1->$key, ); } - field_attach_form('test_entity', $entity_1, $form, $form_state); + field_attach_form('test_entity:test_entity', $entity_1, $form, $form_state); // Second entity. $form['entity_2'] = array( @@ -323,7 +195,7 @@ function field_test_entity_nested_form($form, &$form_state, $entity_1, $entity_2 '#value' => $entity_2->$key, ); } - field_attach_form('test_entity', $entity_2, $form['entity_2'], $form_state); + field_attach_form('test_entity:test_entity', $entity_2, $form['entity_2'], $form_state); $form['save'] = array( '#type' => 'submit', @@ -338,25 +210,25 @@ function field_test_entity_nested_form($form, &$form_state, $entity_1, $entity_2 * Validate handler for field_test_entity_nested_form(). */ function field_test_entity_nested_form_validate($form, &$form_state) { - $entity_1 = entity_create('test_entity', $form_state['values']); - field_attach_submit('test_entity', $entity_1, $form, $form_state); - field_attach_form_validate('test_entity', $entity_1, $form, $form_state); + $entity_1 = entity_create('test_entity:test_entity', $form_state['values']); + field_attach_submit('test_entity:test_entity', $entity_1, $form, $form_state); + field_attach_form_validate('test_entity:test_entity', $entity_1, $form, $form_state); - $entity_2 = entity_create('test_entity', $form_state['values']['entity_2']); - field_attach_submit('test_entity', $entity_2, $form['entity_2'], $form_state); - field_attach_form_validate('test_entity', $entity_2, $form['entity_2'], $form_state); + $entity_2 = entity_create('test_entity:test_entity', $form_state['values']['entity_2']); + field_attach_submit('test_entity:test_entity', $entity_2, $form['entity_2'], $form_state); + field_attach_form_validate('test_entity:test_entity', $entity_2, $form['entity_2'], $form_state); } /** * Submit handler for field_test_entity_nested_form(). */ function field_test_entity_nested_form_submit($form, &$form_state) { - $entity_1 = entity_create('test_entity', $form_state['values']); - field_attach_submit('test_entity', $entity_1, $form, $form_state); + $entity_1 = entity_create('test_entity:test_entity', $form_state['values']); + field_attach_submit('test_entity:test_entity', $entity_1, $form, $form_state); field_test_entity_save($entity_1); - $entity_2 = entity_create('test_entity', $form_state['values']['entity_2']); - field_attach_submit('test_entity', $entity_2, $form['entity_2'], $form_state); + $entity_2 = entity_create('test_entity:test_entity', $form_state['values']['entity_2']); + field_attach_submit('test_entity:test_entity', $entity_2, $form['entity_2'], $form_state); field_test_entity_save($entity_2); drupal_set_message(t('test_entities @id_1 and @id_2 have been updated.', array('@id_1' => $entity_1->ftid, '@id_2' => $entity_2->ftid))); diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module index 8c25b1d..065d99c 100644 --- a/core/modules/field/tests/modules/field_test/field_test.module +++ b/core/modules/field/tests/modules/field_test/field_test.module @@ -41,7 +41,7 @@ function field_test_permission() { */ function field_test_menu() { $items = array(); - $bundles = field_info_bundles('test_entity'); + $bundles = field_info_bundles('test_entity:test_entity'); foreach ($bundles as $bundle_name => $bundle_info) { $items['test-entity/add/' . $bundle_name] = array( diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/TestEntity.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Core/Entity/TestEntity.php similarity index 70% rename from core/modules/field/tests/modules/field_test/lib/Drupal/field_test/TestEntity.php rename to core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Core/Entity/TestEntity.php index 25898c8..4a7ed58 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/TestEntity.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Core/Entity/TestEntity.php @@ -1,16 +1,27 @@ fttype) ? $this->fttype : $this->entityType(); } -} +} diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Derivative/FieldTestEntity.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Derivative/FieldTestEntity.php new file mode 100644 index 0000000..59f2338 --- /dev/null +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Derivative/FieldTestEntity.php @@ -0,0 +1,160 @@ +bundles = variable_get('field_test_bundles', array('test_bundle' => array('label' => 'Test Bundle'))); + $this->test_entity_modes = array( + 'full' => array( + 'label' => t('Full object'), + 'custom settings' => TRUE, + ), + 'teaser' => array( + 'label' => t('Teaser'), + 'custom settings' => TRUE, + ), + ); + $this->entities = array( + 'test_entity' => array( + 'name' => t('Test Entity'), + 'form_controller_class' => array( + 'default' => 'Drupal\field_test\TestEntityFormController', + ), + 'revision table' => 'test_entity_revision', + 'entity keys' => array( + 'id' => 'ftid', + 'revision' => 'ftvid', + 'bundle' => 'fttype', + ), + 'bundles' => $this->bundles, + 'view modes' => $this->test_entity_modes, + ), + // This entity type doesn't get form handling for now... + 'test_cacheable_entity' => array( + 'name' => t('Test Entity, cacheable'), + 'field_cache' => TRUE, + 'entity keys' => array( + 'id' => 'ftid', + 'revision' => 'ftvid', + 'bundle' => 'fttype', + ), + 'bundles' => $this->bundles, + 'view modes' => $this->test_entity_modes, + ), + 'bundle_key' => array( + 'name' => t('Test Entity with a bundle key.'), + 'base_table' => 'test_entity_bundle_key', + 'entity keys' => array( + 'id' => 'ftid', + 'bundle' => 'fttype', + ), + 'bundles' => array( + 'bundle1' => array('label' => 'Bundle1'), + 'bundle2' => array('label' => 'Bundle2'), + ) + $this->bundles, + 'view modes' => $this->test_entity_modes, + ), + // In this case, the bundle key is not stored in the database. + 'test_entity_bundle' => array( + 'name' => t('Test Entity with a specified bundle.'), + 'base_table' => 'test_entity_bundle', + 'controller_class' => 'Drupal\field_test\TestEntityController', + 'entity keys' => array( + 'id' => 'ftid', + 'bundle' => 'fttype', + ), + 'bundles' => array('test_entity_2' => array('label' => 'Test entity 2')) + $this->bundles, + 'view modes' => $this->test_entity_modes, + ), + // @see EntityPropertiesTestCase::testEntityLabel() + 'test_entity_no_label' => array( + 'name' => t('Test entity without label'), + 'entity keys' => array( + 'id' => 'ftid', + 'revision' => 'ftvid', + 'bundle' => 'fttype', + ), + 'bundles' => $this->bundles, + 'view modes' => $this->test_entity_modes, + ), + 'test_entity_label' => array( + 'name' => t('Test entity label'), + 'entity keys' => array( + 'id' => 'ftid', + 'revision' => 'ftvid', + 'bundle' => 'fttype', + 'label' => 'ftlabel', + ), + 'bundles' => $this->bundles, + 'view modes' => $this->test_entity_modes, + ), + 'test_entity_label_callback' => array( + 'name' => t('Test entity label callback'), + 'label callback' => 'field_test_entity_label_callback', + 'entity keys' => array( + 'id' => 'ftid', + 'revision' => 'ftvid', + 'bundle' => 'fttype', + ), + 'bundles' => $this->bundles, + 'view modes' => $this->test_entity_modes, + ), + ); + } + + /** + * Implements DerivativeInterface::getDerivativeDefinition(). + */ + public function getDerivativeDefinition($derivative_id, array $base_plugin_definition) { + if (!empty($this->derivatives) && !empty($this->derivatives[$derivative_id])) { + return $this->derivatives[$derivative_id]; + } + $this->getDerivativeDefinitions($base_plugin_definition); + return $this->derivatives[$derivative_id]; + } + + /** + * Implements DerivativeInterface::getDerivativeDefinitions(). + */ + public function getDerivativeDefinitions(array $base_plugin_definition) { + foreach ($this->entities as $entity_type => $info) { + $this->derivatives[$entity_type] = $info += $base_plugin_definition; + } + return $this->derivatives; + } + +} diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/TestEntityFormController.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/TestEntityFormController.php index 93ef2aa..ddedbb8 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/TestEntityFormController.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/TestEntityFormController.php @@ -40,7 +40,7 @@ public function save(array $form, array &$form_state) { $is_new = $entity->isNew(); $entity->save(); - $message = $is_new ? t('test_entity @id has been created.', array('@id' => $entity->id())) : t('test_entity @id has been updated.', array('@id' => $entity->id())); + $message = $is_new ? t('test_entity:test_entity @id has been created.', array('@id' => $entity->id())) : t('test_entity:test_entity @id has been updated.', array('@id' => $entity->id())); drupal_set_message($message); if ($entity->id()) { diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php index 96f59a2..a1c854f 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php @@ -7,7 +7,7 @@ namespace Drupal\field_ui\Tests; -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; /** * Tests the functionality of the 'Manage display' screens. diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 4e6c8eb..433cb03 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -6,7 +6,7 @@ */ use Drupal\Core\Entity\EntityFieldQuery; -use Drupal\file\File; +use Drupal\file\Plugin\Core\Entity\File; use Drupal\Core\Template\Attribute; use Symfony\Component\HttpFoundation\JsonResponse; use Drupal\file\FileUsage\DatabaseFileUsageBackend; @@ -88,30 +88,17 @@ function file_element_info() { } /** - * Implements hook_entity_info(). + * Implements hook_entity_info_alter(). */ -function file_entity_info() { - return array( - 'file' => array( - 'label' => t('File'), - 'base table' => 'file_managed', - 'controller class' => 'Drupal\file\FileStorageController', - 'entity class' => 'Drupal\file\File', - 'entity keys' => array( - 'id' => 'fid', - 'label' => 'filename', - 'uuid' => 'uuid', - ), - 'view modes' => array( - 'full' => array( - 'label' => t('File default'), - 'custom settings' => FALSE, - ), - ), - 'static cache' => FALSE, +function file_entity_info_alter(&$info) { + $info['file']['view modes'] = array( + 'full' => array( + 'label' => t('File default'), + 'custom settings' => FALSE, ), ); } + /** * Loads file entities from the database. * diff --git a/core/modules/file/lib/Drupal/file/File.php b/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php similarity index 75% rename from core/modules/file/lib/Drupal/file/File.php rename to core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php index 9b965e3..e75d62d 100644 --- a/core/modules/file/lib/Drupal/file/File.php +++ b/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php @@ -2,15 +2,31 @@ /** * @file - * Definition of Drupal\file\File. + * Definition of Drupal\file\Plugin\Core\Entity\File. */ -namespace Drupal\file; +namespace Drupal\file\Plugin\Core\Entity; use Drupal\Core\Entity\Entity; +use Drupal\Core\Annotation\Plugin; +use Drupal\Core\Annotation\Translation; /** * Defines the file entity class. + * + * @Plugin( + * id = "file", + * label = @Translation("File"), + * module = "file", + * controller_class = "Drupal\file\FileStorageController", + * base_table = "file_managed", + * static_cache = FALSE, + * entity_keys = { + * "id" = "fid", + * "label" = "filename", + * "uuid" = "uuid" + * } + * ) */ class File extends Entity { diff --git a/core/modules/file/tests/file_module_test.module b/core/modules/file/tests/file_module_test.module index eae577e..b962e2a 100644 --- a/core/modules/file/tests/file_module_test.module +++ b/core/modules/file/tests/file_module_test.module @@ -6,7 +6,7 @@ */ use Drupal\Core\Entity\EntityInterface; -use Drupal\file\File; +use Drupal\file\Plugin\Core\Entity\File; /** * Implements hook_menu(). diff --git a/core/modules/file/tests/file_test/file_test.module b/core/modules/file/tests/file_test/file_test.module index 46b8604..d4a4359 100644 --- a/core/modules/file/tests/file_test/file_test.module +++ b/core/modules/file/tests/file_test/file_test.module @@ -8,7 +8,7 @@ * calling file_test_get_calls() or file_test_set_return(). */ -use Drupal\file\File; +use Drupal\file\Plugin\Core\Entity\File; const FILE_URL_TEST_CDN_1 = 'http://cdn1.example.com'; const FILE_URL_TEST_CDN_2 = 'http://cdn2.example.com'; diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index af2daa9..82d419f 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -5,8 +5,8 @@ * Provides discussion forums. */ -use Drupal\node\Node; -use Drupal\taxonomy\Term; +use Drupal\node\Plugin\Core\Entity\Node; +use Drupal\taxonomy\Plugin\Core\Entity\Term; /** * Implements hook_help(). diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php index b747a68..25b2060 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -7,7 +7,7 @@ namespace Drupal\forum\Tests; -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\simpletest\WebTestBase; /** diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 9861931..bb5fe8e 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -9,7 +9,7 @@ use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Drupal\Component\Uuid\Uuid; -use Drupal\file\File; +use Drupal\file\Plugin\Core\Entity\File; /** * Image style constant for user presets in the database. diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index cee4ba5..81fb51f 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -11,7 +11,7 @@ * URLs to be added to the main site navigation menu. */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; use Symfony\Component\HttpFoundation\JsonResponse; diff --git a/core/modules/node/lib/Drupal/node/Node.php b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php similarity index 81% rename from core/modules/node/lib/Drupal/node/Node.php rename to core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php index 45d93f0..b828c71 100644 --- a/core/modules/node/lib/Drupal/node/Node.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php @@ -2,16 +2,40 @@ /** * @file - * Definition of Drupal\node\Node. + * Definition of Drupal\node\Plugin\Core\Entity\Node. */ -namespace Drupal\node; +namespace Drupal\node\Plugin\Core\Entity; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\Entity; +use Drupal\Core\Annotation\Plugin; +use Drupal\Core\Annotation\Translation; /** * Defines the node entity class. + * + * @Plugin( + * id = "node", + * label = @Translation("Node"), + * module = "node", + * controller_class = "Drupal\node\NodeStorageController", + * render_controller_class = "Drupal\node\NodeRenderController", + * form_controller_class = { + * "default" = "Drupal\node\NodeFormController" + * }, + * base_table = "node", + * revision_table = "node_revision", + * uri_callback = "node_uri", + * fieldable = TRUE, + * entity_keys = { + * "id" = "nid", + * "revision" = "vid", + * "bundle" = "type", + * "label" = "title", + * "uuid" = "uuid" + * } + * ) */ class Node extends Entity implements ContentEntityInterface { diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 30a6dd5..d67ac4c 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -15,8 +15,8 @@ use Drupal\Core\Database\Query\SelectExtender; use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Template\Attribute; -use Drupal\node\Node; -use Drupal\file\File; +use Drupal\node\Plugin\Core\Entity\Node; +use Drupal\file\Plugin\Core\Entity\File; use Drupal\Core\Entity\EntityInterface; /** @@ -191,59 +191,36 @@ function node_cron() { } /** - * Implements hook_entity_info(). + * Implements hook_entity_info_alter(). */ -function node_entity_info() { - $return = array( - 'node' => array( - 'label' => t('Node'), - 'entity class' => 'Drupal\node\Node', - 'controller class' => 'Drupal\node\NodeStorageController', - 'form controller class' => array( - 'default' => 'Drupal\node\NodeFormController', - ), - 'base table' => 'node', - 'revision table' => 'node_revision', - 'uri callback' => 'node_uri', - 'fieldable' => TRUE, - 'entity keys' => array( - 'id' => 'nid', - 'revision' => 'vid', - 'bundle' => 'type', - 'label' => 'title', - 'uuid' => 'uuid', - ), - 'bundle keys' => array( - 'bundle' => 'type', - ), - 'bundles' => array(), - 'render controller class' => 'Drupal\node\NodeRenderController', - 'view modes' => array( - 'full' => array( - 'label' => t('Full content'), - 'custom settings' => FALSE, - ), - 'teaser' => array( - 'label' => t('Teaser'), - 'custom settings' => TRUE, - ), - 'rss' => array( - 'label' => t('RSS'), - 'custom settings' => FALSE, - ), - ), +function node_entity_info_alter(&$info) { + $info['node']['bundle keys'] = array( + 'bundle' => 'type', + ); + $info['node']['view modes'] = array( + 'full' => array( + 'label' => t('Full content'), + 'custom settings' => FALSE, + ), + 'teaser' => array( + 'label' => t('Teaser'), + 'custom settings' => TRUE, + ), + 'rss' => array( + 'label' => t('RSS'), + 'custom settings' => FALSE, ), ); // Add a translation handler for fields if the language module is enabled. if (module_exists('language')) { - $return['node']['translation']['node'] = TRUE; + $info['node']['translation']['node'] = TRUE; } // Search integration is provided by node.module, so search-related // view modes for nodes are defined here and not in search.module. if (module_exists('search')) { - $return['node']['view modes'] += array( + $info['node']['view modes'] += array( 'search_index' => array( 'label' => t('Search index'), 'custom settings' => FALSE, @@ -259,7 +236,7 @@ function node_entity_info() { // messages, and the path to attach Field admin pages to. node_type_cache_reset(); foreach (node_type_get_names() as $type => $name) { - $return['node']['bundles'][$type] = array( + $info['node']['bundles'][$type] = array( 'label' => $name, 'admin' => array( 'path' => 'admin/structure/types/manage/%node_type', @@ -269,8 +246,6 @@ function node_entity_info() { ), ); } - - return $return; } /** diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index 041dd35..77b2a89 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -9,7 +9,7 @@ * @see node_menu() */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; /** * Page callback: Presents the node editing form. diff --git a/core/modules/node/tests/modules/node_access_test/node_access_test.module b/core/modules/node/tests/modules/node_access_test/node_access_test.module index a503217..bcd5a71 100644 --- a/core/modules/node/tests/modules/node_access_test/node_access_test.module +++ b/core/modules/node/tests/modules/node_access_test/node_access_test.module @@ -9,7 +9,7 @@ use Drupal\Core\Entity\EntityFieldQuery; -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; /** * Implements hook_node_grants(). diff --git a/core/modules/node/tests/modules/node_test/node_test.module b/core/modules/node/tests/modules/node_test/node_test.module index 1686ff0..d3aa004 100644 --- a/core/modules/node/tests/modules/node_test/node_test.module +++ b/core/modules/node/tests/modules/node_test/node_test.module @@ -6,7 +6,7 @@ * the Node module. */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; /** * Implements hook_node_load(). diff --git a/core/modules/node/tests/modules/node_test_exception/node_test_exception.module b/core/modules/node/tests/modules/node_test_exception/node_test_exception.module index 570236b..c5d1129 100644 --- a/core/modules/node/tests/modules/node_test_exception/node_test_exception.module +++ b/core/modules/node/tests/modules/node_test_exception/node_test_exception.module @@ -6,7 +6,7 @@ * the Node module. */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; /** * Implements hook_node_insert(). diff --git a/core/modules/path/path.module b/core/modules/path/path.module index 6a69c13..942fbb6 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -5,9 +5,9 @@ * Enables users to rename URLs. */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; -use Drupal\taxonomy\Term; +use Drupal\taxonomy\Plugin\Core\Entity\Term; /** * Implements hook_help(). diff --git a/core/modules/poll/poll.module b/core/modules/poll/poll.module index c85f121..d3f8d3a 100644 --- a/core/modules/poll/poll.module +++ b/core/modules/poll/poll.module @@ -5,7 +5,7 @@ * Collects votes on different topics in the form of multiple choice questions. */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; /** * Implements hook_help(). diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/CrudTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/CrudTest.php index 3e52bd9..50fbfa4 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/CrudTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CrudTest.php @@ -34,7 +34,7 @@ public static function getInfo() { */ function testCRUD() { // Verify loading of a default mapping. - $mapping = _rdf_mapping_load('test_entity', 'test_bundle'); + $mapping = _rdf_mapping_load('test_entity:test_entity', 'test_bundle'); $this->assertTrue(count($mapping), t('Default mapping was found.')); // Verify saving a mapping. diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/MappingHookTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/MappingHookTest.php index e29d545..30a70c5 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/MappingHookTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/MappingHookTest.php @@ -34,7 +34,7 @@ public static function getInfo() { */ function testMapping() { // Test that the mapping is returned correctly by the hook. - $mapping = rdf_mapping_load('test_entity', 'test_bundle'); + $mapping = rdf_mapping_load('test_entity:test_entity', 'test_bundle'); $this->assertIdentical($mapping['rdftype'], array('sioc:Post'), t('Mapping for rdftype is sioc:Post.')); $this->assertIdentical($mapping['title'], array('predicates' => array('dc:title')), t('Mapping for title is dc:title.')); $this->assertIdentical($mapping['created'], array( @@ -44,7 +44,7 @@ function testMapping() { ), t('Mapping for created is dc:created with datatype xsd:dateTime and callback date_iso8601.')); $this->assertIdentical($mapping['uid'], array('predicates' => array('sioc:has_creator', 'dc:creator'), 'type' => 'rel'), t('Mapping for uid is sioc:has_creator and dc:creator, and type is rel.')); - $mapping = rdf_mapping_load('test_entity', 'test_bundle_no_mapping'); + $mapping = rdf_mapping_load('test_entity:test_entity', 'test_bundle_no_mapping'); $this->assertEqual($mapping, array(), t('Empty array returned when an entity type, bundle pair has no mapping.')); } } diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php index 8c3b398..09d6f4d 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php @@ -39,7 +39,7 @@ function testDrupalRdfaAttributes() { $expected_attributes = array( 'property' => array('dc:title'), ); - $mapping = rdf_mapping_load('test_entity', 'test_bundle'); + $mapping = rdf_mapping_load('test_entity:test_entity', 'test_bundle'); $attributes = rdf_rdfa_attributes($mapping['title']); ksort($expected_attributes); ksort($attributes); @@ -53,7 +53,7 @@ function testDrupalRdfaAttributes() { 'property' => array('dc:created'), 'content' => $isoDate, ); - $mapping = rdf_mapping_load('test_entity', 'test_bundle'); + $mapping = rdf_mapping_load('test_entity:test_entity', 'test_bundle'); $attributes = rdf_rdfa_attributes($mapping['created'], $date); ksort($expected_attributes); ksort($attributes); @@ -64,7 +64,7 @@ function testDrupalRdfaAttributes() { 'datatype' => 'foo:bar1type', 'property' => array('foo:bar1'), ); - $mapping = rdf_mapping_load('test_entity', 'test_bundle'); + $mapping = rdf_mapping_load('test_entity:test_entity', 'test_bundle'); $attributes = rdf_rdfa_attributes($mapping['foobar1']); ksort($expected_attributes); ksort($attributes); @@ -74,7 +74,7 @@ function testDrupalRdfaAttributes() { $expected_attributes = array( 'rel' => array('sioc:has_creator', 'dc:creator'), ); - $mapping = rdf_mapping_load('test_entity', 'test_bundle'); + $mapping = rdf_mapping_load('test_entity:test_entity', 'test_bundle'); $attributes = rdf_rdfa_attributes($mapping['foobar_objproperty1']); ksort($expected_attributes); ksort($attributes); @@ -84,7 +84,7 @@ function testDrupalRdfaAttributes() { $expected_attributes = array( 'rev' => array('sioc:reply_of'), ); - $mapping = rdf_mapping_load('test_entity', 'test_bundle'); + $mapping = rdf_mapping_load('test_entity:test_entity', 'test_bundle'); $attributes = rdf_rdfa_attributes($mapping['foobar_objproperty2']); ksort($expected_attributes); ksort($attributes); diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php index e4f6fe4..d92d106 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php @@ -7,7 +7,7 @@ namespace Drupal\rdf\Tests; -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\simpletest\WebTestBase; /** diff --git a/core/modules/rdf/tests/rdf_test.module b/core/modules/rdf/tests/rdf_test.module index 4d90472..10c20b7 100644 --- a/core/modules/rdf/tests/rdf_test.module +++ b/core/modules/rdf/tests/rdf_test.module @@ -11,7 +11,7 @@ function rdf_test_rdf_mapping() { return array( array( - 'type' => 'test_entity', + 'type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'mapping' => array( 'rdftype' => array('sioc:Post'), diff --git a/core/modules/search/search.module b/core/modules/search/search.module index 315ae7a..a32b5c3 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -5,7 +5,7 @@ * Enables site-wide keyword searching. */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; /** * Matches all 'N' Unicode character classes (numbers) diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module index 8469e52..f11f3ed 100644 --- a/core/modules/statistics/statistics.module +++ b/core/modules/statistics/statistics.module @@ -5,7 +5,7 @@ * Logs and displays access statistics for a site. */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; /** * Implements hook_help(). diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldQueryTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldQueryTest.php index fa0f4b2..a733668 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldQueryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldQueryTest.php @@ -70,11 +70,11 @@ function setUp() { // Add an instance to that bundle. $instances[0]['bundle'] = 'bundle1'; - $instances[0]['entity_type'] = 'test_entity_bundle_key'; + $instances[0]['entity_type'] = 'test_entity:bundle_key'; field_create_instance($instances[0]); $instances[0]['bundle'] = 'bundle2'; field_create_instance($instances[0]); - $instances[0]['bundle'] = $instances[0]['entity_type'] = 'test_entity_bundle'; + $instances[0]['bundle'] = $instances[0]['entity_type'] = 'test_entity:test_entity_bundle'; field_create_instance($instances[0]); $this->field_names[1] = $field_name = drupal_strtolower($this->randomName() . '_field_name'); @@ -104,9 +104,9 @@ function setUp() { // Add a field instance to the bundles. $instances[1]['bundle'] = 'bundle1'; - $instances[1]['entity_type'] = 'test_entity_bundle_key'; + $instances[1]['entity_type'] = 'test_entity:bundle_key'; field_create_instance($instances[1]); - $instances[1]['bundle'] = $instances[1]['entity_type'] = 'test_entity_bundle'; + $instances[1]['bundle'] = $instances[1]['entity_type'] = 'test_entity:test_entity_bundle'; field_create_instance($instances[1]); $this->instances = $instances; @@ -115,7 +115,7 @@ function setUp() { // Create entities which have a 'bundle key' defined. for ($i = 1; $i < 7; $i++) { - $entity = entity_create('test_entity_bundle_key', array()); + $entity = entity_create('test_entity:bundle_key', array()); $entity->ftid = $i; $entity->ftvid = $i; $entity->fttype = ($i < 5) ? 'bundle1' : 'bundle2'; @@ -125,7 +125,7 @@ function setUp() { $entity->save(); } - $entity = entity_create('test_entity_bundle', array('ftid' => 5)); + $entity = entity_create('test_entity:test_entity_bundle', array('ftid' => 5)); $entity->{$this->field_names[1]}[LANGUAGE_NOT_SPECIFIED][0]['shape'] = 'square'; $entity->{$this->field_names[1]}[LANGUAGE_NOT_SPECIFIED][0]['color'] = 'red'; $entity->{$this->field_names[1]}[LANGUAGE_NOT_SPECIFIED][1]['shape'] = 'circle'; @@ -136,7 +136,7 @@ function setUp() { $instances[2] = $instance; $instances[2]['bundle'] = 'test_bundle'; $instances[2]['field_name'] = $this->field_names[0]; - $instances[2]['entity_type'] = 'test_entity'; + $instances[2]['entity_type'] = 'test_entity:test_entity'; field_create_instance($instances[2]); // Create entities with support for revisions. @@ -163,504 +163,504 @@ function setUp() { function testEntityFieldQuery() { $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle') + ->entityCondition('entity_type', 'test_entity:test_entity_bundle') ->entityCondition('entity_id', '5'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle', 5), + array('test_entity:test_entity_bundle', 5), ), 'Test query on an entity type with a generated bundle.'); // Test entity_type condition. $query = new EntityFieldQuery(); - $query->entityCondition('entity_type', 'test_entity_bundle_key'); + $query->entityCondition('entity_type', 'test_entity:bundle_key'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test entity entity_type condition.'); // Test entity_id condition. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->entityCondition('entity_id', '3'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 3), + array('test_entity:bundle_key', 3), ), 'Test entity entity_id condition.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('ftid', '3'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 3), + array('test_entity:bundle_key', 3), ), 'Test entity entity_id condition and entity_id property condition.'); // Test bundle condition. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->entityCondition('bundle', 'bundle1'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), ), 'Test entity bundle condition: bundle1.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->entityCondition('bundle', 'bundle2'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test entity bundle condition: bundle2.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('fttype', 'bundle2'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test entity bundle condition and bundle property condition.'); // Test revision_id condition. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity') + ->entityCondition('entity_type', 'test_entity:test_entity') ->entityCondition('revision_id', '3'); $this->assertEntityFieldQuery($query, array( - array('test_entity', 3), + array('test_entity:test_entity', 3), ), 'Test entity revision_id condition.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity') + ->entityCondition('entity_type', 'test_entity:test_entity') ->propertyCondition('ftvid', '3'); $this->assertEntityFieldQuery($query, array( - array('test_entity', 3), + array('test_entity:test_entity', 3), ), 'Test entity revision_id condition and revision_id property condition.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity') + ->entityCondition('entity_type', 'test_entity:test_entity') ->fieldCondition($this->fields[0], 'value', 100, '>=') ->age(FIELD_LOAD_REVISION); $this->assertEntityFieldQuery($query, array( - array('test_entity', 100), - array('test_entity', 101), + array('test_entity:test_entity', 100), + array('test_entity:test_entity', 101), ), 'Test revision age.'); // Test that fields attached to the non-revision supporting entity - // 'test_entity_bundle_key' are reachable in FIELD_LOAD_REVISION. + // 'test_entity:bundle_key' are reachable in FIELD_LOAD_REVISION. $query = new EntityFieldQuery(); $query ->fieldCondition($this->fields[0], 'value', 100, '<') ->age(FIELD_LOAD_REVISION); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), - array('test_entity', 1), - array('test_entity', 2), - array('test_entity', 3), - array('test_entity', 4), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), + array('test_entity:test_entity', 1), + array('test_entity:test_entity', 2), + array('test_entity:test_entity', 3), + array('test_entity:test_entity', 4), ), 'Test that fields are reachable from FIELD_LOAD_REVISION even for non-revision entities.'); // Test entity sort by entity_id. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->entityOrderBy('entity_id', 'ASC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test sort entity entity_id in ascending order.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->entityOrderBy('entity_id', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 1), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 1), ), 'Test sort entity entity_id in descending order.', TRUE); // Test entity sort by entity_id, with a field condition. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->entityOrderBy('entity_id', 'ASC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test sort entity entity_id in ascending order, with a field condition.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->propertyOrderBy('ftid', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 1), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 1), ), 'Test sort entity entity_id property in descending order, with a field condition.', TRUE); // Test property sort by entity id. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyOrderBy('ftid', 'ASC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test sort entity entity_id property in ascending order.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyOrderBy('ftid', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 1), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 1), ), 'Test sort entity entity_id property in descending order.', TRUE); // Test property sort by entity id, with a field condition. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->propertyOrderBy('ftid', 'ASC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test sort entity entity_id property in ascending order, with a field condition.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->propertyOrderBy('ftid', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 1), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 1), ), 'Test sort entity entity_id property in descending order, with a field condition.', TRUE); // Test entity sort by bundle. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->entityOrderBy('bundle', 'ASC') ->propertyOrderBy('ftid', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 5), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 5), ), 'Test sort entity bundle in ascending order, property in descending order.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->entityOrderBy('bundle', 'DESC') ->propertyOrderBy('ftid', 'ASC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), ), 'Test sort entity bundle in descending order, property in ascending order.', TRUE); // Test entity sort by bundle, with a field condition. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->entityOrderBy('bundle', 'ASC') ->propertyOrderBy('ftid', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 5), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 5), ), 'Test sort entity bundle in ascending order, property in descending order, with a field condition.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->entityOrderBy('bundle', 'DESC') ->propertyOrderBy('ftid', 'ASC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), ), 'Test sort entity bundle in descending order, property in ascending order, with a field condition.', TRUE); // Test entity sort by bundle, field. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->entityOrderBy('bundle', 'ASC') ->fieldOrderBy($this->fields[0], 'value', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 5), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 5), ), 'Test sort entity bundle in ascending order, field in descending order.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->entityOrderBy('bundle', 'DESC') ->fieldOrderBy($this->fields[0], 'value', 'ASC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), ), 'Test sort entity bundle in descending order, field in ascending order.', TRUE); // Test entity sort by revision_id. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity') + ->entityCondition('entity_type', 'test_entity:test_entity') ->entityOrderBy('revision_id', 'ASC'); $this->assertEntityFieldQuery($query, array( - array('test_entity', 1), - array('test_entity', 2), - array('test_entity', 3), - array('test_entity', 4), + array('test_entity:test_entity', 1), + array('test_entity:test_entity', 2), + array('test_entity:test_entity', 3), + array('test_entity:test_entity', 4), ), 'Test sort entity revision_id in ascending order.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity') + ->entityCondition('entity_type', 'test_entity:test_entity') ->entityOrderBy('revision_id', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity', 4), - array('test_entity', 3), - array('test_entity', 2), - array('test_entity', 1), + array('test_entity:test_entity', 4), + array('test_entity:test_entity', 3), + array('test_entity:test_entity', 2), + array('test_entity:test_entity', 1), ), 'Test sort entity revision_id in descending order.', TRUE); // Test entity sort by revision_id, with a field condition. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity') + ->entityCondition('entity_type', 'test_entity:test_entity') ->fieldCondition($this->fields[0], 'value', 0, '>') ->entityOrderBy('revision_id', 'ASC'); $this->assertEntityFieldQuery($query, array( - array('test_entity', 1), - array('test_entity', 2), - array('test_entity', 3), - array('test_entity', 4), + array('test_entity:test_entity', 1), + array('test_entity:test_entity', 2), + array('test_entity:test_entity', 3), + array('test_entity:test_entity', 4), ), 'Test sort entity revision_id in ascending order, with a field condition.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity') + ->entityCondition('entity_type', 'test_entity:test_entity') ->fieldCondition($this->fields[0], 'value', 0, '>') ->entityOrderBy('revision_id', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity', 4), - array('test_entity', 3), - array('test_entity', 2), - array('test_entity', 1), + array('test_entity:test_entity', 4), + array('test_entity:test_entity', 3), + array('test_entity:test_entity', 2), + array('test_entity:test_entity', 1), ), 'Test sort entity revision_id in descending order, with a field condition.', TRUE); // Test property sort by revision_id. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity') + ->entityCondition('entity_type', 'test_entity:test_entity') ->propertyOrderBy('ftvid', 'ASC'); $this->assertEntityFieldQuery($query, array( - array('test_entity', 1), - array('test_entity', 2), - array('test_entity', 3), - array('test_entity', 4), + array('test_entity:test_entity', 1), + array('test_entity:test_entity', 2), + array('test_entity:test_entity', 3), + array('test_entity:test_entity', 4), ), 'Test sort entity revision_id property in ascending order.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity') + ->entityCondition('entity_type', 'test_entity:test_entity') ->propertyOrderBy('ftvid', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity', 4), - array('test_entity', 3), - array('test_entity', 2), - array('test_entity', 1), + array('test_entity:test_entity', 4), + array('test_entity:test_entity', 3), + array('test_entity:test_entity', 2), + array('test_entity:test_entity', 1), ), 'Test sort entity revision_id property in descending order.', TRUE); // Test property sort by revision_id, with a field condition. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity') + ->entityCondition('entity_type', 'test_entity:test_entity') ->fieldCondition($this->fields[0], 'value', 0, '>') ->propertyOrderBy('ftvid', 'ASC'); $this->assertEntityFieldQuery($query, array( - array('test_entity', 1), - array('test_entity', 2), - array('test_entity', 3), - array('test_entity', 4), + array('test_entity:test_entity', 1), + array('test_entity:test_entity', 2), + array('test_entity:test_entity', 3), + array('test_entity:test_entity', 4), ), 'Test sort entity revision_id property in ascending order, with a field condition.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity') + ->entityCondition('entity_type', 'test_entity:test_entity') ->fieldCondition($this->fields[0], 'value', 0, '>') ->propertyOrderBy('ftvid', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity', 4), - array('test_entity', 3), - array('test_entity', 2), - array('test_entity', 1), + array('test_entity:test_entity', 4), + array('test_entity:test_entity', 3), + array('test_entity:test_entity', 2), + array('test_entity:test_entity', 1), ), 'Test sort entity revision_id property in descending order, with a field condition.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldOrderBy($this->fields[0], 'value', 'ASC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test sort field in ascending order without field condition.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldOrderBy($this->fields[0], 'value', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 1), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 1), ), 'Test sort field in descending order without field condition.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->fieldOrderBy($this->fields[0], 'value', 'ASC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test sort field in ascending order.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->fieldOrderBy($this->fields[0], 'value', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 1), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 1), ), 'Test sort field in descending order.', TRUE); // Test "in" operation with entity entity_type condition and entity_id // property condition. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('ftid', array(1, 3, 4), 'IN'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), ), 'Test "in" operation with entity entity_type condition and entity_id property condition.'); // Test "in" operation with entity entity_type condition and entity_id // property condition. Sort in descending order by entity_id. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('ftid', array(1, 3, 4), 'IN') ->propertyOrderBy('ftid', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 1), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 1), ), 'Test "in" operation with entity entity_type condition and entity_id property condition. Sort entity_id in descending order.', TRUE); // Test query count $query = new EntityFieldQuery(); $query_count = $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->count() ->execute(); $this->assertEqual($query_count, 6, 'Test query count on entity condition.'); $query = new EntityFieldQuery(); $query_count = $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('ftid', '1') ->count() ->execute(); @@ -668,7 +668,7 @@ function testEntityFieldQuery() { $query = new EntityFieldQuery(); $query_count = $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('ftid', '4', '>') ->count() ->execute(); @@ -676,7 +676,7 @@ function testEntityFieldQuery() { $query = new EntityFieldQuery(); $query_count = $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 3, '=') ->count() ->execute(); @@ -685,299 +685,299 @@ function testEntityFieldQuery() { // First, test without options. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('fttype', 'und', 'CONTAINS'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test the "contains" operation on a property.'); $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[1], 'shape', 'uar', 'CONTAINS'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle', 5), + array('test_entity:test_entity_bundle', 5), ), 'Test the "contains" operation on a field.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('ftid', 1, '='); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), + array('test_entity:bundle_key', 1), ), 'Test the "equal to" operation on a property.'); $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[0], 'value', 3, '='); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 3), - array('test_entity', 3), + array('test_entity:bundle_key', 3), + array('test_entity:test_entity', 3), ), 'Test the "equal to" operation on a field.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('ftid', 3, '<>'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test the "not equal to" operation on a property.'); $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[0], 'value', 3, '<>'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), - array('test_entity', 1), - array('test_entity', 2), - array('test_entity', 4), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), + array('test_entity:test_entity', 1), + array('test_entity:test_entity', 2), + array('test_entity:test_entity', 4), ), 'Test the "not equal to" operation on a field.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('ftid', 2, '<'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), + array('test_entity:bundle_key', 1), ), 'Test the "less than" operation on a property.'); $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[0], 'value', 2, '<'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity', 1), + array('test_entity:bundle_key', 1), + array('test_entity:test_entity', 1), ), 'Test the "less than" operation on a field.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('ftid', 2, '<='); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), ), 'Test the "less than or equal to" operation on a property.'); $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[0], 'value', 2, '<='); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity', 1), - array('test_entity', 2), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:test_entity', 1), + array('test_entity:test_entity', 2), ), 'Test the "less than or equal to" operation on a field.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('ftid', 4, '>'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test the "greater than" operation on a property.'); $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[0], 'value', 2, '>'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), - array('test_entity', 3), - array('test_entity', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), + array('test_entity:test_entity', 3), + array('test_entity:test_entity', 4), ), 'Test the "greater than" operation on a field.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('ftid', 4, '>='); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test the "greater than or equal to" operation on a property.'); $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[0], 'value', 3, '>='); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), - array('test_entity', 3), - array('test_entity', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), + array('test_entity:test_entity', 3), + array('test_entity:test_entity', 4), ), 'Test the "greater than or equal to" operation on a field.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('ftid', array(3, 4), 'NOT IN'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test the "not in" operation on a property.'); $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[0], 'value', array(3, 4, 100, 101), 'NOT IN'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), - array('test_entity', 1), - array('test_entity', 2), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), + array('test_entity:test_entity', 1), + array('test_entity:test_entity', 2), ), 'Test the "not in" operation on a field.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('ftid', array(3, 4), 'IN'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), ), 'Test the "in" operation on a property.'); $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[0], 'value', array(2, 3), 'IN'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity', 2), - array('test_entity', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:test_entity', 2), + array('test_entity:test_entity', 3), ), 'Test the "in" operation on a field.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('ftid', array(1, 3), 'BETWEEN'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), ), 'Test the "between" operation on a property.'); $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[0], 'value', array(1, 3), 'BETWEEN'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity', 1), - array('test_entity', 2), - array('test_entity', 3), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:test_entity', 1), + array('test_entity:test_entity', 2), + array('test_entity:test_entity', 3), ), 'Test the "between" operation on a field.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('fttype', 'bun', 'STARTS_WITH'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test the "starts_with" operation on a property.'); $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[1], 'shape', 'squ', 'STARTS_WITH'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle', 5), + array('test_entity:test_entity_bundle', 5), ), 'Test the "starts_with" operation on a field.'); $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[0], 'value', 3); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 3), - array('test_entity', 3), + array('test_entity:bundle_key', 3), + array('test_entity:test_entity', 3), ), 'Test omission of an operator with a single item.'); $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[0], 'value', array(2, 3)); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity', 2), - array('test_entity', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:test_entity', 2), + array('test_entity:test_entity', 3), ), 'Test omission of an operator with multiple items.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyCondition('ftid', 1, '>') ->fieldCondition($this->fields[0], 'value', 4, '<'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), ), 'Test entity, property and field conditions.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->entityCondition('bundle', 'bundle', 'STARTS_WITH') ->propertyCondition('ftid', 4) ->fieldCondition($this->fields[0], 'value', 4); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 4), + array('test_entity:bundle_key', 4), ), 'Test entity condition with "starts_with" operation, and property and field conditions.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyOrderBy('ftid', 'ASC') ->range(0, 2); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), ), 'Test limit on a property.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>=') ->fieldOrderBy($this->fields[0], 'value', 'ASC') ->range(0, 2); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), ), 'Test limit on a field.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyOrderBy('ftid', 'ASC') ->range(4, 6); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test offset on a property.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->fieldOrderBy($this->fields[0], 'value', 'ASC') ->range(2, 4); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test offset on a field.', TRUE); for ($i = 6; $i < 10; $i++) { - $entity = entity_create('test_entity_bundle', array('ftid' => $i)); + $entity = entity_create('test_entity:test_entity_bundle', array('ftid' => $i)); $entity->{$this->field_names[0]}[LANGUAGE_NOT_SPECIFIED][0]['value'] = $i - 5; $entity->enforceIsNew(); $entity->save(); @@ -986,14 +986,14 @@ function testEntityFieldQuery() { $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[0], 'value', 2, '>'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), - array('test_entity', 3), - array('test_entity', 4), - array('test_entity_bundle', 8), - array('test_entity_bundle', 9), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), + array('test_entity:test_entity', 3), + array('test_entity:test_entity', 4), + array('test_entity:test_entity_bundle', 8), + array('test_entity:test_entity_bundle', 9), ), 'Select a field across multiple entities.'); $query = new EntityFieldQuery(); @@ -1001,7 +1001,7 @@ function testEntityFieldQuery() { ->fieldCondition($this->fields[1], 'shape', 'square') ->fieldCondition($this->fields[1], 'color', 'blue'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle', 5), + array('test_entity:test_entity_bundle', 5), ), 'Test without a delta group.'); $query = new EntityFieldQuery(); @@ -1011,15 +1011,15 @@ function testEntityFieldQuery() { $this->assertEntityFieldQuery($query, array(), 'Test with a delta group.'); // Test query on a deleted field. - field_attach_delete_bundle('test_entity_bundle_key', 'bundle1'); - field_attach_delete_bundle('test_entity', 'test_bundle'); + field_attach_delete_bundle('test_entity:bundle_key', 'bundle1'); + field_attach_delete_bundle('test_entity:test_entity', 'test_bundle'); $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[0], 'value', '3'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle', 8), + array('test_entity:test_entity_bundle', 8), ), 'Test query on a field after deleting field from some entities.'); - field_attach_delete_bundle('test_entity_bundle', 'test_entity_bundle'); + field_attach_delete_bundle('test_entity:test_entity_bundle', 'test_entity_bundle'); $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[0], 'value', '3'); $this->assertEntityFieldQuery($query, array(), 'Test query on a field after deleting field from all entities.'); @@ -1029,9 +1029,9 @@ function testEntityFieldQuery() { ->fieldCondition($this->fields[0], 'value', '3') ->deleted(TRUE); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 3), - array('test_entity_bundle', 8), - array('test_entity', 3), + array('test_entity:bundle_key', 3), + array('test_entity:test_entity_bundle', 8), + array('test_entity:test_entity', 3), ), 'Test query on a deleted field with deleted option set to TRUE.'); $pass = FALSE; @@ -1054,23 +1054,23 @@ function testEntityFieldQueryTranslatable() { $this->fields[0]['translatable'] = TRUE; $this->fields[0]['cardinality'] = 1; field_update_field($this->fields[0]); - field_test_entity_info_translatable('test_entity', TRUE); + field_test_entity_info_translatable('test_entity:test_entity', TRUE); // Create more items with different languages. - $entity = entity_load('test_entity', 1); + $entity = entity_load('test_entity:test_entity', 1); // Set fields in two languages with one field value. foreach (array(LANGUAGE_NOT_SPECIFIED, 'en') as $langcode) { $entity->{$this->field_names[0]}[$langcode][0]['value'] = 1234; } - field_attach_update('test_entity', $entity); + field_attach_update('test_entity:test_entity', $entity); // Look up number of results when querying a single entity with multilingual // field values. $query = new EntityFieldQuery(); $query_count = $query - ->entityCondition('entity_type', 'test_entity') + ->entityCondition('entity_type', 'test_entity:test_entity') ->entityCondition('bundle', 'test_bundle') ->entityCondition('entity_id', '1') ->fieldCondition($this->fields[0]) @@ -1088,10 +1088,10 @@ function testEntityFieldQueryMetaConditions() { // Make a test field translatable. $this->fields[0]['translatable'] = TRUE; field_update_field($this->fields[0]); - field_test_entity_info_translatable('test_entity', TRUE); + field_test_entity_info_translatable('test_entity:test_entity', TRUE); // Create more items with different languages. - $entity = entity_load('test_entity', 1); + $entity = entity_load('test_entity:test_entity', 1); $j = 0; foreach (array(LANGUAGE_NOT_SPECIFIED, 'en') as $langcode) { @@ -1101,39 +1101,39 @@ function testEntityFieldQueryMetaConditions() { $j += 4; } - field_attach_update('test_entity', $entity); + field_attach_update('test_entity:test_entity', $entity); // Test delta field meta condition. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity', '=') + ->entityCondition('entity_type', 'test_entity:test_entity', '=') ->fieldDeltaCondition($this->fields[0], 0, '>'); $this->assertEntityFieldQuery($query, array( - array('test_entity', 1), + array('test_entity:test_entity', 1), ), 'Test with a delta meta condition.'); // Test language field meta condition. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity', '=') + ->entityCondition('entity_type', 'test_entity:test_entity', '=') ->fieldLanguageCondition($this->fields[0], LANGUAGE_NOT_SPECIFIED, '<>'); $this->assertEntityFieldQuery($query, array( - array('test_entity', 1), + array('test_entity:test_entity', 1), ), 'Test with a language meta condition.'); // Test delta grouping. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity', '=') + ->entityCondition('entity_type', 'test_entity:test_entity', '=') ->fieldCondition($this->fields[0], 'value', 0, '=', 'group') ->fieldDeltaCondition($this->fields[0], 1, '<', 'group'); $this->assertEntityFieldQuery($query, array( - array('test_entity', 1), + array('test_entity:test_entity', 1), ), 'Test with a grouped delta meta condition.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity', '=') + ->entityCondition('entity_type', 'test_entity:test_entity', '=') ->fieldCondition($this->fields[0], 'value', 0, '=', 'group') ->fieldDeltaCondition($this->fields[0], 1, '>=', 'group'); $this->assertEntityFieldQuery($query, array(), 'Test with a grouped delta meta condition (empty result set).'); @@ -1141,16 +1141,16 @@ function testEntityFieldQueryMetaConditions() { // Test language grouping. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity', '=') + ->entityCondition('entity_type', 'test_entity:test_entity', '=') ->fieldCondition($this->fields[0], 'value', 0, '=', NULL, 'group') ->fieldLanguageCondition($this->fields[0], 'en', '<>', NULL, 'group'); $this->assertEntityFieldQuery($query, array( - array('test_entity', 1), + array('test_entity:test_entity', 1), ), 'Test with a grouped language meta condition.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity', '=') + ->entityCondition('entity_type', 'test_entity:test_entity', '=') ->fieldCondition($this->fields[0], 'value', 0, '=', NULL, 'group') ->fieldLanguageCondition($this->fields[0], LANGUAGE_NOT_SPECIFIED, '<>', NULL, 'group'); $this->assertEntityFieldQuery($query, array(), 'Test with a grouped language meta condition (empty result set).'); @@ -1158,17 +1158,17 @@ function testEntityFieldQueryMetaConditions() { // Test delta and language grouping. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity', '=') + ->entityCondition('entity_type', 'test_entity:test_entity', '=') ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language') ->fieldDeltaCondition($this->fields[0], 1, '<', 'delta', 'language') ->fieldLanguageCondition($this->fields[0], 'en', '<>', 'delta', 'language'); $this->assertEntityFieldQuery($query, array( - array('test_entity', 1), + array('test_entity:test_entity', 1), ), 'Test with a grouped delta + language meta condition.'); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity', '=') + ->entityCondition('entity_type', 'test_entity:test_entity', '=') ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language') ->fieldDeltaCondition($this->fields[0], 1, '>=', 'delta', 'language') ->fieldLanguageCondition($this->fields[0], 'en', '<>', 'delta', 'language'); @@ -1176,7 +1176,7 @@ function testEntityFieldQueryMetaConditions() { $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity', '=') + ->entityCondition('entity_type', 'test_entity:test_entity', '=') ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language') ->fieldDeltaCondition($this->fields[0], 1, '<', 'delta', 'language') ->fieldLanguageCondition($this->fields[0], LANGUAGE_NOT_SPECIFIED, '<>', 'delta', 'language'); @@ -1184,7 +1184,7 @@ function testEntityFieldQueryMetaConditions() { $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity', '=') + ->entityCondition('entity_type', 'test_entity:test_entity', '=') ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language') ->fieldDeltaCondition($this->fields[0], 1, '>=', 'delta', 'language') ->fieldLanguageCondition($this->fields[0], LANGUAGE_NOT_SPECIFIED, '<>', 'delta', 'language'); @@ -1194,13 +1194,13 @@ function testEntityFieldQueryMetaConditions() { // properly. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle', '=') + ->entityCondition('entity_type', 'test_entity:test_entity_bundle', '=') ->fieldCondition($this->fields[1], 'shape', 'circle', '=', 'delta', 'language') ->fieldCondition($this->fields[1], 'color', 'blue', '=', 'delta', 'language') ->fieldDeltaCondition($this->fields[1], 1, '=', 'delta', 'language') ->fieldLanguageCondition($this->fields[1], LANGUAGE_NOT_SPECIFIED, '=', 'delta', 'language'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle', 5), + array('test_entity:test_entity_bundle', 5), ), 'Test grouping cache.'); } @@ -1210,7 +1210,7 @@ function testEntityFieldQueryMetaConditions() { function testEntityFieldQueryRouting() { // Entity-only query. $query = new EntityFieldQuery(); - $query->entityCondition('entity_type', 'test_entity_bundle_key'); + $query->entityCondition('entity_type', 'test_entity:bundle_key'); $this->assertIdentical($query->queryCallback(), array($query, 'propertyQuery'), 'Entity-only queries are handled by the propertyQuery handler.'); // Field-only query. @@ -1221,13 +1221,13 @@ function testEntityFieldQueryRouting() { // Mixed entity and field query. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', '3'); $this->assertIdentical($query->queryCallback(), 'field_sql_storage_field_storage_query', 'Mixed queries are handled by the Field storage handler.'); // Overriding with $query->executeCallback. $query = new EntityFieldQuery(); - $query->entityCondition('entity_type', 'test_entity_bundle_key'); + $query->entityCondition('entity_type', 'test_entity:bundle_key'); $query->executeCallback = 'field_test_dummy_field_storage_query'; $this->assertEntityFieldQuery($query, array( array('user', 1), @@ -1235,7 +1235,7 @@ function testEntityFieldQueryRouting() { // Overriding with $query->executeCallback via hook_entity_query_alter(). $query = new EntityFieldQuery(); - $query->entityCondition('entity_type', 'test_entity_bundle_key'); + $query->entityCondition('entity_type', 'test_entity:bundle_key'); // Add a flag that will be caught by field_test_entity_query_alter(). $query->alterMyExecuteCallbackPlease = TRUE; $this->assertEntityFieldQuery($query, array( @@ -1266,48 +1266,48 @@ function testEntityFieldQueryPager() { $_GET['page'] = '0,1'; $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyOrderBy('ftid', 'ASC') ->pager(3, 0); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), ), 'Test pager integration in propertyQuery: page 1.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyOrderBy('ftid', 'ASC') ->pager(3, 1); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test pager integration in propertyQuery: page 2.', TRUE); // Test pager in field storage $_GET['page'] = '0,1'; $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->propertyOrderBy('ftid', 'ASC') ->pager(2, 0); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), ), 'Test pager integration in field storage: page 1.', TRUE); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->propertyOrderBy('ftid', 'ASC') ->pager(2, 1); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), ), 'Test pager integration in field storage: page 2.', TRUE); unset($_GET['page']); @@ -1320,17 +1320,17 @@ function testEntityFieldQueryDisablePager() { // Test enabling a pager and then disabling it. $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->propertyOrderBy('ftid', 'ASC') ->pager(1) ->pager(0); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'All test entities are listed when the pager is enabled and then disabled.', TRUE); } @@ -1347,60 +1347,60 @@ function testEntityFieldQueryTableSort() { ); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->tableSort($header); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test TableSort by property: ftid ASC in propertyQuery.', TRUE); $_GET['sort'] = 'desc'; $_GET['order'] = 'Id'; $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->tableSort($header); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 1), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 1), ), 'Test TableSort by property: ftid DESC in propertyQuery.', TRUE); $_GET['sort'] = 'asc'; $_GET['order'] = 'Type'; $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->tableSort($header); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test TableSort by entity: bundle ASC in propertyQuery.', TRUE); $_GET['sort'] = 'desc'; $_GET['order'] = 'Type'; $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->tableSort($header); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), ), 'Test TableSort by entity: bundle DESC in propertyQuery.', TRUE); // Test TableSort in field storage @@ -1413,98 +1413,98 @@ function testEntityFieldQueryTableSort() { ); $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->tableSort($header); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test TableSort by property: ftid ASC in field storage.', TRUE); $_GET['sort'] = 'desc'; $_GET['order'] = 'Id'; $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->tableSort($header); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 1), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 1), ), 'Test TableSort by property: ftid DESC in field storage.', TRUE); $_GET['sort'] = 'asc'; $_GET['order'] = 'Type'; $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->tableSort($header) ->entityOrderBy('entity_id', 'DESC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 5), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 5), ), 'Test TableSort by entity: bundle ASC in field storage.', TRUE); $_GET['sort'] = 'desc'; $_GET['order'] = 'Type'; $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->tableSort($header) ->entityOrderBy('entity_id', 'ASC'); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), ), 'Test TableSort by entity: bundle DESC in field storage.', TRUE); $_GET['sort'] = 'asc'; $_GET['order'] = 'Field'; $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->tableSort($header); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 1), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 6), + array('test_entity:bundle_key', 1), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 6), ), 'Test TableSort by field ASC.', TRUE); $_GET['sort'] = 'desc'; $_GET['order'] = 'Field'; $query = new EntityFieldQuery(); $query - ->entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($this->fields[0], 'value', 0, '>') ->tableSort($header); $this->assertEntityFieldQuery($query, array( - array('test_entity_bundle_key', 6), - array('test_entity_bundle_key', 5), - array('test_entity_bundle_key', 4), - array('test_entity_bundle_key', 3), - array('test_entity_bundle_key', 2), - array('test_entity_bundle_key', 1), + array('test_entity:bundle_key', 6), + array('test_entity:bundle_key', 5), + array('test_entity:bundle_key', 4), + array('test_entity:bundle_key', 3), + array('test_entity:bundle_key', 2), + array('test_entity:bundle_key', 1), ), 'Test TableSort by field DESC.', TRUE); unset($_GET['sort']); @@ -1575,12 +1575,12 @@ function assertEntityFieldQuery($query, $intended_results, $message, $ordered = function testTablePrefixing() { $query = new EntityFieldQuery(); $query = $query - ->entityCondition('entity_type', 'test_entity') + ->entityCondition('entity_type', 'test_entity:test_entity') ->entityCondition('bundle', 'test_bundle') ->entityCondition('entity_id', '1') ->addTag('efq_table_prefixing_test'); - $expected = array(array('test_entity', 1)); + $expected = array(array('test_entity:test_entity', 1)); $this->assertEntityFieldQuery($query, $expected, 'An EntityFieldQuery returns the expected results when altered with an additional join on the base table.'); } diff --git a/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module b/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module index 2d4b3be..6db46d7 100644 --- a/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module +++ b/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module @@ -6,12 +6,8 @@ */ /** - * Implements hook_entity_info(). + * Implements hook_entity_info_alter(). */ -function entity_cache_test_dependency_entity_info() { - return array( - 'entity_cache_test' => array( - 'label' => variable_get('entity_cache_test_label', 'Entity Cache Test'), - ), - ); +function entity_cache_test_dependency_entity_info_alter(&$info) { + $info['entity_cache_test']['label'] = variable_get('entity_cache_test_label', 'Entity Cache Test'); } diff --git a/core/modules/system/tests/modules/entity_cache_test_dependency/lib/Drupal/entity_cache_test_dependency/Plugin/Core/Entity/EntityCacheTest.php b/core/modules/system/tests/modules/entity_cache_test_dependency/lib/Drupal/entity_cache_test_dependency/Plugin/Core/Entity/EntityCacheTest.php new file mode 100644 index 0000000..1f6d8dc --- /dev/null +++ b/core/modules/system/tests/modules/entity_cache_test_dependency/lib/Drupal/entity_cache_test_dependency/Plugin/Core/Entity/EntityCacheTest.php @@ -0,0 +1,23 @@ +entityCondition('entity_type', 'test_entity_bundle_key') + ->entityCondition('entity_type', 'test_entity:bundle_key') ->fieldCondition($field_name, 'value', 0, '>') ->entityOrderBy('entity_id', 'ASC'); $results = array( diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index 46def82..43daa4a 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -6,29 +6,13 @@ */ /** - * Implements hook_entity_info(). + * Implements hook_entity_info_alter(). */ -function entity_test_entity_info() { - $items['entity_test'] = array( - 'label' => t('Test entity'), - 'entity class' => 'Drupal\entity_test\EntityTest', - 'controller class' => 'Drupal\entity_test\EntityTestStorageController', - 'form controller class' => array( - 'default' => 'Drupal\entity_test\EntityTestFormController', - ), - 'base table' => 'entity_test', - 'data table' => 'entity_test_property_data', - 'fieldable' => TRUE, - 'entity keys' => array( - 'id' => 'id', - 'uuid' => 'uuid', - ), - ); +function entity_test_entity_info_alter(&$info) { // Optionally specify a translation handler for testing translations. if (variable_get('entity_test_translation')) { - $items['entity_test']['translation']['entity_test'] = TRUE; + $info['entity_test']['translation']['entity_test'] = TRUE; } - return $items; } /** @@ -98,7 +82,7 @@ function entity_test_edit($entity) { * @param bool $reset * A boolean indicating that the internal cache should be reset. * - * @return Drupal\entity_test\EntityTest + * @return Drupal\entity_test\Plugin\Core\Entity\EntityTest * The loaded entity object, or FALSE if the entity cannot be loaded. */ function entity_test_load($id, $reset = FALSE) { diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTest.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php similarity index 58% rename from core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTest.php rename to core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php index 17e8470..240c5c7 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTest.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php @@ -2,15 +2,34 @@ /** * @file - * Definition of Drupal\entity_test\EntityTest. + * Definition of Drupal\entity_test\Plugin\Core\Entity\EntityTest. */ -namespace Drupal\entity_test; +namespace Drupal\entity_test\Plugin\Core\Entity; use Drupal\Core\Entity\EntityNG; +use Drupal\Core\Annotation\Plugin; +use Drupal\Core\Annotation\Translation; /** * Defines the test entity class. + * + * @Plugin( + * id = "entity_test", + * label = @Translation("Test entity"), + * module = "entity_test", + * controller_class = "Drupal\entity_test\EntityTestStorageController", + * form_controller_class = { + * "default" = "Drupal\entity_test\EntityTestFormController" + * }, + * base_table = "entity_test", + * data_table = "entity_test_property_data", + * fieldable = TRUE, + * entity_keys = { + * "id" = "id", + * "uuid" = "uuid" + * } + * ) */ class EntityTest extends EntityNG { diff --git a/core/modules/system/tests/modules/taxonomy_test/taxonomy_test.module b/core/modules/system/tests/modules/taxonomy_test/taxonomy_test.module index 63f6406..b2e3adb 100644 --- a/core/modules/system/tests/modules/taxonomy_test/taxonomy_test.module +++ b/core/modules/system/tests/modules/taxonomy_test/taxonomy_test.module @@ -7,7 +7,7 @@ * @see Drupal\taxonomy\Tests\TaxonomyHooksTestCase::testTaxonomyTermHooks() */ -use Drupal\taxonomy\Term; +use Drupal\taxonomy\Plugin\Core\Entity\Term; /** * Implements hook_taxonomy_term_load(). diff --git a/core/modules/system/tests/modules/theme_page_test/theme_page_test.module b/core/modules/system/tests/modules/theme_page_test/theme_page_test.module index fe86da9..63f8cb4 100644 --- a/core/modules/system/tests/modules/theme_page_test/theme_page_test.module +++ b/core/modules/system/tests/modules/theme_page_test/theme_page_test.module @@ -18,4 +18,4 @@ function theme_page_test_system_theme_info() { $themes['test_invalid_basetheme'] = drupal_get_path('module', 'system') . '/tests/themes/test_invalid_basetheme/test_invalid_basetheme.info'; $themes['test_invalid_engine'] = drupal_get_path('module', 'system') . '/tests/themes/test_invalid_engine/test_invalid_engine.info'; return $themes; -} \ No newline at end of file +} diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Term.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php similarity index 71% rename from core/modules/taxonomy/lib/Drupal/taxonomy/Term.php rename to core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php index 42ad4c5..3b4b121 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Term.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php @@ -2,16 +2,38 @@ /** * @file - * Definition of Drupal\taxonomy\Term. + * Definition of Drupal\taxonomy\Plugin\Core\Entity\Term. */ -namespace Drupal\taxonomy; +namespace Drupal\taxonomy\Plugin\Core\Entity; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\Entity; +use Drupal\Core\Annotation\Plugin; +use Drupal\Core\Annotation\Translation; /** * Defines the taxonomy term entity. + * + * @Plugin( + * id = "taxonomy_term", + * label = @Translation("Taxonomy term"), + * module = "taxonomy", + * controller_class = "Drupal\taxonomy\TermStorageController", + * render_controller_class = "Drupal\taxonomy\TermRenderController", + * form_controller_class = { + * "default" = "Drupal\taxonomy\TermFormController" + * }, + * base_table = "taxonomy_term_data", + * uri_callback = "taxonomy_term_uri", + * fieldable = TRUE, + * entity_keys = { + * "id" = "tid", + * "bundle" = "vocabulary_machine_name", + * "label" = "name", + * "uuid" = "uuid" + * } + * ) */ class Term extends Entity implements ContentEntityInterface { diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Vocabulary.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Vocabulary.php similarity index 64% rename from core/modules/taxonomy/lib/Drupal/taxonomy/Vocabulary.php rename to core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Vocabulary.php index e32f285..beee8d1 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Vocabulary.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Vocabulary.php @@ -2,15 +2,32 @@ /** * @file - * Definition of Drupal\taxonomy\Vocabulary. + * Definition of Drupal\taxonomy\Plugin\Core\Entity\Vocabulary. */ -namespace Drupal\taxonomy; +namespace Drupal\taxonomy\Plugin\Core\Entity; use Drupal\Core\Entity\Entity; +use Drupal\Core\Annotation\Plugin; +use Drupal\Core\Annotation\Translation; /** * Defines the taxonomy vocabulary entity. + * + * @Plugin( + * id = "taxonomy_vocabulary", + * label = @Translation("Taxonomy vocabulary"), + * module = "taxonomy", + * controller_class = "Drupal\taxonomy\VocabularyStorageController", + * form_controller_class = { + * "default" = "Drupal\taxonomy\VocabularyFormController" + * }, + * base_table = "taxonomy_vocabulary", + * entity_keys = { + * "id" = "vid", + * "label" = "name" + * } + * ) */ class Vocabulary extends Entity { diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php index 37cbf4e..b10914b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php @@ -61,7 +61,7 @@ function setUp() { field_create_field($this->field); $this->instance = array( 'field_name' => $this->field_name, - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'widget' => array( 'type' => 'options_select', @@ -93,13 +93,13 @@ function testTaxonomyTermFieldMultipleVocabularies() { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created.'); + $this->assertRaw(t('test_entity:test_entity @id has been created.', array('@id' => $id)), 'Entity was created.'); // Render the entity. $entity = field_test_entity_test_load($id); $entities = array($id => $entity); - field_attach_prepare_view('test_entity', $entities, 'full'); - $entity->content = field_attach_view('test_entity', $entity, 'full'); + field_attach_prepare_view('test_entity:test_entity', $entities, 'full'); + $entity->content = field_attach_view('test_entity:test_entity', $entity, 'full'); $this->content = drupal_render($entity->content); $this->assertText($term1->name, 'Term 1 name is displayed.'); $this->assertText($term2->name, 'Term 2 name is displayed.'); @@ -110,8 +110,8 @@ function testTaxonomyTermFieldMultipleVocabularies() { // Re-render the content. $entity = field_test_entity_test_load($id); $entities = array($id => $entity); - field_attach_prepare_view('test_entity', $entities, 'full'); - $entity->content = field_attach_view('test_entity', $entity, 'full'); + field_attach_prepare_view('test_entity:test_entity', $entities, 'full'); + $entity->content = field_attach_view('test_entity:test_entity', $entity, 'full'); $this->plainTextContent = FALSE; $this->content = drupal_render($entity->content); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php index 34065e1..9d56be2 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php @@ -56,7 +56,7 @@ function setUp() { field_create_field($this->field); $this->instance = array( 'field_name' => $this->field_name, - 'entity_type' => 'test_entity', + 'entity_type' => 'test_entity:test_entity', 'bundle' => 'test_bundle', 'widget' => array( 'type' => 'options_select', @@ -80,7 +80,7 @@ function testTaxonomyTermFieldValidation() { $term = $this->createTerm($this->vocabulary); $entity->{$this->field_name}[$langcode][0]['tid'] = $term->tid; try { - field_attach_validate('test_entity', $entity); + field_attach_validate('test_entity:test_entity', $entity); $this->pass('Correct term does not cause validation error.'); } catch (FieldValidationException $e) { @@ -91,7 +91,7 @@ function testTaxonomyTermFieldValidation() { $bad_term = $this->createTerm($this->createVocabulary()); $entity->{$this->field_name}[$langcode][0]['tid'] = $bad_term->tid; try { - field_attach_validate('test_entity', $entity); + field_attach_validate('test_entity:test_entity', $entity); $this->fail('Wrong term causes validation error.'); } catch (FieldValidationException $e) { @@ -118,13 +118,13 @@ function testTaxonomyTermFieldWidgets() { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created.'); + $this->assertRaw(t('test_entity:test_entity @id has been created.', array('@id' => $id)), 'Entity was created.'); // Display the object. $entity = field_test_entity_test_load($id); $entities = array($id => $entity); - field_attach_prepare_view('test_entity', $entities, 'full'); - $entity->content = field_attach_view('test_entity', $entity, 'full'); + field_attach_prepare_view('test_entity:test_entity', $entities, 'full'); + $entity->content = field_attach_view('test_entity:test_entity', $entity, 'full'); $this->content = drupal_render($entity->content); $this->assertText($term->label(), 'Term label is displayed.'); diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc index be305f6..39b29ff 100644 --- a/core/modules/taxonomy/taxonomy.admin.inc +++ b/core/modules/taxonomy/taxonomy.admin.inc @@ -5,8 +5,8 @@ * Administrative page callbacks for the taxonomy module. */ -use Drupal\taxonomy\Term; -use Drupal\taxonomy\Vocabulary; +use Drupal\taxonomy\Plugin\Core\Entity\Term; +use Drupal\taxonomy\Plugin\Core\Entity\Vocabulary; /** * Form builder to list and manage vocabularies. @@ -132,7 +132,7 @@ function taxonomy_vocabulary_add() { * Display a tree of all the terms in a vocabulary, with options to edit * each one. The form is made drag and drop by the theme function. * - * @param Drupal\taxonomy\Vocabulary $vocabulary + * @param Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary * The taxonomy vocabulary entity to list terms for. * * @ingroup forms diff --git a/core/modules/taxonomy/taxonomy.api.php b/core/modules/taxonomy/taxonomy.api.php index 6657624..1eb6bf2 100644 --- a/core/modules/taxonomy/taxonomy.api.php +++ b/core/modules/taxonomy/taxonomy.api.php @@ -34,10 +34,10 @@ function hook_taxonomy_vocabulary_load(array $vocabularies) { * Modules implementing this hook can act on the vocabulary object before it is * inserted or updated. * - * @param Drupal\taxonomy\Vocabulary $vocabulary + * @param Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary * A taxonomy vocabulary entity. */ -function hook_taxonomy_vocabulary_presave(Drupal\taxonomy\Vocabulary $vocabulary) { +function hook_taxonomy_vocabulary_presave(Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary) { $vocabulary->foo = 'bar'; } @@ -47,10 +47,10 @@ function hook_taxonomy_vocabulary_presave(Drupal\taxonomy\Vocabulary $vocabulary * Modules implementing this hook can act on the vocabulary object when saved * to the database. * - * @param Drupal\taxonomy\Vocabulary $vocabulary + * @param Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary * A taxonomy vocabulary entity. */ -function hook_taxonomy_vocabulary_insert(Drupal\taxonomy\Vocabulary $vocabulary) { +function hook_taxonomy_vocabulary_insert(Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary) { if ($vocabulary->synonyms) { variable_set('taxonomy_' . $vocabulary->vid . '_synonyms', TRUE); } @@ -61,10 +61,10 @@ function hook_taxonomy_vocabulary_insert(Drupal\taxonomy\Vocabulary $vocabulary) * * Modules implementing this hook can act on the vocabulary object when updated. * - * @param Drupal\taxonomy\Vocabulary $vocabulary + * @param Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary * A taxonomy vocabulary entity. */ -function hook_taxonomy_vocabulary_update(Drupal\taxonomy\Vocabulary $vocabulary) { +function hook_taxonomy_vocabulary_update(Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary) { $status = $vocabulary->synonyms ? TRUE : FALSE; if ($vocabulary->synonyms) { variable_set('taxonomy_' . $vocabulary->vid . '_synonyms', $status); @@ -78,13 +78,13 @@ function hook_taxonomy_vocabulary_update(Drupal\taxonomy\Vocabulary $vocabulary) * field_attach_delete_bundle() is called and before the vocabulary is actually * removed from the database. * - * @param Drupal\taxonomy\Vocabulary $vocabulary + * @param Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary * The taxonomy vocabulary entity that is about to be deleted. * * @see hook_taxonomy_vocabulary_delete() * @see taxonomy_vocabulary_delete() */ -function hook_taxonomy_vocabulary_predelete(Drupal\taxonomy\Vocabulary $vocabulary) { +function hook_taxonomy_vocabulary_predelete(Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary) { if (variable_get('taxonomy_' . $vocabulary->vid . '_synonyms', FALSE)) { variable_del('taxonomy_' . $vocabulary->vid . '_synonyms'); } @@ -97,13 +97,13 @@ function hook_taxonomy_vocabulary_predelete(Drupal\taxonomy\Vocabulary $vocabula * field_attach_delete_bundle() has been called and after the vocabulary has * been removed from the database. * - * @param Drupal\taxonomy\Vocabulary $vocabulary + * @param Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary * The taxonomy vocabulary entity that has been deleted. * * @see hook_taxonomy_vocabulary_predelete() * @see taxonomy_vocabulary_delete() */ -function hook_taxonomy_vocabulary_delete(Drupal\taxonomy\Vocabulary $vocabulary) { +function hook_taxonomy_vocabulary_delete(Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary) { if (variable_get('taxonomy_' . $vocabulary->vid . '_synonyms', FALSE)) { variable_del('taxonomy_' . $vocabulary->vid . '_synonyms'); } diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 874c78a..888294f 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -5,9 +5,9 @@ * Enables the organization of content into categories. */ -use Drupal\node\Node; -use Drupal\taxonomy\Term; -use Drupal\taxonomy\Vocabulary; +use Drupal\node\Plugin\Core\Entity\Node; +use Drupal\taxonomy\Plugin\Core\Entity\Term; +use Drupal\taxonomy\Plugin\Core\Entity\Vocabulary; use Drupal\Core\Entity\EntityInterface; /** @@ -106,42 +106,21 @@ function taxonomy_permission() { } /** - * Implements hook_entity_info(). + * Implements hook_entity_info_alter(). */ -function taxonomy_entity_info() { - $return = array( - 'taxonomy_term' => array( - 'label' => t('Taxonomy term'), - 'entity class' => 'Drupal\taxonomy\Term', - 'controller class' => 'Drupal\taxonomy\TermStorageController', - 'form controller class' => array( - 'default' => 'Drupal\taxonomy\TermFormController', - ), - 'base table' => 'taxonomy_term_data', - 'uri callback' => 'taxonomy_term_uri', - 'fieldable' => TRUE, - 'entity keys' => array( - 'id' => 'tid', - 'bundle' => 'vocabulary_machine_name', - 'label' => 'name', - 'uuid' => 'uuid', - ), - 'bundle keys' => array( - 'bundle' => 'machine_name', - ), - 'bundles' => array(), - 'render controller class' => 'Drupal\taxonomy\TermRenderController', - 'view modes' => array( - // @todo View mode for display as a field (when attached to nodes etc). - 'full' => array( - 'label' => t('Taxonomy term page'), - 'custom settings' => FALSE, - ), - ), +function taxonomy_entity_info_alter(&$info) { + $info['taxonomy_term']['bundle keys'] = array( + 'bundle' => 'machine_name', + ); + $info['taxonomy_term']['view modes'] = array( + // @todo View mode for display as a field (when attached to nodes etc). + 'full' => array( + 'label' => t('Taxonomy term page'), + 'custom settings' => FALSE, ), ); foreach (taxonomy_vocabulary_get_names() as $machine_name => $vocabulary) { - $return['taxonomy_term']['bundles'][$machine_name] = array( + $info['taxonomy_term']['bundles'][$machine_name] = array( 'label' => $vocabulary->name, 'admin' => array( 'path' => 'admin/structure/taxonomy/%taxonomy_vocabulary_machine_name', @@ -151,28 +130,12 @@ function taxonomy_entity_info() { ), ); } - $return['taxonomy_vocabulary'] = array( - 'label' => t('Taxonomy vocabulary'), - 'entity class' => 'Drupal\taxonomy\Vocabulary', - 'controller class' => 'Drupal\taxonomy\VocabularyStorageController', - 'form controller class' => array( - 'default' => 'Drupal\taxonomy\VocabularyFormController', - ), - 'base table' => 'taxonomy_vocabulary', - 'entity keys' => array( - 'id' => 'vid', - 'label' => 'name', - ), - 'fieldable' => FALSE, - 'view modes' => array( - 'full' => array( - 'label' => t('Taxonomy vocabulary default'), - 'custom settings' => FALSE, - ), + $info['taxonomy_vocabulary']['view modes'] = array( + 'full' => array( + 'label' => t('Taxonomy vocabulary default'), + 'custom settings' => FALSE, ), ); - - return $return; } /** @@ -443,7 +406,7 @@ function taxonomy_term_access($op, $term) { /** * Saves a vocabulary. * - * @param Drupal\taxonomy\Vocabulary $vocabulary + * @param Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary * The taxonomy vocabulary entity to be saved. */ function taxonomy_vocabulary_save(Vocabulary $vocabulary) { @@ -507,7 +470,7 @@ function taxonomy_taxonomy_vocabulary_update(Vocabulary $vocabulary) { * term has multiple parents then the vocabulary will be given a hierarchy of * TAXONOMY_HIERARCHY_MULTIPLE. * - * @param Drupal\taxonomy\Vocabulary $vocabulary + * @param Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary * A taxonomy vocabulary entity. * @param $changed_term * An array of the term structure that was updated. @@ -972,7 +935,7 @@ function taxonomy_vocabulary_load_multiple(array $vids = NULL) { * @param int $vid * The vocabulary's ID. * - * @return Drupal\taxonomy\Vocabulary|false + * @return Drupal\taxonomy\Plugin\Core\Entity\Vocabulary|false * The taxonomy vocabulary entity, if exists, FALSE otherwise. Results are * statically cached. * @@ -988,7 +951,7 @@ function taxonomy_vocabulary_load($vid) { * @param $name * The vocabulary's machine name. * - * @return Drupal\taxonomy\Vocabulary|false + * @return Drupal\taxonomy\Plugin\Core\Entity\Vocabulary|false * The taxonomy vocabulary entity, if exists, FALSE otherwise. Results are * statically cached. * diff --git a/core/modules/taxonomy/taxonomy.pages.inc b/core/modules/taxonomy/taxonomy.pages.inc index f1ec8ea..e57231e 100644 --- a/core/modules/taxonomy/taxonomy.pages.inc +++ b/core/modules/taxonomy/taxonomy.pages.inc @@ -5,8 +5,8 @@ * Page callbacks for the taxonomy module. */ -use Drupal\taxonomy\Term; -use Drupal\taxonomy\Vocabulary; +use Drupal\taxonomy\Plugin\Core\Entity\Term; +use Drupal\taxonomy\Plugin\Core\Entity\Vocabulary; use Symfony\Component\HttpFoundation\JsonResponse; /** diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module index 7060a87..8313269 100644 --- a/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -5,7 +5,7 @@ * Tracks recent content posted by a user or users. */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; /** * Implements hook_help(). diff --git a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php index a9fae77..453cbd2 100644 --- a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php +++ b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php @@ -7,7 +7,7 @@ namespace Drupal\translation\Tests; -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; use Drupal\simpletest\WebTestBase; /** diff --git a/core/modules/translation/tests/translation_test.module b/core/modules/translation/tests/translation_test.module index 1bd0659..8c9fdf2 100644 --- a/core/modules/translation/tests/translation_test.module +++ b/core/modules/translation/tests/translation_test.module @@ -5,7 +5,7 @@ * Mock module for content translation tests. */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; /** * Implements hook_node_insert(). diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module index bf1e528..3f2b62a 100644 --- a/core/modules/translation/translation.module +++ b/core/modules/translation/translation.module @@ -19,7 +19,7 @@ * date (0) or needs to be updated (1). */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; /** * Implements hook_help(). diff --git a/core/modules/translation/translation.pages.inc b/core/modules/translation/translation.pages.inc index e33f53e..cc94a1e 100644 --- a/core/modules/translation/translation.pages.inc +++ b/core/modules/translation/translation.pages.inc @@ -5,7 +5,7 @@ * User page callbacks for the Translation module. */ -use Drupal\node\Node; +use Drupal\node\Plugin\Core\Entity\Node; /** * Page callback: Displays a list of a node's translations. diff --git a/core/modules/user/lib/Drupal/user/User.php b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php similarity index 75% rename from core/modules/user/lib/Drupal/user/User.php rename to core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php index 2217588..4fa5b12 100644 --- a/core/modules/user/lib/Drupal/user/User.php +++ b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php @@ -2,15 +2,37 @@ /** * @file - * Definition of Drupal\user\User. + * Definition of Drupal\user\Plugin\Core\Entity\User. */ -namespace Drupal\user; +namespace Drupal\user\Plugin\Core\Entity; use Drupal\Core\Entity\Entity; +use Drupal\Core\Annotation\Plugin; +use Drupal\Core\Annotation\Translation; /** * Defines the user entity class. + * + * @Plugin( + * id = "user", + * label = @Translation("User"), + * module = "user", + * controller_class = "Drupal\user\UserStorageController", + * render_controller_class = "Drupal\user\UserRenderController", + * form_controller_class = { + * "profile" = "Drupal\user\ProfileFormController", + * "register" = "Drupal\user\RegisterFormController" + * }, + * base_table = "users", + * uri_callback = "user_uri", + * label_callback = "user_label", + * fieldable = TRUE, + * entity_keys = { + * "id" = "uid", + * "uuid" = "uuid" + * } + * ) */ class User extends Entity { diff --git a/core/modules/user/user.module b/core/modules/user/user.module index fae45ad..b99f423 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -2,7 +2,7 @@ use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Entity\EntityInterface; -use Drupal\file\File; +use Drupal\file\Plugin\Core\Entity\File; use Drupal\Core\Template\Attribute; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -139,42 +139,20 @@ function user_theme() { } /** - * Implements hook_entity_info(). + * Implements hook_entity_info_alter(). */ -function user_entity_info() { - return array( - 'user' => array( - 'label' => t('User'), - 'controller class' => 'Drupal\user\UserStorageController', - 'form controller class' => array( - 'profile' => 'Drupal\user\ProfileFormController', - 'register' => 'Drupal\user\RegisterFormController', - ), - 'base table' => 'users', - 'uri callback' => 'user_uri', - 'label callback' => 'user_label', - 'fieldable' => TRUE, - 'entity class' => 'Drupal\user\User', - 'entity keys' => array( - 'id' => 'uid', - 'uuid' => 'uuid', - ), - 'bundles' => array( - 'user' => array( - 'label' => t('User'), - 'admin' => array( - 'path' => 'admin/config/people/accounts', - 'access arguments' => array('administer users'), - ), - ), - ), - 'render controller class' => 'Drupal\user\UserRenderController', - 'view modes' => array( - 'full' => array( - 'label' => t('User account'), - 'custom settings' => FALSE, - ), - ), +function user_entity_info_alter(&$info) { + $info['user']['bundles']['user'] = array( + 'label' => t('User'), + 'admin' => array( + 'path' => 'admin/config/people/accounts', + 'access arguments' => array('administer users'), + ), + ); + $info['user']['view modes'] = array( + 'full' => array( + 'label' => t('User account'), + 'custom settings' => FALSE, ), ); }