Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes

This commit is contained in:
Pantheon Automation 2016-04-20 09:56:34 -07:00 committed by Greg Anderson
parent b11a755ba8
commit c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions

View file

@ -1,5 +1,10 @@
<?php
/**
* @file
* Test fixture.
*/
use Drupal\Core\Database\Database;

View file

@ -1,5 +1,10 @@
<?php
/**
* @file
* Test fixture.
*/
$connection = Drupal\Core\Database\Database::getConnection();
$config = $connection;

View file

@ -0,0 +1,22 @@
<?php
/**
* @file
* Contains database additions to drupal-8-rc1.bare.standard.php.gz for testing
* the upgrade path of https://www.drupal.org/node/2649914.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
$views_config = Yaml::decode(file_get_contents(__DIR__ . '/drupal8.views-image-style-dependency-2649914.yml'));
$connection->insert('config')
->fields(['collection', 'name', 'data'])
->values([
'collection' => '',
'name' => 'views.view.' . $views_config['id'],
'data' => serialize($views_config),
])->execute();

View file

@ -0,0 +1,43 @@
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_image
module:
- image
- node
id: foo
label: Foo
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
fields:
field_image:
id: field_image
table: node__field_image
field: field_image
type: image
settings:
image_style: thumbnail
image_link: ''
plugin_id: field
field_image_1:
id: field_image_1
table: node__field_image
field: field_image
type: image
settings:
# This field's formatter is using a non-existent image style.
image_style: nonexistent
image_link: ''
plugin_id: field

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\accept_header_routing_test\AcceptHeaderMiddleware.
*/
namespace Drupal\accept_header_routing_test;
use Symfony\Component\HttpFoundation\Request;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\accept_header_routing_test\AcceptHeaderRoutingTestServiceProvider.
*/
namespace Drupal\accept_header_routing_test;
use Drupal\Core\DependencyInjection\ContainerBuilder;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\accept_header_routing_test\Routing\AcceptHeaderMatcher.
*/
namespace Drupal\accept_header_routing_test\Routing;
use Drupal\Core\Routing\RouteFilterInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Tests\accept_header_routing_teste\Unit\Routing\AcceptHeaderMatcherTest.
*/
namespace Drupal\Tests\accept_header_routing_teste\Unit\Routing;
use Drupal\accept_header_routing_test\Routing\AcceptHeaderMatcher;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\action_test\Plugin\Action\NoType.
*/
namespace Drupal\action_test\Plugin\Action;
use Drupal\Core\Access\AccessResult;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\action_test\Plugin\Action\SaveEntity.
*/
namespace Drupal\action_test\Plugin\Action;
use Drupal\Core\Action\ActionBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\ajax_forms_test\Callbacks.
*/
namespace Drupal\ajax_forms_test;
use Drupal\Core\Ajax\AjaxResponse;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\ajax_forms_test\Form\AjaxFormsTestCommandsForm.
*/
namespace Drupal\ajax_forms_test\Form;
use Drupal\Core\Form\FormBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\ajax_forms_test\Form\AjaxFormsTestLazyLoadForm.
*/
namespace Drupal\ajax_forms_test\Form;
use Drupal\Core\Form\FormBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\ajax_forms_test\Form\AjaxFormsTestSimpleForm.
*/
namespace Drupal\ajax_forms_test\Form;
use Drupal\Core\Form\FormBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\ajax_forms_test\Form\AjaxFormsTestValidationForm.
*/
namespace Drupal\ajax_forms_test\Form;
use Drupal\Core\Form\FormBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\ajax_forms_test\Plugin\Block\AjaxFormBlock.
*/
namespace Drupal\ajax_forms_test\Plugin\Block;
use Drupal\Core\Block\BlockBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\ajax_test\Controller\AjaxTestController.
*/
namespace Drupal\ajax_test\Controller;
use Drupal\Core\Ajax\AjaxResponse;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\ajax_test\Form\AjaxTestDialogForm.
*/
namespace Drupal\ajax_test\Form;
use Drupal\ajax_test\Controller\AjaxTestController;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\ajax_test\Form\AjaxTestForm.
*/
namespace Drupal\ajax_test\Form;
use Drupal\Core\Form\FormBase;

View file

