@see Command

@throws \InvalidArgumentException When the target directory does not exist
542678
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $bundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('bundle'));
        $output->writeln(sprintf('Vardius Crud generating for bundle "<info>%s</info>"', $bundle->getName()));

        $generator = new CrudGenerator($this->getContainer()->getParameter('kernel.root_dir'), $input->getOption('propel'), $bundle, $output);

        if ($input->getOption('propel') === true) {
            if ($schemas = $this->getSchemasFromBundle($bundle)) {
                $schemas = $this->getFinalSchemas($this->getContainer()->get('kernel'));

                $transformer = new \XmlToAppData(null, null, 'UTF-8');
                foreach ($schemas as $fileName => $array) {
                    foreach ($this->getDatabasesFromSchema($array[1], $transformer) as $database) {
                        $this->createForPropel($bundle, $database, $input->getArgument('classes'), $generator, $output);
                    }
                }
            } else {
                $output->writeln(sprintf('No <comment>*schemas.xml</comment> files found in bundle <comment>%s</comment>.', $bundle->getName()));
            }
        } else {
            $this->createForOrm($bundle, $input->getArgument('classes'), $generator, $output);
        }
    }
40951
protected function verifyMigrationDirectory($path)
    {
        if (!is_dir($path)) {
            throw new \InvalidArgumentException(sprintf(
                'Migration directory "%s" does not exist',
                $path
            ));
        }

        if (!is_writable($path)) {
            throw new \InvalidArgumentException(sprintf(
                'Migration directory "%s" is not writable',
                $path
            ));
        }
    }
286129
protected function doExecute()
    {
        $name        = $this->io->getArgument(0) ?: exit("Please enter command name");
        $namespace   = $this->io->getArgument(1) ?: exit("Please enter command namespace");
        $description = $this->getOption('d') ?: $name;

        if (!$name || !$namespace) {
            throw new \InvalidArgumentException('Need name & namespace.');
        }

        // Regularize Namespace
        $namespace = str_replace(['/', '\\'], ' ', $namespace);

        $namespace = ucwords($namespace);

        $namespace = str_replace(' ', '\\', $namespace);

        $namespace = explode('\\', $namespace);

        if ($namespace[0] == 'Command') {
            array_shift($namespace);
        }

        $class = $namespace;

        $class = array_pop($class);

        $namespace = implode('\\', $namespace);

        $replace = [
            '{{NAME}}' => $name,
            '{{NAMESPACE}}' => $namespace,
            '{{CLASS}}' => $class,
            '{{DESCRIPTION}}' => $description,
        ];

        $content = strtr($this->template, $replace);

        $config = Ioc::getConfig();

        $file = $config->get('path.root') . '/src/' . $namespace . '/' . $class . 'Command.php';

        $file = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $file);

        if (!File::write($file, $content)) {
            $this->out()->out('Failure when writing file.');

            return false;
        }

        $this->out('File generated: ' . $file);

        return true;
    }
408962
public function copyChildren($targetDir)
    {
        $info = new \SplFileInfo($targetDir);

        if (!$info->isDir())
        {
            throw new InvalidArgumentException(sprintf('Target dir not found'));
        }

        if (!$info->isReadable())
        {
            throw new InvalidArgumentException(sprintf('Target dir not readable'));
        }

        if (!$info->isWritable())
        {
            throw new InvalidArgumentException(sprintf('Target dir not writable'));
        }

        $files = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($this->dir, \FilesystemIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::SELF_FIRST
        );

        foreach($files as $info)
        {
            $sourcePathname = $info->getPathname();
            $subdirPathname = $this->subtractBasedir($sourcePathname, $this->dir);
            $targetPathname = sprintf('%s/%s', $targetDir, $subdirPathname);

            if ($info->isDir())
            {
                mkdir($targetPathname);
            }
            else {
                copy($sourcePathname, $targetPathname);
            }
        }
    }
120088
public function setTargetdir()
	{
		//set the target dir
		$this->target_dir =  Path::base() . $this->upload_path;

		//check if the directory exists and create if not
		if( ! file_exists($this->target_dir)) mkdir($this->target_dir);

		return $this;

	}
