PHP Interface Jackalope\Transport\TransportInterface

Note that the JCR Repository Compliance specification defines a larger set of functions, but we want Jackalope to even work with very minimalistic backends. See the README.md in this folder for general information about the transport layer. This interface is now synchronized with what we had for davex as per 2011-12-28 TODO: keep this in sync with Transport/Jackrabbit/Client.php
Exibir arquivo Open project: jackalope/jackalope Interface Usage Examples

Public Methods

Method Description
getAccessibleWorkspaceNames ( ) : array Returns the workspace names that can be used when logging in.
getAutoLastModified ( ) : boolean Get the auto last modified flag.
getBinaryStream ( string $path ) : resource Retrieve a stream of a binary property value
getFetchDepth ( ) : integer Returns the current fetchDepth
getNamespaces ( ) : array Get the registered namespaces mappings from the backend.
getNode ( string $path ) : array Get the node from an absolute path
getNodeByIdentifier ( string $uuid ) : array Get the node from a uuid. Same data format as getNode, but additionally must have the :jcr:path property.
getNodePathForIdentifier ( string $uuid, string $workspace = null ) : string Get the node path from a JCR uuid. This is mainly useful for cross-workspace functionality like clone or updateFrom.
getNodeTypes ( $nodeTypes = [] ) : array Get node types, either filtered or all.
getNodes ( array $paths ) : array Get the nodes from an array of absolute paths.
getNodesByIdentifier ( array $identifiers ) : array Get the nodes from an array of uuid.
getProperty ( string $path ) : stdClass Get the property stored at an absolute path.
getReferences ( string $path, string $name = null ) : array Returns the path of all accessible REFERENCE properties in the workspace that point to the node
getRepositoryDescriptors ( ) : array Get all repository descriptors
getWeakReferences ( string $path, string $name = null ) : array Returns the path of all accessible WEAKREFERENCE properties in the workspace that point to the node
login ( PHPCR\CredentialsInterface $credentials = null, string $workspaceName = null ) : string Set this transport to a specific credential and a workspace.
logout ( ) Releases all resources associated with this Session.
setAutoLastModified ( boolean $autoLastModified ) Set whether to automatically update nodes having mix:lastModified.
setFetchDepth ( integer $depth ) Sets the depth with which a transport should fetch childnodes If depth = 0 it only fetches the requested node If depth = 1 it also fetches its children If depth = 2 it also fetches its children and grandchildren and so on
setNodeTypeManager ( NodeTypeManager $nodeTypeManager ) Pass the node type manager into the transport to be used for validation and such.

Method Details

getAccessibleWorkspaceNames() public method

Returns the workspace names that can be used when logging in.
public getAccessibleWorkspaceNames ( ) : array
return array List of workspaces that can be specified on login

getAutoLastModified() public method

Get the auto last modified flag.
public getAutoLastModified ( ) : boolean
return boolean Whether to update the last modified information.

getBinaryStream() public method

Retrieve a stream of a binary property value
public getBinaryStream ( string $path ) : resource
$path string absolute path to the property containing binary data
return resource with binary data

getFetchDepth() public method

Returns the current fetchDepth
public getFetchDepth ( ) : integer
return integer with the current fetchDepth

getNamespaces() public method

Returns all additional namespaces. Does not return the ones defined as constants in \PHPCR\NamespaceRegistryInterface
public getNamespaces ( ) : array
return array Associative array of prefix => uri

getNode() public method

Returns a json_decode stdClass structure that contains two fields for each property and one field for each child. A child is just containing an empty class as value (in the future we could use this for eager loading with recursive structure). A property consists of a field named as the property is and a value that is the property value, plus a second field with the same name but prefixed with a colon that has a type specified as value (out of the string constants from PropertyType) For binary properties, the value of the type declaration is not the type but the length of the binary, thus integer instead of string. There is no value field for binary data (to avoid loading large amount of unneeded data) Use getBinaryStream to get the actual data of a binary property. If prefetch is active, eventual children to be cached may be included as stdClass children. This can be several levels deep, depending on the prefetch setting. There is a couple of "magic" properties:
  • jcr:uuid - the unique id of the node
  • jcr:primaryType - name of the primary type
  • jcr:mixinTypes - comma separated list of mixin types
  • jcr:index - the index of same name siblings
public getNode ( string $path ) : array
$path string Absolute path to the node.
return array associative array for the node (decoded from json with associative = true)

getNodeByIdentifier() public method

Get the node from a uuid. Same data format as getNode, but additionally must have the :jcr:path property.
public getNodeByIdentifier ( string $uuid ) : array
$uuid string the id in JCR format
return array associative array for the node (decoded from json with associative = true)

