public function onKernelController(FilterControllerEvent $event)
    {
        $controllerDefinition = $event->getController();
        $controller = $controllerDefinition[0];

        if (
            !$controller instanceof SecuredControllerInterface &&
            !$controller instanceof SecuredObjectControllerInterface
        ) {
            return;
        }

        $request = $event->getRequest();

        // find appropriate permission type for request
        $permission = '';

        switch ($request->getMethod()) {
            case 'GET':
                $permission = PermissionTypes::VIEW;
                break;
            case 'POST':
                if ('postAction' == $controllerDefinition[1]) { // means that the ClassResourceInterface has to be used
                    $permission = PermissionTypes::ADD;
                } else {
                    $permission = PermissionTypes::EDIT;
                }
                break;
            case 'PUT':
            case 'PATCH':
                $permission = PermissionTypes::EDIT;
                break;
            case 'DELETE':
                $permission = PermissionTypes::DELETE;
                break;
        }

        $securityContext = null;
        $locale = $controller->getLocale($request);
        $objectType = null;
        $objectId = null;

        if ($controller instanceof SecuredObjectControllerInterface) {
            $objectType = $controller->getSecuredClass();
            $objectId = $controller->getSecuredObjectId($request);
        }

        // check permission
        if ($controller instanceof SecuredControllerInterface) {
            $securityContext = $controller->getSecurityContext();
        }

        if (null !== $securityContext) {
            $this->securityChecker->checkPermission(
                new SecurityCondition($securityContext, $locale, $objectType, $objectId),
                $permission
            );
        }
    }