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
225
Merge Requests
225
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
625e3009
Commit
625e3009
authored
Sep 02, 2012
by
tim.plunkett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1766088
by tim.plunkett: Update ViewStorage* for Configurables rename.
parent
774ef63c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
59 deletions
+59
-59
lib/Drupal/views/Tests/ViewStorageTest.php
lib/Drupal/views/Tests/ViewStorageTest.php
+19
-19
lib/Drupal/views/ViewStorage.php
lib/Drupal/views/ViewStorage.php
+4
-4
lib/Drupal/views/ViewStorageController.php
lib/Drupal/views/ViewStorageController.php
+31
-31
lib/Drupal/views/ViewStorageInterface.php
lib/Drupal/views/ViewStorageInterface.php
+5
-5
No files found.
lib/Drupal/views/Tests/ViewStorageTest.php
View file @
625e3009
...
...
@@ -36,14 +36,14 @@ class ViewStorageTest extends WebTestBase {
);
/**
* The
Configurable
information from entity_get_info().
* The
configuration entity
information from entity_get_info().
*
* @var array
*/
protected
$info
;
/**
* The
Configurabl
e controller.
* The
configuration entity storag
e controller.
*
* @var Drupal\views\ViewStorageController
*/
...
...
@@ -58,7 +58,7 @@ class ViewStorageTest extends WebTestBase {
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Configura
bles
CRUD tests'
,
'name'
=>
'Configura
tion entity
CRUD tests'
,
'description'
=>
'Tests the CRUD functionality for ViewStorage.'
,
'group'
=>
'Views'
,
);
...
...
@@ -67,8 +67,8 @@ public static function getInfo() {
/**
* Tests CRUD operations.
*/
function
testConfigura
ble
CRUD
()
{
// Get the
Configurable
information and controller.
function
testConfigura
tionEntity
CRUD
()
{
// Get the
configuration entity
information and controller.
$this
->
info
=
entity_get_info
(
'view'
);
$this
->
controller
=
entity_get_controller
(
'view'
);
...
...
@@ -88,7 +88,7 @@ function testConfigurableCRUD() {
}
/**
* Tests loading configura
bl
es.
* Tests loading configura
tion entiti
es.
*/
protected
function
loadTests
()
{
$view
=
$this
->
loadView
(
'archive'
);
...
...
@@ -113,27 +113,27 @@ protected function loadTests() {
$this
->
assertTrue
(
!
empty
(
$display_options
)
&&
is_array
(
$display_options
),
'Display options exist.'
);
}
// Fetch data for all
Configurable object
s and default view configurations.
$all_configura
bl
es
=
$this
->
controller
->
load
();
// Fetch data for all
configuration entitie
s and default view configurations.
$all_configura
tion_entiti
es
=
$this
->
controller
->
load
();
$all_config
=
config_get_storage_names_with_prefix
(
'views.view'
);
// Remove the 'views.view.' prefix from config names for comparision with
// loaded
Configurable object
s.
// loaded
configuration entitie
s.
$prefix_map
=
function
(
$value
)
{
$parts
=
explode
(
'.'
,
$value
);
return
end
(
$parts
);
};
// Check that the correct number of
Configurable object
s have been loaded.
$count
=
count
(
$all_configura
bl
es
);
$this
->
assertEqual
(
$count
,
count
(
$all_config
),
format_string
(
'The array of all @count
Configurable object
s is loaded.'
,
array
(
'@count'
=>
$count
)));
// Check that the correct number of
configuration entitie
s have been loaded.
$count
=
count
(
$all_configura
tion_entiti
es
);
$this
->
assertEqual
(
$count
,
count
(
$all_config
),
format_string
(
'The array of all @count
configuration entitie
s is loaded.'
,
array
(
'@count'
=>
$count
)));
// Check that all of these machine names match.
$this
->
assertIdentical
(
array_keys
(
$all_configura
bl
es
),
array_map
(
$prefix_map
,
$all_config
),
'All loaded elements match.'
);
$this
->
assertIdentical
(
array_keys
(
$all_configura
tion_entiti
es
),
array_map
(
$prefix_map
,
$all_config
),
'All loaded elements match.'
);
}
/**
* Tests creating configura
bl
es.
* Tests creating configura
tion entiti
es.
*/
protected
function
createTests
()
{
// Create a new View instance with empty values.
...
...
@@ -169,7 +169,7 @@ protected function createTests() {
}
/**
* Tests saving configura
bl
es.
* Tests saving configura
tion entiti
es.
*/
protected
function
saveTests
()
{
$view
=
$this
->
loadView
(
'archive'
);
...
...
@@ -209,7 +209,7 @@ protected function saveTests() {
}
/**
* Tests deleting configura
bl
es.
* Tests deleting configura
tion entiti
es.
*/
protected
function
deleteTests
()
{
$view
=
$this
->
loadView
(
'tracker'
);
...
...
@@ -222,7 +222,7 @@ protected function deleteTests() {
}
/**
* Tests adding, saving, and loading displays on configura
bl
es.
* Tests adding, saving, and loading displays on configura
tion entiti
es.
*/
protected
function
displayTests
()
{
// Check whether a display can be added and saved to a View.
...
...
@@ -247,7 +247,7 @@ protected function displayTests() {
}
/**
* Tests statuses of configura
bl
es.
* Tests statuses of configura
tion entiti
es.
*/
protected
function
statusTests
()
{
// Test a View can be enabled and disabled again (with a new view).
...
...
@@ -273,7 +273,7 @@ protected function statusTests() {
}
/**
* Loads a single
Configurable object
from the controller.
* Loads a single
configuration entity
from the controller.
*
* @param string $view_name
* The machine name of the view.
...
...
lib/Drupal/views/ViewStorage.php
View file @
625e3009
...
...
@@ -7,15 +7,15 @@
namespace
Drupal\views
;
use
Drupal\config\Config
urable
Base
;
use
Drupal\config\Config
Entity
Base
;
/**
* Defines a ViewStorage configura
ble
class.
* Defines a ViewStorage configura
tion entity
class.
*/
class
ViewStorage
extends
Config
urable
Base
implements
ViewStorageInterface
{
class
ViewStorage
extends
Config
Entity
Base
implements
ViewStorageInterface
{
/**
* Overrides Drupal\entity\
Storable
Interface::id().
* Overrides Drupal\entity\
Entity
Interface::id().
*/
public
function
id
()
{
return
$this
->
name
;
...
...
lib/Drupal/views/ViewStorageController.php
View file @
625e3009
...
...
@@ -8,7 +8,7 @@
namespace
Drupal\views
;
use
Drupal\config\ConfigStorageController
;
use
Drupal\entity\
Storable
Interface
;
use
Drupal\entity\
Entity
Interface
;
/**
* Defines the storage controller class for ViewStorage entities.
...
...
@@ -18,11 +18,11 @@ class ViewStorageController extends ConfigStorageController {
/**
* Overrides Drupal\config\ConfigStorageController::attachLoad();
*/
protected
function
attachLoad
(
&
$queried_
object
s
,
$revision_id
=
FALSE
)
{
foreach
(
$queried_
objects
as
$id
=>
$configurable
)
{
protected
function
attachLoad
(
&
$queried_
entitie
s
,
$revision_id
=
FALSE
)
{
foreach
(
$queried_
entities
as
$id
=>
$entity
)
{
// @todo This property is left in for CTools export UI.
$
configurable
->
type
=
t
(
'Normal'
);
$this
->
attachDisplays
(
$
configurable
);
$
entity
->
type
=
t
(
'Normal'
);
$this
->
attachDisplays
(
$
entity
);
}
}
...
...
@@ -33,25 +33,25 @@ protected function attachLoad(&$queried_objects, $revision_id = FALSE) {
* properties to be set on the config object. This can be removed when the
* view storage is isolated so the ReflectionClass can work.
*/
public
function
save
(
StorableInterface
$configurable
)
{
public
function
save
(
EntityInterface
$entity
)
{
$prefix
=
$this
->
entityInfo
[
'config prefix'
]
.
'.'
;
// Load the stored
configurable
, if any, and rename it.
if
(
$
configurable
->
getOriginalID
())
{
$id
=
$
configurable
->
getOriginalID
();
// Load the stored
entity
, if any, and rename it.
if
(
$
entity
->
getOriginalID
())
{
$id
=
$
entity
->
getOriginalID
();
}
else
{
$id
=
$
configurable
->
id
();
$id
=
$
entity
->
id
();
}
$config
=
config
(
$prefix
.
$id
);
$config
->
setName
(
$prefix
.
$
configurable
->
id
());
$config
->
setName
(
$prefix
.
$
entity
->
id
());
if
(
!
$config
->
isNew
()
&&
!
isset
(
$
configurable
->
original
))
{
$
configurable
->
original
=
entity_load_unchanged
(
$this
->
entityType
,
$id
);
if
(
!
$config
->
isNew
()
&&
!
isset
(
$
entity
->
original
))
{
$
entity
->
original
=
entity_load_unchanged
(
$this
->
entityType
,
$id
);
}
$this
->
preSave
(
$
configurable
);
$this
->
invokeHook
(
'presave'
,
$
configurable
);
$this
->
preSave
(
$
entity
);
$this
->
invokeHook
(
'presave'
,
$
entity
);
// @todo This temp measure will be removed once we have a better way or
// separation of storage and the executed view.
...
...
@@ -70,7 +70,7 @@ public function save(StorableInterface $configurable) {
foreach
(
$config_properties
as
$property
)
{
if
(
$property
==
'display'
)
{
$displays
=
array
();
foreach
(
$
configurable
->
display
as
$key
=>
$display
)
{
foreach
(
$
entity
->
display
as
$key
=>
$display
)
{
$displays
[
$key
]
=
array
(
'display_options'
=>
$display
->
display_options
,
'display_plugin'
=>
$display
->
display_plugin
,
...
...
@@ -82,28 +82,28 @@ public function save(StorableInterface $configurable) {
$config
->
set
(
'display'
,
$displays
);
}
else
{
$config
->
set
(
$property
,
$
configurable
->
$property
);
$config
->
set
(
$property
,
$
entity
->
$property
);
}
}
if
(
!
$config
->
isNew
())
{
$return
=
SAVED_NEW
;
$config
->
save
();
$this
->
postSave
(
$
configurable
,
TRUE
);
$this
->
invokeHook
(
'update'
,
$
configurable
);
$this
->
postSave
(
$
entity
,
TRUE
);
$this
->
invokeHook
(
'update'
,
$
entity
);
}
else
{
$return
=
SAVED_UPDATED
;
$config
->
save
();
$
configurable
->
enforceIsNew
(
FALSE
);
$this
->
postSave
(
$
configurable
,
FALSE
);
$this
->
invokeHook
(
'insert'
,
$
configurable
);
$
entity
->
enforceIsNew
(
FALSE
);
$this
->
postSave
(
$
entity
,
FALSE
);
$this
->
invokeHook
(
'insert'
,
$
entity
);
}
// Clear caches.
views_invalidate_cache
();
unset
(
$
configurable
->
original
);
unset
(
$
entity
->
original
);
return
$return
;
}
...
...
@@ -124,22 +124,22 @@ public function create(array $values) {
)
);
$
configurable
=
parent
::
create
(
$values
);
$
entity
=
parent
::
create
(
$values
);
$this
->
attachDisplays
(
$
configurable
);
return
$
configurable
;
$this
->
attachDisplays
(
$
entity
);
return
$
entity
;
}
/**
* Attaches an array of ViewDisplay objects to the view display property.
*
* @param Drupal\entity\
StorableInterface $configurable
* @param Drupal\entity\
EntityInterface $entity
*/
protected
function
attachDisplays
(
StorableInterface
$configurable
)
{
if
(
isset
(
$
configurable
->
display
)
&&
is_array
(
$configurable
->
display
))
{
protected
function
attachDisplays
(
EntityInterface
$entity
)
{
if
(
isset
(
$
entity
->
display
)
&&
is_array
(
$entity
->
display
))
{
$displays
=
array
();
foreach
(
$
configurable
->
get
(
'display'
)
as
$key
=>
$options
)
{
foreach
(
$
entity
->
get
(
'display'
)
as
$key
=>
$options
)
{
$options
+=
array
(
'display_options'
=>
array
(),
'display_plugin'
=>
NULL
,
...
...
@@ -151,7 +151,7 @@ protected function attachDisplays(StorableInterface $configurable) {
$displays
[
$key
]
=
new
ViewDisplay
(
$options
);
}
$
configurable
->
set
(
'display'
,
$displays
);
$
entity
->
set
(
'display'
,
$displays
);
}
}
...
...
lib/Drupal/views/ViewStorageInterface.php
View file @
625e3009
...
...
@@ -7,25 +7,25 @@
namespace
Drupal\views
;
use
Drupal\config\Config
urable
Interface
;
use
Drupal\config\Config
Entity
Interface
;
/**
* Defines an interface for View storage classes.
*/
interface
ViewStorageInterface
extends
Config
urable
Interface
{
interface
ViewStorageInterface
extends
Config
Entity
Interface
{
/**
* Sets the configura
ble
entity status to enabled.
* Sets the configura
tion
entity status to enabled.
*/
public
function
enable
();
/**
* Sets the configura
ble
entity status to disabled.
* Sets the configura
tion
entity status to disabled.
*/
public
function
disable
();
/**
* Returns whether the configura
ble
entity is enabled.
* Returns whether the configura
tion
entity is enabled.
*
* @return bool
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment