protected function findPolicy($class, $name, $namespace)
    {
        $namespace = $this->getNamespace($namespace);
        $policyClass = false;

        // plugin entities can have application overides defined.
        if ($namespace !== $this->appNamespace) {
            $policyClass = App::className($name, 'Policy\\' . $namespace, 'Policy');
        }

        // Check the application/plugin.
        if ($policyClass === false) {
            $policyClass = App::className($namespace . '.' . $name, 'Policy', 'Policy');
        }

        if ($policyClass === false) {
            throw new MissingPolicyException([$class]);
        }

        return new $policyClass();
    }