<commit_before><?php

declare(strict_types=1);

/*
 * This file is part of eelly package.
 *
 * (c) eelly.com
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Shadon\Events\Listener;

use Phalcon\Events\Event;
use Phalcon\Mvc\Dispatcher;

/**
 * @author hehui<<EMAIL>>
 */
class AclListener extends AbstractListener
{
    public function beforeExecuteRoute(Event $event, Dispatcher $dispatcher): void
    {
    }
}<commit_msg>Add internal annotation<commit_after><?php

declare(strict_types=1);

/*
 * This file is part of eelly package.
 *
 * (c) eelly.com
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Shadon\Events\Listener;

use League\OAuth2\Server\Exception\OAuthServerException;
use Phalcon\Events\Event;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Text;
use Shadon\Application\ApplicationConst;

/**
 * 访问控制.
 *
 * @author hehui<<EMAIL>>
 */
class AclListener extends AbstractListener
{
    /**
     * 仅内部可调用的服务
     *
     * @var string
     */
    private const INTERNAL_ANNOTATION = 'internal';

    public function beforeExecuteRoute(Event $event, Dispatcher $dispatcher): void
    {
        // Parse the annotations in the method currently executed
        $annotations = $this->annotations->getMethod(
            $dispatcher->getControllerClass(),
            $dispatcher->getActiveMethod()
        );
        if ($annotations->has(self::INTERNAL_ANNOTATION)) {
            if (!Text::startsWith(ApplicationConst::$oauth['oauth_client_id'], self::INTERNAL_ANNOTATION)) {
                /* @var \Phalcon\Http\Request $request */
                $request = $this->getDI()->getShared('request');
                throw OAuthServerException::invalidScope($request->getURI());
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.11629125196437926, 'fraction_numerical': 0.001571503404924044, 'mean_word_length': 3.197802197802198, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4105703', 'n_tokens_mistral': 569, 'n_tokens_neox': 564, 'n_words': 138}