Check if action name is available

Returns false when
1. method is not found
2. method is not public
3. method letters case error

@param object $object The object of controller
@param string $action The name of action
@return bool
15374
public function isActionAvailable($object, $action)
    {
        $method = $this->getActionMethod($action);
        try {
            $ref = new \ReflectionMethod($object, $method);
            if ($ref->isPublic() && $method === $ref->name) {
                return true;
            } else {
                return false;
            }
        } catch (\ReflectionException $e) {
            return false;
        }
    }
1314445
public function checkAction($actions)
    {
        if (!$this->action) {
            return false;
        }

        if (in_array($this->action, (array)$actions)) {
            return true;
        }

        return false;
    }
694492
protected function check_access($action = null)
	{
		is_null($action) and $action = $this->request->action;

		if ($this->has_access($action) === false)
		{
			$context = array(
				'form' => array(
					'%action%' => $action,
					'%items%'  => $this->get_name(999),
				)
			);

			\Logger::instance('alert')->error(gettext('You are not authorized to %action% %items%.'), $context);

			return \Response::redirect_back(\Uri::admin(false));
		}
	}
1190469
public function getActivityStatus(KModelEntityInterface $object, $action = null)
    {
        $status = $object->getStatus();

        // Commands may change the original status of an action.
        if ($action == 'after.add' && $status == KModelEntityInterface::STATUS_UPDATED) {
            $status = KModelEntityInterface::STATUS_CREATED;
        }

        // Ignore non-changing edits.
        if ($action == 'after.edit' && $status == KModelEntityInterface::STATUS_FETCHED) {
            $status = null;
        }

        return $status;
    }
1292743
public function isValid($action) {
		$authCtrl=$this->_getAuthController();
		$isValid=$authCtrl->_isValidUser($action);
		if(!$isValid){
			$authCtrl->_autoConnect();
			return $authCtrl->_isValidUser($action);
		}
		return $isValid;
	}
1372677
public function hasAction($controller, $action = null)
    {
        if ($action === null) {
            list($controller, $action) = explode('.', $controller);
        }
        return in_array("{$controller}.{$action}", $this->action_names);
    }
470670
public function passesOrFail($action = null)
    {
        if(  !$this->passes($action) ){
            throw new ValidatorException( $this->errorsBag() );
        }

        return true;
    }
1002783
private static function isValidObject($object): bool {
        if (null === $object) {
            return false;
        }
        if (!\is_object($object)) {
            return false;
        }
        return true;
    }
1196168
protected function _mapAction($action) {
		$actionMap = $this->getConfig('actionMap');
		if (isset($actionMap[$action]) && method_exists($this, $actionMap[$action]['method'])) {
			$pass = (array)$this->_getRequest()->param('pass');
			call_user_func_array([$this, $actionMap[$action]['method']], $pass);

			if ($this->_redirectResponse instanceof Response) {
				return $this->_redirectResponse;
			}

			if (is_string($actionMap[$action]['view'])) {
				try {
					return $this->getController()->render($this->getController()->request->param('action'));
				} catch (MissingTemplateException $e) {
					return $this->getController()->render($actionMap[$action]['view']);
				}
			}

				return $this->_getResponse();
			}

		return false;
	}
1171512
static function isCurrentAction( $action ) {

		if ( isset( $_REQUEST['action'] ) && -1 !== (int) $_REQUEST['action'] ) {
			$compare = $_REQUEST['action'];
		} elseif ( isset( $_REQUEST['action2'] ) && -1 !== (int) $_REQUEST['action2'] ) {
			$compare = $_REQUEST['action2'];
		} else {
			return false;
		}

		return ( $action === $compare );
	}
22117
def validate_object_action(self, action_name, obj=None):
        
        action_method = getattr(self, action_name)
        if not getattr(action_method, 'detail', False) and action_name not in ('update', 'partial_update', 'destroy'):
            # DRF does not add flag 'detail' to update and delete actions, however they execute operation with
            # particular object. We need to enable validation for them too.
            return
        validators = getattr(self, action_name + '_validators', [])
        for validator in validators:
            validator(obj or self.get_object())
198787
protected function checkActionAlreadyExists($action, $controllers)
    {
        $controllerName = $action->getControllerName();
        if (!array_key_exists($controllerName, $controllers)) {
            return false;
        }

        if (!array_key_exists($action->getMethod(), $controllers[$controllerName])) {
            return false;
        }

        return true;
    }
1237287
public static function isMethod($action) {
        switch (strtoupper($action)) {
        case 'GET':
            return $_SERVER['REQUEST_METHOD'] == 'GET';
        case 'POST':
            return $_SERVER['REQUEST_METHOD'] == 'POST';
        case 'DELETE':
            return $_SERVER['REQUEST_METHOD'] == 'DELETE'
            ?: (isset($_POST['_method']) && $_POST['_method'] == 'DELETE');
        case 'PUT':
            return $_SERVER['REQUEST_METHOD'] == 'PUT'
            ?: (isset($_POST['_method']) && $_POST['_method'] == 'PUT');
        case 'AJAX':
            return static::isAjax();
        case 'wechat':
            return static::isWeChat();
        case 'mobile':
            return static::isMobile();
        }
    }
722412
public function isActionAvailable($action, $payment = null)
    {
        if ($payment) {
            $this->setPayment($payment);
        }

        $payment = $this->getPayment();

        $isAvailable = in_array($action, $this->getAvailableActions($payment->getAction(), $payment->getStatus()));

        if ($isAvailable) {
            $isAvailable = false;

            switch ($action) {
                case 'refund':
                    $isAvailable = ($payment->getAmount() > $payment->getRefundedAmount());
                    break;
            }
        }

        return $isAvailable;
    }
438015
public function canAccessAction(string $controllerName, string $action): bool
    {
        if (isset($this->actions[$controllerName][$action])) {
            if (!$this->actions[$controllerName][$action]) {
                return true;
            }

            foreach ($this->actions[$controllerName][$action] as $role) {
                if ($this->hasRoleWithName($role)) {
                    return true;
                }
            }

            return false;
        }

        return $this->canAccessController($controllerName);
    }
1208924
public function beforeAction($action)
    {
        if (!parent::beforeAction($action)) {
            return false;
        }
        switch ($action->id) {
        case 'index':
        case 'profile':
        case 'profilePicture':
            if (Yii::$app->user->isGuest) {
                $this->redirect(['login']);

                return false;
            }
            break;
        case 'login':
        case 'recovery':
            if ($action->id === 'recovery' && !$this->module->recoveryEnabled) {
                throw new AccessDeniedHttpException(Yii::t('usr', 'Password recovery has not been enabled.'));
            }
            if (!Yii::$app->user->isGuest) {
                $this->goBack();

                return false;
            }
            break;
        case 'register':
            if (!$this->module->registrationEnabled) {
                throw new AccessDeniedHttpException(Yii::t('usr', 'Registration has not been enabled.'));
            }
            if (!Yii::$app->user->isGuest) {
                $this->redirect(['profile']);

                return false;
            }
            break;
        case 'verify':
            if (!isset($_GET['activationKey'])) {
                throw new BadRequestHttpException(Yii::t('usr', 'Activation key is missing.'));
            }
            break;
        }

        return true;
    }
634273
protected function _directMapping($action) {
		if (!method_exists($this, $action)) {
			return false;
		}

		$pass = (array)$this->_getRequest()->param('pass');
		$result = call_user_func_array([$this, $action], $pass);

		if ($result instanceof Response) {
			return $result;
		}

		return $this->getController()->render($action);
	}