|
Perforce Chronicle 2012.2/486814
API Documentation
|
A mechanism for providing an adapter that will be loaded on-demand. More...
Public Member Functions | |
| __construct ($callback) | |
| Create a new deferred adapter from the given callback. | |
| beginBatch ($description) | |
| Start a batch. | |
| commitBatch ($description=null, $options=null) | |
| Commit the batch. | |
| getAdapter () | |
| Resolves the callback to a real adapter. | |
| getBasePath () | |
| Get the base path in Perforce under which records should be read from and written to. | |
| getBatchId () | |
| Get the id of the current batch. | |
| getConnection () | |
| Override every method in the base class to call through to the real adapter. | |
| getProperties () | |
| Get all properties of this adapter. | |
| getProperty ($name) | |
| Get a particular property value of this adapter. | |
| hasProperty ($name) | |
| Check if adapter has a particular property. | |
| inBatch () | |
| Determine if we are currently in a batch on this storage adapter. | |
| revertBatch () | |
| Reverts all files in the pending change corresponding to the batch id. | |
| setBasePath ($path) | |
| Set the base path in Perforce under which records should be read from and written to. | |
| setBatchDescription ($description) | |
| Change the description of the current batch. | |
| setCallback ($callback) | |
| Set the callback to use to get the real adapter to use. | |
| setConnection ($p4) | |
| Set the Perforce connection to use to communicate with the Perforce backend. | |
| setProperties (array $properties) | |
| Set adapter properties. | |
| setProperty ($name, $value) | |
| Set a particular property of this adapter. | |
Protected Attributes | |
| $_callback = null | |
A mechanism for providing an adapter that will be loaded on-demand.
This is particularly useful if creating the adapter will have notable expense you wish to avoid, or if you expect the adapter may change.
| P4Cms_Record_DeferredAdapter::__construct | ( | $ | callback | ) |
Create a new deferred adapter from the given callback.
A callback must be provided.
| callable | $callback | the callback function to get the real adapter. |
| InvalidArgumentException | if the given callback is not callable. |
{
$this->setCallback($callback);
}
| P4Cms_Record_DeferredAdapter::beginBatch | ( | $ | description | ) |
Start a batch.
Changes made to records will be placed in a numbered pending change and will not be submitted until the batch is committed.
Batches cannot be nested. Attempting to begin a batch while in a batch will result in an exception.
| string | $description | required - a description of the batch. |
| P4Cms_Record_Exception | if already in a batch. |
Reimplemented from P4Cms_Record_Adapter.
{ return $this->getAdapter()->beginBatch($description); }
| P4Cms_Record_DeferredAdapter::commitBatch | ( | $ | description = null, |
| $ | options = null |
||
| ) |
Commit the batch.
Submits the pending change corresponding to the batch id.
| string | $description | optional - a final description of the batch. |
| null | string | array | $options | optional - passing the SAVE_THROW_CONFLICTS flag will cause exceptions on conflict; default behaviour is to crush any conflicts. |
| P4Cms_Record_Exception | if not in a batch. |
Reimplemented from P4Cms_Record_Adapter.
{ return $this->getAdapter()->commitBatch($description, $options); }
| P4Cms_Record_DeferredAdapter::getAdapter | ( | ) |
Resolves the callback to a real adapter.
| P4Cms_Record_Exception | if callback fails to return a proper adapter. |
{
$adapter = call_user_func($this->_callback);
if (!$adapter instanceof P4Cms_Record_Adapter) {
throw new P4Cms_Record_Exception(
"Cannot resolve deferred adapter. Callback failed to return a proper adapter."
);
}
return $adapter;
}
| P4Cms_Record_DeferredAdapter::getBasePath | ( | ) |
Get the base path in Perforce under which records should be read from and written to.
| P4Cms_Record_Exception | if no base path is set. |
Reimplemented from P4Cms_Record_Adapter.
{ return $this->getAdapter()->getBasePath(); }
| P4Cms_Record_DeferredAdapter::getBatchId | ( | ) |
Get the id of the current batch.
The batch id corresponds to a pending changelist in Perforce.
| P4Cms_Record_Exception | if not in a batch. |
Reimplemented from P4Cms_Record_Adapter.
{ return $this->getAdapter()->getBatchId(); }
| P4Cms_Record_DeferredAdapter::getConnection | ( | ) |
Override every method in the base class to call through to the real adapter.
Reimplemented from P4Cms_Record_Adapter.
{ return $this->getAdapter()->getConnection(); }
| P4Cms_Record_DeferredAdapter::getProperties | ( | ) |
Get all properties of this adapter.
Reimplemented from P4Cms_Record_Adapter.
{ return $this->getAdapter()->getProperties(); }
| P4Cms_Record_DeferredAdapter::getProperty | ( | $ | name | ) |
Get a particular property value of this adapter.
| string | $name | name of the property to get the value of |
| P4Cms_Record_Exception | if the property name does not exist |
Reimplemented from P4Cms_Record_Adapter.
{ return $this->getAdapter()->getProperty($name); }
| P4Cms_Record_DeferredAdapter::hasProperty | ( | $ | name | ) |
Check if adapter has a particular property.
| string | $name | the property name to check for the existence of |
Reimplemented from P4Cms_Record_Adapter.
{ return $this->getAdapter()->hasProperty($name); }
| P4Cms_Record_DeferredAdapter::inBatch | ( | ) |
Determine if we are currently in a batch on this storage adapter.
Reimplemented from P4Cms_Record_Adapter.
{ return $this->getAdapter()->inBatch(); }
| P4Cms_Record_DeferredAdapter::revertBatch | ( | ) |
Reverts all files in the pending change corresponding to the batch id.
| P4Cms_Record_Exception | if not in a batch. |
Reimplemented from P4Cms_Record_Adapter.
{ return $this->getAdapter()->revertBatch(); }
| P4Cms_Record_DeferredAdapter::setBasePath | ( | $ | path | ) |
Set the base path in Perforce under which records should be read from and written to.
| string | $path | the record storage base path. |
| P4Cms_Record_Exception | if the base path is not a valid string. |
Reimplemented from P4Cms_Record_Adapter.
{ return $this->getAdapter()->setBasePath($path); }
| P4Cms_Record_DeferredAdapter::setBatchDescription | ( | $ | description | ) |
Change the description of the current batch.
| string | $description | the description of the current batch. |
Reimplemented from P4Cms_Record_Adapter.
{ return $this->getAdapter()->setBatchDescription($description); }
| P4Cms_Record_DeferredAdapter::setCallback | ( | $ | callback | ) |
Set the callback to use to get the real adapter to use.
| callable | $callback | the callback function to get the real adapter. the callback will be called with no arguments and must return an adapter instance |
| InvalidArgumentException | if the given callback is not callable. |
{
if (!is_callable($callback)) {
throw new InvalidArgumentException(
"Cannot set callback. Given callback is not callable."
);
}
$this->_callback = $callback;
return $this;
}
| P4Cms_Record_DeferredAdapter::setConnection | ( | $ | p4 | ) |
Set the Perforce connection to use to communicate with the Perforce backend.
| P4_Connection_Abstract | $p4 | the p4 connection to use. |
| P4Cms_Record_Exception | if the connection object is invalid. |
Reimplemented from P4Cms_Record_Adapter.
{ return $this->getAdapter()->setConnection($p4); }
| P4Cms_Record_DeferredAdapter::setProperties | ( | array $ | properties | ) |
Set adapter properties.
| array | $properties | array with properties to set |
Reimplemented from P4Cms_Record_Adapter.
{ return $this->getAdapter()->setProperties($properties); }
| P4Cms_Record_DeferredAdapter::setProperty | ( | $ | name, |
| $ | value | ||
| ) |
Set a particular property of this adapter.
| string | $name | name of the property to set the value of |
| mixed | $value | value to set |
Reimplemented from P4Cms_Record_Adapter.
{ return $this->getAdapter()->setProperty($name, $value); }
P4Cms_Record_DeferredAdapter::$_callback = null [protected] |