992725
function resolveCommandPath(string $groupID, string $command) {
        $paths = array();
        
        foreach($this->commandsDirectories as $dir) {
            $paths[] = $dir.'/'.\mb_strtolower($groupID);
        }
        
        $paths[] = __DIR__.'/Commands/'.\mb_strtolower($groupID);
        $filename = '/'.\mb_strtolower($command).'.php';
        
        foreach($paths as $path) {
            $file = $path.$filename;
            if(\file_exists($file)) {
                return \realpath($file);
            }
        }
        
        throw new \InvalidArgumentException('Unable to resolve command path');
    }
73814
public function ensureGitRemote($dir, $url)
    {
        if (!file_exists($dir . '/.git')) {
            throw new \InvalidArgumentException('The directory is not a Git repository');
        }
        $this->git->ensureInstalled();
        $currentUrl = $this->git->getConfig(
            sprintf('remote.%s.url', $this->config->get('detection.git_remote_name')),
            $dir
        );
        if (!$currentUrl) {
            $this->git->execute(
                ['remote', 'add', $this->config->get('detection.git_remote_name'), $url],
                $dir,
                true
            );
        } elseif ($currentUrl !== $url) {
            $this->git->execute([
                'remote',
                'set-url',
                $this->config->get('detection.git_remote_name'),
                $url
            ], $dir, true);
        }
    }
1236917
public function handleChangeDir(string $dir = null): void
	{
		if ($dir !== null) {
			if (
				strpos($dir, '..' . DIRECTORY_SEPARATOR) !== false
				|| !is_dir($this->getBasePath() . $dir)
			) {
				throw new InvalidArgumentException;
			}
		}
		$this->path = $dir;
		$this->redrawControl('fileManagerContainer');
	}
871884
public function load(string $path, string ...$paths): void
    {
        array_unshift($paths, $path);
        foreach ($paths as $path) {
            if (!is_readable($path) || is_dir($path) || ($contents = parse_ini_file($path, false)) === false) {
                throw new InvalidArgumentException("{$path} is not a readable file.");
            }
            $this->populate($contents);
        }
    }
487676
protected function checkFilePermissions()
    {
        if (!is_dir($this->logDir)) {
            throw new \InvalidArgumentException(
                sprintf('Cannot locate log directory: %s', $this->logDir)
            );
        }

        if ((!file_exists($this->logFile)) && (!touch($this->logFile))) {
            throw new \InvalidArgumentException(
                sprintf('Cannot create log file: %s', $this->logFile)
            );
        } elseif (!is_writable($this->logFile)) {
            throw new \InvalidArgumentException(
                sprintf('Cannot write to log file: %s', $this->logFile)
            );
        }
    }
1201916
protected function doExecute()
    {
        $env      = $this->getOption('env');
        $resolver = ConsoleHelper::getAllPackagesResolver($env, $this->console);
        $names    = $this->io->getArguments();

        if (!$names) {
            throw new \InvalidArgumentException('No package input.');
        }

        foreach ($names as $name) {
            $this->out()
                ->out('Start installing package: <info>' . $name . '</info>')
                ->out('---------------------------');

            $package = $resolver->getPackage($name);

            if (!$package) {
                $this->err('<comment>Package: ' . $name . ' not found.</comment>');

                continue;
            }

            $this->installConfig($package);
            $this->installRouting($package);
            $this->copyMigration($package);
            $this->copySeeders($package);
            $this->syncAssets($package);

            if (is_callable([$package, 'install'])) {
                $package->install($this);
            }
        }

        return true;
    }
749690
protected function notFound()
    {
        $closest   = [];
        $attempted = $this->argv[1];
        $available = \array_keys($this->commands() + $this->aliases);

        foreach ($available as $cmd) {
            $lev = \levenshtein($attempted, $cmd);
            if ($lev > 0 || $lev < 5) {
                $closest[$cmd] = $lev;
            }
        }

        $this->io()->error("Command $attempted not found", true);
        if ($closest) {
            \asort($closest);
            $closest = \key($closest);
            $this->io()->bgRed("Did you mean $closest?", true);
        }

        return ($this->onExit)(127);
    }
