Delete public key

@param EventInterface $event The current event
327886
public function deleteKey(EventInterface $event) {
        $acl = $event->getAccessControl();

        if (!($acl instanceof MutableAdapterInterface)) {
            throw new ResourceException('Access control adapter is immutable', 405);
        }

        $request = $event->getRequest();
        $publicKey = $request->getRoute()->get('publickey');

        $keyExists = $acl->publicKeyExists($publicKey);

        if (!$keyExists) {
            throw new RuntimeException('Public key not found', 404);
        }

        $request = $event->getRequest();
        $publicKey = $request->getRoute()->get('publickey');

        $acl->deletePublicKey($publicKey);
    }
937843
public function setKey(EventInterface $event) {
        $acl = $event->getAccessControl();

        if (!($acl instanceof MutableAdapterInterface)) {
            throw new ResourceException('Access control adapter is immutable', 405);
        }

        $request = $event->getRequest();
        $data = json_decode($request->getContent(), true);

        if (!isset($data['privateKey'])) {
            throw new InvalidArgumentException('No privateKey provided', 400);
        }

        $publicKey = $request->getRoute()->get('publickey');
        $privateKey = $data['privateKey'];

        $keyExists = $acl->publicKeyExists($publicKey);

        if ($keyExists) {
            $acl->updatePrivateKey($publicKey, $privateKey);
        } else {
            $acl->addKeyPair($publicKey, $privateKey);
        }

        $event->getResponse()->setStatusCode($keyExists ? 200 : 201);
    }
466412
public function doUnserialize(EventInterface $event)/*# : bool */
    {
        /* @var CacheItem $item */
        $item = $event->getParam('item');
        $val = @unserialize($item->getStrVal());
        if (false !== $val) {
            $item->set($val);
        }
        return true;
    }
646709
public function handle(EventInterface $event)
    {
        $dir = yii::getAlias('@runtime');

        FileHelper::createDirectory($dir);
        file_put_contents($dir . DIRECTORY_SEPARATOR . 'events.log', $this->serializeEvent($event) . PHP_EOL, FILE_APPEND | LOCK_EX);
    }
1147408
public function updateMetadata(EventInterface $event) {
        $request = $event->getRequest();

        $event->getDatabase()->updateMetadata(
            $request->getUser(),
            $request->getImageIdentifier(),
            $event->getArgument('metadata')
        );

        $event->getDatabase()->setLastModifiedNow(
            $request->getUser(),
            $request->getImageIdentifier()
        );
    }
1299289
public static function remove(\core\event\base $event) {
        global $DB;

        $DB->delete_records(self::$table, array('cmid' => $event->contextinstanceid));
    }
408861
public function deleteBatch(EntityInterface $entity)
    {
        if (is_null($this->deleteBatch)) {
            $this->deleteBatch = WriteRequestBatch::factory($this->dynamoDb);
        }
        $this->deleteBatch->add(new DeleteRequest($this->formatKeyCondition($entity), $this->getEntityTable($entity)));
    }
40397
public function handle(EventInterface $event)
    {

        try {
            // load the application server instance
            /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */
            $applicationServer = $this->getApplicationServer();

            // write a log message that the event has been invoked
            $applicationServer->getSystemLogger()->info($event->getName());

            // load the service instance and create the SSL file if not available
            /** @var \AppserverIo\Appserver\Core\Api\ContainerService $service */
            $service = $applicationServer->newService('AppserverIo\Appserver\Core\Api\ContainerService');
            $service->createSslCertificate(new \SplFileInfo($service->getConfDir(CreateSslCertificateListener::DEFAULT_CERTIFICATE_NAME)));

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
878426
public function delete($event)
    {
        $formName = $event->sender->formName();
        $primaryKey = $event->sender->primaryKey;

        $this->model::deleteAll([
            'model' => $formName,
            'model_id' => $primaryKey,
        ]);
    }
775270
public function save(EventInterface $event)
    {
        $this->events[(string) $event->uuid()][] = new $event(
            $event->uuid(),
            $event->type(),
            $event->body(),
            $this->count($event->uuid()),
            $event->occurredOn()->format('Y-m-d H:i:s.u')
        );
    }
853327
public function handle(EventInterface $event)
    {
        // header获取日志ID和spanid请求跨度ID
        $logid = RequestContext::getRequest()->getHeaderLine('logid');
        $spanid = RequestContext::getRequest()->getHeaderLine('spanid');
        if (empty($logid)) {
            $logid = uniqid();
        }
        if (empty($spanid)) {
            $spanid = 0;
        }
        $uri = RequestContext::getRequest()->getUri();

        $contextData = [
            'logid'       => $logid,
            'spanid'      => $spanid,
            'uri'         => $uri,
            'requestTime' => microtime(true),
        ];

        RequestContext::setContextData($contextData);
    }
570296
public function handle(EventInterface $event)
    {

        try {
            // load the application server instance
            /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */
            $applicationServer = $this->getApplicationServer();

            // unbind the loggers from the naming directory
            foreach (array_keys($applicationServer->getLoggers()) as $name) {
                $applicationServer->getNamingDirectory()->unbind(sprintf('php:global/log/%s', $name));
            }

            // set the initialized loggers finally
            $applicationServer->setLoggers(array());

        } catch (\Exception $e) {
            error_log($e->__toString());
        }
    }
1318413
public function delete(ConfigDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== ($config = ConfigQuery::create()->findPk($event->getConfigId()))) {
            if (!$config->getSecured()) {
                $config->setDispatcher($dispatcher)->delete();

                $event->setConfig($config);
            }
        }
    }
1305987
public function deleteFromCache(EventInterface $event) {
        $request = $event->getRequest();
        $cacheDir = $this->getCacheDir($request->getUser(), $request->getImageIdentifier());

        if (is_dir($cacheDir)) {
            $this->rmdir($cacheDir);
        }
    }
524692
public function record(EventInterface $event)
    {
        $eventUuid = $event->uuid();
        $this->recordedEvents[(string) $eventUuid] = $event;
    }
427747
public function publish(EventInterface $event)
    {
        $commandsToDispatch = $this->eventBus->publish($event);

        $commands = $this->extractCommands($commandsToDispatch);
        foreach ($commands as $command) {
            $this->dispatch($command);
        }
    }
896185
public function handle(EventInterface $event)
    {
        $params = $event->getParams();

        if (count($params) < 1) {
            return;
        }

        // 初始化
        $spanid = 0;
        $logid = uniqid();

        $processName = $params[0];
        $uri = 'process-' . $processName;
        $flushInterval = 1;

        $contextData = [
            'logid'       => $logid,
            'spanid'      => $spanid,
            'uri'         => $uri,
            'requestTime' => microtime(true)
        ];

        App::getLogger()->setFlushInterval($flushInterval);
        RequestContext::setContextData($contextData);

        // 日志初始化
        App::getLogger()->initialize();
    }