add('stages', $this::class); $context->get('logger')->debug("Pass: " . $this::class); if (!in_array(PhpDocumentorStage::class, $context->get('stages'))) { throw new ContextException(sprintf('Stage "%s" needs to be done after stage "%s".', 'JsonAutodocStage', 'PhpDocumentorStage')); } $output_directory = $context->directory->output; /** @var Package */ $package = $context->get('package'); // FIXME: This should be a real class. (and encoded / decoded with symfony/serializer ?) $json = new stdClass(); $json->title = $context->get('title'); $json->prefix = $package->get('prefix'); $json->slogan = $package->get('slogan'); $json->version = $package->get('version'); $json->revision = ($context->has('git') ? $context->get('git')->getCommit() : ''); $json->date = (new DateTime())->format(DateTimeInterface::W3C); $json->urls = new stdClass(); $json->urls->package = $package->get('url_package'); $json->urls->documentation = $package->get('url_documentation'); $json->urls->development = $package->get('url_development'); $json->urls->repository = $context->has('git_asked') ? ($context->get('git_asked')->getRepositoryUrl() ?? '') : ''; file_put_contents($output_directory . '/autodoc.json', json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); $context->set('autodoc.json', $json); return $context; } }