886815
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $targetArg = rtrim($input->getArgument('target'), '/');

        if (!is_dir($targetArg)) {
            throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
        }

        if (!function_exists('symlink') && $input->getOption('symlink')) {
            throw new \InvalidArgumentException('The symlink() function is not available on your system. You need to install the assets without the --symlink option.');
        }

        $filesystem = $this->getServiceManager()->get('filesystem');

        // Create the modules directory otherwise symlink will fail.
        $filesystem->mkdir($targetArg . '/modules/', 0777);

        $output->writeln(sprintf("Installing assets using the <comment>%s</comment> option", $input->getOption('symlink') ? 'symlink' : 'hard copy'));

        foreach ($this->getServiceManager()->get('modulemanager')->getLoadedModules() as $module) {
            if (!method_exists($module, 'getPath')) {
                continue;
            }
            if (!is_dir($originDir = $module->getPath() . '/resources/public')) {
                continue;
            }
            $modulesDir = $targetArg . '/modules/';
            $targetDir = $modulesDir . str_replace('module', '', strtolower($module->getName()));

            $output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $module->getNamespace(), $targetDir));

            $filesystem->remove($targetDir);

            if ($input->getOption('symlink')) {
                if ($input->getOption('relative')) {
                    $relativeOriginDir = $filesystem->makePathRelative($originDir, realpath($modulesDir));
                } else {
                    $relativeOriginDir = $originDir;
                }
                $filesystem->symlink($relativeOriginDir, $targetDir);
            } else {
                $filesystem->mkdir($targetDir, 0777);
                // We use a custom iterator to ignore VCS files
                $filesystem->mirror($originDir, $targetDir, Finder::create()->in($originDir));
            }
        }
    }
991653
public function seek($offset, $whence = SEEK_SET){
        if(!is_int($offset)){
            throw new \InvalidArgumentException();
        }

        if(!in_array($whence, [SEEK_SET, SEEK_CUR, SEEK_END])){
            throw new \InvalidArgumentException();
        }

        if(null === $this->resource){
            throw new Exception\StreamUnavailableException(
                static::EXCEPTION_MSG_UNAVAILABLE
            );
        }

        if(!$this->isSeekable()){
            throw new Exception\StreamUnseekableException(
                static::EXCEPTION_MSG_UNSEEKABLE
            );
        }

        if(0 !== fseek($this->resource, $offset, $whence)){
            throw new \RuntimeException("Failed to seek file pointer.");
        }

        return $this;
    }
1005141
private function checkDir() : void
    {
        $dir = dirname($this->path);
        if (!is_dir($dir)) {
            if (file_exists($dir)) {
                throw new \RuntimeException($dir . ' exists and is not a directory.');
            }
            if (!@mkdir($dir, 0755, true)) {
                throw new \RuntimeException($dir . ' does not exist and could not be created.');
            }
        }
    }
1234379
public function actionFolderRemove() {
		$source = $this->getSource();

		$file_path = false;

		$path = $source->getPath();

		$this->accessControl->checkPermission($this->getUserRole(), $this->action, $path);

		$target = $this->request->name;

		if (realpath($path . $target) && strpos(realpath($path . $target), $source->getRoot()) !== false) {
			$file_path = realpath($path . $target);
		}

		if ($file_path && file_exists($file_path)) {
			if (is_dir($file_path)) {
				$thumb = $file_path . Consts::DS . $source->thumbFolderName . Consts::DS;
				if (is_dir($thumb)) {
					Helper::deleteDir($thumb);
				}
				Helper::deleteDir($file_path);
			} else {
				throw new \Exception('It is not a directory!', Consts::ERROR_CODE_IS_NOT_WRITEBLE);
			}
		} else {
			throw new \Exception('Directory not exists', Consts::ERROR_CODE_NOT_EXISTS);
		}
	}
848682
public function loadFromDirectory($dir)
    {
        if (!is_dir($dir)) {
            throw new \InvalidArgumentException(sprintf('"%s" does not exist', $dir));
        }

        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::LEAVES_ONLY
        );

        return $this->loadFromIterator($iterator);
    }