@ -1,8 +1,4 @@
<?php
/**
* @file
* Contains \Drupal\batch_test\Controller\BatchTestController.
*/
namespace Drupal\batch_test\Controller;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\batch_test\Form\BatchTestChainedForm.
*/
namespace Drupal\batch_test\Form;
use Drupal\Core\Form\FormBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\batch_test\Form\BatchTestMockForm.
*/
namespace Drupal\batch_test\Form;
use Drupal\Core\Form\FormBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\batch_test\Form\BatchTestMultiStepForm.
*/
namespace Drupal\batch_test\Form;
use Drupal\Core\Form\FormBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\batch_test\Form\BatchTestSimpleForm.
*/
namespace Drupal\batch_test\Form;
use Drupal\Core\Form\FormBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\cache_test\Controller\CacheTestController.
*/
namespace Drupal\cache_test\Controller;
use Drupal\Core\Url;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\common_test\Controller\CommonTestController.
*/
namespace Drupal\common_test\Controller;
use Drupal\Component\Utility\Html;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\common_test\Render\MainContent\JsonRenderer.
*/
namespace Drupal\common_test\Render\MainContent;
use Drupal\Core\Cache\CacheableJsonResponse;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\condition_test\FormController.
*/
namespace Drupal\condition_test;
use Drupal\Core\Form\FormInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\condition_test\Plugin\Condition\ConditionTestDualUser.
*/
namespace Drupal\condition_test\Plugin\Condition;
use Drupal\Core\Condition\ConditionPluginBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\condition_test\Plugin\Condition\OptionalContextCondition.
*/
namespace Drupal\condition_test\Plugin\Condition;
use Drupal\Core\Condition\ConditionPluginBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\condition_test\Tests\ConditionTestDualUserTest.
*/
namespace Drupal\condition_test\Tests;
use Drupal\Core\Plugin\Context\Context;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\condition_test\Tests\OptionalContextConditionTest.
*/
namespace Drupal\condition_test\Tests;
use Drupal\Core\Plugin\Context\Context;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\conneg_test\Controller\TestController.
*/
namespace Drupal\conneg_test\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\cron_queue_test\Plugin\QueueWorker\CronQueueTestBrokenQueue.
*/
namespace Drupal\cron_queue_test\Plugin\QueueWorker;
use Drupal\Core\Queue\QueueWorkerBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\cron_queue_test\Plugin\QueueWorker\CronQueueTestException.
*/
namespace Drupal\cron_queue_test\Plugin\QueueWorker;
use Drupal\Core\Queue\QueueWorkerBase;

View file

@ -0,0 +1,31 @@
<?php
namespace Drupal\cron_queue_test\Plugin\QueueWorker;
use Drupal\Core\Queue\QueueWorkerBase;
use Drupal\Core\Queue\RequeueException;
/**
* @QueueWorker(
* id = "cron_queue_test_requeue_exception",
* title = @Translation("RequeueException test"),
* cron = {"time" = 60}
* )
*/
class CronQueueTestRequeueException extends QueueWorkerBase {
/**
* {@inheritdoc}
*/
public function processItem($data) {
$state = \Drupal::state();
if (!$state->get('cron_queue_test_requeue_exception')) {
$state->set('cron_queue_test_requeue_exception', 1);
throw new RequeueException('I am not done yet!');
}
else {
$state->set('cron_queue_test_requeue_exception', 2);
}
}
}

View file

