コード例 #1
0
 /**
  * This method will return the controller actions defined in the controller class. This assumes
  * that controllers DO NOT extend each other, which they should not.
  *
  * @return array
  */
 protected function getCustomCommitActions()
 {
     $customCommitActions = [];
     $expectedList = ['postAction', 'deleteAction', 'getAction', 'getByIdAction', 'validateAction', 'rulesAction'];
     $resourceControllerClass = $this->controllerClassInfo->getClassPath('controller');
     $resourceController = new $resourceControllerClass();
     $controllerReflectionClass = new \ReflectionClass($resourceController);
     foreach ($controllerReflectionClass->getMethods() as $reflectionMethod) {
         if (!$reflectionMethod->isPublic()) {
             // methods that aren't public can't be controller actions
             continue;
         }
         if (!ReflectionUtility::classDefinesMethod($resourceControllerClass, $reflectionMethod->getName())) {
             // methods that aren't overridden in the specific controller cannot be service actions
             continue;
         }
         if (!preg_match('/Action$/', $reflectionMethod->getName())) {
             // all controller actions end with the string "Action"
             continue;
         }
         if (in_array($reflectionMethod->getName(), $expectedList)) {
             // these are one of the standard actions that are handled specifically by the framework. we
             // do not want to redefine these as custom actions
             continue;
         }
         $actionInfo = new \stdClass();
         $actionInfo->reflectionMethod = $reflectionMethod;
         $actionInfo->actionMethodName = preg_replace('/Action$/', '', $reflectionMethod->getName());
         $actionInfo->buildMethodName = 'build' . ucfirst($actionInfo->actionMethodName) . 'Data';
         $customCommitActions[] = $actionInfo;
     }
     return $customCommitActions;
 }
コード例 #2
0
 public function testClassThatInheritsMethodWithoutOverrideReturnsFalse()
 {
     $reflectionUtility = new ReflectionUtility();
     $this->assertFalse($reflectionUtility->classDefinesMethod(ReflectionDerivedClass::class, 'theBaseMethod'));
 }