Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions lib/Doctrine/ODM/PHPCR/OperationQueue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Doctrine\ODM\PHPCR;

class OperationQueue extends \SplQueue
{
public function hasOperationForDocument($document, $type)
{
foreach ($this as $operation) {
list($opType, $opDocument, $data) = $operation;
if ($document === $opDocument) {
return true;
}
}

return false;
}

public function removeOperationsForDocument($document, $type)
{
foreach ($this as $i => $operation) {
list($opType, $opDocument, $data) = $operation;

if ($document === $opDocument && $type === $opType) {
$this->offsetUnset($i);
}
}
}

public function filterByOperationType($targetOperationType)
{
$res = array();
foreach ($this as $operation) {
list ($operationType, $document, $data) = $operation;
if ($targetOperationType == $operationType) {
$res[] = $document;
}
}

return $res;
}

public function push($operationType, $document, $data = array())
{
parent::push(array($operationType, $document, $data));
}
}
Loading