generate write routes

@param string $service       service name
@param string $resource      resource name
@param array  $serviceConfig service configuration

@return void
552557
public function loadWriteRoutes($service, $resource, $serviceConfig)
    {
        $actionPost = ActionUtils::getRoutePost($service, $serviceConfig);
        $this->routes->add($resource . '.post', $actionPost);

        $actionPut = ActionUtils::getRoutePut($service, $serviceConfig);
        $this->routes->add($resource . '.put', $actionPut);

        $actionPostNoSlash = ActionUtils::getRoutePost($service, $serviceConfig);
        $actionPostNoSlash->setPath(substr($actionPostNoSlash->getPath(), 0, -1));
        $this->routes->add($resource . '.postNoSlash', $actionPostNoSlash);

        $actionPatch = ActionUtils::getRoutePatch($service, $serviceConfig);
        $this->routes->add($resource . '.patch', $actionPatch);

        $actionDelete = ActionUtils::getRouteDelete($service, $serviceConfig);
        $this->routes->add($resource . '.delete', $actionDelete);
    }
931162
protected function createRoute(ServiceLocatorInterface $serviceLocator, array $config): RouteInterface
    {
        $route = $serviceLocator->getService($config['name'], $config['options'] ?? []);
        if (array_key_exists('children', $config) === true) {
            $route = $this->createGroup($serviceLocator, $route, $config['children'], $config['abstract'] ?? null);
        }

        return $route;
    }
199160
protected function treatRoutesConfig(array $config): void
    {
        if (!\array_key_exists('routes', $config)) {
            return;
        }

        if (!\is_array($config['routes'])) {
            throw new RouterException('Config routes has to be an array');
        }

        foreach ($config['routes'] as $route) {
            if (!\array_key_exists('methods', $route)) {
                throw new RouterException('Config routes/methods is mandatory');
            }

            if (!\array_key_exists('url', $route)) {
                throw new RouterException('Config routes/url is mandatory');
            }

            if (!\array_key_exists('callback', $route)) {
                throw new RouterException('Config routes/callback is mandatory');
            }

            $newRoute = new Route($route['methods'], $route['url'], $route['callback']);

            if (\array_key_exists('constraints', $route)) {
                $newRoute->setParametersConstraints($route['constraints']);
            }

            if (\array_key_exists('middlewares', $route)) {
                if (!\is_array($route['middlewares'])) {
                    throw new RouterException('Config routes/middlewares has to be an array');
                }

                foreach ($route['middlewares'] as $middleware) {
                    $newRoute->addMiddleware($middleware);
                }
            }

            if (\array_key_exists('name', $route)) {
                if (!\is_string($route['name'])) {
                    throw new RouterException('Config routes/name has to be a string');
                }

                $newRoute->setName($route['name']);
            }

            if (\array_key_exists('host', $route)) {
                if (!\is_string($route['host'])) {
                    throw new RouterException('Config routes/host has to be a string');
                }

                $newRoute->setHost($route['host']);
            }

            if (\array_key_exists('host_constraints', $route)) {
                if (!\is_array($route['host_constraints'])) {
                    throw new RouterException('Config routes/host_constraints has to be an array');
                }

                $newRoute->setHostConstraints($route['host_constraints']);
            }

            if (\array_key_exists('optionals_parameters', $route)) {
                if (!\is_array($route['optionals_parameters'])) {
                    throw new RouterException('Config routes/optionals_parameters has to be an array');
                }

                $newRoute->setOptionalsParameters($route['optionals_parameters']);
            }

            $this->addRoute($newRoute);
        }
    }
