/** * Returns the domain model class name for the given API path * * @param string $path API path to get the repository for * @return string */ public function getModelClassForPath($path) { list($vendor, $extension, $model) = Utility::getClassNamePartsForPath($path); $modelClass = 'Tx_' . $extension . '_Domain_Model_' . $model; if (!class_exists($modelClass)) { $modelClass = ($vendor ? $vendor . '\\' : '') . $extension . '\\Domain\\Model\\' . $model; } return $modelClass; }
/** * Returns the Handler which is responsible for handling the current request * * @return HandlerInterface */ public function getHandler() { /** @var \Cundd\Rest\HandlerInterface $handler */ list($vendor, $extension, ) = Utility::getClassNamePartsForPath($this->getRequest()->path()); // Check if an extension provides a Handler $handlerClass = 'Tx_' . $extension . '_Rest_Handler'; if (!class_exists($handlerClass)) { $handlerClass = ($vendor ? $vendor . '\\' : '') . $extension . '\\Rest\\Handler'; } // Get the specific builtin handler if (!class_exists($handlerClass)) { $handlerClass = 'Cundd\\Rest\\Handler\\' . $extension . 'Handler'; // Get the default handler if (!class_exists($handlerClass)) { $handlerClass = 'Cundd\\Rest\\HandlerInterface'; } } return $this->get($handlerClass); }
/** * Returns the tags for the current request * * @return array[string] */ protected function _getTags() { $currentPath = $this->currentRequest->path(); list($vendor, $extension, $model) = Utility::getClassNamePartsForPath($currentPath); return array($vendor . '_' . $extension . '_' . $model, $extension . '_' . $model, $currentPath); }
/** * @test */ public function getClassNamePartsForPathTest() { $this->assertEquals(array('', 'MyExt', 'MyModel'), Utility::getClassNamePartsForPath('my_ext-my_model')); }