Created
November 15, 2023 09:58
-
-
Save bwaidelich/68aafae0dd882c91ccc06db8f732e0f2 to your computer and use it in GitHub Desktop.
Creating a service for the Neos 9.0 Content Repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
final class CatchUpWorkerCommandController extends CommandController { | |
public function __construct( | |
private readonly ContentRepositoryRegistry $contentRepositoryRegistry, | |
private readonly ProjectionCatchUpServiceFactory $projectionCatchUpServiceFactory, | |
) { | |
parent::__construct(); | |
} | |
/** | |
* @param string $contentRepository ID of the content repository to catch up projections for | |
**/ | |
public function catchUpAllCommand(string $contentRepository): void { | |
$catchUpService = $this->contentRepositoryRegistry->buildService( | |
ContentRepositoryId::fromString($contentRepository), | |
$this->projectionCatchUpServiceFactory, | |
); | |
$catchUpService->catchUpAll(CatchUpOptions::create()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
final class ProjectionCatchUpService implements ContentRepositoryServiceInterface | |
{ | |
public function __construct( | |
private readonly Projections $projections, | |
private readonly ContentRepository $contentRepository, | |
) { | |
} | |
public function catchUpAllProjections(CatchUpOptions $options): void | |
{ | |
$this->contentRepository->catchUpProjection($classNamesAndAlias['className'], $options); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
#[Flow\Scope("singleton")] | |
final class ProjectionCatchUpServiceFactory implements ContentRepositoryServiceFactoryInterface { | |
public function build(ContentRepositoryServiceFactoryDependencies $serviceFactoryDependencies): ContentRepositoryServiceInterface | |
{ | |
return new ProjectionCatchUpService($serviceFactoryDependencies->projections, $serviceFactoryDependencies->contentRepository); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment