private function secure(AbstractAdmin $admin, $attributes, $object = null)
    {
        if (!is_array($attributes)) {
            $attributes = [$attributes];
        }

        if (is_null($object)) {
            // object is required at least to get the class to check permissions against in ContentVoter
            $entityClass = $admin->getEntityClass();
            $object = new $entityClass();
        }

        if (!$this->get('security.authorization_checker')->isGranted($attributes, $object)) {
            throw new AccessDeniedException();
        }
    }