public function onPrepareWorkspaceCreateWorkspace(WorkspaceEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
    {
        $workspace = $event->getWorkspace();
        $connection = $this->ensureConnection($workspace->getHost());

        $workspacePath = $workspace->getHost()->getPath();
        if ($connection->isDirectory($workspacePath) === false && $connection->createDirectory($workspacePath) === false) {
            throw new TaskRuntimeException(sprintf('The workspace path "%s" does not exist and could not be created.', $workspacePath), $this);
        }

        $directories = array_merge(
            array(
                $workspace->getReleasesDirectory(),
                $workspace->getDataDirectory(),
                $workspace->getCacheDirectory(),
            ),
            $workspace->getOtherDirectories()
        );

        foreach ($directories as $directory) {
            $context = array('directory' => $directory, 'event.task.action' => TaskInterface::ACTION_IN_PROGRESS);

            $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Creating directory "{directory}".', $eventName, $this, $context));
            if ($connection->isDirectory($directory) === false) {
                if ($connection->createDirectory($directory)) {
                    $context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
                    $context['output.resetLine'] = true;

                    $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Created directory "{directory}".', $eventName, $this, $context));
                } else {
                    $context['event.task.action'] = TaskInterface::ACTION_FAILED;
                    $context['output.resetLine'] = true;

                    $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed creating directory "{directory}".', $eventName, $this, $context));
                }
            } else {
                $context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
                $context['output.resetLine'] = true;

                $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Directory "{directory}" exists.', $eventName, $this, $context));
            }
        }
    }
public function onPrepareWorkspaceCreateWorkspace(WorkspaceEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
    {
        $workspace = $event->getWorkspace();
        $connection = $this->ensureConnection($workspace->getHost());

        $workspacePath = $workspace->getHost()->getPath();
        if ($connection->isDirectory($workspacePath) === false && $connection->createDirectory($workspacePath) === false) {
            throw new TaskRuntimeException(sprintf('The workspace path "%s" does not exist and could not be created.', $workspacePath), $this);
        }

        $directories = array_merge(
            array(
                $workspace->getReleasesDirectory(),
                $workspace->getDataDirectory(),
                $workspace->getCacheDirectory(),
            ),
            $workspace->getOtherDirectories()
        );

        foreach ($directories as $directory) {
            $context = array('directory' => $directory, 'event.task.action' => TaskInterface::ACTION_IN_PROGRESS);

            $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Creating directory "{directory}".', $eventName, $this, $context));
            if ($connection->isDirectory($directory) === false) {
                if ($connection->createDirectory($directory)) {
                    $context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
                    $context['output.resetLine'] = true;

                    $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Created directory "{directory}".', $eventName, $this, $context));
                } else {
                    $context['event.task.action'] = TaskInterface::ACTION_FAILED;
                    $context['output.resetLine'] = true;

                    $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed creating directory "{directory}".', $eventName, $this, $context));
                }
            } else {
                $context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
                $context['output.resetLine'] = true;

                $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Directory "{directory}" exists.', $eventName, $this, $context));
            }
        }
    }
public function onPrepareWorkspaceCreateWorkspace ( WorkspaceEvent $ event , $ eventName , EventDispatcherInterface $ eventDispatcher ) { $ workspace = $ event -> getWorkspace ( ) ; $ connection = $ this -> ensureConnection ( $ workspace -> getHost ( ) ) ; $ workspacePath = $ workspace -> getHost ( ) -> getPath ( ) ; if ( $ connection -> isDirectory ( $ workspacePath ) === false && $ connection -> createDirectory ( $ workspacePath ) === false ) { throw new TaskRuntimeException ( sprintf ( 'The workspace path "%s" does not exist and could not be created.' , $ workspacePath ) , $ this ) ; } $ directories = array_merge ( array ( $ workspace -> getReleasesDirectory ( ) , $ workspace -> getDataDirectory ( ) , $ workspace -> getCacheDirectory ( ) , ) , $ workspace -> getOtherDirectories ( ) ) ; foreach ( $ directories as $ directory ) { $ context = array ( 'directory' => $ directory , 'event.task.action' => TaskInterface :: ACTION_IN_PROGRESS ) ; $ eventDispatcher -> dispatch ( AccompliEvents :: LOG , new LogEvent ( LogLevel :: INFO , 'Creating directory "{directory}".' , $ eventName , $ this , $ context ) ) ; if ( $ connection -> isDirectory ( $ directory ) === false ) { if ( $ connection -> createDirectory ( $ directory ) ) { $ context [ 'event.task.action' ] = TaskInterface :: ACTION_COMPLETED ; $ context [ 'output.resetLine' ] = true ; $ eventDispatcher -> dispatch ( AccompliEvents :: LOG , new LogEvent ( LogLevel :: INFO , 'Created directory "{directory}".' , $ eventName , $ this , $ context ) ) ; } else { $ context [ 'event.task.action' ] = TaskInterface :: ACTION_FAILED ; $ context [ 'output.resetLine' ] = true ; $ eventDispatcher -> dispatch ( AccompliEvents :: LOG , new LogEvent ( LogLevel :: WARNING , 'Failed creating directory "{directory}".' , $ eventName , $ this , $ context ) ) ; } } else { $ context [ 'event.task.action' ] = TaskInterface :: ACTION_COMPLETED ; $ context [ 'output.resetLine' ] = true ; $ eventDispatcher -> dispatch ( AccompliEvents :: LOG , new LogEvent ( LogLevel :: INFO , 'Directory "{directory}" exists.' , $ eventName , $ this , $ context ) ) ; } } }
Creates the workspace directories when not already existing.

@param WorkspaceEvent           $event
@param string                   $eventName
@param EventDispatcherInterface $eventDispatcher

@throws TaskRuntimeException when the workspace path doesn't exist and can't be created.
Creates the workspace directories when not already existing .