Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3485117
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3485117
Commits
24a7b3cd
Commit
24a7b3cd
authored
12 years ago
by
Damian Lee
Committed by
Tim Plunkett
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added missing ViewStorage and ViewStorageController files
parent
67065496
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/Drupal/views/ViewStorage.php
+13
-161
13 additions, 161 deletions
lib/Drupal/views/ViewStorage.php
lib/Drupal/views/ViewStorageController.php
+26
-0
26 additions, 0 deletions
lib/Drupal/views/ViewStorageController.php
with
39 additions
and
161 deletions
lib/Drupal/views/View
sDbObject
.php
→
lib/Drupal/views/View
Storage
.php
+
13
−
161
View file @
24a7b3cd
...
...
@@ -2,172 +2,19 @@
/**
* @file
* Definition of Drupal\views\View
sDbObject
.
* Definition of Drupal\views\View
Storage
.
*/
namespace
Drupal\views
;
/**
* Base class for views' database objects.
*/
class
ViewsDbObject
{
public
$db_table
;
/**
* Initialize this object, setting values from schema defaults.
*
* @param $init
* If an array, this is a set of values from db_fetch_object to
* load. Otherwse, if TRUE values will be filled in from schema
* defaults.
*/
function
init
(
$init
=
TRUE
)
{
if
(
is_array
(
$init
))
{
return
$this
->
load_row
(
$init
);
}
if
(
!
$init
)
{
return
;
}
$schema
=
drupal_get_schema
(
$this
->
db_table
);
if
(
!
$schema
)
{
return
;
}
// Go through our schema and build correlations.
foreach
(
$schema
[
'fields'
]
as
$field
=>
$info
)
{
if
(
$info
[
'type'
]
==
'serial'
)
{
$this
->
$field
=
NULL
;
}
if
(
!
isset
(
$this
->
$field
))
{
if
(
!
empty
(
$info
[
'serialize'
])
&&
isset
(
$info
[
'serialized default'
]))
{
$this
->
$field
=
unserialize
(
$info
[
'serialized default'
]);
}
elseif
(
isset
(
$info
[
'default'
]))
{
$this
->
$field
=
$info
[
'default'
];
}
else
{
$this
->
$field
=
''
;
}
}
}
}
/**
* Write the row to the database.
*
* @param $update
* If true this will be an UPDATE query. Otherwise it will be an INSERT.
*/
function
save_row
(
$update
=
NULL
)
{
$fields
=
$defs
=
$values
=
$serials
=
array
();
$schema
=
drupal_get_schema
(
$this
->
db_table
);
// Go through our schema and build correlations.
foreach
(
$schema
[
'fields'
]
as
$field
=>
$info
)
{
// special case -- skip serial types if we are updating.
if
(
$info
[
'type'
]
==
'serial'
)
{
$serials
[]
=
$field
;
continue
;
}
elseif
(
$info
[
'type'
]
==
'int'
)
{
$this
->
$field
=
(
int
)
$this
->
$field
;
}
$fields
[
$field
]
=
empty
(
$info
[
'serialize'
])
?
$this
->
$field
:
serialize
(
$this
->
$field
);
}
if
(
!
$update
)
{
$query
=
db_insert
(
$this
->
db_table
);
}
else
{
$query
=
db_update
(
$this
->
db_table
)
->
condition
(
$update
,
$this
->
$update
);
}
$return
=
$query
->
fields
(
$fields
)
->
execute
();
if
(
$serials
&&
!
$update
)
{
// get last insert ids and fill them in.
// Well, one ID.
foreach
(
$serials
as
$field
)
{
$this
->
$field
=
$return
;
}
}
}
/**
* Load the object with a row from the database.
*
* This method is separate from the constructor in order to give us
* more flexibility in terms of how the view object is built in different
* contexts.
*
* @param $data
* An object from db_fetch_object. It should contain all of the fields
* that are in the schema.
*/
function
load_row
(
$data
)
{
$schema
=
drupal_get_schema
(
$this
->
db_table
);
use
Drupal\config\ConfigurableBase
;
// Go through our schema and build correlations.
foreach
(
$schema
[
'fields'
]
as
$field
=>
$info
)
{
$this
->
$field
=
empty
(
$info
[
'serialize'
])
?
$data
->
$field
:
unserialize
(
$data
->
$field
);
}
}
class
ViewStorage
extends
ConfigurableBase
{
/**
* Export a loaded row, such as an argument, field or the view itself to PHP code.
*
* @param $identifier
* The variable to assign the PHP code for this object to.
* @param $indent
* An optional indentation for prettifying nested code.
* @var string
*/
function
export_row
(
$identifier
=
NULL
,
$indent
=
''
)
{
// @todo replace with http://drupal.org/node/1741154.
ctools_include
(
'export'
);
if
(
!
$identifier
)
{
$identifier
=
$this
->
db_table
;
}
$schema
=
drupal_get_schema
(
$this
->
db_table
);
$output
=
$indent
.
'$'
.
$identifier
.
' = new '
.
get_class
(
$this
)
.
"();
\n
"
;
// Go through our schema and build correlations.
foreach
(
$schema
[
'fields'
]
as
$field
=>
$info
)
{
if
(
!
empty
(
$info
[
'no export'
]))
{
continue
;
}
if
(
!
isset
(
$this
->
$field
))
{
if
(
isset
(
$info
[
'default'
]))
{
$this
->
$field
=
$info
[
'default'
];
}
else
{
$this
->
$field
=
''
;
}
// serialized defaults must be set as serialized.
if
(
isset
(
$info
[
'serialize'
]))
{
$this
->
$field
=
unserialize
(
$this
->
$field
);
}
}
$value
=
$this
->
$field
;
if
(
$info
[
'type'
]
==
'int'
)
{
if
(
isset
(
$info
[
'size'
])
&&
$info
[
'size'
]
==
'tiny'
)
{
$value
=
(
bool
)
$value
;
}
else
{
$value
=
(
int
)
$value
;
}
}
$output
.
=
$indent
.
'$'
.
$identifier
.
'->'
.
$field
.
' = '
.
ctools_var_export
(
$value
,
$indent
)
.
";
\n
"
;
}
return
$output
;
}
public
$db_table
;
/**
* Add a new display handler to the view, automatically creating an id.
...
...
@@ -213,9 +60,14 @@ function add_display($type = 'page', $title = NULL, $id = NULL) {
}
}
$display_options
=
array
(
'type'
=>
$type
,
'id'
=>
$id
,
'display_title'
=>
$title
,
);
// Create the new display object
$display
=
new
ViewsDisplay
();
$display
->
options
(
$type
,
$id
,
$title
);
$display
=
new
ViewsDisplay
(
$display_options
);
// Add the new display object to the view.
$this
->
display
[
$id
]
=
$display
;
...
...
@@ -410,4 +262,4 @@ function set_item_option($display_id, $type, $id, $option, $value) {
$this
->
set_item
(
$display_id
,
$type
,
$id
,
$item
);
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lib/Drupal/views/ViewStorageController.php
0 → 100644
+
26
−
0
View file @
24a7b3cd
<?php
/**
* @file
* Definition of Drupal\views\ViewStorageController.
*/
namespace
Drupal\views
;
use
Drupal\config\ConfigStorageController
;
class
ViewStorageController
extends
ConfigStorageController
{
/**
* Overrides Drupal\config\ConfigStorageController::attachLoad();
*/
protected
function
attachLoad
(
&
$queried_entities
,
$revision_id
=
FALSE
)
{
foreach
(
$queried_entities
as
$id
=>
$entity
)
{
foreach
(
$entity
->
display
as
$key
=>
$options
)
{
// Create a ViewsDisplay object using the display options.
$entity
->
display
[
$key
]
=
new
ViewsDisplay
(
$options
);
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment