Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
14f07719
Commit
14f07719
authored
May 15, 2012
by
Tim Plunkett
Browse files
Use classed entities instead of stdClass.
parent
a5e71d0b
Changes
15
Hide whitespace changes
Inline
Side-by-side
modules/comment/views_handler_field_comment_username.inc
View file @
14f07719
...
...
@@ -37,7 +37,7 @@ function options_form(&$form, &$form_state) {
function
render_link
(
$data
,
$values
)
{
if
(
!
empty
(
$this
->
options
[
'link_to_user'
]))
{
$account
=
new
stdClass
(
);
$account
=
entity_create
(
'user'
,
array
()
);
$account
->
uid
=
$this
->
get_value
(
$values
,
'uid'
);
$account
->
name
=
$this
->
get_value
(
$values
);
$account
->
homepage
=
$this
->
get_value
(
$values
,
'homepage'
);
...
...
modules/comment/views_handler_field_ncs_last_comment_name.inc
View file @
14f07719
...
...
@@ -40,7 +40,7 @@ function option_definition() {
function
render
(
$values
)
{
if
(
!
empty
(
$this
->
options
[
'link_to_user'
]))
{
$account
=
new
stdClass
(
);
$account
=
entity_create
(
'user'
,
array
()
);
$account
->
name
=
$this
->
get_value
(
$values
);
$account
->
uid
=
$values
->
{
$this
->
uid
};
return
theme
(
'username'
,
array
(
...
...
modules/comment/views_handler_field_node_new_comments.inc
View file @
14f07719
...
...
@@ -91,9 +91,10 @@ function pre_render(&$values) {
function
render_link
(
$data
,
$values
)
{
if
(
!
empty
(
$this
->
options
[
'link_to_comment'
])
&&
$data
!==
NULL
&&
$data
!==
''
)
{
$node
=
new
stdClass
();
$node
->
nid
=
$this
->
get_value
(
$values
,
'nid'
);
$node
->
type
=
$this
->
get_value
(
$values
,
'type'
);
$node
=
entity_create
(
'node'
,
array
(
'nid'
=>
$this
->
get_value
(
$values
,
'nid'
),
'type'
=>
$this
->
get_value
(
$values
,
'type'
),
));
$this
->
options
[
'alter'
][
'make_link'
]
=
TRUE
;
$this
->
options
[
'alter'
][
'path'
]
=
'node/'
.
$node
->
nid
;
$this
->
options
[
'alter'
][
'query'
]
=
comment_new_page_count
(
$this
->
get_value
(
$values
,
'comment_count'
),
$this
->
get_value
(
$values
),
$node
);
...
...
modules/comment/views_plugin_row_comment_rss.inc
View file @
14f07719
...
...
@@ -97,7 +97,7 @@ function render($row) {
$item_text
=
''
;
$uri
=
entity_uri
(
'comment'
,
$comment
);
$uri
=
$comment
->
uri
(
);
$comment
->
link
=
url
(
$uri
[
'path'
],
$uri
[
'options'
]
+
array
(
'absolute'
=>
TRUE
));
$comment
->
rss_namespaces
=
array
();
$comment
->
rss_elements
=
array
(
...
...
modules/field/views_handler_field_field.inc
View file @
14f07719
...
...
@@ -629,7 +629,7 @@ function post_execute(&$values) {
foreach
(
$entities_by_type
as
$entity_type
=>
$entity_ids
)
{
$entity_info
=
entity_get_info
(
$entity_type
);
if
(
empty
(
$this
->
definition
[
'is revision'
]))
{
$entities
=
entity_load
(
$entity_type
,
$entity_ids
);
$entities
=
entity_load
_multiple
(
$entity_type
,
$entity_ids
);
$keys
=
$entity_ids
;
}
else
{
...
...
@@ -639,7 +639,7 @@ function post_execute(&$values) {
$keys
=
array
();
foreach
(
$entity_ids
as
$key
=>
$combined
)
{
list
(
$entity_id
,
$revision_id
)
=
$combined
;
$entity
=
entity_load
(
$entity_type
,
array
(
$entity_id
),
array
(
$entity_info
[
'entity keys'
][
'revision'
]
=>
$revision_id
));
$entity
=
entity_load
_multiple
(
$entity_type
,
array
(
$entity_id
),
array
(
$entity_info
[
'entity keys'
][
'revision'
]
=>
$revision_id
));
if
(
$entity
)
{
$entities
[
$revision_id
]
=
array_shift
(
$entity
);
$keys
[
$key
]
=
$revision_id
;
...
...
modules/node/views_plugin_row_node_rss.inc
View file @
14f07719
...
...
@@ -107,7 +107,7 @@ function render($row) {
$item_text
=
''
;
$uri
=
entity_uri
(
'node'
,
$node
);
$uri
=
$node
->
uri
(
);
$node
->
link
=
url
(
$uri
[
'path'
],
$uri
[
'options'
]
+
array
(
'absolute'
=>
TRUE
));
$node
->
rss_namespaces
=
array
();
$node
->
rss_elements
=
array
(
...
...
modules/taxonomy/views_handler_field_taxonomy.inc
View file @
14f07719
...
...
@@ -62,12 +62,13 @@ function options_form(&$form, &$form_state) {
function
render_link
(
$data
,
$values
)
{
$tid
=
$this
->
get_value
(
$values
,
'tid'
);
if
(
!
empty
(
$this
->
options
[
'link_to_taxonomy'
])
&&
!
empty
(
$tid
)
&&
$data
!==
NULL
&&
$data
!==
''
)
{
$term
=
new
stdClass
();
$term
->
tid
=
$tid
;
$term
->
vid
=
$this
->
get_value
(
$values
,
'vid'
);
$term
->
vocabulary_machine_name
=
$values
->
{
$this
->
aliases
[
'vocabulary_machine_name'
]};
$term
=
entity_create
(
'taxonomy_term'
,
array
(
'tid'
=>
$tid
,
'vid'
=>
$this
->
get_value
(
$values
,
'vid'
),
'vocabulary_machine_name'
=>
$values
->
{
$this
->
aliases
[
'vocabulary_machine_name'
]},
));
$this
->
options
[
'alter'
][
'make_link'
]
=
TRUE
;
$uri
=
entity_uri
(
'taxonomy_term'
,
$term
);
$uri
=
$term
->
uri
(
);
$this
->
options
[
'alter'
][
'path'
]
=
$uri
[
'path'
];
}
...
...
modules/taxonomy/views_handler_field_term_link_edit.inc
View file @
14f07719
...
...
@@ -44,13 +44,14 @@ function query() {
}
function
render
(
$values
)
{
// Mock a term object for taxonomy_term_
edit_
access(). Use machine name and
// Mock a term object for taxonomy_term_access(). Use machine name and
// vid to ensure compatibility with vid based and machine name based
// access checks. See http://drupal.org/node/995156
$term
=
new
stdClass
();
$term
->
vid
=
$values
->
{
$this
->
aliases
[
'vid'
]};
$term
->
vocabulary_machine_name
=
$values
->
{
$this
->
aliases
[
'vocabulary_machine_name'
]};
if
(
taxonomy_term_edit_access
(
$term
))
{
$term
=
entity_create
(
'taxonomy_term'
,
array
(
'vid'
=>
$values
->
{
$this
->
aliases
[
'vid'
]},
'vocabulary_machine_name'
=>
$values
->
{
$this
->
aliases
[
'vocabulary_machine_name'
]},
));
if
(
taxonomy_term_access
(
'edit'
,
$term
))
{
$text
=
!
empty
(
$this
->
options
[
'text'
])
?
$this
->
options
[
'text'
]
:
t
(
'edit'
);
$tid
=
$this
->
get_value
(
$values
,
'tid'
);
return
l
(
$text
,
'taxonomy/term/'
.
$tid
.
'/edit'
,
array
(
'query'
=>
drupal_get_destination
()));
...
...
modules/user/views_handler_field_user_link_cancel.inc
View file @
14f07719
...
...
@@ -16,7 +16,7 @@ function render_link($data, $values) {
$uid
=
$values
->
{
$this
->
aliases
[
'uid'
]};
// Build a pseudo account object to be able to check the access.
$account
=
new
stdClass
(
);
$account
=
entity_create
(
'user'
,
array
()
);
$account
->
uid
=
$uid
;
if
(
$uid
&&
user_cancel_access
(
$account
))
{
...
...
modules/user/views_handler_field_user_link_edit.inc
View file @
14f07719
...
...
@@ -13,7 +13,7 @@
class
views_handler_field_user_link_edit
extends
views_handler_field_user_link
{
function
render_link
(
$data
,
$values
)
{
// Build a pseudo account object to be able to check the access.
$account
=
new
stdClass
(
);
$account
=
entity_create
(
'user'
,
array
()
);
$account
->
uid
=
$data
;
if
(
$data
&&
user_edit_access
(
$account
))
{
...
...
modules/user/views_handler_field_user_name.inc
View file @
14f07719
...
...
@@ -60,7 +60,7 @@ function options_form(&$form, &$form_state) {
}
function
render_link
(
$data
,
$values
)
{
$account
=
new
stdClass
(
);
$account
=
entity_create
(
'user'
,
array
()
);
$account
->
uid
=
$this
->
get_value
(
$values
,
'uid'
);
$account
->
name
=
$this
->
get_value
(
$values
);
if
(
!
empty
(
$this
->
options
[
'link_to_user'
])
||
!
empty
(
$this
->
options
[
'overwrite_anonymous'
]))
{
...
...
modules/user/views_handler_field_user_picture.inc
View file @
14f07719
...
...
@@ -97,7 +97,7 @@ function render($values) {
}
else
{
// Fake an account object.
$account
=
new
stdClass
(
);
$account
=
entity_create
(
'user'
,
array
()
);
if
(
$this
->
options
[
'link_photo_to_profile'
])
{
// Prevent template_preprocess_user_picture from adding a link
// by not setting the uid.
...
...
plugins/views_plugin_query_default.inc
View file @
14f07719
...
...
@@ -1605,7 +1605,7 @@ function get_result_entities($results, $relationship = NULL) {
}
}
$entities
=
entity_load
(
$entity_type
,
$ids
);
$entities
=
entity_load
_multiple
(
$entity_type
,
$ids
);
// Re-key the array by row-index.
$result
=
array
();
foreach
(
$ids
as
$key
=>
$id
)
{
...
...
tests/comment/views_handler_argument_comment_user_uid.test
View file @
14f07719
...
...
@@ -32,7 +32,7 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest {
'cid'
=>
''
,
'pid'
=>
''
,
);
return
comment_save
((
object
)
$comment
);
return
entity_create
(
'comment'
,
$comment
)
->
save
()
;
}
function
setUp
()
{
...
...
tests/views_ui.test
View file @
14f07719
...
...
@@ -283,10 +283,11 @@ class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper {
$this
->
node_type_without_tags
=
$this
->
drupalCreateContentType
();
// Create the vocabulary for the tag field.
$this
->
tag_vocabulary
=
new
stdClass
();
$this
->
tag_vocabulary
->
name
=
'Views testing tags'
;
$this
->
tag_vocabulary
->
machine_name
=
'views_testing_tags'
;
taxonomy_vocabulary_save
(
$this
->
tag_vocabulary
);
$this
->
tag_vocabulary
=
entity_create
(
'taxonomy_vocabulary'
,
array
(
'name'
=>
'Views testing tags'
,
'machine_name'
=>
'views_testing_tags'
,
));
$this
->
tag_vocabulary
->
save
();
// Create the tag field itself.
$this
->
tag_field
=
array
(
...
...
@@ -710,7 +711,7 @@ class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper {
*/
function
createNodeAndGetPath
()
{
$node
=
$this
->
drupalCreateNode
();
return
entity_uri
(
'node'
,
$node
);
return
$node
->
uri
(
);
}
/**
...
...
@@ -718,7 +719,7 @@ class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper {
*/
function
createUserAndGetPath
()
{
$account
=
$this
->
drupalCreateUser
();
return
entity_uri
(
'user'
,
$account
);
return
$account
->
uri
(
);
}
/**
...
...
@@ -726,7 +727,7 @@ class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper {
*/
function
createCommentAndGetPath
()
{
$node
=
$this
->
drupalCreateNode
();
$comment
=
(
object
)
array
(
$comment
=
entity_create
(
'comment'
,
array
(
'cid'
=>
NULL
,
'nid'
=>
$node
->
nid
,
'pid'
=>
0
,
...
...
@@ -735,26 +736,28 @@ class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper {
'subject'
=>
$this
->
randomName
(),
'language'
=>
LANGUAGE_NOT_SPECIFIED
,
'comment_body'
=>
array
(
LANGUAGE_NOT_SPECIFIED
=>
array
(
$this
->
randomName
())),
);
comment
_
save
(
$comment
);
return
entity_uri
(
'comment'
,
$comment
);
)
);
$
comment
->
save
();
return
$comment
->
uri
(
);
}
/**
* Helper function to create a taxonomy term and return its expected path.
*/
function
createTaxonomyTermAndGetPath
()
{
$vocabulary
=
new
stdClass
();
$vocabulary
->
name
=
$this
->
randomName
();
$vocabulary
->
machine_name
=
drupal_strtolower
(
$this
->
randomName
());
taxonomy_vocabulary_save
(
$vocabulary
);
$term
=
new
stdClass
();
$term
->
name
=
$this
->
randomName
();
$term
->
vid
=
$vocabulary
->
vid
;
taxonomy_term_save
(
$term
);
return
entity_uri
(
'taxonomy_term'
,
$term
);
$vocabulary
=
entity_create
(
'taxonomy_vocabulary'
,
array
(
'name'
=>
$this
->
randomName
(),
'machine_name'
=>
drupal_strtolower
(
$this
->
randomName
()),
));
$vocabulary
->
save
();
$term
=
entity_create
(
'taxonomy_term'
,
array
(
'name'
=>
$this
->
randomName
(),
'vid'
=>
$vocabulary
->
vid
,
'vocabulary_machine_name'
=>
$vocabulary
->
machine_name
,
));
$term
->
save
();
return
$term
->
uri
();
}
/**
...
...
@@ -783,7 +786,7 @@ class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper {
$settings
=
array
(
'revision'
=>
TRUE
);
$node
=
$this
->
drupalCreateNode
(
$settings
);
$node
->
vid
=
NULL
;
node
_
save
(
$node
);
$
node
->
save
();
return
'node/'
.
$node
->
nid
.
'/revisions/'
.
$node
->
vid
.
'/view'
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment