Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
229
Merge Requests
229
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
fe61b43d
Commit
fe61b43d
authored
Feb 08, 2014
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2183923
by tim.plunkett: Break the circular dependency in EntityManager.
parent
1939de98
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
267 additions
and
210 deletions
+267
-210
core/core.services.yml
core/core.services.yml
+3
-0
core/includes/entity.inc
core/includes/entity.inc
+0
-25
core/lib/Drupal/Core/Controller/ControllerBase.php
core/lib/Drupal/Core/Controller/ControllerBase.php
+20
-0
core/lib/Drupal/Core/Entity/EntityFormBuilder.php
core/lib/Drupal/Core/Entity/EntityFormBuilder.php
+58
-0
core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php
core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php
+38
-0
core/lib/Drupal/Core/Entity/EntityManager.php
core/lib/Drupal/Core/Entity/EntityManager.php
+0
-16
core/lib/Drupal/Core/Entity/EntityManagerInterface.php
core/lib/Drupal/Core/Entity/EntityManagerInterface.php
+0
-24
core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php
...lib/Drupal/aggregator/Controller/AggregatorController.php
+2
-3
core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php
.../Drupal/custom_block/Controller/CustomBlockController.php
+2
-13
core/modules/block/lib/Drupal/block/Controller/BlockAddController.php
.../block/lib/Drupal/block/Controller/BlockAddController.php
+1
-1
core/modules/comment/comment.module
core/modules/comment/comment.module
+1
-1
core/modules/comment/lib/Drupal/comment/Controller/CommentController.php
...mment/lib/Drupal/comment/Controller/CommentController.php
+1
-1
core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestController.php
...nfig_test/lib/Drupal/config_test/ConfigTestController.php
+1
-1
core/modules/contact/lib/Drupal/contact/Controller/ContactController.php
...ntact/lib/Drupal/contact/Controller/ContactController.php
+2
-2
core/modules/content_translation/content_translation.pages.inc
...modules/content_translation/content_translation.pages.inc
+2
-2
core/modules/forum/lib/Drupal/forum/Controller/ForumController.php
...les/forum/lib/Drupal/forum/Controller/ForumController.php
+2
-2
core/modules/menu/lib/Drupal/menu/Controller/MenuController.php
...odules/menu/lib/Drupal/menu/Controller/MenuController.php
+1
-1
core/modules/node/lib/Drupal/node/Controller/NodeController.php
...odules/node/lib/Drupal/node/Controller/NodeController.php
+1
-1
core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
...les/options/lib/Drupal/options/Tests/OptionsFieldTest.php
+4
-4
core/modules/search/lib/Drupal/search/Controller/SearchController.php
.../search/lib/Drupal/search/Controller/SearchController.php
+1
-1
core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutController.php
...cut/lib/Drupal/shortcut/Controller/ShortcutController.php
+1
-1
core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php
.../Drupal/system/Tests/Entity/EntityTranslationFormTest.php
+1
-1
core/modules/system/tests/modules/entity_test/entity_test.module
...dules/system/tests/modules/entity_test/entity_test.module
+2
-2
core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Controller/FormTestController.php
...st/lib/Drupal/form_test/Controller/FormTestController.php
+2
-2
core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TaxonomyController.php
...omy/lib/Drupal/taxonomy/Controller/TaxonomyController.php
+1
-1
core/modules/views_ui/lib/Drupal/views_ui/Controller/ViewsUIController.php
...s_ui/lib/Drupal/views_ui/Controller/ViewsUIController.php
+6
-18
core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php
core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php
+1
-10
core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php
.../tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php
+84
-0
core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php
core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php
+2
-57
core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php
core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php
+1
-10
core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php
...sts/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php
+1
-10
core/tests/Drupal/Tests/UnitTestCase.php
core/tests/Drupal/Tests/UnitTestCase.php
+25
-0
No files found.
core/core.services.yml
View file @
fe61b43d
...
...
@@ -188,6 +188,9 @@ services:
entity.manager
:
class
:
Drupal\Core\Entity\EntityManager
arguments
:
[
'
@container.namespaces'
,
'
@service_container'
,
'
@module_handler'
,
'
@cache.cache'
,
'
@language_manager'
,
'
@string_translation'
]
entity.form_builder
:
class
:
Drupal\Core\Entity\EntityFormBuilder
arguments
:
[
'
@entity.manager'
,
'
@form_builder'
]
plugin.manager.field.field_type
:
class
:
Drupal\Core\Field\FieldTypePluginManager
arguments
:
[
'
@container.namespaces'
,
'
@cache.field'
,
'
@language_manager'
,
'
@module_handler'
]
...
...
core/includes/entity.inc
View file @
fe61b43d
...
...
@@ -442,31 +442,6 @@ function entity_access_controller($entity_type) {
->
getAccessController
(
$entity_type
);
}
/**
* Returns the built and processed entity form for the given entity.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to be created or edited.
* @param string $operation
* (optional) The operation identifying the form variation to be returned.
* @param array $form_state
* (optional) An associative array containing the current state of the form.
* Use this to pass additional information to the form, such as the langcode.
* @code
* $form_state['langcode'] = $langcode;
* $form = entity_get_form($entity, 'default', $form_state);
* @endcode
*
* @return array
* The processed form for the given entity and operation.
*
* @deprecated Use \Drupal::entityManager()->getForm() or _entity_form from a
* routing.yml file instead of a page callback.
*/
function
entity_get_form
(
EntityInterface
$entity
,
$operation
=
'default'
,
array
$form_state
=
array
())
{
return
\
Drupal
::
entityManager
()
->
getForm
(
$entity
,
$operation
,
$form_state
);
}
/**
* Returns an entity list controller for a given entity type.
*
...
...
core/lib/Drupal/Core/Controller/ControllerBase.php
View file @
fe61b43d
...
...
@@ -39,6 +39,13 @@ abstract class ControllerBase implements ContainerInjectionInterface {
*/
protected
$entityManager
;
/**
* The entity form builder.
*
* @var \Drupal\Core\Entity\EntityFormBuilderInterface
*/
protected
$entityFormBuilder
;
/**
* The language manager.
*
...
...
@@ -122,6 +129,19 @@ protected function entityManager() {
return
$this
->
entityManager
;
}
/**
* Retrieves the entity form builder.
*
* @return \Drupal\Core\Entity\EntityFormBuilderInterface
* The entity form builder.
*/
protected
function
entityFormBuilder
()
{
if
(
!
$this
->
entityFormBuilder
)
{
$this
->
entityFormBuilder
=
$this
->
container
()
->
get
(
'entity.form_builder'
);
}
return
$this
->
entityFormBuilder
;
}
/**
* Returns the requested cache bin.
*
...
...
core/lib/Drupal/Core/Entity/EntityFormBuilder.php
0 → 100644
View file @
fe61b43d
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityFormBuilder.
*/
namespace
Drupal\Core\Entity
;
use
Drupal\Core\Form\FormBuilderInterface
;
/**
* Builds entity forms.
*/
class
EntityFormBuilder
implements
EntityFormBuilderInterface
{
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected
$entityManager
;
/**
* The form builder.
*
* @var \Drupal\Core\Form\FormBuilderInterface
*/
protected
$formBuilder
;
/**
* Constructs a new EntityFormBuilder.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
* The form builder.
*/
public
function
__construct
(
EntityManagerInterface
$entity_manager
,
FormBuilderInterface
$form_builder
)
{
$this
->
entityManager
=
$entity_manager
;
$this
->
formBuilder
=
$form_builder
;
}
/**
* {@inheritdoc}
*/
public
function
getForm
(
EntityInterface
$entity
,
$operation
=
'default'
,
array
$form_state
=
array
())
{
$controller
=
$this
->
entityManager
->
getFormController
(
$entity
->
getEntityTypeId
(),
$operation
);
$controller
->
setEntity
(
$entity
);
$form_state
[
'build_info'
][
'callback_object'
]
=
$controller
;
$form_state
[
'build_info'
][
'base_form_id'
]
=
$controller
->
getBaseFormID
();
$form_state
[
'build_info'
]
+=
array
(
'args'
=>
array
());
return
$this
->
formBuilder
->
buildForm
(
$controller
->
getFormId
(),
$form_state
);
}
}
core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php
0 → 100644
View file @
fe61b43d
<?php
/**
* @file
* Contains \Drupal\Core\Entity\EntityFormBuilderInterface.
*/
namespace
Drupal\Core\Entity
;
/**
* Builds entity forms.
*/
interface
EntityFormBuilderInterface
{
/**
* Returns the built and processed entity form for the given entity.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to be created or edited.
* @param string $operation
* (optional) The operation identifying the form variation to be returned.
* Defaults to 'default'.
* @param array $form_state
* (optional) An associative array containing the current state of the form.
* Use this to pass additional information to the form, such as the
* langcode. Defaults to an empty array.
*
* @code
* $form_state['langcode'] = $langcode;
* $form = \Drupal::service('entity.form_builder')->getForm($entity, 'default', $form_state);
* @endcode
*
* @return array
* The processed form for the given entity and operation.
*/
public
function
getForm
(
EntityInterface
$entity
,
$operation
=
'default'
,
array
$form_state
=
array
());
}
core/lib/Drupal/Core/Entity/EntityManager.php
View file @
fe61b43d
...
...
@@ -279,22 +279,6 @@ public function getController($entity_type, $controller_type, $controller_class_
return
$this
->
controllers
[
$controller_type
][
$entity_type
];
}
/**
* {@inheritdoc}
*/
public
function
getForm
(
EntityInterface
$entity
,
$operation
=
'default'
,
array
$form_state
=
array
())
{
$form_state
[
'build_info'
]
=
isset
(
$form_state
[
'build_info'
])
?
$form_state
[
'build_info'
]
:
array
();
$controller
=
$this
->
getFormController
(
$entity
->
getEntityTypeId
(),
$operation
);
$controller
->
setEntity
(
$entity
);
$form_state
[
'build_info'
]
+=
array
(
'callback_object'
=>
$controller
,
'base_form_id'
=>
$controller
->
getBaseFormID
(),
'args'
=>
array
(),
);
$form_id
=
$controller
->
getFormID
();
return
\
Drupal
::
formBuilder
()
->
buildForm
(
$form_id
,
$form_state
);
}
/**
* {@inheritdoc}
*/
...
...
core/lib/Drupal/Core/Entity/EntityManagerInterface.php
View file @
fe61b43d
...
...
@@ -185,30 +185,6 @@ public function hasController($entity_type, $controller_type);
*/
public
function
getController
(
$entity_type
,
$controller_type
);
/**
* Returns the built and processed entity form for the given entity.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to be created or edited.
* @param string $operation
* (optional) The operation identifying the form variation to be returned.
* Defaults to 'default'.
* @param array $form_state
* (optional) An associative array containing the current state of the form.
* Use this to pass additional information to the form, such as the
* langcode. Defaults to an empty array.
*
* @code
* $form_state['langcode'] = $langcode;
* $manager = \Drupal::entityManager();
* $form = $manager->getForm($entity, 'default', $form_state);
* @endcode
*
* @return array
* The processed form for the given entity and operation.
*/
public
function
getForm
(
EntityInterface
$entity
,
$operation
=
'default'
,
array
$form_state
=
array
());
/**
* Get the bundle info of an entity type.
*
...
...
core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php
View file @
fe61b43d
...
...
@@ -55,12 +55,11 @@ public static function create(ContainerInterface $container) {
* A form array as expected by drupal_render().
*/
public
function
feedAdd
()
{
$entity_manager
=
$this
->
entityManager
();
$feed
=
$entity_manager
->
getStorageController
(
'aggregator_feed'
)
$feed
=
$this
->
entityManager
()
->
getStorageController
(
'aggregator_feed'
)
->
create
(
array
(
'refresh'
=>
3600
,
));
return
$
entity_manager
->
getForm
(
$feed
);
return
$
this
->
entityFormBuilder
()
->
getForm
(
$feed
);
}
/**
...
...
core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php
View file @
fe61b43d
...
...
@@ -16,13 +16,6 @@
class
CustomBlockController
extends
ControllerBase
{
/**
* The entity manager.
*
* @var \Drupal\Component\Plugin\PluginManagerInterface
*/
protected
$entityManager
;
/**
* The custom block storage controller.
*
...
...
@@ -43,7 +36,6 @@ class CustomBlockController extends ControllerBase {
public
static
function
create
(
ContainerInterface
$container
)
{
$entity_manager
=
$container
->
get
(
'entity.manager'
);
return
new
static
(
$entity_manager
,
$entity_manager
->
getStorageController
(
'custom_block'
),
$entity_manager
->
getStorageController
(
'custom_block_type'
)
);
...
...
@@ -52,17 +44,14 @@ public static function create(ContainerInterface $container) {
/**
* Constructs a CustomBlock object.
*
* @param \Drupal\Component\Plugin\PluginManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Entity\EntityStorageControllerInterface $custom_block_storage
* The custom block storage controller.
* @param \Drupal\Core\Entity\EntityStorageControllerInterface $custom_block_type_storage
* The custom block type storage controller.
*/
public
function
__construct
(
PluginManagerInterface
$entity_manager
,
EntityStorageControllerInterface
$custom_block_storage
,
EntityStorageControllerInterface
$custom_block_type_storage
)
{
public
function
__construct
(
EntityStorageControllerInterface
$custom_block_storage
,
EntityStorageControllerInterface
$custom_block_type_storage
)
{
$this
->
customBlockStorage
=
$custom_block_storage
;
$this
->
customBlockTypeStorage
=
$custom_block_type_storage
;
$this
->
entityManager
=
$entity_manager
;
}
/**
...
...
@@ -107,7 +96,7 @@ public function addForm(CustomBlockTypeInterface $custom_block_type, Request $re
// newly created block in the given theme.
$block
->
setTheme
(
$theme
);
}
return
$this
->
entity
Manager
->
getForm
(
$block
);
return
$this
->
entity
FormBuilder
()
->
getForm
(
$block
);
}
/**
...
...
core/modules/block/lib/Drupal/block/Controller/BlockAddController.php
View file @
fe61b43d
...
...
@@ -30,7 +30,7 @@ public function blockAddConfigureForm($plugin_id, $theme) {
// Create a block entity.
$entity
=
$this
->
entityManager
()
->
getStorageController
(
'block'
)
->
create
(
array
(
'plugin'
=>
$plugin_id
,
'theme'
=>
$theme
));
return
$this
->
entity
Manag
er
()
->
getForm
(
$entity
);
return
$this
->
entity
FormBuild
er
()
->
getForm
(
$entity
);
}
}
core/modules/comment/comment.module
View file @
fe61b43d
...
...
@@ -603,7 +603,7 @@ function comment_add(EntityInterface $entity, $field_name = 'comment', $pid = NU
'pid'
=>
$pid
,
);
$comment
=
entity_create
(
'comment'
,
$values
);
return
\
Drupal
::
entityManager
(
)
->
getForm
(
$comment
);
return
\
Drupal
::
service
(
'entity.form_builder'
)
->
getForm
(
$comment
);
}
/**
...
...
core/modules/comment/lib/Drupal/comment/Controller/CommentController.php
View file @
fe61b43d
...
...
@@ -270,7 +270,7 @@ public function getReplyForm(Request $request, $entity_type, $entity_id, $field_
'entity_type'
=>
$entity
->
getEntityTypeId
(),
'field_id'
=>
$entity
->
getEntityTypeId
()
.
'__'
.
$field_name
,
));
$build
[
'comment_form'
]
=
$this
->
entity
Manag
er
()
->
getForm
(
$comment
);
$build
[
'comment_form'
]
=
$this
->
entity
FormBuild
er
()
->
getForm
(
$comment
);
return
$build
;
}
...
...
core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestController.php
View file @
fe61b43d
...
...
@@ -28,7 +28,7 @@ class ConfigTestController extends ControllerBase {
* A form array as expected by drupal_render().
*/
public
function
edit
(
ConfigTest
$config_test
)
{
$form
=
$this
->
entity
Manag
er
()
->
getForm
(
$config_test
);
$form
=
$this
->
entity
FormBuild
er
()
->
getForm
(
$config_test
);
$form
[
'#title'
]
=
String
::
format
(
'Edit %label'
,
array
(
'%label'
=>
$config_test
->
label
()));
return
$form
;
}
...
...
core/modules/contact/lib/Drupal/contact/Controller/ContactController.php
View file @
fe61b43d
...
...
@@ -90,7 +90,7 @@ public function contactSitePage(CategoryInterface $contact_category = NULL) {
'category'
=>
$contact_category
->
id
(),
));
$form
=
$this
->
entity
Manag
er
()
->
getForm
(
$message
);
$form
=
$this
->
entity
FormBuild
er
()
->
getForm
(
$message
);
$form
[
'#title'
]
=
String
::
checkPlain
(
$contact_category
->
label
());
return
$form
;
}
...
...
@@ -115,7 +115,7 @@ public function contactPersonalPage(UserInterface $user) {
'recipient'
=>
$user
->
id
(),
));
$form
=
$this
->
entity
Manag
er
()
->
getForm
(
$message
);
$form
=
$this
->
entity
FormBuild
er
()
->
getForm
(
$message
);
$form
[
'#title'
]
=
$this
->
t
(
'Contact @username'
,
array
(
'@username'
=>
$user
->
getUsername
()));
return
$form
;
}
...
...
core/modules/content_translation/content_translation.pages.inc
View file @
fe61b43d
...
...
@@ -189,7 +189,7 @@ function content_translation_add_page(EntityInterface $entity, Language $source
$form_state
[
'content_translation'
][
'source'
]
=
$source
;
$form_state
[
'content_translation'
][
'target'
]
=
$target
;
$form_state
[
'content_translation'
][
'translation_form'
]
=
!
$entity
->
access
(
'update'
);
return
\
Drupal
::
entityManager
(
)
->
getForm
(
$entity
,
'default'
,
$form_state
);
return
\
Drupal
::
service
(
'entity.form_builder'
)
->
getForm
(
$entity
,
'default'
,
$form_state
);
}
/**
...
...
@@ -210,7 +210,7 @@ function content_translation_edit_page(EntityInterface $entity, Language $langua
$language
=
!
empty
(
$language
)
?
$language
:
language
(
Language
::
TYPE_CONTENT
);
$form_state
[
'langcode'
]
=
$language
->
id
;
$form_state
[
'content_translation'
][
'translation_form'
]
=
TRUE
;
return
\
Drupal
::
entityManager
(
)
->
getForm
(
$entity
,
'default'
,
$form_state
);
return
\
Drupal
::
service
(
'entity.form_builder'
)
->
getForm
(
$entity
,
'default'
,
$form_state
);
}
/**
...
...
core/modules/forum/lib/Drupal/forum/Controller/ForumController.php
View file @
fe61b43d
...
...
@@ -157,7 +157,7 @@ public function addForum() {
'vid'
=>
$vid
,
'forum_controller'
=>
0
,
));
return
$this
->
entity
Manag
er
()
->
getForm
(
$taxonomy_term
,
'forum'
);
return
$this
->
entity
FormBuild
er
()
->
getForm
(
$taxonomy_term
,
'forum'
);
}
/**
...
...
@@ -172,7 +172,7 @@ public function addContainer() {
'vid'
=>
$vid
,
'forum_container'
=>
1
,
));
return
$this
->
entity
Manag
er
()
->
getForm
(
$taxonomy_term
,
'container'
);
return
$this
->
entity
FormBuild
er
()
->
getForm
(
$taxonomy_term
,
'container'
);
}
}
core/modules/menu/lib/Drupal/menu/Controller/MenuController.php
View file @
fe61b43d
...
...
@@ -54,7 +54,7 @@ public function addLink(MenuInterface $menu) {
'plid'
=>
0
,
'menu_name'
=>
$menu
->
id
(),
));
return
$this
->
entity
Manag
er
()
->
getForm
(
$menu_link
);
return
$this
->
entity
FormBuild
er
()
->
getForm
(
$menu_link
);
}
/**
...
...
core/modules/node/lib/Drupal/node/Controller/NodeController.php
View file @
fe61b43d
...
...
@@ -72,7 +72,7 @@ public function add(NodeTypeInterface $node_type) {
'langcode'
=>
$langcode
?
$langcode
:
$this
->
languageManager
()
->
getCurrentLanguage
()
->
id
,
));
$form
=
$this
->
entity
Manag
er
()
->
getForm
(
$node
);
$form
=
$this
->
entity
FormBuild
er
()
->
getForm
(
$node
);
return
$form
;
}
...
...
core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
View file @
fe61b43d
...
...
@@ -35,7 +35,7 @@ public static function getInfo() {
function
testUpdateAllowedValues
()
{
// All three options appear.
$entity
=
entity_create
(
'entity_test'
);
$form
=
\
Drupal
::
entityManager
(
)
->
getForm
(
$entity
);
$form
=
\
Drupal
::
service
(
'entity.form_builder'
)
->
getForm
(
$entity
);
$this
->
assertTrue
(
!
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
1
]),
'Option 1 exists'
);
$this
->
assertTrue
(
!
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
2
]),
'Option 2 exists'
);
$this
->
assertTrue
(
!
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
3
]),
'Option 3 exists'
);
...
...
@@ -61,7 +61,7 @@ function testUpdateAllowedValues() {
$this
->
field
->
settings
[
'allowed_values'
]
=
array
(
2
=>
'Two'
);
$this
->
field
->
save
();
$entity
=
entity_create
(
'entity_test'
);
$form
=
\
Drupal
::
entityManager
(
)
->
getForm
(
$entity
);
$form
=
\
Drupal
::
service
(
'entity.form_builder'
)
->
getForm
(
$entity
);
$this
->
assertTrue
(
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
1
]),
'Option 1 does not exist'
);
$this
->
assertTrue
(
!
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
2
]),
'Option 2 exists'
);
$this
->
assertTrue
(
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
3
]),
'Option 3 does not exist'
);
...
...
@@ -72,7 +72,7 @@ function testUpdateAllowedValues() {
// The entity holds an outdated field object with the old allowed values
// setting, so we need to reintialize the entity object.
$entity
=
entity_create
(
'entity_test'
);
$form
=
\
Drupal
::
entityManager
(
)
->
getForm
(
$entity
);
$form
=
\
Drupal
::
service
(
'entity.form_builder'
)
->
getForm
(
$entity
);
$this
->
assertTrue
(
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
1
]),
'Option 1 does not exist'
);
$this
->
assertTrue
(
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
2
]),
'Option 2 does not exist'
);
$this
->
assertTrue
(
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
3
]),
'Option 3 does not exist'
);
...
...
@@ -93,7 +93,7 @@ function testUpdateAllowedValues() {
))
->
save
();
$entity
=
entity_create
(
'entity_test'
);
$form
=
\
Drupal
::
entityManager
(
)
->
getForm
(
$entity
);
$form
=
\
Drupal
::
service
(
'entity.form_builder'
)
->
getForm
(
$entity
);
$this
->
assertTrue
(
!
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
1
]),
'Option 1 exists'
);
$this
->
assertTrue
(
!
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
2
]),
'Option 2 exists'
);
$this
->
assertTrue
(
!
empty
(
$form
[
$this
->
fieldName
][
'widget'
][
3
]),
'Option 3 exists'
);
...
...
core/modules/search/lib/Drupal/search/Controller/SearchController.php
View file @
fe61b43d
...
...
@@ -87,7 +87,7 @@ public function view(Request $request, SearchPageInterface $entity, $keys = '')
}
}
// The form may be altered based on whether the search was run.
$build
[
'search_form'
]
=
$this
->
entity
Manag
er
()
->
getForm
(
$entity
,
'search'
);
$build
[
'search_form'
]
=
$this
->
entity
FormBuild
er
()
->
getForm
(
$entity
,
'search'
);
$build
[
'search_results'
]
=
$results
;
return
$build
;
}
...
...
core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutController.php
View file @
fe61b43d
...
...
@@ -31,7 +31,7 @@ public function addForm(ShortcutSetInterface $shortcut_set) {
if
(
$this
->
moduleHandler
()
->
moduleExists
(
'language'
))
{
$shortcut
->
langcode
=
language_get_default_langcode
(
'shortcut'
,
$shortcut_set
->
id
());
}
return
$this
->
entity
Manag
er
()
->
getForm
(
$shortcut
,
'add'
);
return
$this
->
entity
FormBuild
er
()
->
getForm
(
$shortcut
,
'add'
);
}
}
core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php
View file @
fe61b43d
...
...
@@ -78,7 +78,7 @@ function testEntityFormLanguage() {
// Explicitly set form langcode.
$langcode
=
$this
->
langcodes
[
0
];
$form_state
[
'langcode'
]
=
$langcode
;
\
Drupal
::
entityManager
(
)
->
getForm
(
$node
,
'default'
,
$form_state
);
\
Drupal
::
service
(
'entity.form_builder'
)
->
getForm
(
$node
,
'default'
,
$form_state
);
$form_langcode
=
\
Drupal
::
state
()
->
get
(
'entity_test.form_langcode'
)
?:
FALSE
;
$this
->
assertTrue
(
$langcode
==
$form_langcode
,
'Form language is the same as the language parameter.'
);
...
...
core/modules/system/tests/modules/entity_test/entity_test.module
View file @
fe61b43d
...
...
@@ -287,7 +287,7 @@ function entity_test_form_node_form_alter(&$form, &$form_state, $form_id) {
function
entity_test_add
(
$entity_type
)
{
drupal_set_title
(
t
(
'Create an @type'
,
array
(
'@type'
=>
$entity_type
)));
$entity
=
entity_create
(
$entity_type
);
return
\
Drupal
::
entityManager
(
)
->
getForm
(
$entity
);
return
\
Drupal
::
service
(
'entity.form_builder'
)
->
getForm
(
$entity
);
}
/**
...
...
@@ -305,7 +305,7 @@ function entity_test_add($entity_type) {
*/
function
entity_test_edit
(
EntityInterface
$entity
)
{
drupal_set_title
(
$entity
->
label
(),
PASS_THROUGH
);
return
\
Drupal
::
entityManager
(
)
->
getForm
(
$entity
);
return
\
Drupal
::
service
(
'entity.form_builder'
)
->
getForm
(
$entity
);
}
/**
...
...
core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Controller/FormTestController.php
View file @
fe61b43d
...
...
@@ -30,8 +30,8 @@ public function twoFormInstances() {
);
$node1
=
$this
->
entityManager
()
->
getStorageController
(
'node'
)
->
create
(
$values
);
$node2
=
clone
(
$node1
);
$return
[
'node_form_1'
]
=
$this
->
entity
Manag
er
()
->
getForm
(
$node1
);
$return
[
'node_form_2'
]
=
$this
->
entity
Manag
er
()
->
getForm
(
$node2
);
$return
[
'node_form_1'
]
=
$this
->
entity
FormBuild
er
()
->
getForm
(
$node1
);
$return
[
'node_form_2'
]
=
$this
->
entity
FormBuild
er
()
->
getForm
(
$node2
);
return
$return
;
}
...
...
core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TaxonomyController.php
View file @
fe61b43d
...
...
@@ -32,7 +32,7 @@ public function addForm(VocabularyInterface $taxonomy_vocabulary) {
if
(
$this
->
moduleHandler
()
->
moduleExists
(
'language'
))
{
$term
->
langcode
=
language_get_default_langcode
(
'taxonomy_term'
,
$taxonomy_vocabulary
->
id
());
}
return
$this
->
entity
Manag
er
()
->
getForm
(
$term
);
return
$this
->
entity
FormBuild
er
()
->
getForm
(
$term
);
}
/**
...
...
core/modules/views_ui/lib/Drupal/views_ui/Controller/ViewsUIController.php
View file @
fe61b43d
...
...
@@ -8,7 +8,6 @@
namespace
Drupal\views_ui\Controller
;
use
Drupal\Core\Controller\ControllerBase
;
use
Drupal\Core\Entity\EntityManagerInterface
;
use
Drupal\views\ViewExecutable
;
use
Drupal\views\ViewStorageInterface
;
use
Drupal\views_ui
\
ViewUI
;
...
...
@@ -24,13 +23,6 @@
*/
class
ViewsUIController
extends
ControllerBase
{
/**
* Stores the Entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected
$entityManager
;
/**
* Stores the Views data cache object.
*
...
...
@@ -41,13 +33,10 @@ class ViewsUIController extends ControllerBase {
/**
* Constructs a new \Drupal\views_ui\Controller\ViewsUIController object.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The Entity manager.
* @param \Drupal\views\ViewsData views_data
* The Views data cache object.
*/
public
function
__construct
(
EntityManagerInterface
$entity_manager
,
ViewsData
$views_data
)
{
$this
->
entityManager
=
$entity_manager
;
public
function
__construct
(
ViewsData
$views_data
)
{
$this
->
viewsData
=
$views_data
;
}
...
...
@@ -56,7 +45,6 @@ public function __construct(EntityManagerInterface $entity_manager, ViewsData $v
*/
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
$container
->
get
(
'entity.manager'
),
$container
->
get
(
'views.views_data'
)
);
}
...
...
@@ -68,7 +56,7 @@ public static function create(ContainerInterface $container) {
* The Views fields report page.
*/
public
function
reportFields
()
{
$views
=
$this
->
entityManager
->
getStorageController
(
'view'
)
->
loadMultiple
();
$views
=
$this
->
entityManager
()
->
getStorageController
(
'view'
)
->
loadMultiple
();
// Fetch all fieldapi fields which are used in views
// Therefore search in all views, displays and handler-types.
...
...
@@ -164,7 +152,7 @@ public function ajaxOperation(ViewStorageInterface $view, $op, Request $request)
// If the request is via AJAX, return the rendered list as JSON.
if
(
$request
->
request
->
get
(
'js'
))
{
$list
=
$this
->
entityManager
->
getListController
(
'view'
)
->
render
();
$list
=
$this
->
entityManager
()
->
getListController
(
'view'
)
->
render
();
$response
=
new
AjaxResponse
();
$response
->
addCommand
(
new
ReplaceCommand
(
'#views-entity-list'
,
drupal_render
(
$list
)));
return
$response
;
...
...
@@ -187,7 +175,7 @@ public function autocompleteTag(Request $request) {
$matches
=
array
();
$string
=
$request
->
query
->
get
(
'q'
);
// Get matches from default views.
$views
=
$this
->
entityManager
->
getStorageController
(
'view'
)
->
loadMultiple
();
$views
=
$this
->
entityManager
()
->
getStorageController
(
'view'
)
->
loadMultiple
();
foreach
(
$views
as
$view
)
{
$tag
=
$view
->
get
(
'tag'
);
if
(
$tag
&&
strpos
(
$tag
,
$string
)
===
0
)
{
...
...
@@ -222,8 +210,8 @@ public function edit(ViewUI $view, $display_id = NULL) {
}
$build
[
'#title'
]
=
$name
;
$build
[
'edit'
]
=
$this
->
entity
Manager
->
getForm
(
$view
,
'edit'
,
array
(
'display_id'
=>
$display_id
));
$build
[
'preview'
]
=
$this
->
entity
Manager
->
getForm
(
$view
,
'preview'
,
array
(
'display_id'
=>
$display_id
));
$build
[
'edit'
]
=
$this
->
entity
FormBuilder
()
->
getForm
(
$view
,
'edit'
,
array
(
'display_id'
=>
$display_id
));
$build
[
'preview'
]
=
$this
->
entity
FormBuilder
()
->
getForm
(
$view
,
'preview'
,
array
(
'display_id'
=>
$display_id
));
return
$build
;
}
...
...
core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php
View file @
fe61b43d
...
...
@@ -64,16 +64,7 @@ protected function setUp() {
$this
->
cid
=
$this
->
randomName
();
$this
->
collector
=
new
CacheCollectorHelper
(
$this
->
cid
,
$this
->
cache
,
$this
->
lock
);