summaryrefslogtreecommitdiffstats
path: root/core/modules/breakpoint
diff options
context:
space:
mode:
authorNathaniel Catchpole2014-05-20 10:29:40 +0100
committerNathaniel Catchpole2014-05-20 10:29:40 +0100
commitc972b3ee9d6ef7d1554480ea95d0bcc623d01c77 (patch)
treecd99a0eb05894994a5612d59067cce0b3d7f361c /core/modules/breakpoint
parent21fbb5ddaffc925ed58f8086d0bf90e44845d4b3 (diff)
Issue #2190313 by pfrenssen, Berdir, amateescu, ianthomas_uk: Add $EntityType::load() and loadMultiple() to simplify loading entities.
Diffstat (limited to 'core/modules/breakpoint')
-rw-r--r--core/modules/breakpoint/breakpoint.module20
-rw-r--r--core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php4
-rw-r--r--core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php8
-rw-r--r--core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointTestBase.php6
4 files changed, 11 insertions, 27 deletions
diff --git a/core/modules/breakpoint/breakpoint.module b/core/modules/breakpoint/breakpoint.module
index 8d6283b..5d358b3 100644
--- a/core/modules/breakpoint/breakpoint.module
+++ b/core/modules/breakpoint/breakpoint.module
@@ -40,22 +40,6 @@ function breakpoint_help($route_name, Request $request) {
}
/**
- * Load one breakpoint by its identifier.
- *
- * @param int $id
- * The id of the breakpoint to load.
- *
- * @return \Drupal\breakpoint\Entity\Breakpoint|null
- * The entity object, or NULL if there is no entity with the given id.
- *
- * @todo Remove this in a follow-up issue.
- * @see http://drupal.org/node/1798214
- */
-function breakpoint_load($id) {
- return entity_load('breakpoint', $id);
-}
-
-/**
* Load all breakpoint groups as select options.
*
* @return array
@@ -63,7 +47,7 @@ function breakpoint_load($id) {
*/
function breakpoint_group_select_options() {
$options = array();
- $breakpoint_groups = entity_load_multiple('breakpoint_group');
+ $breakpoint_groups = BreakpointGroup::loadMultiple();
foreach ($breakpoint_groups as $breakpoint_group) {
$options[$breakpoint_group->id()] = $breakpoint_group->label();
}
@@ -79,7 +63,7 @@ function breakpoint_group_select_options() {
*/
function breakpoint_select_options() {
$options = array();
- $breakpoints = entity_load_multiple('breakpoint');
+ $breakpoints = Breakpoint::loadMultiple();
foreach ($breakpoints as $breakpoint) {
$options[$breakpoint->id()] = $breakpoint->label() . ' (' . $breakpoint->source . ' - ' . $breakpoint->sourceType . ') [' . $breakpoint->mediaQuery . ']';
}
diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php
index c2426b7..02d6e29 100644
--- a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php
+++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php
@@ -157,7 +157,7 @@ class BreakpointGroup extends ConfigEntityBase implements BreakpointGroupInterfa
*/
public function addBreakpointFromMediaQuery($name, $media_query) {
// Use the existing breakpoint if it exists.
- $breakpoint = entity_load('breakpoint', $this->sourceType . '.' . $this->name . '.' . $name);
+ $breakpoint = Breakpoint::load($this->sourceType . '.' . $this->name . '.' . $name);
if (!$breakpoint) {
// Build a new breakpoint.
$breakpoint = entity_create('breakpoint', array(
@@ -191,7 +191,7 @@ class BreakpointGroup extends ConfigEntityBase implements BreakpointGroupInterfa
public function getBreakpoints() {
if (empty($this->breakpoints)) {
foreach ($this->breakpoint_ids as $breakpoint_id) {
- $breakpoint = breakpoint_load($breakpoint_id);
+ $breakpoint = Breakpoint::load($breakpoint_id);
if ($breakpoint) {
$this->breakpoints[$breakpoint_id] = $breakpoint;
}
diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php
index 646100a..a9fcadf 100644
--- a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php
+++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php
@@ -37,10 +37,10 @@ class BreakpointCRUDTest extends BreakpointTestBase {
$this->verifyBreakpoint($breakpoint);
- // Test breakpoint_load_all
- $all_breakpoints = entity_load_multiple('breakpoint');
+ // Test BreakPoint::loadMultiple().
+ $all_breakpoints = Breakpoint::loadMultiple();
$config_name = $breakpoint->id();
- $this->assertTrue(isset($all_breakpoints[$config_name]), 'breakpoint_load_all: New breakpoint is present when loading all breakpoints.');
+ $this->assertTrue(isset($all_breakpoints[$config_name]), 'New breakpoint is present when loading all breakpoints.');
$this->verifyBreakpoint($breakpoint, $all_breakpoints[$config_name]);
// Update the breakpoint.
@@ -51,6 +51,6 @@ class BreakpointCRUDTest extends BreakpointTestBase {
// Delete the breakpoint.
$breakpoint->delete();
- $this->assertFalse(breakpoint_load($config_name), 'breakpoint_load: Loading a deleted breakpoint returns false.', 'Breakpoints API');
+ $this->assertNull(Breakpoint::load($config_name), 'Loading a deleted breakpoint returns null.', 'Breakpoints API');
}
}
diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointTestBase.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointTestBase.php
index 89d0cc1..aac96c9 100644
--- a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointTestBase.php
+++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointTestBase.php
@@ -38,14 +38,14 @@ abstract class BreakpointTestBase extends WebTestBase {
'multipliers',
);
- // Verify breakpoint_load().
- $compare_breakpoint = is_null($compare_breakpoint) ? breakpoint_load($breakpoint->id()) : $compare_breakpoint;
+ // Verify Breakpoint::load().
+ $compare_breakpoint = is_null($compare_breakpoint) ? Breakpoint::load($breakpoint->id()) : $compare_breakpoint;
foreach ($properties as $property) {
$t_args = array(
'%breakpoint' => $breakpoint->label(),
'%property' => $property,
);
- $this->assertEqual($compare_breakpoint->{$property}, $breakpoint->{$property}, format_string('breakpoint_load: Proper %property for breakpoint %breakpoint.', $t_args), 'Breakpoint API');
+ $this->assertEqual($compare_breakpoint->{$property}, $breakpoint->{$property}, format_string('Proper %property for breakpoint %breakpoint.', $t_args), 'Breakpoint API');
}
}
}