ZF\Apigility\Admin\Controller\PackageController::create PHP Метод

create() приватный Метод

Create a package, given a format and options.
private create ( string $format, array $params ) : array | ZF\ApiProblem\ApiProblemResponse
$format string
$params array
Результат array | ZF\ApiProblem\ApiProblemResponse
    private function create($format, array $params)
    {
        if (!$format || !is_string($format) || !in_array(strtolower($format), ['zip', 'tar', 'tgz', 'zpk'])) {
            return new ApiProblemResponse(new ApiProblem(422, 'Format parameter not valid, we accept only zip, tar, tgz or zpk type', 'https://tools.ietf.org/html/rfc4918', 'Unprocessable Entity'));
        }
        $format = strtolower($format);
        $fileId = uniqid();
        $package = $this->getPackageFile($fileId, $format);
        $cmd = sprintf('php %s build %s', $this->zfdeployPath, $package);
        $apis = array_key_exists('apis', $params) ? $params['apis'] : null;
        $cmd .= $this->createModulesOption($apis);
        $composer = array_key_exists('composer', $params) ? $params['composer'] : null;
        $cmd .= $this->createComposerOption($composer);
        $config = array_key_exists('config', $params) ? $params['config'] : null;
        $cmd .= $this->createConfigOption($config);
        if ($format === 'zpk') {
            $cmd .= $this->createZpkOptions($params);
        }
        // Execute zf-deploy
        shell_exec($cmd);
        if (!file_exists($package)) {
            return new ApiProblemResponse(new ApiProblem(500, 'Unable to create package, or error creating package'));
        }
        return ['token' => $fileId, 'format' => $format];
    }