1166962
public function write(Config $config)
    {
        $pathBuildDb = Config::KEY_BUILD . '/' . Config::KEY_DB . '/';

        /** @var array $artifacts */
        $artifacts = $config->get(Config::KEY_DEPLOY . '/' . Config::KEY_ARTIFACTS);
        $artifactsExport = '';
        foreach ($artifacts as $artifactName => $artifact) {
            $artifactVarExport = $this->varExport($artifact);
            $artifactsExport .= "'$artifactName' => $artifactVarExport,\n";
        }

        /** @var array $themes */
        $themes = $config->get(Config::KEY_DEPLOY . '/' . Config::KEY_THEMES);
        $themesExport = '';
        foreach ($themes as $theme) {
            $themesExport .= $this->varExport($theme) . ",\n";
        }

        $vars = [
            '{{GIT_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_GIT_BIN),
            '{{PHP_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_PHP_BIN),
            '{{TAR_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_TAR_BIN),
            '{{MYSQL_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_MYSQL_BIN),
            '{{COMPOSER_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_COMPOSER_BIN),
            '{{DEPLOYER_BIN}}' => $config->get(Config::KEY_ENV . '/' . Config::KEY_DEPLOYER_BIN),

            '{{GIT_URL}}' => $config->get(Config::KEY_DEPLOY . '/' . Config::KEY_GIT_URL),
            "'{{ARTIFACTS}}'" => trim($artifactsExport),
            "'{{THEMES}}'" => trim($themesExport),

            '{{DB_HOST}}' => $config->get($pathBuildDb . 'db-host'),
            '{{DB_NAME}}' => $config->get($pathBuildDb . 'db-name'),
            '{{DB_USER}}' => $config->get($pathBuildDb . 'db-user'),
            '{{DB_PASSWORD}}' => $config->get($pathBuildDb . 'db-password'),
        ];

        $search = array_keys($vars);
        $replace = array_values($vars);

        $md2Template = file_get_contents(__DIR__ . '/magedeploy2.template.php');
        $configFileContent = str_replace($search, $replace, $md2Template);

        file_put_contents(Config::FILENAME, $configFileContent);
    }
878705
private function reloadConfig($config = null, $service = '') {
        if (!$config) {
            $config       = $this->loadRuntimeCfg();
            $this->config = $config;
            $this->setVerbose($this->getOption('verbose'));
        }
        if ($config) {
            $services = isset($config['services']) ? $config['services'] : [];
            if ($service) {
                if (isset($services[ $service ]) && isset($this->services[ $service ])) {
                    $this->services[ $service ] = array_merge($this->services[ $service ], $services[ $service ]);
                    $status                     = isset($services[ $service ]['status']) ? $services[ $service ]['status'] : '';
                    if (!$status && $this->services[ $service ]['status'] == 'running') {
                        $this->services[ $service ]['status'] = 'reload';
                    }

                    return true;
                }

                return false;
            }
            foreach ($services as $s => $conf) {
                if (!isset($this->services[ $s ])) {
                    $this->services[ $s ] = $conf;
                    if ($conf['status'] != 'disabled') {
                        $this->services[ $s ]['status'] = 'new';
                    }
                } else {
                    $this->services[ $s ] = array_merge($this->services[ $s ], $conf);
                    $status               = isset($conf['status']) ? $conf['status'] : '';
                    if (!$status) {
                        if ($status == 'disabled') {
                            $this->services[ $s ]['status'] = 'disabled';
                        } else if ($this->services[ $s ]['status'] == 'running') {
                            $this->services[ $s ]['status'] = 'reload';
                        }
                    }
                }
            }
            $sids = array_keys($this->services);
            if ($sids) {
                foreach ($sids as $sid) {
                    if (!isset($services[ $sid ])) {
                        $this->services[ $sid ]['status'] = 'remove';
                    }
                }
            }

            return true;
        }

        return false;
    }
180332
private function findServiceIdsByTag(ContainerBuilder $container, ServiceConfig $serviceConfig)
    {
        $tag = $serviceConfig->get(ServiceConfig::FIND_TAG);

        $serviceIds = array();

        foreach ($container->findTaggedServiceIds($tag) as $id => $services) {
            foreach ((array) $services as $service) {
                if (null === $name = $this->findName($service, $serviceConfig)) {
                    throw new \InvalidArgumentException(
                        sprintf(
                            'Service "%s" must define a name attribute like "key" or "type" for "%s" tags.',
                            $id,
                            $tag
                        )
                    );
                }

                $serviceIds[$service[$name]] = $id;
            }
        }

        return $serviceIds;
    }