@ -1,5 +1,10 @@
<?php
/**
* @file
* Database test module.
*/
use Drupal\Core\Database\Query\AlterableInterface;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\database_test\Controller\DatabaseTestController.
*/
namespace Drupal\database_test\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\database_test\Form\DatabaseTestForm.
*/
namespace Drupal\database_test\Form;
use Drupal\Core\Form\FormBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\display_variant_test\EventSubscriber\TestPageDisplayVariantSubscriber.
*/
namespace Drupal\display_variant_test\EventSubscriber;
use Drupal\Core\Plugin\Context\Context;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\display_variant_test\Plugin\DisplayVariant\TestDisplayVariant.
*/
namespace Drupal\display_variant_test\Plugin\DisplayVariant;
use Drupal\Core\Cache\CacheableMetadata;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\early_rendering_controller_test\AttachmentsTestDomainObject.
*/
namespace Drupal\early_rendering_controller_test;
use Drupal\Core\Render\AttachmentsInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\early_rendering_controller_test\AttachmentsTestResponse.
*/
namespace Drupal\early_rendering_controller_test;
use Drupal\Core\Render\AttachmentsInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\early_rendering_controller_test\CacheableTestDomainObject.
*/
namespace Drupal\early_rendering_controller_test;
use Drupal\Core\Cache\CacheableDependencyInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\early_rendering_controller_test\CacheableTestResponse.
*/
namespace Drupal\early_rendering_controller_test;
use Drupal\Core\Cache\CacheableResponseInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\early_rendering_controller_test\EarlyRenderingTestController.
*/
namespace Drupal\early_rendering_controller_test;
use Drupal\Core\Ajax\AjaxResponse;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\early_rendering_controller_test\TestDomainObject.
*/
namespace Drupal\early_rendering_controller_test;
class TestDomainObject { }

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\early_rendering_controller_test\TestDomainObjectViewSubscriber.
*/
namespace Drupal\early_rendering_controller_test;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

View file

@ -13,3 +13,17 @@ field.storage_settings.shape:
foreign_key_name:
type: string
label: 'Foreign key name'
entity_test.entity_test_bundle.*:
type: config_entity
label: 'Entity test bundle'
mapping:
label:
type: label
label: 'Label'
id:
type: string
label: 'Machine-readable name'
description:
type: text
label: 'Description'

View file

@ -6,6 +6,8 @@
*/
use Drupal\system\Tests\Update\DbUpdatesTrait;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;
/**
* Implements hook_install().
@ -13,19 +15,19 @@ use Drupal\system\Tests\Update\DbUpdatesTrait;
function entity_test_install() {
foreach (entity_test_entity_types() as $entity_type) {
// Auto-create fields for testing.
entity_create('field_storage_config', array(
FieldStorageConfig::create(array(
'entity_type' => $entity_type,
'field_name' => 'field_test_text',
'type' => 'text',
'cardinality' => 1,
))->save();
entity_create('field_config', array(
FieldConfig::create([
'entity_type' => $entity_type,
'field_name' => 'field_test_text',
'bundle' => $entity_type,
'label' => 'Test text-field',
'translatable' => FALSE,
))->save();
])->save();
entity_get_form_display($entity_type, $entity_type, 'default')
->setComponent('field_test_text', array('type' => 'text_textfield'))

View file

@ -67,6 +67,8 @@ function entity_test_entity_types($filter = NULL) {
}
if ($filter === ENTITY_TEST_TYPES_ROUTING) {
$types[] = 'entity_test_base_field_display';
$types[] = 'entity_test_string_id';
$types[] = 'entity_test_no_id';
}
$types[] = 'entity_test_mulrev';
$types[] = 'entity_test_mulrev_changed';
@ -194,7 +196,7 @@ function entity_test_entity_bundle_info() {
$bundles = array();
$entity_types = \Drupal::entityManager()->getDefinitions();
foreach ($entity_types as $entity_type_id => $entity_type) {
if ($entity_type->getProvider() == 'entity_test') {
if ($entity_type->getProvider() == 'entity_test' && $entity_type_id != 'entity_test_with_bundle') {
$bundles[$entity_type_id] = \Drupal::state()->get($entity_type_id . '.bundles') ?: array($entity_type_id => array('label' => 'Entity Test Bundle'));
}
}
@ -248,8 +250,8 @@ function entity_test_entity_extra_field_info() {
$extra['entity_test']['bundle_with_extra_fields'] = array(
'display' => array(
// Note: those extra fields do not currently display anything, they are
// just used in \Drupal\field_ui\Tests\EntityDisplayTest to test the
// behavior of entity display objects.
// just used in \Drupal\Tests\field_ui\Kernel\EntityDisplayTest to test
// the behavior of entity display objects.
'display_extra_field' => array(
'label' => t('Display extra field'),
'description' => t('An extra field on the display side.'),
@ -416,7 +418,7 @@ function entity_test_entity_field_access($operation, FieldDefinitionInterface $f
*/
function entity_test_entity_field_access_alter(array &$grants, array $context) {
if ($context['field_definition']->getName() == 'field_test_text' && $context['items']->value == 'access alter value') {
$grants[':default'] = AccessResult::forbidden()->inheritCacheability($grants[':default'])->cacheUntilEntityChanges($context['items']->getEntity());
$grants[':default'] = AccessResult::forbidden()->inheritCacheability($grants[':default'])->addCacheableDependency($context['items']->getEntity());
}
}

View file

@ -7,3 +7,11 @@ view test entity translations:
title: 'View translations of test entities'
view test entity field:
title: 'View test entity field'
administer entity_test_with_bundle content:
title: 'administer entity_test_with_bundle content'
description: 'administer entity_test_with_bundle content'
administer entity_test_bundle content:
title: 'administer entity_test_bundle content'
permission_callbacks:
- \Drupal\entity_test\EntityTestPermissions::entityTestBundlePermissions

View file

@ -58,7 +58,13 @@ entity.entity_test.collection:
entity.entity_test_rev.revision:
path: '/entity_test_rev/{entity_test_rev}/revision/{entity_test_rev_revision}/view'
defaults:
_entity_view: 'entity_test_rev'
_controller: '\Drupal\Core\Entity\Controller\EntityViewController::viewRevision'
options:
parameters:
entity_test_rev:
type: entity:entity_test_rev
entity_test_rev_revision:
type: entity_revision:entity_test_rev
requirements:
_access: 'TRUE'

View file

@ -1,5 +1,10 @@
<?php
/**
* @file
* Include file for test module.
*/
/**
* Implements hook_views_data_alter().
*/

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Cache\EntityTestViewGrantsCacheContext.
*/
namespace Drupal\entity_test\Cache;
use Drupal\Core\Cache\CacheableMetadata;

View file

@ -1,16 +1,10 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Controller\EntityTestController.
*/
namespace Drupal\entity_test\Controller;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Routing\RouteMatchInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@ -44,24 +38,6 @@ class EntityTestController extends ControllerBase {
);
}
/**
* Displays the 'Add new entity_test' form.
*
* @param string $entity_type_id
* Name of the entity type for which a create form should be displayed.
*
* @return array
* The processed form for a new entity_test.
*
* @see \Drupal\entity_test\Routing\EntityTestRoutes::routes()
*/
public function testAdd($entity_type_id) {
$entity = entity_create($entity_type_id, array());
$form = $this->entityFormBuilder()->getForm($entity);
$form['#title'] = $this->t('Create an @type', array('@type' => $entity_type_id));
return $form;
}
/**
* Returns an empty page.
*

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTest.
*/
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\ContentEntityBase;
@ -47,6 +42,7 @@ use Drupal\user\UserInterface;
* },
* links = {
* "canonical" = "/entity_test/{entity_test}",
* "add-form" = "/entity_test/add",
* "edit-form" = "/entity_test/manage/{entity_test}/edit",
* "delete-form" = "/entity_test/delete/entity_test/{entity_test}",
* },
@ -69,21 +65,7 @@ class EntityTest extends ContentEntityBase implements EntityOwnerInterface {
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['id'] = BaseFieldDefinition::create('integer')
->setLabel(t('ID'))
->setDescription(t('The ID of the test entity.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The UUID of the test entity.'))
->setReadOnly(TRUE);
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language code'))
->setDescription(t('The language code of the test entity.'))
->setTranslatable(TRUE);
$fields = parent::baseFieldDefinitions($entity_type);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
@ -100,12 +82,6 @@ class EntityTest extends ContentEntityBase implements EntityOwnerInterface {
'weight' => -5,
));
// @todo: Add allowed values validation.
$fields['type'] = BaseFieldDefinition::create('string')
->setLabel(t('Type'))
->setDescription(t('The bundle of the test entity.'))
->setRequired(TRUE);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Authored on'))
->setDescription(t('Time the entity was created'))

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestAdminRoutes.
*/
namespace Drupal\entity_test\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestBaseFieldDisplay.
*/
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\EntityTypeInterface;
@ -33,10 +28,12 @@ use Drupal\entity_test\FieldStorageDefinition;
* "id" = "id",
* "label" = "name",
* "uuid" = "uuid",
* "bundle" = "type"
* "bundle" = "type",
* "langcode" = "langcode",
* },
* links = {
* "canonical" = "/entity_test_base_field_display/{entity_test_base_field_display}/edit",
* "add-form" = "/entity_test_base_field_display/add",
* "edit-form" = "/entity_test_base_field_display/manage/{entity_test_base_field_display}",
* "delete-form" = "/entity_test/delete/entity_test_base_field_display/{entity_test_base_field_display}/edit",
* },

