PHP 클래스 Jackalope\Item

Jackalope Implementation: The item has a state machine to track in what state it currently is. All API exposed methods must call Item::checkState() before doing anything. Most important is that everything that is in state deleted can not be used anymore (will detect logic errors in client code) and that if the item needs to be refreshed from the backend, this can be postponed until the item is actually accessed again. Figure: workflow state transitions For the special case of Item state after a failed transaction, see Item::rollbackTransaction()
상속: implements PHPCR\ItemInterface
파일 보기 프로젝트 열기: jackalope/jackalope 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$available_states The states an Item can take
$depth Depth in the workspace graph
$factory The jackalope object factory for this object
$isNode Whether this item is a node (otherwise it is a property)
$keepChanges To know whether to keep changes or not when reloading in dirty state
$name the node or property name
$new false if item is read from backend, true if created locally in this session
$objectManager The object manager to get nodes and properties from
$oldPath While this item is moved but unsaved, stores the old path for refresh.
$parentPath Normalized and absolute path to the parent item for convenience.
$path Normalized and absolute path to this item.
$postDirtyState The state to take after this dirty node has been refreshed. One of the STATE_ constants
$savedState The state of the item saved when a transaction is started
$session The session this item belongs to
$state The state of the item, one of the STATE_ constants
$valueConverter PHPCR\Util\ValueConverter

공개 메소드들

메소드 설명
accept ( PHPCR\ItemVisitorInterface $visitor ) {@inheritDoc}
beginTransaction ( ) Manage item state when transaction starts. This method is called on every cached item by the ObjectManager.
commitTransaction ( ) Clean up state after a transaction. This method is called on every cached item by the ObjectManager.
confirmSaved ( ) notify this item that it has been saved into the backend.
getAncestor ( $depth ) {@inheritDoc}
getDepth ( ) {@inheritDoc}
getName ( ) {@inheritDoc}
getParent ( ) {@inheritDoc}
getPath ( ) {@inheritDoc}
getSession ( ) {@inheritDoc}
getState ( ) : integer Get the state of the item
isClean ( ) : boolean Whether this item is in STATE_CLEAN (meaning its data is fully synchronized with the backend)
isDeleted ( ) : boolean Whether this item has been deleted and can not be used anymore.
isDirty ( ) : boolean Whether this item is in state dirty.
isModified ( ) {@inheritDoc}
isMoved ( ) {@inheritDoc}
isNew ( ) {@inheritDoc}
isNode ( ) {@inheritDoc}
isSame ( PHPCR\ItemInterface $otherItem ) {@inheritDoc}
remove ( ) {@inheritDoc}
revert ( ) {@inheritDoc}
rollbackTransaction ( ) Adjust the correct item state after a transaction rollback. This method is called on every cached item by the ObjectManager.
setClean ( ) Tell this item it is clean (i.e. it has been refreshed after a modification)
setDeleted ( ) Tell this item it has been deleted and cannot be used anymore
setDirty ( boolean $keepChanges = false, $targetState = false ) Tell this item that it is dirty and needs to be refreshed
setModified ( ) Tell this item that it has been modified.
setPath ( string $path, boolean $move = false ) Set or update the path, depth, name and parent reference

보호된 메소드들

메소드 설명
__construct ( jackalope\FactoryInterface $factory, string $path, jackalope\Session $session, ObjectManager $objectManager, boolean $new = false ) Initialize basic information common to nodes and properties
checkState ( ) This function will modify the state of the item as well as refresh it if necessary (i.e.
findItemDefinition ( callable $definitions ) : PHPCR\NodeType\ItemDefinitionInterface Find the matching item definition for this item.
refresh ( boolean $keepChanges ) Updates the state of the current item.

비공개 메소드들

메소드 설명
setState ( integer $state ) Change the state of the item

메소드 상세

__construct() 보호된 메소드

Initialize basic information common to nodes and properties
protected __construct ( jackalope\FactoryInterface $factory, string $path, jackalope\Session $session, ObjectManager $objectManager, boolean $new = false )
$factory jackalope\FactoryInterface the object factory
$path string The normalized and absolute path to this item
$session jackalope\Session
$objectManager ObjectManager
$new boolean can be set to true to tell the object that it has been created locally

accept() 공개 메소드

{@inheritDoc}
public accept ( PHPCR\ItemVisitorInterface $visitor )
$visitor PHPCR\ItemVisitorInterface

beginTransaction() 공개 메소드

Saves the current item state in case a rollback occurs.
또한 보기: Item::rollbackTransaction
public beginTransaction ( )

checkState() 보호된 메소드

if it is DIRTY).
protected checkState ( )

