Q:

SilverStripe check whether Controller action is called

Is there a way to check if a controller's action is called?
private static $url_handlers = array(
    '$Foo!' => 'Bar'
);

// action 'Bar' is allowed ...

public function Bar(SS_HTTPRequest $request) {
    // method body
}

public function checkBar() {
    // Check if Bar is called
}

A:

As an aside to WillParky93's answer, which will work for repeated action calls on a single controller instance, you can also use Controller::getAction() to check which action is being executed in the current request:
if ($this->getAction() === 'Bar') {
    // foo something
}

Or if you're expecting different instances of your controller to be called multiple times in the same request you could do what WillParky93 suggested, but use a static property instead so the state will persist over different instances.

