Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
docker
osticket
Commits
40e1ac2e
Commit
40e1ac2e
authored
11 years ago
by
Jared Hancock
Browse files
Options
Downloads
Patches
Plain Diff
orm: Add ::count() and ::expunge() to InstrumentedList
parent
5ef66b87
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/class.orm.php
+26
-10
26 additions, 10 deletions
include/class.orm.php
with
26 additions
and
10 deletions
include/class.orm.php
+
26
−
10
View file @
40e1ac2e
...
...
@@ -435,10 +435,6 @@ class ModelInstanceIterator implements Iterator, ArrayAccess {
return
$this
->
cache
;
}
function
objects
()
{
return
clone
$this
->
queryset
;
}
// Iterator interface
function
rewind
()
{
$this
->
position
=
0
;
...
...
@@ -507,23 +503,43 @@ class InstrumentedList extends ModelInstanceIterator {
$this
->
resource
=
null
;
}
function
add
(
$object
)
{
function
add
(
$object
,
$at
=
false
)
{
if
(
!
$object
||
!
$object
instanceof
$this
->
model
)
throw
new
Exception
(
'Attempting to add invalid object to list'
);
$object
->
{
$this
->
key
}
=
$this
->
id
;
$object
->
set
(
$this
->
key
,
$this
->
id
)
;
$object
->
save
();
$this
->
list
[]
=
$object
;
if
(
$at
!==
false
)
$this
->
cache
[
$at
]
=
$object
;
else
$this
->
cache
[]
=
$object
;
}
function
remove
(
$object
)
{
$object
->
delete
();
}
function
reset
()
{
$this
->
cache
=
array
();
}
// QuerySet delegates
function
count
()
{
return
$this
->
queryset
->
count
();
}
function
exists
()
{
return
$this
->
queryset
->
exists
();
}
function
expunge
()
{
return
$this
->
queryset
->
delete
();
}
function
update
(
array
$what
)
{
return
$this
->
queryset
->
update
(
$what
);
}
function
reset
()
{
$this
->
cache
=
array
();
// Fetch a new QuerySet
function
objects
()
{
return
clone
$this
->
queryset
;
}
function
offsetUnset
(
$a
)
{
...
...
@@ -533,7 +549,7 @@ class InstrumentedList extends ModelInstanceIterator {
function
offsetSet
(
$a
,
$b
)
{
$this
->
fillTo
(
$a
);
$this
->
cache
[
$a
]
->
delete
();
$this
->
add
(
$b
);
$this
->
add
(
$b
,
$a
);
}
}
...
...
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