예제 #1
0
 public function refExists(NodeRef $nodeRef)
 {
     if (!$nodeRef->isFullyQualified()) {
         throw new NodeException('Cannot check node exists without fully-qualified NodeRef');
     }
     // retrieve the DB connection and table from DataSourceManager
     $db = $this->getConnectionForWrite($nodeRef);
     // determine if node exists at url, excluding deleted nodes
     $sql = "SELECT {$this->NodeDBMeta->getPrimaryKey($nodeRef)}\n                FROM {$db->quoteIdentifier($this->NodeDBMeta->getTableName($nodeRef))}\n                WHERE Slug = {$db->quote($nodeRef->getSlug())}\n                    AND Status != 'deleted'";
     $unique = $db->readOne($sql);
     return !empty($unique);
 }
 public function delete(NodeRef $nodeRef)
 {
     if (!$nodeRef->isFullyQualified()) {
         throw new Exception('Cannot delete node from index without fully-qualified NodeRef');
     }
     if (substr($this->Elements, 0, 1) == '@') {
         if (!$nodeRef->getElement()->hasAspect($this->Elements)) {
             return;
         }
     } else {
         if (!in_array($nodeRef->getElement()->getSlug(), StringUtils::smartExplode($this->Elements))) {
             return;
         }
     }
     if (array_key_exists('' . $nodeRef, $this->markedForReindex)) {
         unset($this->markedForReindex['' . $nodeRef]);
     }
     if (array_key_exists('' . $nodeRef, $this->markedForDeletion)) {
         return;
     }
     $this->markedForDeletion['' . $nodeRef] = $nodeRef;
     $this->bindReindex();
 }
예제 #3
0
 public function purge(NodeRef $nodeRef)
 {
     if (!$nodeRef->isFullyQualified()) {
         throw new NodeException('Cannot purge node without fully-qualified NodeRef');
     }
     $this->NodeEvents->fireNodeEvents(__FUNCTION__, 'pre', $nodeRef);
     $this->purgeInternal($nodeRef);
     $this->NodeEvents->fireNodeEvents(__FUNCTION__, 'post', $nodeRef);
 }
예제 #4
0
 protected function delete(NodeRef $nodeRef)
 {
     if (!$nodeRef->isFullyQualified()) {
         $this->getErrors()->reject('Cannot delete node without Slug')->throwOnError();
     }
     if (!$this->NodeLookupDAO->refExists($nodeRef)) {
         $this->getErrors()->reject('Record not found for NodeRef: ' . $nodeRef->getRefURL());
         return;
     }
     $errors = $this->getErrors();
     $this->NodeEvents->fireValidationEvents(__FUNCTION__, $errors, $nodeRef);
 }
예제 #5
0
 /**
  * Changes our NodeRef
  *
  * @param NodeRef $newNodeRef
  */
 public function setNodeRef($newNodeRef)
 {
     $this->fields['NodeRef'] = $newNodeRef;
     $this->fields['Slug'] = $newNodeRef->isFullyQualified() ? $newNodeRef->getSlug() : '';
 }
 protected function getRecordIDFromNodeRef(NodeRef $nodeRef)
 {
     if (!$nodeRef->isFullyQualified()) {
         throw new NodeException('Cannot retrieve record ID without fully-qualified NodeRef');
     }
     $db = $this->getConnectionForWrite($nodeRef);
     $tableid = $this->NodeDBMeta->getPrimaryKey($nodeRef);
     $nodes = $this->multiGetFromDB($db, $tableid, $this->NodeDBMeta->getTableName($nodeRef), $nodeRef, (array) $nodeRef->getSlug(), false, true, true);
     if (empty($nodes)) {
         throw new NodeException('Node not found for NodeRef: ' . $nodeRef);
     }
     $node = current($nodes);
     return $node['ID'];
 }