Commit 10db2c17 authored by dawehner's avatar dawehner Committed by tim.plunkett
Browse files

Simplify the constructor of ViewDisplay.

parent b93c8e0e
......@@ -168,7 +168,7 @@ function testConfigurableCRUD() {
$created_loaded = reset($loaded_entities);
$values_loaded = config('views.view.archive')->get();
$this->assertTrue(isset($created_loaded->display['default']->display_options), 'Make sure that the display options exists.');
$this->assertTrue(isset($created_loaded->display['default']->display_options), 'Make sure that the display options exist.');
$this->assertEqual($created_loaded->display['default']->display_plugin, 'default', 'Make sure the right display plugin is set.');
$this->assertEqual($values, $values_loaded, 'The loaded config is the same as the original loaded one.');
......
......@@ -29,13 +29,19 @@ class ViewDisplay {
*/
public $display_options;
function __construct(array $display_options = array()) {
if (!empty($display_options)) {
$this->display_options = $display_options['display_options'];
$this->display_plugin = $display_options['display_plugin'];
$this->id = $display_options['id'];
$this->display_title = $display_options['display_title'];
}
public function __construct(array $display_options = array()) {
$display_options += array(
'display_options' => array(),
'display_plugin' => NULL,
'id' => NULL,
'display_title' => '',
'position' => NULL,
);
$this->display_options = $display_options['display_options'];
$this->display_plugin = $display_options['display_plugin'];
$this->id = $display_options['id'];
$this->display_title = $display_options['display_title'];
}
}
......@@ -104,7 +104,6 @@ public function save(StorableInterface $entity) {
* Overrides Drupal\config\ConfigStorageController::create().
*/
public function create(array $values) {
// If there is no information about displays available add at least the
// default display.
$values += array(
......@@ -124,13 +123,22 @@ public function create(array $values) {
*
* @param Drupal\entity\StorableInterface $entity
*/
protected function attachDisplays($entity) {
protected function attachDisplays(StorableInterface $entity) {
if (isset($entity->display) && is_array($entity->display)) {
$displays = array();
foreach ($entity->get('display') as $key => $options) {
$options += array(
'display_options' => array(),
'display_plugin' => NULL,
'id' => NULL,
'display_title' => '',
'position' => NULL,
);
// Create a ViewDisplay object using the display options.
$displays[$key] = new ViewDisplay($options);
}
$entity->set('display', $displays);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment