/** * Commits new objects and changes to objects in the current persistence * session into the backend * * @return void * @author Robert Lemke <*****@*****.**> * @author Karsten Dambekalns <*****@*****.**> * @api */ public function persistAll() { $aggregateRootObjects = new \SplObjectStorage(); $deletedEntities = new \SplObjectStorage(); // fetch and inspect objects from all known repositories $repositoryClassNames = $this->reflectionService->getAllImplementationClassNamesForInterface('F3\\FLOW3\\Persistence\\RepositoryInterface'); foreach ($repositoryClassNames as $repositoryClassName) { $repository = $this->objectManager->getObject($repositoryClassName); $aggregateRootObjects->addAll($repository->getAddedObjects()); $deletedEntities->addAll($repository->getRemovedObjects()); } $aggregateRootObjects->addAll($this->persistenceSession->getReconstitutedObjects()); // hand in only aggregate roots, leaving handling of subobjects to // the underlying storage layer $this->backend->setAggregateRootObjects($aggregateRootObjects); $this->backend->setDeletedEntities($deletedEntities); $this->backend->commit(); // this needs to unregister more than just those, as at least some of // the subobjects are supposed to go away as well... // OTOH those do no harm, changes to the unused ones should not happen, // so all they do is eat some memory. foreach ($deletedEntities as $deletedEntity) { $this->persistenceSession->unregisterReconstitutedObject($deletedEntity); } }
/** * Initializes this Property Mapper * * @return void * @author Robert Lemke <*****@*****.**> */ public function initializeObject() { foreach ($this->reflectionService->getAllImplementationClassNamesForInterface('F3\\FLOW3\\Property\\ObjectConverterInterface') as $objectConverterClassName) { $objectConverter = $this->objectManager->getObject($objectConverterClassName); foreach ($objectConverter->getSupportedTypes() as $supportedType) { $this->objectConverters[$supportedType] = $objectConverter; } } }
/** * Analyzes the raw request and tries to find a request handler which can handle * it. If none is found, an exception is thrown. * * @return \F3\FLOW3\MVC\RequestHandler A request handler * @throws \F3\FLOW3\MVC\Exception * @author Robert Lemke <*****@*****.**> */ public function resolveRequestHandler() { $availableRequestHandlerClassNames = $this->reflectionService->getAllImplementationClassNamesForInterface('F3\\FLOW3\\MVC\\RequestHandlerInterface'); $suitableRequestHandlers = array(); foreach ($availableRequestHandlerClassNames as $requestHandlerClassName) { if (!$this->objectManager->isObjectRegistered($requestHandlerClassName)) { continue; } $requestHandler = $this->objectManager->getObject($requestHandlerClassName); if ($requestHandler->canHandleRequest()) { $priority = $requestHandler->getPriority(); if (isset($suitableRequestHandlers[$priority])) { throw new \F3\FLOW3\MVC\Exception('More than one request handler with the same priority can handle the request, but only one handler may be active at a time!', 1176475350); } $suitableRequestHandlers[$priority] = $requestHandler; } } if (count($suitableRequestHandlers) === 0) { throw new \F3\FLOW3\MVC\Exception('No suitable request handler found.', 1205414233); } ksort($suitableRequestHandlers); return array_pop($suitableRequestHandlers); }
/** * Check for implementations of F3\FLOW3\Resource\Streams\StreamWrapperInterface and * register them. * * @return void * @author Karsten Dambekalns <*****@*****.**> */ public function initialize() { \F3\FLOW3\Resource\Streams\StreamWrapperAdapter::setObjectFactory($this->objectFactory); $streamWrapperClassNames = $this->reflectionService->getAllImplementationClassNamesForInterface('F3\\FLOW3\\Resource\\Streams\\StreamWrapperInterface'); foreach ($streamWrapperClassNames as $streamWrapperClassName) { $scheme = $streamWrapperClassName::getScheme(); if (in_array($scheme, stream_get_wrappers())) { stream_wrapper_unregister($scheme); } stream_wrapper_register($scheme, '\\F3\\FLOW3\\Resource\\Streams\\StreamWrapperAdapter'); \F3\FLOW3\Resource\Streams\StreamWrapperAdapter::registerStreamWrapper($scheme, $streamWrapperClassName); } // For now this URI is hardcoded, but might be manageable in the future // if additional persistent resources storages are supported. $this->persistentResourcesStorageBaseUri = FLOW3_PATH_DATA . 'Persistent/Resources/'; }