Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
fbe93225
Commit
fbe93225
authored
Nov 20, 2013
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2111823
by amateescu, dawehner: Convert field_ui / Entity local tasks to YAML definitions.
parent
e86305a0
Changes
36
Hide whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
475 additions
and
220 deletions
+475
-220
core/lib/Drupal/Core/Entity/Annotation/EntityType.php
core/lib/Drupal/Core/Entity/Annotation/EntityType.php
+2
-7
core/lib/Drupal/Core/Entity/EntityManager.php
core/lib/Drupal/Core/Entity/EntityManager.php
+5
-4
core/lib/Drupal/Core/Entity/EntityManagerInterface.php
core/lib/Drupal/Core/Entity/EntityManagerInterface.php
+5
-0
core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php
...stom_block/lib/Drupal/custom_block/Entity/CustomBlock.php
+4
-3
core/modules/comment/lib/Drupal/comment/Entity/Comment.php
core/modules/comment/lib/Drupal/comment/Entity/Comment.php
+2
-2
core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php
...s/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php
+6
-6
core/modules/config_translation/lib/Drupal/config_translation/ConfigFieldInstanceMapper.php
...b/Drupal/config_translation/ConfigFieldInstanceMapper.php
+2
-5
core/modules/contact/contact.local_tasks.yml
core/modules/contact/contact.local_tasks.yml
+4
-0
core/modules/contact/contact.module
core/modules/contact/contact.module
+0
-4
core/modules/contact/lib/Drupal/contact/Entity/Message.php
core/modules/contact/lib/Drupal/contact/Entity/Message.php
+4
-1
core/modules/field_ui/field_ui.local_tasks.yml
core/modules/field_ui/field_ui.local_tasks.yml
+3
-0
core/modules/field_ui/field_ui.module
core/modules/field_ui/field_ui.module
+10
-94
core/modules/field_ui/field_ui.services.yml
core/modules/field_ui/field_ui.services.yml
+3
-1
core/modules/field_ui/lib/Drupal/field_ui/Access/FormModeAccessCheck.php
...eld_ui/lib/Drupal/field_ui/Access/FormModeAccessCheck.php
+28
-8
core/modules/field_ui/lib/Drupal/field_ui/Access/ViewModeAccessCheck.php
...eld_ui/lib/Drupal/field_ui/Access/ViewModeAccessCheck.php
+27
-7
core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
.../modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
+11
-0
core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php
...ules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php
+4
-2
core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php
...les/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php
+1
-6
core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php
...dules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php
+1
-6
core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php
...eld_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php
+3
-7
core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php
...ules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php
+11
-0
core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php
core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php
+8
-2
core/modules/field_ui/lib/Drupal/field_ui/Plugin/Derivative/FieldUiLocalTask.php
...ib/Drupal/field_ui/Plugin/Derivative/FieldUiLocalTask.php
+234
-0
core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php
.../field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php
+57
-25
core/modules/field_ui/tests/modules/field_ui_test/lib/Drupal/field_ui_test/Entity/FieldUITestNoBundle.php
...t/lib/Drupal/field_ui_test/Entity/FieldUITestNoBundle.php
+1
-2
core/modules/node/lib/Drupal/node/Entity/Node.php
core/modules/node/lib/Drupal/node/Entity/Node.php
+3
-2
core/modules/node/node.local_tasks.yml
core/modules/node/node.local_tasks.yml
+4
-0
core/modules/node/node.module
core/modules/node/node.module
+0
-10
core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Controller/EntityTestController.php
...ib/Drupal/entity_test/Controller/EntityTestController.php
+7
-0
core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php
.../entity_test/lib/Drupal/entity_test/Entity/EntityTest.php
+2
-2
core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestMul.php
...tity_test/lib/Drupal/entity_test/Entity/EntityTestMul.php
+2
-2
core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Routing/RouteSubscriber.php
...y_test/lib/Drupal/entity_test/Routing/RouteSubscriber.php
+7
-0
core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php
core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php
+3
-2
core/modules/taxonomy/taxonomy.local_tasks.yml
core/modules/taxonomy/taxonomy.local_tasks.yml
+9
-0
core/modules/taxonomy/taxonomy.module
core/modules/taxonomy/taxonomy.module
+0
-8
core/modules/user/lib/Drupal/user/Entity/User.php
core/modules/user/lib/Drupal/user/Entity/User.php
+2
-2
No files found.
core/lib/Drupal/Core/Entity/Annotation/EntityType.php
View file @
fbe93225
...
...
@@ -225,16 +225,11 @@ class EntityType extends Plugin {
public
$bundle_keys
;
/**
* The base router path for the entity type's field administration page.
*
* If the entity type has a bundle, include {bundle} in the path.
*
* For example, the node entity type specifies
* "admin/structure/types/manage/{bundle}" as its base field admin path.
* The name of the entity type which provides bundles.
*
* @var string (optional)
*/
public
$
route_base_path
;
public
$
bundle_entity_type
=
'bundle'
;
/**
* Link templates using the URI template syntax.
...
...
core/lib/Drupal/Core/Entity/EntityManager.php
View file @
fbe93225
...
...
@@ -301,9 +301,9 @@ public function getAdminPath($entity_type, $bundle) {
$admin_path
=
''
;
$entity_info
=
$this
->
getDefinition
(
$entity_type
);
// Check for an entity type's admin base path.
if
(
isset
(
$entity_info
[
'
route_base_path
'
]))
{
// Replace any dynamic 'bundle' portion of the path with the actual
bundle
.
$admin_path
=
str_replace
(
'{bundle}'
,
$bundle
,
$entity_info
[
'route_base_path'
]
);
if
(
isset
(
$entity_info
[
'
links'
][
'admin-form
'
]))
{
$route_parameters
[
$entity_info
[
'bundle_entity_type'
]]
=
$
bundle
;
$admin_path
=
\
Drupal
::
urlGenerator
()
->
getPathFromRoute
(
$entity_info
[
'links'
][
'admin-form'
],
$route_parameters
);
}
return
$admin_path
;
...
...
@@ -313,10 +313,11 @@ public function getAdminPath($entity_type, $bundle) {
* {@inheritdoc}
*/
public
function
getAdminRouteInfo
(
$entity_type
,
$bundle
)
{
$entity_info
=
$this
->
getDefinition
(
$entity_type
);
return
array
(
'route_name'
=>
"field_ui.overview_
$entity_type
"
,
'route_parameters'
=>
array
(
'bundle'
=>
$bundle
,
$entity_info
[
'bundle_entity_type'
]
=>
$bundle
,
)
);
}
...
...
core/lib/Drupal/Core/Entity/EntityManagerInterface.php
View file @
fbe93225
...
...
@@ -164,6 +164,11 @@ public function getViewBuilder($entity_type);
*
* @return string
* The administration path for an entity type bundle, if it exists.
*
* @deprecated since version 8.0
* System paths should not be used - use route names and parameters.
*
* @see self::getAdminRouteInfo()
*/
public
function
getAdminPath
(
$entity_type
,
$bundle
);
...
...
core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php
View file @
fbe93225
...
...
@@ -36,10 +36,10 @@
* admin_permission = "administer blocks",
* base_table = "custom_block",
* revision_table = "custom_block_revision",
* route_base_path = "admin/structure/block/custom-blocks/manage/{bundle}",
* links = {
* "canonical" = "custom_block.edit",
* "edit-form" = "custom_block.edit"
* "edit-form" = "custom_block.edit",
* "admin-form" = "custom_block.type_edit"
* },
* fieldable = TRUE,
* translatable = TRUE,
...
...
@@ -52,7 +52,8 @@
* },
* bundle_keys = {
* "bundle" = "type"
* }
* },
* bundle_entity_type = "custom_block_type"
* )
*/
class
CustomBlock
extends
ContentEntityBase
implements
CustomBlockInterface
{
...
...
core/modules/comment/lib/Drupal/comment/Entity/Comment.php
View file @
fbe93225
...
...
@@ -36,7 +36,6 @@
* fieldable = TRUE,
* translatable = TRUE,
* render_cache = FALSE,
* route_base_path = "admin/structure/comments/manage/{bundle}",
* entity_keys = {
* "id" = "cid",
* "bundle" = "field_id",
...
...
@@ -48,7 +47,8 @@
* },
* links = {
* "canonical" = "comment.permalink",
* "edit-form" = "comment.edit_page"
* "edit-form" = "comment.edit_page",
* "admin-form" = "comment.bundle"
* }
* )
*/
...
...
core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php
View file @
fbe93225
...
...
@@ -229,11 +229,11 @@ function testCommentFunctionality() {
));
$this
->
drupalLogin
(
$limited_user
);
// Test that default field exists.
$this
->
drupalGet
(
'
admin/structure/
entity
-
test/
manag
e/entity_test/fields'
);
$this
->
drupalGet
(
'entity
_
test/
structur
e/entity_test/fields'
);
$this
->
assertText
(
t
(
'Comment settings'
));
$this
->
assertLinkByHref
(
'
admin/structure/
entity
-
test/
manag
e/entity_test/fields/entity_test.entity_test.comment'
);
$this
->
assertLinkByHref
(
'entity
_
test/
structur
e/entity_test/fields/entity_test.entity_test.comment'
);
// Test widget hidden option is not visible when there's no comments.
$this
->
drupalGet
(
'
admin/structure/
entity
-
test/
manag
e/entity_test/entity-test/fields/entity_test.entity_test.comment'
);
$this
->
drupalGet
(
'entity
_
test/
structur
e/entity_test/entity-test/fields/entity_test.entity_test.comment'
);
$this
->
assertNoField
(
'edit-default-value-input-comment-und-0-status-0'
);
$this
->
drupalLogin
(
$this
->
admin_user
);
...
...
@@ -343,20 +343,20 @@ function testCommentFunctionality() {
'administer entity_test content'
,
));
$this
->
drupalLogin
(
$limited_user
);
$this
->
drupalGet
(
'
admin/structure/
entity
-
test/
manag
e/entity_test/fields/entity_test.entity_test.comment'
);
$this
->
drupalGet
(
'entity
_
test/
structur
e/entity_test/fields/entity_test.entity_test.comment'
);
$this
->
assertNoFieldChecked
(
'edit-default-value-input-comment-0-status-0'
);
$this
->
assertNoFieldChecked
(
'edit-default-value-input-comment-0-status-1'
);
$this
->
assertFieldChecked
(
'edit-default-value-input-comment-0-status-2'
);
// Test comment option change in field settings.
$edit
=
array
(
'default_value_input[comment][0][status]'
=>
COMMENT_CLOSED
);
$this
->
drupalPostForm
(
NULL
,
$edit
,
t
(
'Save settings'
));
$this
->
drupalGet
(
'
admin/structure/
entity
-
test/
manag
e/entity_test/fields/entity_test.entity_test.comment'
);
$this
->
drupalGet
(
'entity
_
test/
structur
e/entity_test/fields/entity_test.entity_test.comment'
);
$this
->
assertNoFieldChecked
(
'edit-default-value-input-comment-0-status-0'
);
$this
->
assertFieldChecked
(
'edit-default-value-input-comment-0-status-1'
);
$this
->
assertNoFieldChecked
(
'edit-default-value-input-comment-0-status-2'
);
// Add a new comment field.
$this
->
drupalGet
(
'
admin/structure/
entity
-
test/
manag
e/entity_test/fields'
);
$this
->
drupalGet
(
'entity
_
test/
structur
e/entity_test/fields'
);
$edit
=
array
(
'fields[_add_new_field][label]'
=>
'Foobar'
,
'fields[_add_new_field][field_name]'
=>
'foobar'
,
...
...
core/modules/config_translation/lib/Drupal/config_translation/ConfigFieldInstanceMapper.php
View file @
fbe93225
...
...
@@ -23,13 +23,10 @@ class ConfigFieldInstanceMapper extends ConfigEntityMapper {
*/
public
function
getBaseRouteParameters
()
{
$parameters
=
parent
::
getBaseRouteParameters
();
// @todo All core content entity path placeholders can be fully filled in
// with an additional {bundle} value in their paths, but a more
// predictable solution would be ideal. See
// https://drupal.org/node/2134871
$base_entity_info
=
$this
->
entityManager
->
getDefinition
(
$this
->
pluginDefinition
[
'base_entity_type'
]);
// @todo Field instances have no method to return the bundle the instance is
// attached to. See https://drupal.org/node/2134861
$parameters
[
'bundle'
]
=
$this
->
entity
->
bundle
;
$parameters
[
$base_entity_info
[
'bundle_entity_type'
]
]
=
$this
->
entity
->
bundle
;
return
$parameters
;
}
...
...
core/modules/contact/contact.local_tasks.yml
0 → 100644
View file @
fbe93225
contact.category_edit
:
title
:
'
Edit'
route_name
:
contact.category_edit
tab_root_id
:
contact.category_edit
core/modules/contact/contact.module
View file @
fbe93225
...
...
@@ -67,10 +67,6 @@ function contact_menu() {
'title'
=>
'Edit contact category'
,
'route_name'
=>
'contact.category_edit'
,
);
$items
[
'admin/structure/contact/manage/%contact_category/edit'
]
=
array
(
'title'
=>
'Edit'
,
'type'
=>
MENU_DEFAULT_LOCAL_TASK
,
);
$items
[
'contact'
]
=
array
(
'title'
=>
'Contact'
,
...
...
core/modules/contact/lib/Drupal/contact/Entity/Message.php
View file @
fbe93225
...
...
@@ -26,10 +26,13 @@
* entity_keys = {
* "bundle" = "category"
* },
*
route_base_path = "admin/structure/contact/manage/{bundle}
",
*
bundle_entity_type = "contact_category
",
* fieldable = TRUE,
* bundle_keys = {
* "bundle" = "id"
* },
* links = {
* "admin-form" = "contact.category_edit"
* }
* )
*/
...
...
core/modules/field_ui/field_ui.local_tasks.yml
View file @
fbe93225
...
...
@@ -2,3 +2,6 @@ field_ui.list:
title
:
Entities
route_name
:
field_ui.list
tab_root_id
:
field_ui.list
field_ui.fields
:
class
:
\Drupal\Core\Menu\LocalTaskDefault
derivative
:
\Drupal\field_ui\Plugin\Derivative\FieldUiLocalTask
core/modules/field_ui/field_ui.module
View file @
fbe93225
...
...
@@ -7,6 +7,7 @@
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\entity\EntityViewModeInterface
;
use
Drupal\field_ui
\
Plugin\Derivative\FieldUiLocalTask
;
/**
* Implements hook_help().
...
...
@@ -61,94 +62,6 @@ function field_ui_menu() {
'type'
=>
MENU_NORMAL_ITEM
,
);
// Create tabs for all possible bundles.
foreach
(
entity_get_info
()
as
$entity_type
=>
$entity_info
)
{
if
(
$entity_info
[
'fieldable'
]
&&
isset
(
$entity_info
[
'route_base_path'
]))
{
// Extract path information from the entity type.
$path
=
$entity_info
[
'route_base_path'
];
$default_path
=
preg_replace
(
'/{'
.
DRUPAL_PHP_FUNCTION_PATTERN
.
'}/'
,
'%'
,
$path
);
// This is the position of the %field_ui_instance placeholder in the
// items below.
$field_position
=
count
(
explode
(
'/'
,
$path
))
+
1
;
$items
[
"
$path
/fields"
]
=
array
(
'title'
=>
'Manage fields'
,
'type'
=>
MENU_LOCAL_TASK
,
'route_name'
=>
"field_ui.overview_
$entity_type
"
,
'weight'
=>
1
,
);
$items
[
"
$path
/fields/%"
]
=
array
(
'title callback'
=>
'entity_page_label'
,
'title arguments'
=>
array
(
$field_position
),
'route_name'
=>
"field_ui.instance_edit_
$entity_type
"
,
);
$items
[
"
$default_path
/fields/%/edit"
]
=
array
(
'title'
=>
'Edit'
,
'type'
=>
MENU_DEFAULT_LOCAL_TASK
,
);
$items
[
"
$path
/fields/%/field"
]
=
array
(
'title'
=>
'Field settings'
,
'type'
=>
MENU_LOCAL_TASK
,
'route_name'
=>
"field_ui.field_edit_
$entity_type
"
,
);
$items
[
"
$path
/fields/%/delete"
]
=
array
(
'title'
=>
'Delete'
,
'type'
=>
MENU_VISIBLE_IN_BREADCRUMB
,
'route_name'
=>
"field_ui.delete_
$entity_type
"
,
'weight'
=>
10
,
);
// 'Manage form display' tab.
$items
[
"
$path
/form-display"
]
=
array
(
'title'
=>
'Manage form display'
,
'type'
=>
MENU_LOCAL_TASK
,
'route_name'
=>
"field_ui.form_display_overview_
$entity_type
"
,
'weight'
=>
2
,
);
// 'Manage display' tab.
$items
[
"
$path
/display"
]
=
array
(
'title'
=>
'Manage display'
,
'type'
=>
MENU_LOCAL_TASK
,
'route_name'
=>
"field_ui.display_overview_
$entity_type
"
,
'weight'
=>
3
,
);
// View and form modes secondary tabs.
// The same base $path for the menu item (with a placeholder) can be
// used for all bundles of a given entity type; but depending on
// administrator settings, each bundle has a different set of view
// modes available for customisation. So we define menu items for all
// view modes, and use a route requirement to determine which ones are
// actually visible for a given bundle.
$items
[
"
$default_path
/form-display/default"
]
=
array
(
'title'
=>
t
(
'Default'
),
'type'
=>
MENU_DEFAULT_LOCAL_TASK
,
);
$items
[
"
$default_path
/display/default"
]
=
array
(
'title'
=>
t
(
'Default'
),
'type'
=>
MENU_DEFAULT_LOCAL_TASK
,
);
$weight
=
0
;
foreach
(
entity_get_form_modes
(
$entity_type
)
as
$form_mode
=>
$form_mode_info
)
{
$items
[
"
$path
/form-display/
$form_mode
"
]
=
array
(
'title'
=>
$form_mode_info
[
'label'
],
'type'
=>
MENU_LOCAL_TASK
,
'weight'
=>
$weight
++
,
'route_name'
=>
"field_ui.form_display_overview_
$entity_type
"
.
'_'
.
$form_mode
,
);
}
$weight
=
0
;
foreach
(
entity_get_view_modes
(
$entity_type
)
as
$view_mode
=>
$view_mode_info
)
{
$items
[
"
$path
/display/
$view_mode
"
]
=
array
(
'title'
=>
$view_mode_info
[
'label'
],
'type'
=>
MENU_LOCAL_TASK
,
'weight'
=>
$weight
++
,
'route_name'
=>
"field_ui.display_overview_
$entity_type
"
.
'_'
.
$view_mode
,
);
}
}
}
return
$items
;
}
...
...
@@ -334,12 +247,7 @@ function field_ui_entity_operation_alter(array &$operations, EntityInterface $en
*/
function
field_ui_form_node_type_form_submit
(
$form
,
&
$form_state
)
{
if
(
$form_state
[
'triggering_element'
][
'#parents'
][
0
]
===
'save_continue'
)
{
$form_state
[
'redirect_route'
]
=
array
(
'route_name'
=>
'field_ui.overview_node'
,
'route_parameters'
=>
array
(
'bundle'
=>
$form_state
[
'values'
][
'type'
],
),
);
$form_state
[
'redirect_route'
]
=
\
Drupal
::
entityManager
()
->
getAdminRouteInfo
(
'node'
,
$form_state
[
'values'
][
'type'
]);
}
}
...
...
@@ -462,3 +370,11 @@ function theme_field_ui_table($variables) {
return
drupal_render
(
$table
);
}
/**
* Implements hook_local_tasks_alter().
*/
function
field_ui_local_tasks_alter
(
&
$local_tasks
)
{
$container
=
\
Drupal
::
getContainer
();
$local_task
=
FieldUiLocalTask
::
create
(
$container
,
'field_ui.fields'
);
$local_task
->
alterLocalTasks
(
$local_tasks
);
}
core/modules/field_ui/field_ui.services.yml
View file @
fbe93225
services
:
field_ui.subscriber
:
class
:
Drupal\field_ui\Routing\RouteSubscriber
arguments
:
[
'
@entity.manager'
]
arguments
:
[
'
@entity.manager'
,
'
@router.route_provider'
]
tags
:
-
{
name
:
event_subscriber
}
access_check.field_ui.view_mode
:
class
:
Drupal\field_ui\Access\ViewModeAccessCheck
arguments
:
[
'
@entity.manager'
]
tags
:
-
{
name
:
access_check
}
access_check.field_ui.form_mode
:
class
:
Drupal\field_ui\Access\FormModeAccessCheck
arguments
:
[
'
@entity.manager'
]
tags
:
-
{
name
:
access_check
}
core/modules/field_ui/lib/Drupal/field_ui/Access/FormModeAccessCheck.php
View file @
fbe93225
...
...
@@ -8,6 +8,7 @@
namespace
Drupal\field_ui\Access
;
use
Drupal\Core\Access\StaticAccessCheckInterface
;
use
Drupal\Core\Entity\EntityManagerInterface
;
use
Drupal\Core\Session\AccountInterface
;
use
Symfony\Component\Routing\Route
;
use
Symfony\Component\HttpFoundation\Request
;
...
...
@@ -17,6 +18,23 @@
*/
class
FormModeAccessCheck
implements
StaticAccessCheckInterface
{
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected
$entityManager
;
/**
* Creates a new FormModeAccessCheck.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
*/
public
function
__construct
(
EntityManagerInterface
$entity_manager
)
{
$this
->
entityManager
=
$entity_manager
;
}
/**
* {@inheritdoc}
*/
...
...
@@ -29,17 +47,19 @@ public function appliesTo() {
*/
public
function
access
(
Route
$route
,
Request
$request
,
AccountInterface
$account
)
{
if
(
$entity_type
=
$request
->
attributes
->
get
(
'entity_type'
))
{
$bundle
=
$request
->
attributes
->
get
(
'bundle'
);
$form_mode
=
$request
->
attributes
->
get
(
'mode'
);
$form_mode
=
$request
->
attributes
->
get
(
'form_mode_name'
);
if
(
$form_mode
==
'default'
)
{
$visibility
=
TRUE
;
if
(
!
(
$bundle
=
$request
->
attributes
->
get
(
'bundle'
)))
{
$entity_info
=
$this
->
entityManager
->
getDefinition
(
$entity_type
);
$bundle
=
$request
->
attributes
->
get
(
'_raw_variables'
)
->
get
(
$entity_info
[
'bundle_entity_type'
]);
}
elseif
(
$entity_form_display
=
entity_load
(
'entity_form_display'
,
$entity_type
.
'.'
.
$bundle
.
'.'
.
$form_mode
))
{
$visibility
=
$entity_form_display
->
status
();
$visibility
=
FALSE
;
if
(
!
$form_mode
||
$form_mode
==
'default'
)
{
$visibility
=
TRUE
;
}
else
{
$visibility
=
FALSE
;
else
if
(
$entity_display
=
$this
->
entityManager
->
getStorageController
(
'entity_form_display'
)
->
load
(
$entity_type
.
'.'
.
$bundle
.
'.'
.
$form_mode
))
{
$visibility
=
$entity_display
->
status
()
;
}
if
(
$visibility
)
{
...
...
core/modules/field_ui/lib/Drupal/field_ui/Access/ViewModeAccessCheck.php
View file @
fbe93225
...
...
@@ -8,6 +8,7 @@
namespace
Drupal\field_ui\Access
;
use
Drupal\Core\Access\StaticAccessCheckInterface
;
use
Drupal\Core\Entity\EntityManagerInterface
;
use
Drupal\Core\Session\AccountInterface
;
use
Symfony\Component\Routing\Route
;
use
Symfony\Component\HttpFoundation\Request
;
...
...
@@ -17,6 +18,23 @@
*/
class
ViewModeAccessCheck
implements
StaticAccessCheckInterface
{
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected
$entityManager
;
/**
* Creates a new ViewModeAccessCheck.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
*/
public
function
__construct
(
EntityManagerInterface
$entity_manager
)
{
$this
->
entityManager
=
$entity_manager
;
}
/**
* {@inheritdoc}
*/
...
...
@@ -29,18 +47,20 @@ public function appliesTo() {
*/
public
function
access
(
Route
$route
,
Request
$request
,
AccountInterface
$account
)
{
if
(
$entity_type
=
$request
->
attributes
->
get
(
'entity_type'
))
{
$bundle
=
$request
->
attributes
->
get
(
'bundle'
);
$view_mode
=
$request
->
attributes
->
get
(
'mode'
);
$view_mode
=
$request
->
attributes
->
get
(
'view_mode_name'
);
if
(
$view_mode
==
'default'
)
{
if
(
!
(
$bundle
=
$request
->
attributes
->
get
(
'bundle'
)))
{
$entity_info
=
$this
->
entityManager
->
getDefinition
(
$entity_type
);
$bundle
=
$request
->
attributes
->
get
(
'_raw_variables'
)
->
get
(
$entity_info
[
'bundle_entity_type'
]);
}
$visibility
=
FALSE
;
if
(
!
$view_mode
||
$view_mode
==
'default'
)
{
$visibility
=
TRUE
;
}
elseif
(
$entity_display
=
entity_load
(
'entity_display'
,
$entity_type
.
'.'
.
$bundle
.
'.'
.
$view_mode
))
{
elseif
(
$entity_display
=
$this
->
entityManager
->
getStorageController
(
'entity_display'
)
->
load
(
$entity_type
.
'.'
.
$bundle
.
'.'
.
$view_mode
))
{
$visibility
=
$entity_display
->
status
();
}
else
{
$visibility
=
FALSE
;
}
if
(
$visibility
)
{
$permission
=
$route
->
getRequirement
(
'_field_ui_view_mode_access'
);
...
...
core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php
View file @
fbe93225
...
...
@@ -35,6 +35,17 @@ public function getFormId() {
return
'field_ui_display_overview_form'
;
}
/**
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
array
&
$form_state
,
$entity_type
=
NULL
,
$bundle
=
NULL
)
{
if
(
$this
->
getRequest
()
->
attributes
->
has
(
'view_mode_name'
))
{
$this
->
mode
=
$this
->
getRequest
()
->
attributes
->
get
(
'view_mode_name'
);
}
return
parent
::
buildForm
(
$form
,
$form_state
,
$entity_type
,
$bundle
);
}
/**
* {@inheritdoc}
*/
...
...
core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php
View file @
fbe93225
...
...
@@ -82,10 +82,12 @@ public function getRegions() {
/**
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
array
&
$form_state
,
$entity_type
=
NULL
,
$bundle
=
NULL
,
$mode
=
NULL
)
{
public
function
buildForm
(
array
$form
,
array
&
$form_state
,
$entity_type
=
NULL
,
$bundle
=
NULL
)
{
parent
::
buildForm
(
$form
,
$form_state
,
$entity_type
,
$bundle
);
$this
->
mode
=
(
isset
(
$mode
)
?
$mode
:
'default'
);
if
(
empty
(
$this
->
mode
))
{
$this
->
mode
=
'default'
;
}
// Gather type information.
$instances
=
field_info_instances
(
$this
->
entity_type
,
$this
->
bundle
);
...
...
core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php
View file @
fbe93225
...
...
@@ -79,12 +79,7 @@ public function submit(array $form, array &$form_state) {
drupal_set_message
(
$this
->
t
(
'There was a problem removing the %field from the %type content type.'
,
array
(
'%field'
=>
$this
->
entity
->
label
(),
'%type'
=>
$bundle_label
)),
'error'
);
}
$form_state
[
'redirect_route'
]
=
array
(
'route_name'
=>
'field_ui.overview_'
.
$this
->
entity
->
entity_type
,
'route_parameters'
=>
array
(
'bundle'
=>
$this
->
entity
->
bundle
,
)
);
$form_state
[
'redirect_route'
]
=
$this
->
entityManager
->
getAdminRouteInfo
(
$this
->
entity
->
entity_type
,
$this
->
entity
->
bundle
);
// Fields are purged on cron. However field module prevents disabling modules
// when field types they provided are used in a field until it is fully
...
...
core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php
View file @
fbe93225
...
...
@@ -206,12 +206,7 @@ public function submitForm(array &$form, array &$form_state) {
$form_state
[
'redirect'
]
=
$next_destination
;
}
else
{
$form_state
[
'redirect_route'
]
=
array
(
'route_name'
=>
'field_ui.overview_'
.
$this
->
instance
->
entity_type
,
'route_parameters'
=>
array
(
'bundle'
=>
$this
->
instance
->
bundle
,
)
);
$form_state
[
'redirect_route'
]
=
$this
->
entityManager
->
getAdminRouteInfo
(
$this
->
instance
->
entity_type
,
$this
->
instance
->
bundle
);
}
}
catch
(
\
Exception
$e
)
{
...
...
core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php
View file @
fbe93225
...
...
@@ -193,12 +193,7 @@ public function submitForm(array &$form, array &$form_state) {
$form_state
[
'redirect'
]
=
$next_destination
;
}
else
{
$form_state
[
'redirect_route'
]
=
array
(
'route_name'
=>
'field_ui.overview_'
.
$this
->
instance
->
entity_type
,
'route_parameters'
=>
array
(
'bundle'
=>
$this
->
instance
->
bundle
,
)
);
$form_state
[
'redirect_route'
]
=
$this
->
entityManager
->
getAdminRouteInfo
(
$this
->
instance
->
entity_type
,
$this
->
instance
->
bundle
);
}
}
...
...
@@ -212,10 +207,11 @@ public function delete(array &$form, array &$form_state) {
$destination
=
drupal_get_destination
();
$request
->
query
->
remove
(
'destination'
);
}
$entity_info
=
$this
->
entityManager
->
getDefinition
(
$this
->
instance
->
entity_type
);
$form_state
[
'redirect_route'
]
=
array
(
'route_name'
=>
'field_ui.delete_'
.
$this
->
instance
->
entity_type
,
'route_parameters'
=>
array
(
'bundle'
=>
$this
->
instance
->
bundle
,
$entity_info
[
'bundle_entity_type'
]
=>
$this
->
instance
->
bundle
,
'field_instance'
=>
$this
->
instance
->
id
(),
),
'options'
=>
array
(
...
...
core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php
View file @
fbe93225
...
...
@@ -35,6 +35,17 @@ public function getFormId() {
return
'field_ui_form_display_overview_form'
;
}
/**
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
array
&
$form_state
,
$entity_type
=
NULL
,
$bundle
=
NULL
)
{
if
(
$this
->
getRequest
()
->
attributes
->
has
(
'form_mode_name'
))
{
$this
->
mode
=
$this
->
getRequest
()
->
attributes
->
get
(
'form_mode_name'
);
}
return
parent
::
buildForm
(
$form
,
$form_state
,
$entity_type
,
$bundle
);
}
/**
* {@inheritdoc}
*/
...
...
core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php
View file @
fbe93225
...
...
@@ -74,10 +74,16 @@ public static function create(ContainerInterface $container) {
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
array
&
$form_state
,
$entity_type
=
NULL
,
$bundle
=
NULL
)
{
$entity_info
=
$this
->
entityManager
->
getDefinition
(
$entity_type
);
if
(
!
isset
(
$form_state
[
'bundle'
]))
{