View file

@ -0,0 +1,78 @@
<?php
namespace Drupal\entity_test\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
use Drupal\Core\Entity\EntityDescriptionInterface;
/**
* Defines the Test entity bundle configuration entity.
*
* @ConfigEntityType(
* id = "entity_test_bundle",
* label = @Translation("Test entity bundle"),
* handlers = {
* "access" = "\Drupal\Core\Entity\EntityAccessControlHandler",
* "form" = {
* "default" = "\Drupal\Core\Entity\BundleEntityFormBase",
* },
* "route_provider" = {
* "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
* },
* },
* admin_permission = "administer entity_test_bundle content",
* config_prefix = "entity_test_bundle",
* bundle_of = "entity_test_with_bundle",
* entity_keys = {
* "id" = "id",
* "label" = "label"
* },
* config_export = {
* "id",
* "label",
* "description",
* },
* links = {
* "add-form" = "/entity_test_bundle/add",
* }
* )
*/
class EntityTestBundle extends ConfigEntityBundleBase implements EntityDescriptionInterface {
/**
* The machine name.
*
* @var string
*/
protected $id;
/**
* The human-readable name.
*
* @var string
*/
protected $label;
/**
* The description.
*
* @var string
*/
protected $description;
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->description;
}
/**
* {@inheritdoc}
*/
public function setDescription($description) {
$this->description = $description;
return $this;
}
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestCache.
*/
namespace Drupal\entity_test\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestCompositeConstraint.
*/
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\EntityTypeInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestConstraintViolation.
*/
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\EntityTypeInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestConstraints.
*/
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\EntityChangedTrait;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestDefaultAccess.
*/
namespace Drupal\entity_test\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestDefaultValue.
*/
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\EntityTypeInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestFieldOverride.
*/
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\EntityTypeInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestLabel.
*/
namespace Drupal\entity_test\Entity;
/**
@ -20,9 +15,11 @@ namespace Drupal\entity_test\Entity;
* base_table = "entity_test",
* render_cache = FALSE,
* entity_keys = {
* "uuid" = "uuid",
* "id" = "id",
* "label" = "name",
* "bundle" = "type"
* "bundle" = "type",
* "langcode" = "langcode",
* }
* )
*/

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestLabelCallback.
*/
namespace Drupal\entity_test\Entity;
/**
@ -18,7 +13,9 @@ namespace Drupal\entity_test\Entity;
* label_callback = "entity_test_label_callback",
* entity_keys = {
* "id" = "id",
* "bundle" = "type"
* "bundle" = "type",
* "uuid" = "uuid",
* "langcode" = "langcode",
* }
* )
*/

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestMul.
*/
namespace Drupal\entity_test\Entity;
/**
@ -38,6 +33,8 @@ namespace Drupal\entity_test\Entity;
* "langcode" = "langcode",
* },
* links = {
* "add-page" = "/entity_test_mul/add",
* "add-form" = "/entity_test_mul/add/{type}",
* "canonical" = "/entity_test_mul/manage/{entity_test_mul}",
* "edit-form" = "/entity_test_mul/manage/{entity_test_mul}/edit",
* "delete-form" = "/entity_test/delete/entity_test_mul/{entity_test_mul}",

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestMulChanged.
*/
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\EntityChangedInterface;
@ -42,6 +37,7 @@ use Drupal\Core\Field\BaseFieldDefinition;
* "langcode" = "langcode"
* },
* links = {
* "add-form" = "/entity_test_mul_changed/add",
* "canonical" = "/entity_test_mul_changed/manage/{entity_test_mul_changed}",
* "edit-form" = "/entity_test_mul_changed/manage/{entity_test_mul_changed}/edit",
* "delete-form" = "/entity_test/delete/entity_test_mul_changed/{entity_test_mul_changed}",

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestMulDefaultValue.
*/
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\EntityTypeInterface;

View file

@ -1,14 +1,7 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestMulLangcodeKey.
*/
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\EntityTypeInterface;
/**
* Defines a test entity class using a custom langcode entity key.
*
@ -41,6 +34,7 @@ use Drupal\Core\Entity\EntityTypeInterface;
* "default_langcode" = "custom_default_langcode_key",
* },
* links = {
* "add-form" = "/entity_test_mul_langcode_key/add",
* "canonical" = "/entity_test_mul_langcode_key/manage/{entity_test_mul_langcode_key}",
* "edit-form" = "/entity_test_mul_langcode_key/manage/{entity_test_mul_langcode_key}/edit",
* "delete-form" = "/entity_test/delete/entity_test_mul_langcode_key/{entity_test_mul_langcode_key}",
@ -50,14 +44,4 @@ use Drupal\Core\Entity\EntityTypeInterface;
*/
class EntityTestMulLangcodeKey extends EntityTest {
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['custom_langcode_key'] = $fields['langcode'];
unset($fields['langcode']);
return $fields;
}
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestMulRev.
*/
namespace Drupal\entity_test\Entity;
/**
@ -41,6 +36,7 @@ namespace Drupal\entity_test\Entity;
* "langcode" = "langcode",
* },
* links = {
* "add-form" = "/entity_test_mulrev/add",
* "canonical" = "/entity_test_mulrev/manage/{entity_test_mulrev}",
* "delete-form" = "/entity_test/delete/entity_test_mulrev/{entity_test_mulrev}",
* "edit-form" = "/entity_test_mulrev/manage/{entity_test_mulrev}/edit",

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestMulRevChanged.
*/
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\EntityTypeInterface;
@ -43,6 +38,7 @@ use Drupal\Core\Field\BaseFieldDefinition;
* "langcode" = "langcode",
* },
* links = {
* "add-form" = "/entity_test_mulrev_changed/add",
* "canonical" = "/entity_test_mulrev_changed/manage/{entity_test_mulrev_changed}",
* "delete-form" = "/entity_test/delete/entity_test_mulrev_changed/{entity_test_mulrev_changed}",
* "edit-form" = "/entity_test_mulrev_changed/manage/{entity_test_mulrev_changed}/edit",

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestNew.
*/
namespace Drupal\entity_test\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestNoId.
*/
namespace Drupal\entity_test\Entity;
/**
@ -19,7 +14,11 @@ namespace Drupal\entity_test\Entity;
* entity_keys = {
* "bundle" = "type",
* },
* admin_permission = "administer entity_test content",
* field_ui_base_route = "entity.entity_test_no_id.admin_form",
* links = {
* "add-form" = "/entity_test_no_id/add",
* },
* )
*/
class EntityTestNoId extends EntityTest {

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestNoLabel.
*/
namespace Drupal\entity_test\Entity;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestRev.
*/
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\EntityTypeInterface;
@ -42,6 +37,7 @@ use Drupal\Core\Field\BaseFieldDefinition;
* "langcode" = "langcode",
* },
* links = {
* "add-form" = "/entity_test_rev/add",
* "canonical" = "/entity_test_rev/manage/{entity_test_rev}",
* "delete-form" = "/entity_test/delete/entity_test_rev/{entity_test_rev}",
* "edit-form" = "/entity_test_rev/manage/{entity_test_rev}/edit",

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestStringId.
*/
namespace Drupal\entity_test\Entity;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\EntityTypeInterface;
@ -34,6 +29,7 @@ use Drupal\Core\Entity\EntityTypeInterface;
* },
* links = {
* "canonical" = "/entity_test_string_id/manage/{entity_test_string_id}",
* "add-form" = "/entity_test_string_id/add",
* "edit-form" = "/entity_test_string_id/manage/{entity_test_string_id}",
* },
* field_ui_base_route = "entity.entity_test_string_id.admin_form",

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestUpdate.
*/
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\EntityTypeInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestViewBuilder.
*/
namespace Drupal\entity_test\Entity;
/**
@ -21,8 +16,10 @@ namespace Drupal\entity_test\Entity;
* render_cache = FALSE,
* entity_keys = {
* "id" = "id",
* "uuid" = "uuid",
* "label" = "name",
* "bundle" = "type"
* "bundle" = "type",
* "langcode" = "langcode",
* }
* )
*/

View file

@ -0,0 +1,72 @@
<?php
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
/**
* Defines the Test entity with bundle entity class.
*
* @ContentEntityType(
* id = "entity_test_with_bundle",
* label = @Translation("Test entity with bundle"),
* handlers = {
* "list_builder" = "Drupal\entity_test\EntityTestListBuilder",
* "view_builder" = "Drupal\entity_test\EntityTestViewBuilder",
* "access" = "Drupal\entity_test\EntityTestAccessControlHandler",
* "form" = {
* "default" = "\Drupal\Core\Entity\ContentEntityForm",
* "delete" = "\Drupal\Core\Entity\EntityDeleteForm"
* },
* "route_provider" = {
* "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
* },
* },
* base_table = "entity_test_with_bundle",
* admin_permission = "administer entity_test_with_bundle content",
* persistent_cache = FALSE,
* entity_keys = {
* "id" = "id",
* "uuid" = "uuid",
* "bundle" = "type",
* "label" = "name",
* "langcode" = "langcode",
* },
* bundle_entity_type = "entity_test_bundle",
* links = {
* "canonical" = "/entity_test_with_bundle/{entity_test_with_bundle}",
* "add-page" = "/entity_test_with_bundle/add",
* "add-form" = "/entity_test_with_bundle/add/{entity_test_bundle}",
* "edit-form" = "/entity_test_with_bundle/{entity_test_with_bundle}/edit",
* "delete-form" = "/entity_test_with_bundle/{entity_test_with_bundle}/delete",
* },
* )
*/
class EntityTestWithBundle extends ContentEntityBase {
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of the test entity.'))
->setTranslatable(TRUE)
->setSetting('max_length', 32)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'string',
'weight' => -5,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -5,
]);
return $fields;
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\RevisionableContentEntityBase;
/**
* Defines the test entity class.
*
* @ContentEntityType(
* id = "entity_test_revlog",
* label = @Translation("Test entity - revisions log"),
* handlers = {
* "access" = "Drupal\entity_test\EntityTestAccessControlHandler",
* "view_builder" = "Drupal\entity_test\EntityTestViewBuilder",
* "form" = {
* "default" = "Drupal\entity_test\EntityTestForm",
* "delete" = "Drupal\entity_test\EntityTestDeleteForm"
* },
* "view_builder" = "Drupal\entity_test\EntityTestViewBuilder",
* "translation" = "Drupal\content_translation\ContentTranslationHandler",
* "views_data" = "Drupal\views\EntityViewsData",
* "route_provider" = {
* "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
* },
* },
* base_table = "entity_test_revlog",
* revision_table = "entity_test_revlog_revision",
* admin_permission = "administer entity_test content",
* entity_keys = {
* "id" = "id",
* "uuid" = "uuid",
* "revision" = "revision_id",
* "bundle" = "type",
* "label" = "name",
* "langcode" = "langcode",
* },
* links = {
* "canonical" = "/entity_test_revlog/manage/{entity_test_revlog}",
* "delete-form" = "/entity_test/delete/entity_test_revlog/{entity_test_revlog}",
* "edit-form" = "/entity_test_revlog/manage/{entity_test_revlog}/edit",
* "revision" = "/entity_test_revlog/{entity_test_revlog}/revision/{entity_test_revlog_revision}/view",
* }
* )
*/
class EntityTestWithRevisionLog extends RevisionableContentEntityBase {
}

