-
- /**
- * Find a page parent entity via an identifier string in the format:
- * {type}:{id}
- * Example: (book:5).
- *
- * @throws MoveOperationException
- */
- public function findParentByIdentifier(string $identifier): ?Book
- {
- $stringExploded = explode(':', $identifier);
- $entityType = $stringExploded[0];
- $entityId = intval($stringExploded[1]);
-
- if ($entityType !== 'book') {
- throw new MoveOperationException('Chapters can only be in books');
- }
-
- return Book::visible()->where('id', '=', $entityId)->first();
- }