Task #53257

Content Repository API

Added by Bastian Waidelich almost 2 years ago. Updated 8 months ago.

Status:Closed Start date:2013-10-31
Priority:Should have Due date:
Assigned To:Bastian Waidelich % Done:

0%

Category:Low Level Spent time: -
Target version:-

Description

We need a solid foundation for all kinds of interactions with the TYPO3 Content Repository in order to streamline client/server communication and provide open endpoints for 3rd parties.

Some measures towards a stable API I could imagine:

1. Encapsulate NodeDataRepository calls into a public service (e.g. "NodeRepository")

2. Merge functions with similar functionality

If you look at the list of "lookup" interactions below you can see that we do similar jobs multiple times. I would suggest following changes:

  • Replace Workspace arguments by ContextInterface arguments (and provide some easy way to retrieve a context from a workspace if we see the need for it). This will also render arguments like "$includeRemovedNodes" obsolete.
  • The service should only return NULL, NodeInterface or QueryResultInterface<NodeInterface> if possible (Until we rewrote the queries to use DQL we could create a NodeQueryResult that implements a subset of the QueryResultInterface)

3. Extend the Neos "Node REST API" so that it provides common operations (using the NodeRepository)

4. Replace existing client/server interactions (ExtDirect, possibly some Backend\*Controller) by interactions with the REST API

History

#1 Updated by Bastian Waidelich almost 2 years ago

The current direct interactions with the NodeDataRepository that should be replaced by proper API calls:

Lookup

Find one node by identifier & workspace

1NodeDataRepository::findOneByIdentifier($identifier, Workspace $workspace);

Usages:

TYPO3.Neos:
1Module\Management\WorkspacesController::indexAction();
2Service\NodeController::showAction();
3TypoScript\ConvertNodeUrisImplementation::convertNodeIdentifierToUri();

TYPO3.TYPO3CR:
1Domain\Model\Workspace::publishNode()
2TypeConverter\NodeConverter::convertFrom()

Find one node by path and context

1NodeDataRepository::findOneByPathInContext($path, ContextInterface $context);

Usages:

TYPO3.TYPO3CR:
1Domain\Model\Node::getParent()
2Domain\Model\NodeData::getParent()

Find one node by path and workspace

1NodeDataRepository::findOneByPath($path, Workspace $workspace);

Usages:

TYPO3.TYPO3CR:
1Domain\Model\NodeData::getNode()

Find first node by parent and type in context

1NodeDataRepository::findFirstByParentAndNodeTypeInContext($parentPath, $nodeTypeFilter, ContextInterface $context);

Usages:

TYPO3.TYPO3CR:
1Domain\Model\Node::getPrimaryChildNode()
2Domain\Model\NodeData::getPrimaryChildNode()

Find nodes by parent and type in context

1NodeDataRepository::findByParentAndNodeTypeInContext($parentPath, $nodeTypeFilter, ContextInterface $context, $limit = NULL, $offset = NULL);

Usages:

TYPO3.TYPO3CR:
1Domain\Model\Node::getChildNodes()
2Domain\Model\NodeData::getChildNodes()

Find nodes by parent node and type

1NodeDataRepository::findByParentAndNodeTypeRecursively($parentPath, $nodeTypeFilter, Workspace $workspace, $limit = NULL, $offset = NULL, $includeRemovedNodes = FALSE)

Usages:

TYPO3.Neos:
1Service\PluginService::getNodes()

Find nodes by workspace

1NodeDataRepository::findByWorkspace(Workspace $workspace);

Usages:

TYPO3.Neos:
1Service\PublishingService::getUnpublishedNodes()

Find nodes on path by context

1NodeDataRepository::findOnPathInContext($pathStartingPoint, $pathEndPoint, ContextInterface $context, $nodeTypeFilter = NULL);

Usages:

TYPO3.TYPO3CR:
1Domain\Model\Node::getClosestAncestor()
2Domain\Model\Node::getNode()
3Domain\Service\Context::getNodesOnPath()

Find arbitrary nodes (custom queries)

1NodeDataRepository::createQuery(); // …

Usages:

TYPO3.Neos:
1Domain\Service\NodeSearchService::findByProperties()

Counting

Count nodes by parent and type in context

1NodeDataRepository::countByParentAndNodeType($parentPath, $nodeTypeFilter, Workspace $workspace, $includeRemovedNodes = FALSE);

Usages:

TYPO3.TYPO3CR:
1Domain\Model\Node::getNumberOfChildNodes()
2Domain\Model\NodeData::getNumberOfChildNodes()

Count nodes by workspace

1NodeDataRepository::countByWorkspace(Workspace $workspace)

Usages:

TYPO3.TYPO3CR:
1Domain\Model\Workspace::getNodeCount()

Interaction with single nodes / miscellaneous

Add a new node

1NodeDataRepository::add($nodeData)

Usages:

TYPO3.TYPO3CR:
1Domain\Model\Node::materializeNodeData()
2Domain\Model\NodeData::createSingleNode()
3Domain\Model\Workspace::initializeObject()

Update a node

1NodeDataRepository::update($nodeData)

Usages:

TYPO3.TYPO3CR:
1Domain\Model\Node::update()
2Domain\Model\NodeData::setName()
3Domain\Model\NodeData::setIndex()
4Domain\Model\NodeData::update()
5Domain\Model\NodeData::remove()

Remove a single node:

1NodeDataRepository::remove($node);

Usages:

TYPO3.Neos:
1Module\Management\WorkspacesController::discardNodeAction()
2Module\Management\WorkspacesController::publishOrDiscardNodesAction()
3Module\Management\WorkspacesController::discardWorkspaceAction()

TYPO3.TYPO3CR:
1Domain\Model\NodeData::remove()
2Domain\Model\Workspace::publishNode()

Remove all nodes:

1NodeDataRepository::removeAll();

Usages:

TYPO3.Neos:
1Command\SiteCommandController::pruneCommand()
2Setup\Step\SiteImportStep::importSite();

Change node index

1NodeDataRepository::setNewIndex(NodeData $node, $position, NodeData $referenceNode = NULL)

Usages:

TYPO3.TYPO3CR:
1Domain\Model\NodeData::moveBefore()
2Domain\Model\NodeData::moveAfter()
3Domain\Model\NodeData::moveInto()
4Domain\Model\NodeData::createSingleNode()

Manually persist nodes

1NodeDataRepository::persistEntities();

Usages:

TYPO3.Neos:
1Service\BackendRedirectionService::getAfterLoginRedirectionUri()

TYPO3.TYPO3CR:
1Domain\Model\NodeData::setName()

#2 Updated by Bastian Waidelich over 1 year ago

  • Status changed from New to Accepted
  • Assigned To set to Bastian Waidelich

#3 Updated by Bastian Waidelich 8 months ago

  • Status changed from Accepted to Closed
  • Remaining (hours) set to 0.0

In the meantime the CR has been changed drastically and IMO a rewrite from scratch (maybe based on CQRS?) is more realistic than a substantial refactoring

Also available in: Atom PDF