View file

@ -1,16 +1,12 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\EntityTestAccessControlHandler.
*/
namespace Drupal\entity_test;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Session\AccountInterface;
use Drupal\entity_test\Entity\EntityTestLabel;
/**
* Defines the access control handler for the test entity type.
@ -21,10 +17,18 @@ use Drupal\Core\Session\AccountInterface;
* @see \Drupal\entity_test\Entity\EntityTestMul
* @see \Drupal\entity_test\Entity\EntityTestMulRev
* @see \Drupal\entity_test\Entity\EntityTestRev
* @see \Drupal\entity_test\Entity\EntityTestWithBundle
* @see \Drupal\entity_test\Entity\EntityTestStringId
*/
class EntityTestAccessControlHandler extends EntityAccessControlHandler {
/**
* Allows to grant access to just the labels.
*
* @var bool
*/
protected $viewLabelOperation = TRUE;
/**
* {@inheritdoc}
*/
@ -37,7 +41,11 @@ class EntityTestAccessControlHandler extends EntityAccessControlHandler {
return AccessResult::forbidden();
}
if ($operation === 'view') {
if ($operation === 'view label' && $entity instanceof EntityTestLabel) {
// Viewing the label of the 'entity_test_label' entity type is allowed.
return AccessResult::allowed();
}
elseif (in_array($operation, array('view', 'view label'))) {
if (!$entity->isDefaultTranslation()) {
return AccessResult::allowedIfHasPermission($account, 'view test entity translations');
}
@ -56,7 +64,11 @@ class EntityTestAccessControlHandler extends EntityAccessControlHandler {
* {@inheritdoc}
*/
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return AccessResult::allowedIfHasPermission($account, 'administer entity_test content');
return AccessResult::allowedIfHasPermissions($account, [
'administer entity_test content',
'administer entity_test_with_bundle content',
'create ' . $entity_bundle . ' entity_test_with_bundle entities',
], 'OR');
}
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\EntityTestDefinitionSubscriber.
*/
namespace Drupal\entity_test;
use Drupal\Core\Entity\EntityTypeEvents;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\EntityTestDeleteForm.
*/
namespace Drupal\entity_test;
use Drupal\Core\Entity\ContentEntityDeleteForm;

View file

@ -1,8 +1,4 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\EntityTestForm.
*/
namespace Drupal\entity_test;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\EntityTestListBuilder.
*/
namespace Drupal\entity_test;
use Drupal\Core\Entity\EntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\EntityTestNoLoadStorage.
*/
namespace Drupal\entity_test;
use Drupal\Core\Entity\EntityStorageException;

View file

@ -0,0 +1,52 @@
<?php
namespace Drupal\entity_test;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\entity_test\Entity\EntityTestBundle;
/**
* Provides dynamic permissions for entity test.
*/
class EntityTestPermissions {
use StringTranslationTrait;
/**
* Returns an array of entity_test_bundle permissions.
*
* @return array
* An array of entity_test_bundle permissions.
* @see \Drupal\user\PermissionHandlerInterface::getPermissions()
*/
public function entityTestBundlePermissions() {
$perms = [];
// Generate permissions for all EntityTestBundle bundles.
foreach (EntityTestBundle::loadMultiple() as $type) {
$perms += $this->buildPermissions($type);
}
return $perms;
}
/**
* Returns a list of entity test permissions for a given entity test bundle.
*
* @param EntityTestBundle $type
* The entity test bundle.
*
* @return array
* An associative array of permission names and descriptions.
*/
protected function buildPermissions(EntityTestBundle $type) {
$type_id = $type->id();
$type_params = ['%type_name' => $type->label()];
return [
"create $type_id entity_test_with_bundle entities" => [
'title' => $this->t('%type_name: Create new entity', $type_params),
],
];
}
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\EntityTestStorageSchema.
*/
namespace Drupal\entity_test;
use Drupal\Core\Entity\ContentEntityTypeInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\EntityTestViewBuilder.
*/
namespace Drupal\entity_test;
use Drupal\Core\Entity\EntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\EntityTestViewBuilderOverriddenView.
*/
namespace Drupal\entity_test;
use Drupal\Core\Entity\EntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\EntityTestViewsData.
*/
namespace Drupal\entity_test;
use Drupal\Component\Utility\NestedArray;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\FieldStorageDefinition.
*/
namespace Drupal\entity_test;
use Drupal\Core\Field\BaseFieldDefinition;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Plugin\Derivative\EntityTestLocalTasks.
*/
namespace Drupal\entity_test\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Plugin\Field\FieldType\ChangedTestItem.
*/
namespace Drupal\entity_test\Plugin\Field\FieldType;
use Drupal\Core\Field\Plugin\Field\FieldType\ChangedItem;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\entity_test\Plugin\Field\FieldType\FieldTestItem.
*/
namespace Drupal\entity_test\Plugin\Field\FieldType;
use Drupal\Core\Field\FieldItemBase;

Some files were not shown because too many files have changed in this diff Show more