/** * Returns an action method name if the path contains a special information identifier, otherwise FALSE * * @param Request $request * @param string $interface * @return string|bool */ protected static function getActionForRequestAndInterface($request, $interface) { $path = $request->getPath(); $method = $request->getMethod(); if ($path[0] === '/') { $path = substr($path, 1); } if ($path[0] === '_') { list($path, ) = explode('/', $path, 2); $handlerAction = GeneralUtility::underscoreToCamelCase(strtolower($method) . '_' . substr($path, 1)) . 'Action'; if (method_exists($interface, $handlerAction)) { return $handlerAction; } } return FALSE; }
/** * @test */ public function underscoreToCamelCaseTest() { $this->assertEquals('_mySuperMethod', GeneralUtility::underscoreToCamelCase('_my_super_method')); $this->assertEquals('_someThingPrivate', GeneralUtility::underscoreToCamelCase('_some_thing_private')); $this->assertEquals('thisWouldBeMorePublic', GeneralUtility::underscoreToCamelCase('this_would_be_more_public')); $this->assertEquals('butThatsJustNamesAnyway', GeneralUtility::underscoreToCamelCase('but_thats_just_names_anyway')); $this->assertEquals('howDoesThisWork4numbers', GeneralUtility::underscoreToCamelCase('how_does_this_work_4numbers')); $this->assertEquals('2Good', GeneralUtility::underscoreToCamelCase('2_good')); }