commitTransaction() 공개 메소드

Clean up state after a transaction. This method is called on every cached item by the ObjectManager.
또한 보기: Item::rollbackTransaction
public commitTransaction ( )

confirmSaved() 공개 메소드

allowing it to clear the modified / new flags
public confirmSaved ( )

findItemDefinition() 보호된 메소드

Find the matching item definition for this item.
protected findItemDefinition ( callable $definitions ) : PHPCR\NodeType\ItemDefinitionInterface
$definitions callable Function that extracts the ItemDefinitions from a NodeType
리턴 PHPCR\NodeType\ItemDefinitionInterface The definition for this item.

getAncestor() 공개 메소드

{@inheritDoc}
public getAncestor ( $depth )

getDepth() 공개 메소드

{@inheritDoc}
public getDepth ( )

getName() 공개 메소드

{@inheritDoc}
public getName ( )

getParent() 공개 메소드

{@inheritDoc}
public getParent ( )

getPath() 공개 메소드

{@inheritDoc}
public getPath ( )

getSession() 공개 메소드

{@inheritDoc}
public getSession ( )

getState() 공개 메소드

Get the state of the item
public getState ( ) : integer
리턴 integer one of the state constants

isClean() 공개 메소드

Whether this item is in STATE_CLEAN (meaning its data is fully synchronized with the backend)
public isClean ( ) : boolean
리턴 boolean

isDeleted() 공개 메소드

Whether this item has been deleted and can not be used anymore.
public isDeleted ( ) : boolean
리턴 boolean

isDirty() 공개 메소드

Returns true if this Item has been marked dirty (i.e. being saved) and has not been refreshed since. The in-memory representation of the item in memory might not reflect the current state in the backend (for instance if mix:referenceable mixin type has been added to the item the backend creates a UUID on save).
public isDirty ( ) : boolean
리턴 boolean

isModified() 공개 메소드

{@inheritDoc}
public isModified ( )

isMoved() 공개 메소드

{@inheritDoc}
public isMoved ( )

isNew() 공개 메소드

{@inheritDoc}
public isNew ( )

isNode() 공개 메소드

{@inheritDoc}
public isNode ( )

isSame() 공개 메소드

{@inheritDoc}
public isSame ( PHPCR\ItemInterface $otherItem )
$otherItem PHPCR\ItemInterface

refresh() 추상적인 보호된 메소드

In JSR-283 this was part of the interface. While JSR-333 deprecated the refresh() method and replaces it with revert(), the functionality is still needed as Session::refresh() has been kept. If keepChanges is false, this method discards all pending changes currently recorded in this Session that apply to this Item or any of its descendants (that is, the subgraph rooted at this Item) and returns all items to reflect the current saved state. Outside a transaction this state is simply the current state of persistent storage. Within a transaction, this state will reflect persistent storage as modified by changes that have been saved but not yet committed. If keepChanges is true then pending change are not discarded but items that do not have changes pending have their state refreshed to reflect the current saved state, thus revealing changes made by other sessions.
abstract protected refresh ( boolean $keepChanges )
$keepChanges boolean a boolean

remove() 공개 메소드

{@inheritDoc}
public remove ( )

revert() 공개 메소드

{@inheritDoc}
public revert ( )

rollbackTransaction() 공개 메소드