getNodePathForIdentifier() public method

Get the node path from a JCR uuid. This is mainly useful for cross-workspace functionality like clone or updateFrom.
See also: getNodeByIdentifier
public getNodePathForIdentifier ( string $uuid, string $workspace = null ) : string
$uuid string the unique uuid to find the path of
$workspace string pass null to use the current workspace of this transport
return string Absolute path to the node (not the node itself!)

getNodeTypes() public method

If the transport does not support registering new node types, it can just return types from the hard coded definition at Jackalope\Transport\StandardNodeTypes
See also: NodeTypeDefinition::fromArray
public getNodeTypes ( $nodeTypes = [] ) : array
return array with the definitions

getNodes() public method

This is an optimization over getNode to get many nodes in one call. If the transport implementation does not optimize, it can just loop over the paths and call getNode repeatedly. If a transport can do it, it should also implement NodeTypeFilterInterface. For prefetch, there are two mechanisms: As with getNode, the stdClass structure may be recursive. Additionally, the transport is allowed to return additional entries that where not requested in the returned array. Jackalope takes care of only returning nodes that where actually requested by the client and caching the rest.
public getNodes ( array $paths ) : array
$paths array Absolute paths to the nodes.
return array keys are the absolute paths, values is the node data as associative array (decoded from json with associative = true)

getNodesByIdentifier() public method

This is an optimization over getNodeByIdentifier to get many nodes in one call. If the transport implementation does not optimize, it can just loop over the uuids and call getNodeByIdentifier repeatedly.
public getNodesByIdentifier ( array $identifiers ) : array
$identifiers array list of uuid to retrieve
return array keys are the absolute paths, values is the node data as associative array (decoded from json with associative = true). they will have the identifier value set.

getProperty() public method

Same format as getNode with just one property. Again, for binary properties just returns the size and not the actual data.
public getProperty ( string $path ) : stdClass
$path string absolute path to the property to get
return stdClass a json struct with the property type and property value(s)

getReferences() public method

Returns the path of all accessible REFERENCE properties in the workspace that point to the node
public getReferences ( string $path, string $name = null ) : array
$path string absolute path to the node we need the references to
$name string name of referring REFERENCE properties to be returned; if null then all referring REFERENCEs are returned
return array

getRepositoryDescriptors() public method

This may be called before login or accessing any specific workspace. With this, you can get some information without being logged in. Must return at least the constants defined in \PHPCR\RepositoryInterface Doc about each constant is found there. Implementations may add their own constants. The transport has to make sure the correct boolean values are set for optional features. Jackalope will rely on the interface implementation, but client code could check the descriptors and be confused if you announce invalid capabilities here.
See also: http://www.day.com/specs/jcr/2.0/24_Repository_Compliance.html#24.2%20Repository%20Descriptors
See also: RepositoryInterface
public getRepositoryDescriptors ( ) : array
return array with name => value/array of value for the descriptors

getWeakReferences() public method

Returns the path of all accessible WEAKREFERENCE properties in the workspace that point to the node
public getWeakReferences ( string $path, string $name = null ) : array
$path string absolute path to the node we need the references to
$name string name of referring WEAKREFERENCE properties to be returned; if null then all referring WEAKREFERENCEs are returned
return array

login() public method

This can only be called once. To connect to another workspace or with another credential, use a fresh instance of transport. What implementation of credentials is supported is transport specific.
public login ( PHPCR\CredentialsInterface $credentials = null, string $workspaceName = null ) : string
$credentials PHPCR\CredentialsInterface the credentials to connect with the backend
$workspaceName string The workspace name to connect to. Null means to connect to the default workspace.
return string The workspace name that we connected to. This must be $workspaceName unless that was null, where it is the name of the default workspace.

logout() public method

This method is called on $session->logout Implementations can use it to close database connections and similar.
public logout ( )

setAutoLastModified() public method

If this is true, the transport has to make sure that on any node change that does not already include a change to the lastModified property, the jcr:lastModified property on nodes with the mixin is set to the current DateTime, and jcr:lastModifiedBy to the user id according to the credentials. Note: On read only stores, this is never used.
public setAutoLastModified ( boolean $autoLastModified )
$autoLastModified boolean

setFetchDepth() public method

Be aware the the actual Session->getNode call does not return all the children. This setting only tells the transport to preemptively fetch all the children from the backend.
public setFetchDepth ( integer $depth )
$depth integer The depth with which the nodes should be fetched.

setNodeTypeManager() public method

Pass the node type manager into the transport to be used for validation and such.
public setNodeTypeManager ( NodeTypeManager $nodeTypeManager )
$nodeTypeManager Jackalope\NodeType\NodeTypeManager