src/Admin/Model/DoctrineRpcServiceModel.php
/**
     * Create a controller in the current module named for the given service
     *
     * @param string $serviceName
     * @return mixed
     */
Create a controller in the current module named for the given service
@param string $serviceName
@return mixed
Create a controller in the current module named for the given service @param string $serviceName @return mixed
public function createController($serviceName)
    {
        $module     = $this->module;
        $version    = $this->moduleEntity->getLatestVersion();
        $serviceName = str_replace("\\", "/", $serviceName);
        $srcPath = $this->modules->getRpcPath($module, $version, $serviceName);
        if (! file_exists($srcPath)) {
            mkdir($srcPath, 0775, true);
        }
        $className         = sprintf('%sController', $serviceName);
        $classPath         = sprintf('%s/%s.php', $srcPath, $className);
        $controllerService = sprintf('%s\\V%s\\Rpc\\%s\\Controller', $module, $version, $serviceName);
        if (file_exists($classPath)) {
            throw new Exception\RuntimeException(sprintf(
                'The controller "%s" already exists',
                $className
            ));
        }
        $view = new ViewModel([
            'module'      => $module,
            'classname'   => $className,
            'servicename' => $serviceName,
            'version'     => $version,
        ]);
        $resolver = new Resolver\TemplateMapResolver([
            'code-connected/rpc-controller' => __DIR__ . '/../../../view/doctrine/rpc-controller.phtml',
        ]);
        $view->setTemplate('code-connected/rpc-controller');
        $renderer = new PhpRenderer();
        $renderer->setResolver($resolver);
        if (! file_put_contents(
            $classPath,
            "<" . "?php\n" . $renderer->render($view)
        )) {
            return false;
        }
        $fullClassName = sprintf('%s\\V%s\\Rpc\\%s\\%s', $module, $version, $serviceName, $className);
        $this->configResource->patch(
            [
                'controllers' => [
                    'aliases' => [
                        $controllerService => $fullClassName,
                    ],
                    'factories' => [
                        $fullClassName => InvokableFactory::class,
                    ],
                ],
            ],
            true
        );
        return (object) [
            'class'   => $fullClassName,
            'file'    => $classPath,
            'service' => $controllerService,
        ];
    }
public function createController ( $ serviceName ) { $ module = $ this -> module ; $ version = $ this -> moduleEntity -> getLatestVersion ( ) ; $ serviceName = str_replace ( " \\ " , " / " , $ serviceName ) ; $ srcPath = $ this -> modules -> getRpcPath ( $ module , $ version , $ serviceName ) ; if ( ! file_exists ( $ srcPath ) ) { mkdir ( $ srcPath , 0775 , true ) ; } $ className = sprintf ( '%sController' , $ serviceName ) ; $ classPath = sprintf ( '%s/%s.php' , $ srcPath , $ className ) ; $ controllerService = sprintf ( '%s\\V%s\\Rpc\\%s\\Controller' , $ module , $ version , $ serviceName ) ; if ( file_exists ( $ classPath ) ) { throw new Exception \ RuntimeException ( sprintf ( 'The controller "%s" already exists' , $ className ) ) ; } $ view = new ViewModel ( [ 'module' => $ module , 'classname' => $ className , 'servicename' => $ serviceName , 'version' => $ version , ] ) ; $ resolver = new Resolver \ TemplateMapResolver ( [ 'code-connected/rpc-controller' => __DIR__ . '/../../../view/doctrine/rpc-controller.phtml' , ] ) ; $ view -> setTemplate ( 'code-connected/rpc-controller' ) ; $ renderer = new PhpRenderer ( ) ; $ renderer -> setResolver ( $ resolver ) ; if ( ! file_put_contents ( $ classPath , " < " . " ?php \n " . $ renderer -> render ( $ view ) ) ) { return false ; } $ fullClassName = sprintf ( '%s\\V%s\\Rpc\\%s\\%s' , $ module , $ version , $ serviceName , $ className ) ; $ this -> configResource -> patch ( [ 'controllers' => [ 'aliases' => [ $ controllerService => $ fullClassName , ] , 'factories' => [ $ fullClassName => InvokableFactory :: class , ] , ] , ] , true ) ; return ( object ) [ 'class' => $ fullClassName , 'file' => $ classPath , 'service' => $ controllerService , ] ; }
Create a controller in the current module named for the given service
 @param string $serviceName
 @return mixed
Create a controller in the current module named for the given service @param string $serviceName @return mixed