1134730
public function buildService(Container $container, ArrayResolver $serviceConfig, $serviceName)
    {
        return $this->serviceBuilder->buildService($container, $serviceConfig, $serviceName);
    }
692233
public function load(ContainerBuilder $container, array $config)
    {
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/config'));
        $loader->load('services.xml');

        if (!empty($config['path'])) {
            if (isset($config['path']['resources'])) {
                $container->setParameter('paths.resources.resource', $config['path']['resources']);
            }

            if (isset($config['path']['base'])) {
                $container->setParameter('paths.resources.base', $config['path']['base']);
            }
        }

        if (!empty($config['resource_map'])) {
            $container->setParameter('resource.map', $config['resource_map']);
        }
    }
1027104
function setServiceManagerConfig(array $smConfig)
    {
        if ($this->sm instanceof ServiceLocatorInterface)
            throw new \Exception(
                'Service Config is used on first time instancing, '
                .'Service Manager is configured for now you must use "getServiceManager()"'
            );

        $this->def_sm_config = Core\array_merge(
            $this->def_sm_config
            , $smConfig
        );

        return $this;
    }
1054182
public function write($path, $resource, Config $config)
    {
        $path = pathinfo($path)['filename'];

        return parent::write($path, $resource, $config);
    }
1069490
def _write_service_config(self):
        
        with open(self.config_path, 'w') as output:
            output.write(json.dumps(self.data, sort_keys=True, indent=4))
581601
public function registerService(Service\Serviceable $service, Service\Configurable $config)
    {
        $service->register($this->container, $config);
    }
610282
public function updateStream($path, $resource, Config $config)
    {
        return $this->write($path, $resource, $config);
    }
1074386
protected function generatePut(ResourceConfiguration $config)
    {
        $that = $this;

        $this->slim->put("{$this->baseRoute($config)}/:id", function () use ($that) {
            $that->executeRoute('update', func_get_args());
        });
    }
558600
private function generateConfiguration()
    {
        if (!in_array($this->format, array('yml', 'xml', 'php'))) {
            return;
        }

        $target = sprintf(
            '%s/Resources/config/routing/%s.%s',
            $this->bundle->getPath(),
            strtolower(str_replace('\\', '_', $this->document)),
            $this->format
        );

        $this->renderFile('config/routing.'.$this->format.'.twig', $target, array(
            'actions' => $this->actions,
            'route_prefix' => $this->routePrefix,
            'route_name_prefix' => $this->routeNamePrefix,
            'bundle' => $this->bundle->getName(),
            'document' => $this->document,
        ));
    }
1216145
private function initializeServiceDefinitions(array $mergedConfig, ContainerBuilder $container)
    {
        $initManager = $container->get(ServiceNames::SERVICE_DEFINITION_INITIALIZATION_MANAGER);
        $initManager->initializeServiceDefinitions($mergedConfig, $container);
    }
76022
private function updateActions(stdClass $config, stdClass $serviceData)
    {
        $servicePermissions = [
            "name"       => "admin." . $serviceData->serviceRouteName,
            "controller" => $serviceData->controllerNamespace . '\\' . $serviceData->controllerName,
            "actions"    => [
                $serviceData->aclPrefix . "_list",
                $serviceData->aclPrefix . "_create",
                $serviceData->aclPrefix . "_update",
                $serviceData->aclPrefix . "_delete",
                $serviceData->aclPrefix . "_force_delete",
            ],
        ];

        $contentChanged = false;

        foreach ( $config->acl->permissions as &$value ) {
            if( $value->name == "admin." . $serviceData->serviceRouteName ) {
                if( $this->confirm('Duplicate ACL found ' . "admin." . $serviceData->serviceRouteName . ' Confirm override', 'no') ) {
                    $contentChanged = true;
                    $value = $servicePermissions;
                    break;
                } else {
                    $this->abort('Can not override existing configuration. Aborting...');

                    return null;
                }
            }
        }

        if( ! $contentChanged )
            $config->acl->permissions = array_merge($config->acl->permissions, [$servicePermissions]);

        return $config;
    }