summaryrefslogtreecommitdiffstats
path: root/core/modules/breakpoint
diff options
context:
space:
mode:
authorxjm2017-03-03 19:20:24 -0600
committerxjm2017-03-03 19:20:24 -0600
commit52e3eec616efab4d5201e30d085a09ba5c4817e6 (patch)
treed295cc8b862edc04018ba0e04ded752fd1a2f5c6 /core/modules/breakpoint
parent3aba956a39a4852f42cad8483e4e6e307bedbd0e (diff)
Issue #2776975 by joelpittet, dawehner, tim.plunkett, xjm, pfrenssen: March 3, 2017: Convert core to array syntax coding standards for Drupal 8.3.x RC phase
Diffstat (limited to 'core/modules/breakpoint')
-rw-r--r--core/modules/breakpoint/breakpoint.module4
-rw-r--r--core/modules/breakpoint/src/Breakpoint.php2
-rw-r--r--core/modules/breakpoint/src/BreakpointManager.php30
-rw-r--r--core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php96
-rw-r--r--core/modules/breakpoint/tests/src/Unit/BreakpointTest.php12
5 files changed, 72 insertions, 72 deletions
diff --git a/core/modules/breakpoint/breakpoint.module b/core/modules/breakpoint/breakpoint.module
index 103edd9..a0fd468 100644
--- a/core/modules/breakpoint/breakpoint.module
+++ b/core/modules/breakpoint/breakpoint.module
@@ -15,13 +15,13 @@ function breakpoint_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.breakpoint':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Breakpoint module keeps track of the height, width, and resolution breakpoints where a responsive design needs to change in order to respond to different devices being used to view the site. This module does not have a user interface. For more information, see the <a href=":docs">online documentation for the Breakpoint module</a>.', array(':docs' => 'https://www.drupal.org/documentation/modules/breakpoint')) . '</p>';
+ $output .= '<p>' . t('The Breakpoint module keeps track of the height, width, and resolution breakpoints where a responsive design needs to change in order to respond to different devices being used to view the site. This module does not have a user interface. For more information, see the <a href=":docs">online documentation for the Breakpoint module</a>.', [':docs' => 'https://www.drupal.org/documentation/modules/breakpoint']) . '</p>';
$output .= '<h4>' . t('Terminology') . '</h4>';
$output .= '<dl>';
$output .= '<dt>' . t('Breakpoint') . '</dt>';
$output .= '<dd>' . t('A breakpoint separates the height or width of viewports (screens, printers, and other media output types) into steps. For instance, a width breakpoint of 40em creates two steps: one for widths up to 40em and one for widths above 40em. Breakpoints can be used to define when layouts should shift from one form to another, when images should be resized, and other changes that need to respond to changes in viewport height or width.') . '</dd>';
$output .= '<dt>' . t('Media query') . '</dt>';
- $output .= '<dd>' . t('<a href=":w3">Media queries</a> are a formal way to encode breakpoints. For instance, a width breakpoint at 40em would be written as the media query "(min-width: 40em)". Breakpoints are really just media queries with some additional meta-data, such as a name and multiplier information.', array(':w3' => 'http://www.w3.org/TR/css3-mediaqueries/')) . '</dd>';
+ $output .= '<dd>' . t('<a href=":w3">Media queries</a> are a formal way to encode breakpoints. For instance, a width breakpoint at 40em would be written as the media query "(min-width: 40em)". Breakpoints are really just media queries with some additional meta-data, such as a name and multiplier information.', [':w3' => 'http://www.w3.org/TR/css3-mediaqueries/']) . '</dd>';
$output .= '<dt>' . t('Resolution multiplier') . '</dt>';
$output .= '<dd>' . t('Resolution multipliers are a measure of the viewport\'s device resolution, defined to be the ratio between the physical pixel size of the active device and the <a href="http://en.wikipedia.org/wiki/Device_independent_pixel">device-independent pixel</a> size. The Breakpoint module defines multipliers of 1, 1.5, and 2; when defining breakpoints, modules and themes can define which multipliers apply to each breakpoint.') . '</dd>';
$output .= '<dt>' . t('Breakpoint group') . '</dt>';
diff --git a/core/modules/breakpoint/src/Breakpoint.php b/core/modules/breakpoint/src/Breakpoint.php
index 0c51e63..0928d55 100644
--- a/core/modules/breakpoint/src/Breakpoint.php
+++ b/core/modules/breakpoint/src/Breakpoint.php
@@ -16,7 +16,7 @@ class Breakpoint extends PluginBase implements BreakpointInterface {
* {@inheritdoc}
*/
public function getLabel() {
- return $this->t($this->pluginDefinition['label'], array(), array('context' => 'breakpoint'));
+ return $this->t($this->pluginDefinition['label'], [], ['context' => 'breakpoint']);
}
/**
diff --git a/core/modules/breakpoint/src/BreakpointManager.php b/core/modules/breakpoint/src/BreakpointManager.php
index 693ffa9..30caf27 100644
--- a/core/modules/breakpoint/src/BreakpointManager.php
+++ b/core/modules/breakpoint/src/BreakpointManager.php
@@ -50,7 +50,7 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
/**
* {@inheritdoc}
*/
- protected $defaults = array(
+ protected $defaults = [
// Human readable label for breakpoint.
'label' => '',
// The media query for the breakpoint.
@@ -58,14 +58,14 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
// Weight used for ordering breakpoints.
'weight' => 0,
// Breakpoint multipliers.
- 'multipliers' => array(),
+ 'multipliers' => [],
// The breakpoint group.
'group' => '',
// Default class for breakpoint implementations.
'class' => 'Drupal\breakpoint\Breakpoint',
// The plugin id. Set by the plugin system based on the top-level YAML key.
'id' => '',
- );
+ ];
/**
* The theme handler.
@@ -86,7 +86,7 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
*
* @var array
*/
- protected $instances = array();
+ protected $instances = [];
/**
* Constructs a new BreakpointManager instance.
@@ -106,7 +106,7 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
$this->themeHandler = $theme_handler;
$this->setStringTranslation($string_translation);
$this->alterInfo('breakpoints');
- $this->setCacheBackend($cache_backend, 'breakpoints', array('breakpoints'));
+ $this->setCacheBackend($cache_backend, 'breakpoints', ['breakpoints']);
}
/**
@@ -153,19 +153,19 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
$this->breakpointsByGroup[$group] = $cache->data;
}
else {
- $breakpoints = array();
+ $breakpoints = [];
foreach ($this->getDefinitions() as $plugin_id => $plugin_definition) {
if ($plugin_definition['group'] == $group) {
$breakpoints[$plugin_id] = $plugin_definition;
}
}
- uasort($breakpoints, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
- $this->cacheBackend->set($this->cacheKey . ':' . $group, $breakpoints, Cache::PERMANENT, array('breakpoints'));
+ uasort($breakpoints, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
+ $this->cacheBackend->set($this->cacheKey . ':' . $group, $breakpoints, Cache::PERMANENT, ['breakpoints']);
$this->breakpointsByGroup[$group] = $breakpoints;
}
}
- $instances = array();
+ $instances = [];
foreach ($this->breakpointsByGroup[$group] as $plugin_id => $definition) {
if (!isset($this->instances[$plugin_id])) {
$this->instances[$plugin_id] = $this->createInstance($plugin_id);
@@ -184,16 +184,16 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
$groups = $cache->data;
}
else {
- $groups = array();
+ $groups = [];
foreach ($this->getDefinitions() as $plugin_definition) {
if (!isset($groups[$plugin_definition['group']])) {
$groups[$plugin_definition['group']] = $plugin_definition['group'];
}
}
- $this->cacheBackend->set($this->cacheKey . '::groups', $groups, Cache::PERMANENT, array('breakpoints'));
+ $this->cacheBackend->set($this->cacheKey . '::groups', $groups, Cache::PERMANENT, ['breakpoints']);
}
// Get the labels. This is not cacheable due to translation.
- $group_labels = array();
+ $group_labels = [];
foreach ($groups as $group) {
$group_labels[$group] = $this->getGroupLabel($group);
}
@@ -205,7 +205,7 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
* {@inheritdoc}
*/
public function getGroupProviders($group) {
- $providers = array();
+ $providers = [];
$breakpoints = $this->getBreakpointsByGroup($group);
foreach ($breakpoints as $breakpoint) {
$provider = $breakpoint->getProvider();
@@ -229,7 +229,7 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
public function clearCachedDefinitions() {
parent::clearCachedDefinitions();
$this->breakpointsByGroup = NULL;
- $this->instances = array();
+ $this->instances = [];
}
/**
@@ -251,7 +251,7 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage
}
else {
// Custom group label that should be translatable.
- $label = $this->t($group, array(), array('context' => 'breakpoint'));
+ $label = $this->t($group, [], ['context' => 'breakpoint']);
}
return $label;
}
diff --git a/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php b/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php
index 7683ea1..dc81757 100644
--- a/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php
+++ b/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php
@@ -16,11 +16,11 @@ class BreakpointDiscoveryTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('system', 'breakpoint', 'breakpoint_module_test');
+ public static $modules = ['system', 'breakpoint', 'breakpoint_module_test'];
protected function setUp() {
parent::setUp();
- \Drupal::service('theme_handler')->install(array('breakpoint_theme_test'));
+ \Drupal::service('theme_handler')->install(['breakpoint_theme_test']);
}
/**
@@ -28,56 +28,56 @@ class BreakpointDiscoveryTest extends KernelTestBase {
*/
public function testThemeBreakpoints() {
// Verify the breakpoint group for breakpoint_theme_test was created.
- $expected_breakpoints = array(
- 'breakpoint_theme_test.mobile' => array(
+ $expected_breakpoints = [
+ 'breakpoint_theme_test.mobile' => [
'label' => 'mobile',
'mediaQuery' => '(min-width: 0px)',
'weight' => 0,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
- ),
+ ],
'provider' => 'breakpoint_theme_test',
'id' => 'breakpoint_theme_test.mobile',
'group' => 'breakpoint_theme_test',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- 'breakpoint_theme_test.narrow' => array(
+ ],
+ 'breakpoint_theme_test.narrow' => [
'label' => 'narrow',
'mediaQuery' => '(min-width: 560px)',
'weight' => 1,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
- ),
+ ],
'provider' => 'breakpoint_theme_test',
'id' => 'breakpoint_theme_test.narrow',
'group' => 'breakpoint_theme_test',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- 'breakpoint_theme_test.wide' => array(
+ ],
+ 'breakpoint_theme_test.wide' => [
'label' => 'wide',
'mediaQuery' => '(min-width: 851px)',
'weight' => 2,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
- ),
+ ],
'provider' => 'breakpoint_theme_test',
'id' => 'breakpoint_theme_test.wide',
'group' => 'breakpoint_theme_test',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- 'breakpoint_theme_test.tv' => array(
+ ],
+ 'breakpoint_theme_test.tv' => [
'label' => 'tv',
'mediaQuery' => 'only screen and (min-width: 1220px)',
'weight' => 3,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
- ),
+ ],
'provider' => 'breakpoint_theme_test',
'id' => 'breakpoint_theme_test.tv',
'group' => 'breakpoint_theme_test',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- );
+ ],
+ ];
$breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup('breakpoint_theme_test');
foreach ($expected_breakpoints as $id => $expected_breakpoint) {
@@ -93,46 +93,46 @@ class BreakpointDiscoveryTest extends KernelTestBase {
*/
public function testCustomBreakpointGroups() {
// Verify the breakpoint group for breakpoint_theme_test.group2 was created.
- $expected_breakpoints = array(
- 'breakpoint_theme_test.group2.narrow' => array(
+ $expected_breakpoints = [
+ 'breakpoint_theme_test.group2.narrow' => [
'label' => 'narrow',
'mediaQuery' => '(min-width: 560px)',
'weight' => 0,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
'2x',
- ),
+ ],
'provider' => 'breakpoint_theme_test',
'id' => 'breakpoint_theme_test.group2.narrow',
'group' => 'breakpoint_theme_test.group2',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- 'breakpoint_theme_test.group2.wide' => array(
+ ],
+ 'breakpoint_theme_test.group2.wide' => [
'label' => 'wide',
'mediaQuery' => '(min-width: 851px)',
'weight' => 1,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
'2x',
- ),
+ ],
'provider' => 'breakpoint_theme_test',
'id' => 'breakpoint_theme_test.group2.wide',
'group' => 'breakpoint_theme_test.group2',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- 'breakpoint_module_test.breakpoint_theme_test.group2.tv' => array(
+ ],
+ 'breakpoint_module_test.breakpoint_theme_test.group2.tv' => [
'label' => 'tv',
'mediaQuery' => '(min-width: 6000px)',
'weight' => 2,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
- ),
+ ],
'provider' => 'breakpoint_module_test',
'id' => 'breakpoint_module_test.breakpoint_theme_test.group2.tv',
'group' => 'breakpoint_theme_test.group2',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- );
+ ],
+ ];
$breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup('breakpoint_theme_test.group2');
foreach ($expected_breakpoints as $id => $expected_breakpoint) {
@@ -144,33 +144,33 @@ class BreakpointDiscoveryTest extends KernelTestBase {
* Test the breakpoint group created for a module.
*/
public function testModuleBreakpoints() {
- $expected_breakpoints = array(
- 'breakpoint_module_test.mobile' => array(
+ $expected_breakpoints = [
+ 'breakpoint_module_test.mobile' => [
'label' => 'mobile',
'mediaQuery' => '(min-width: 0px)',
'weight' => 0,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
- ),
+ ],
'provider' => 'breakpoint_module_test',
'id' => 'breakpoint_module_test.mobile',
'group' => 'breakpoint_module_test',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- 'breakpoint_module_test.standard' => array(
+ ],
+ 'breakpoint_module_test.standard' => [
'label' => 'standard',
'mediaQuery' => '(min-width: 560px)',
'weight' => 1,
- 'multipliers' => array(
+ 'multipliers' => [
'1x',
'2x',
- ),
+ ],
'provider' => 'breakpoint_module_test',
'id' => 'breakpoint_module_test.standard',
'group' => 'breakpoint_module_test',
'class' => 'Drupal\\breakpoint\\Breakpoint',
- ),
- );
+ ],
+ ];
$breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup('breakpoint_module_test');
$this->assertEqual(array_keys($expected_breakpoints), array_keys($breakpoints));
@@ -180,20 +180,20 @@ class BreakpointDiscoveryTest extends KernelTestBase {
* Test the collection of breakpoint groups.
*/
public function testBreakpointGroups() {
- $expected = array(
+ $expected = [
'bartik' => 'Bartik',
'breakpoint_module_test' => 'Breakpoint test module',
'breakpoint_theme_test' => 'Breakpoint test theme',
'breakpoint_theme_test.group2' => 'breakpoint_theme_test.group2',
- );
+ ];
$breakpoint_groups = \Drupal::service('breakpoint.manager')->getGroups();
// Ensure the order is as expected. Should be sorted by label.
$this->assertIdentical($expected, $this->castSafeStrings($breakpoint_groups));
- $expected = array(
+ $expected = [
'breakpoint_theme_test' => 'theme',
'breakpoint_module_test' => 'module',
- );
+ ];
$breakpoint_group_providers = \Drupal::service('breakpoint.manager')->getGroupProviders('breakpoint_theme_test.group2');
$this->assertEqual($expected, $breakpoint_group_providers);
}
diff --git a/core/modules/breakpoint/tests/src/Unit/BreakpointTest.php b/core/modules/breakpoint/tests/src/Unit/BreakpointTest.php
index bdd5cd9..4b8fd88 100644
--- a/core/modules/breakpoint/tests/src/Unit/BreakpointTest.php
+++ b/core/modules/breakpoint/tests/src/Unit/BreakpointTest.php
@@ -24,9 +24,9 @@ class BreakpointTest extends UnitTestCase {
*
* @var array
*/
- protected $pluginDefinition = array(
+ protected $pluginDefinition = [
'id' => 'breakpoint',
- );
+ ];
/**
* The breakpoint under test.
@@ -52,7 +52,7 @@ class BreakpointTest extends UnitTestCase {
* Sets up the breakpoint defaults.
*/
protected function setupBreakpoint() {
- $this->breakpoint = new Breakpoint(array(), $this->pluginId, $this->pluginDefinition);
+ $this->breakpoint = new Breakpoint([], $this->pluginId, $this->pluginDefinition);
$this->breakpoint->setStringTranslation($this->stringTranslation);
}
@@ -62,7 +62,7 @@ class BreakpointTest extends UnitTestCase {
public function testGetLabel() {
$this->pluginDefinition['label'] = 'Test label';
$this->setupBreakpoint();
- $this->assertEquals(new TranslatableMarkup('Test label', array(), array('context' => 'breakpoint'), $this->stringTranslation), $this->breakpoint->getLabel());
+ $this->assertEquals(new TranslatableMarkup('Test label', [], ['context' => 'breakpoint'], $this->stringTranslation), $this->breakpoint->getLabel());
}
/**
@@ -88,9 +88,9 @@ class BreakpointTest extends UnitTestCase {
* @covers ::getMultipliers
*/
public function testGetMultipliers() {
- $this->pluginDefinition['multipliers'] = array('1x', '2x');
+ $this->pluginDefinition['multipliers'] = ['1x', '2x'];
$this->setupBreakpoint();
- $this->assertSame(array('1x', '2x'), $this->breakpoint->getMultipliers());
+ $this->assertSame(['1x', '2x'], $this->breakpoint->getMultipliers());
}
/**