Skip to content

Commit

Permalink
Added parameter allowUpdate to registerNodeTypeCnd
Browse files Browse the repository at this point in the history
The parameter allowUpdate makes sure that a node type
is not modified accidentially
  • Loading branch information
uwej711 committed Apr 7, 2011
1 parent d32303b commit f122589
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Jackalope/NodeType/NodeTypeManager.php
Expand Up @@ -360,12 +360,12 @@ public function registerNodeTypes(array $definitions, $allowUpdate)
*
* @author david at liip.ch
*/
public function registerNodeTypesCnd($cnd)
public function registerNodeTypesCnd($cnd, $allowUpdate)
{
//set fetched from backend to false to allow to load the new types from backend
$fetched = $this->fetchedAllFromBackend;
$this->fetchedAllFromBackend = false;
$this->objectManager->registerNodeTypesCnd($cnd);
$this->objectManager->registerNodeTypesCnd($cnd, $allowUpdate);

//parse out type names and fetch types to return definitions of the new nodes
preg_match_all('/\[([^\]]*)\]/', $cnd, $names);
Expand Down
4 changes: 2 additions & 2 deletions src/Jackalope/ObjectManager.php
Expand Up @@ -347,9 +347,9 @@ public function registerNodeTypes($types)
*
* This is only a proxy to the transport
*/
public function registerNodeTypesCnd($cnd)
public function registerNodeTypesCnd($cnd, $allowUpdate)
{
return $this->transport->registerNodeTypesCnd($cnd);
return $this->transport->registerNodeTypesCnd($cnd, $allowUpdate);
}

/**
Expand Down
9 changes: 5 additions & 4 deletions src/Jackalope/Transport/Davex/Client.php
Expand Up @@ -767,10 +767,10 @@ public function getNodeTypes($nodeTypes = array())
*
* @author david at liip.ch
*/
public function registerNodeTypesCnd($cnd)
public function registerNodeTypesCnd($cnd, $allowUpdate)
{
$request = $this->getRequest(Request::PROPPATCH, $this->workspaceUri);
$request->setBody($this->buildRegisterNodeTypeRequest($cnd));
$request->setBody($this->buildRegisterNodeTypeRequest($cnd, $allowUpdate));
$request->execute();
return true;
}
Expand All @@ -793,9 +793,10 @@ public function registerNodeTypes($types)
*
* @author david at liip.ch
*/
protected function buildRegisterNodeTypeRequest($cnd)
protected function buildRegisterNodeTypeRequest($cnd, $allowUpdate)
{
$cnd = str_replace(array('<','>'), array('&lt;','&gt;'), $cnd);
$cnd = '<dcr:cnd>'.str_replace(array('<','>'), array('&lt;','&gt;'), $cnd).'</dcr:cnd>';
$cnd .= '<dcr:allowupdate>'.($allowUpdate ? 'true' : 'false').'</dcr:allowupdate>';
return '<?xml version="1.0" encoding="UTF-8" standalone="no"?><D:propertyupdate xmlns:D="DAV:"><D:set><D:prop><dcr:nodetypes-cnd xmlns:dcr="http://www.day.com/jcr/webdav/1.0">'.$cnd.'</dcr:nodetypes-cnd></D:prop></D:set></D:propertyupdate>';
}

Expand Down

0 comments on commit f122589

Please sign in to comment.