Item state represents the state of an in-memory item. This has nothing to do with the state of the item in the backend. Referring to the JCR spec (21.3 Save vs. Commit) a transaction rollback or commit will not change the in-memory state of items, but only the backend. When a transaction is rolled back, we try to correct the state of in-memory items so that the session could be correctly saved if no more constraint violations remain. Note that this does not fully work yet. On Item::beginTransaction() we save the current state into savedState. On a rollback, we basically go back to the saved state, with a couple of exceptions. The following table shows an ordered list of rules - the first match is used. The * denotes any state.
#$savedState$state Resulting $state
1DELETED * DELETED
2* DELETED DELETED
3NEW * NEW
4* MODIFIEDMODIFIED
5MODIFIED * MODIFIED
6CLEAN CLEAN CLEAN (if the item was not modified in the TRX)
7CLEAN CLEAN MODIFIED (if the item was modified in the TRX)
note: case 7 is handled in Item::setState() by changing $savedState to MODIFIED if $savedState is CLEAN and current state changes to MODIFIED Without this special case, we would miss the situation where a clean node is modified after transaction start and successfully saved, ending up with clean state again. it has to be modified as its different from the backend value.
8CLEAN DIRTY DIRTY
9DIRTY * DIRTY
또한 보기: ObjectManager::rollbackTransaction()
public rollbackTransaction ( )

setClean() 공개 메소드

Tell this item it is clean (i.e. it has been refreshed after a modification)
public setClean ( )

setDeleted() 공개 메소드

Tell this item it has been deleted and cannot be used anymore
public setDeleted ( )

setDirty() 공개 메소드

Tell this item that it is dirty and needs to be refreshed
public setDirty ( boolean $keepChanges = false, $targetState = false )
$keepChanges boolean whether to keep changes when reloading or not

setModified() 공개 메소드

This will do nothing if the node is new, to avoid duplicating store commands.
public setModified ( )

setPath() 공개 메소드

Set or update the path, depth, name and parent reference
public setPath ( string $path, boolean $move = false )
$path string the new path this item lives at
$move boolean whether this item is being moved in session context and should store the current path until the next save operation.

프로퍼티 상세

$available_states 보호되어 있는 프로퍼티

The states an Item can take
protected $available_states

$depth 보호되어 있는 프로퍼티

Depth in the workspace graph
protected $depth

$factory 보호되어 있는 프로퍼티

The jackalope object factory for this object
protected $factory

$isNode 보호되어 있는 프로퍼티

Whether this item is a node (otherwise it is a property)
protected $isNode

$keepChanges 보호되어 있는 프로퍼티

To know whether to keep changes or not when reloading in dirty state
protected $keepChanges

$name 보호되어 있는 프로퍼티

the node or property name
protected $name

$new 보호되어 있는 프로퍼티

false if item is read from backend, true if created locally in this session
protected $new

$objectManager 보호되어 있는 프로퍼티

The object manager to get nodes and properties from
protected $objectManager

$oldPath 보호되어 있는 프로퍼티

While this item is moved but unsaved, stores the old path for refresh.
protected $oldPath

$parentPath 보호되어 있는 프로퍼티

Normalized and absolute path to the parent item for convenience.
protected $parentPath

$path 보호되어 있는 프로퍼티

Normalized and absolute path to this item.
protected $path

$postDirtyState 보호되어 있는 프로퍼티

The state to take after this dirty node has been refreshed. One of the STATE_ constants
protected $postDirtyState

$savedState 보호되어 있는 프로퍼티

The state of the item saved when a transaction is started
또한 보기: Item::rollbackTransaction()
protected $savedState

$session 보호되어 있는 프로퍼티

The session this item belongs to
protected $session

$state 보호되어 있는 프로퍼티

The state of the item, one of the STATE_ constants
protected $state

$valueConverter 보호되어 있는 프로퍼티

protected ValueConverter,PHPCR\Util $valueConverter
리턴 PHPCR\Util\ValueConverter