Skip to content

Commit

Permalink
make fetch_depth a constant to avoid spelling errors in code
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed May 11, 2012
1 parent f3b4620 commit efe994e
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/Jackalope/Session.php
Expand Up @@ -28,10 +28,24 @@
/**
* {@inheritDoc}
*
* Jackalope adds the SessionOption concept to handle session specific tweaking
* and optimization. We distinguish between options that are purely
* optimization but do not affect the behaviour and those that are change the
* behaviour.
*
* @api
*/
class Session implements SessionInterface
{
/**
* constant for setSessionOption to manage the fetch depth.
*
* This option is used to set the depth with which nodes should be fetched
* from the backend to optimize performance when you know you will need
* the child nodes.
*/
const OPTION_FETCH_DEPTH = 'jackalope.fetch_depth';

/**
* A registry for all created sessions to be able to reference them by id in
* the stream wrapper for lazy loading binary properties.
Expand Down Expand Up @@ -696,8 +710,8 @@ public static function getSessionFromRegistry($key)

/**
* Sets a session specific option.
* Currently only 'jackalope.fetch_depth' is supported. This option sets the depth with which
* nodes should be gotten from the backend.
*
* Currently only OPTION_FETCH_DEPTH is supported.
*
* @param string $key the key to be set
* @param mixed $value the value to be set
Expand All @@ -711,7 +725,7 @@ public static function getSessionFromRegistry($key)
public function setSessionOption($key, $value)
{
switch ($key) {
case 'jackalope.fetch_depth':
case self::OPTION_FETCH_DEPTH:
$this->getTransport()->setFetchDepth($value);
break;
default:
Expand All @@ -731,7 +745,7 @@ public function setSessionOption($key, $value)
public function getSessionOption($key)
{
switch ($key) {
case 'jackalope.fetch_depth':
case self::OPTION_FETCH_DEPTH:
return $this->getTransport()->getFetchDepth();
}

Expand Down

0 comments on commit efe994e

Please sign in to comment.