recursiveDelete() public static method

Recursive delete
public static recursiveDelete ( string $dir ) : boolean
$dir string
return boolean
コード例 #1
0
 /**
  * Delete a DB-Connected service
  *
  * @param  DbConnectedRestServiceEntity $entity
  * @param  bool $recursive
  * @return true
  */
 public function deleteService(DbConnectedRestServiceEntity $entity, $recursive = false)
 {
     $this->restModel->deleteService($entity->controllerServiceName);
     $this->deleteDbConnectedConfig($entity);
     if ($recursive) {
         $reflection = new ReflectionClass($entity->entityClass);
         Utility::recursiveDelete(dirname($reflection->getFileName()));
     }
     return true;
 }
コード例 #2
0
 /**
  * Delete a named service
  *
  * @todo Remove content-negotiation and/or HAL configuration?
  * @param string $controllerService
  * @param bool $recursive
  * @return true
  */
 public function deleteService($controllerService, $recursive = false)
 {
     try {
         $service = $this->fetch($controllerService);
     } catch (Exception\RuntimeException $e) {
         throw new Exception\RuntimeException(sprintf('Cannot delete REST service "%s"; not found', $controllerService), 404);
     }
     if ($recursive) {
         $reflection = new ReflectionClass($service->resourceClass);
         Utility::recursiveDelete(dirname($reflection->getFileName()));
     }
     $this->deleteRoute($service);
     $response = $this->deleteDoctrineRestConfig($service);
     if ($response instanceof ApiProblem) {
         return $response;
     }
     return true;
 }
コード例 #3
0
 /**
  * Delete a named service
  *
  * @todo   Remove content-negotiation and/or HAL configuration?
  * @param  string $controllerService
  * @param  bool   $recursive
  * @return true
  * @throws Exception\RuntimeException
  */
 public function deleteService($controllerService, $recursive = false)
 {
     try {
         $service = $this->fetch($controllerService);
     } catch (Exception\RuntimeException $e) {
         throw new Exception\RuntimeException(sprintf('Cannot delete REST service "%s"; not found', $controllerService), 404);
     }
     $this->deleteRoute($service);
     $this->deleteRestConfig($service);
     $this->deleteContentNegotiationConfig($service);
     $this->deleteContentValidationConfig($service);
     $this->deleteHalConfig($service);
     $this->deleteAuthorizationConfig($service);
     $this->deleteVersioningConfig($service);
     $this->deleteServiceManagerConfig($service);
     if ($recursive) {
         $reflection = new ReflectionClass($service->resourceClass);
         Utility::recursiveDelete(dirname($reflection->getFileName()));
     }
     return true;
 }
コード例 #4
0
 /**
  * Delete an existing module
  *
  * @param  string $module
  * @param  string $path
  * @param  bool $recursive
  * @return boolean
  */
 public function deleteModule($module, $path = '.', $recursive = false)
 {
     $application = (require "{$path}/config/application.config.php");
     if (!is_array($application) || !isset($application['modules']) || !in_array($module, $application['modules'], true)) {
         // Module does not exist in configuration; nothing to do
         return true;
     }
     $modules = array_filter($application['modules'], function ($value) use($module) {
         return $module !== $value;
     });
     $application['modules'] = $modules;
     if (!$this->writeApplicationConfig($application, $path)) {
         // error writing application config
         return false;
     }
     if (!$recursive) {
         // Not a recursive deletion? done
         return true;
     }
     $modulePath = sprintf('%s/module/%s', $path, $module);
     if (!file_exists($modulePath)) {
         // module path does not exist; we can be done.
         return true;
     }
     Utility::recursiveDelete($modulePath);
     return true;
 }
コード例 #5
0
 /**
  * Delete a service
  *
  * @param  RpcServiceEntity $entity
  * @param  bool $recursive
  * @return true
  * @throws Exception\RuntimeException
  */
 public function deleteService(RpcServiceEntity $entity, $recursive = false)
 {
     $serviceName = $entity->controllerServiceName;
     $routeName = $entity->routeName;
     $this->deleteRouteConfig($routeName, $serviceName);
     $this->deleteRpcConfig($serviceName);
     $this->deleteContentNegotiationConfig($serviceName);
     $this->deleteContentValidationConfig($serviceName);
     $this->deleteVersioningConfig($routeName, $serviceName);
     $this->deleteAuthorizationConfig($serviceName);
     $this->deleteControllersConfig($serviceName);
     if ($recursive) {
         $className = substr($entity->controllerServiceName, 0, strrpos($entity->controllerServiceName, '\\')) . '\\' . $entity->serviceName . 'Controller';
         if (!class_exists($className)) {
             throw new Exception\RuntimeException(sprintf('I cannot determine the class name, tried with "%s"', $className), 400);
         }
         $reflection = new ReflectionClass($className);
         Utility::recursiveDelete(dirname($reflection->getFileName()));
     }
     return true;
 }