protected function runInsertSudoerProcess() 
    {
        if (!$this->input->getOption('user_name') || !$this->input->getOption('user_password') || !$this->input->getOption('user_email')) {
            $this->output->writeln('<info>You have to specify all option in order to insert a new superadmin user (--user_name, --user_password, --user_email)</info>');
            return $this;
        }

        # Check if user already exists in db
        if (null === $adminUser = $this->entyMgr
                        ->getRepository('BackBee\Security\User')
                        ->findOneBy(array('_login' => $this->input->getOption('user_name')))) {
            $adminUser = $this->createUser(
                            $this->input->getOption('user_name'),
                            $this->input->getOption('user_password'),
                            $this->input->getOption('user_email')
                        );
            $this->output->writeln('<info>New user created.</info>');
        }

        # Recreate security.yml
        $securityConf = $this->bbapp->getConfig()->getSecurityConfig();
        if (!array_key_exists($adminUser->getLogin(), $securityConf['sudoers'])) {
            $securityConf['sudoers'][$adminUser->getLogin()] = $adminUser->getId();

            file_put_contents(
                $this->bbapp->getBaseDir().DIRECTORY_SEPARATOR.'repository/Config/security.yml',
                Yaml::dump($securityConf)
            );

            $this->output->writeln('<info>User added in security.yml file.</info>');
        }

        return $this;
    }
protected function runInsertSudoerProcess() 
    {
        if (!$this->input->getOption('user_name') || !$this->input->getOption('user_password') || !$this->input->getOption('user_email')) {
            $this->output->writeln('<info>You have to specify all option in order to insert a new superadmin user (--user_name, --user_password, --user_email)</info>');
            return $this;
        }

        # Check if user already exists in db
        if (null === $adminUser = $this->entyMgr
                        ->getRepository('BackBee\Security\User')
                        ->findOneBy(array('_login' => $this->input->getOption('user_name')))) {
            $adminUser = $this->createUser(
                            $this->input->getOption('user_name'),
                            $this->input->getOption('user_password'),
                            $this->input->getOption('user_email')
                        );
            $this->output->writeln('<info>New user created.</info>');
        }

        # Recreate security.yml
        $securityConf = $this->bbapp->getConfig()->getSecurityConfig();
        if (!array_key_exists($adminUser->getLogin(), $securityConf['sudoers'])) {
            $securityConf['sudoers'][$adminUser->getLogin()] = $adminUser->getId();

            file_put_contents(
                $this->bbapp->getBaseDir().DIRECTORY_SEPARATOR.'repository/Config/security.yml',
                Yaml::dump($securityConf)
            );

            $this->output->writeln('<info>User added in security.yml file.</info>');
        }

        return $this;
    }
protected function runInsertSudoerProcess ( ) { if ( ! $ this -> input -> getOption ( 'user_name' ) || ! $ this -> input -> getOption ( 'user_password' ) || ! $ this -> input -> getOption ( 'user_email' ) ) { $ this -> output -> writeln ( '<info>You have to specify all option in order to insert a new superadmin user (--user_name, --user_password, --user_email)</info>' ) ; return $ this ; } # Check if user already exists in db if ( null === $ adminUser = $ this -> entyMgr -> getRepository ( 'BackBee\Security\User' ) -> findOneBy ( array ( '_login' => $ this -> input -> getOption ( 'user_name' ) ) ) ) { $ adminUser = $ this -> createUser ( $ this -> input -> getOption ( 'user_name' ) , $ this -> input -> getOption ( 'user_password' ) , $ this -> input -> getOption ( 'user_email' ) ) ; $ this -> output -> writeln ( '<info>New user created.</info>' ) ; } # Recreate security.yml $ securityConf = $ this -> bbapp -> getConfig ( ) -> getSecurityConfig ( ) ; if ( ! array_key_exists ( $ adminUser -> getLogin ( ) , $ securityConf [ 'sudoers' ] ) ) { $ securityConf [ 'sudoers' ] [ $ adminUser -> getLogin ( ) ] = $ adminUser -> getId ( ) ; file_put_contents ( $ this -> bbapp -> getBaseDir ( ) . DIRECTORY_SEPARATOR . 'repository/Config/security.yml' , Yaml :: dump ( $ securityConf ) ) ; $ this -> output -> writeln ( '<info>User added in security.yml file.</info>' ) ; } return $ this ; }
Insert the user in DB and security.yml file

@return CreateSudoerCommand
Insert the user in DB and security . yml file