src/CommandBus/Config/InitHandler.php
public function handle(InitMessage $message)
    {
        $output = $message->getOutput();
        $configStorage = $message->getConfigStorage();

        if ($configStorage->isInitialized($message->getConfig())) {
            $output->writeln(sprintf(
                '%s is already initialised!',
                $message->getCliCommand()->getApplication()->getName()
            ));

            return;
        }

        $result = $configStorage->write($message->getConfig());

        if ($result !== false) {
            $msg = sprintf('Config file created at "<info>%s</info>".', $message->getConfig()->getFileName());
        } else {
            $msg = sprintf(
                '<error>Error: Could not create and write file "<info>%s</info>". '.
                'Please check file and directory permissions.</error>',
                $message->getConfig()->getFileName()
            );
        }
        $output->writeln($msg);
    }
public function handle(InitMessage $message)
    {
        $output = $message->getOutput();
        $configStorage = $message->getConfigStorage();

        if ($configStorage->isInitialized($message->getConfig())) {
            $output->writeln(sprintf(
                '%s is already initialised!',
                $message->getCliCommand()->getApplication()->getName()
            ));

            return;
        }

        $result = $configStorage->write($message->getConfig());

        if ($result !== false) {
            $msg = sprintf('Config file created at "<info>%s</info>".', $message->getConfig()->getFileName());
        } else {
            $msg = sprintf(
                '<error>Error: Could not create and write file "<info>%s</info>". '.
                'Please check file and directory permissions.</error>',
                $message->getConfig()->getFileName()
            );
        }
        $output->writeln($msg);
    }
public function handle ( InitMessage $ message ) { $ output = $ message -> getOutput ( ) ; $ configStorage = $ message -> getConfigStorage ( ) ; if ( $ configStorage -> isInitialized ( $ message -> getConfig ( ) ) ) { $ output -> writeln ( sprintf ( '%s is already initialised!' , $ message -> getCliCommand ( ) -> getApplication ( ) -> getName ( ) ) ) ; return ; } $ result = $ configStorage -> write ( $ message -> getConfig ( ) ) ; if ( $ result !== false ) { $ msg = sprintf ( 'Config file created at "<info>%s</info>".' , $ message -> getConfig ( ) -> getFileName ( ) ) ; } else { $ msg = sprintf ( '<error>Error: Could not create and write file "<info>%s</info>". ' . 'Please check file and directory permissions.</error>' , $ message -> getConfig ( ) -> getFileName ( ) ) ; } $ output -> writeln ( $ msg ) ; }
Handle an InitMessage. Creates an end-user configuration file using default values. If the file already exists
it simply exists without doing anything.

@param InitMessage $message
Handle an InitMessage . Creates an end - user configuration file using default values . If the file already exists it simply exists without doing anything .