Handle directive

@return string
6060
public function message($view) : string
  {
    $view = $this->getPath($view);
    $path = self::$views . $view . self::$extension;

    if (file_exists($path)) {
      return '<!--%' .base64_encode($view). '%-->' . PHP_EOL . file_get_contents($path);
    }
    else {
      throw new PartialNotFoundException($path);
    }
  }
409937
public function handle()
    {
        $ds = DIRECTORY_SEPARATOR;
        $resources = $this->argument('resources');
        $resources = !is_array($resources) ? [$resources] : $resources;
        $module = $this->option('module');
        $routesFile = base_path('routes') . $ds . 'web.php';

        if ($module) {
            $module = is_array($module) ? $module[0] : $module;
            $moduleDirectory = config('support.module.directory') . $ds . ucfirst($module);
            
            $this->namespace = $this->getAppNamespace() . ucfirst($module);
            $routesFile = config('support.module.directory') . $ds . ucfirst($module) . $ds . config('support.module.routes');
            
            if (!file_exists($moduleDirectory)) {
                $this->error("The requested module '$moduleDirectory' does not exists!");
                return;
            }

            if(config('support.namespace')) {
                $this->namespace = config('support.namespace');
            }
        }
        
        foreach ($resources as $resource) {
            $stub = file_get_contents(__DIR__ . $ds . '..' . $ds . '..' . $ds . '..' . $ds . '..' . $ds . 'resources' . $ds . 'Stubs' . $ds . (empty($module) ? 'Standard' : 'Modular') . $ds . 'Route.stub');
            $stub = str_replace([
                        '{{resource}}',                    '{{class}}'],
                        [str_plural(strtolower($resource)),  str_plural(ucfirst($resource))],
                        $stub);

            if (!file_exists($routesFile)) {
                $this->error('Could not update routes file \'' . $routesFile . '\' as it does not exist!');
                return;
            }

            $routes = file_get_contents($routesFile);
            $stub = $routes ? $routes . "\n" . $stub : $stub;

            file_put_contents($routesFile, $stub);
            $this->info($routesFile . ' routes updated!');
        }
    }
188803
public function handle()
    {
        if (parent::handle() === false) {
            return;
        }

        $providerFileName = $this->getPath($this->qualifyClass($this->getNameInput()));
        $this->files->put(//Replace the
            $providerFileName,
            str_replace(
                'DummyProviderFolder',
                str_replace('/', '\\', $this->convention->providersFolder()),
                $this->files->get($providerFileName)
            )
        );

        $name         = $this->getNameInput();
        $manifestPath = str_replace(
                sprintf('%s/ModuleServiceProvider.php', $this->convention->providersFolder()),
                $this->convention->manifestFile(),
                $this->getPath($this->getFQCNComp($name)
            )
        );

        if (!$this->files->exists($manifestPath)) {
            $this->makeDirectory($manifestPath);

            $this->files->put($manifestPath, $this->buildManifest($name));
        }
    }
178863
public static function handle()
	{
		$args = func_get_args();
		$key = array_shift( $args );
		
		return call_user_func_array( array( static::$builder, 'build_'.$key ), $args );
	}
234996
protected function _handle()
    {
        $subject = $this->_subject();
        $subject->set(['success' => true, 'viewVar' => $this->viewVar()]);

        $this->_trigger('beforePaginate', $subject);

        $controller = $this->_controller();
        $items = $controller->paginate();
        $subject->set(['items' => $items]);

        $this->_trigger('afterPaginate', $subject);

        $controller->set(['success' => $subject->success, $subject->viewVar => $subject->items]);
        $this->_trigger('beforeRender', $subject);
    }
880247
public function handle()
	{
		$path = public_path(config('asset.public_cache_folder'));

		$fileSystem = new Filesystem();
		$fileSystem->cleanDirectory($path);

		return $this->info("'$path' folder cleared. ");
	}
467370
public function handle()
    {
        $paths = $this->_extractFilePaths($this->request->files->all());

        $response = array();

        foreach ($paths as $path => &$file) {
            $processor = $this->_getProcessor($path);
            $config = $processor->getConfig();

            $prefix = preg_replace('#^(.*?)\.[^\.]+$#', '$1', $path);

//            if (strpos($prefix, '.') === false) {
//                $form = $this->form;
//            }
//            else {

//                $form = UtilFormAccessor::getForm($this->form, $prefix);
//
//                niechginie(array(
//                    $prefix,
//                    $this->form,
//                    $form,
//                    $form->getData()
//                ));
//
////                niechginie($form);
//            }

            $result = new UploadResult($prefix.'.'.$config['field'], str_replace('.', '_', $path), $this->request);

            $response[] = $result;

            $processor->handle($file, $result);
        }

        $return = array();
        foreach ($response as $res) {
            /* @var $res UploadResult */
            $return[] = $res->getResult();
        }

        return array(
            'files' => $return,
        );
    }
1069564
public function handle()
    {
        $name = $this->argument('name');
        $studly_name = studly_case($name);

        $js = file_get_contents(__DIR__.'/Stubs/AngularFilter/filter.js.stub');

        $js = str_replace('{{StudlyName}}', $studly_name, $js);

        $folder = base_path(config('generators.source.root')).'/'.config('generators.source.filters');

        if(!File::exists($folder))
            File::makeDirectory($folder);
        
        //create filter (.js)
        if(!File::exists($folder.'/'.$name.config('generators.suffix.filter')))
            File::put($folder.'/'.$name.config('generators.suffix.filter'), $js);
        else{
            $this->info('Filter already exists.');
            return false;
        }

        //import filter
        $filters_index = base_path(config('generators.source.root')).'/index.filters.js';
        
        if(!config('generators.angular_modules.filters.standalone'))
            $module = "angular.module('".config('generators.angular_modules.root')."')";
        else
            $module = "angular.module('"
                      .(config('generators.angular_modules.filters.use_prefix') ? config('generators.angular_modules.filters.prefix')."." : "")
                      .config('generators.angular_modules.filters.suffix')
                      ."', [])";

        if(!file_exists($filters_index)){
            File::put($filters_index, $module);
        }

        if (config('generators.misc.auto_import') && !$this->option('no-import')) {
            $filters = file_get_contents($filters_index);
            $filterName = lcfirst($studly_name);
            $newFilters = "\r\n\t.filter('$filterName', {$studly_name}Filter)";
            $filters = str_replace($module, $module.$newFilters, $filters);
            $filters = 'import {'.$studly_name."Filter} from './filters/{$name}.filter';\n".$filters;
            file_put_contents($filters_index, $filters);
        }

        $this->info('Filter created successfully.');
    }
1232266
public function handle()
    {
        set_time_limit(0);
        $root = function_exists('base_path') === true ? base_path() : getcwd();
        $root = rtrim($root, '/').'/';

        $docs = ['README*', 'CHANGELOG*', 'FAQ*', 'CONTRIBUTING*', 'HISTORY*', 'UPGRADING*', 'UPGRADE*', 'package*', 'demo', 'example', 'examples', 'doc', 'docs', 'readme*'];
        $tests = ['.travis.yml', '.scrutinizer.yml', 'phpunit.xml*', 'phpunit.php', 'test', 'Test', 'tests', 'Tests', 'travis'];
        $vcs = ['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'];
        $others = [
            'vendor',
            '.babelrc',
            '.editorconfig',
            '.eslintrc.*',
            '.gitattributes',
            '.gitignore',
            '.nitpick.json',
            '.php_cs',
            '.scrutinizer.yml',
            '.styleci.yml',
            '.travis.yml',
            'appveyor.yml',
            'package.json',
            'phpcs.xml',
            'ruleset.xml',
        ];
        $common = [
            'node_modules',
        ];

        (new Collection(
            Glob::glob($root.'{'.(new Collection(Glob::glob($root.'vendor/*/*')))
                ->map(function ($item) {
                    return substr($item, strpos($item, 'vendor'));
                })
                ->implode(',').'}/**/{'.(implode(',', array_merge($vcs, $common, $others, $tests, $docs))).'}')
            ))
            ->merge(Glob::glob($root.'{'.(implode(',', array_merge($vcs, $common))).'}'))
            ->merge([
                $root.'vendor/phpunit',
            ])
            ->filter()
            ->each(function ($item) {
                if ($this->files->isDirectory($item) === true) {
                    $this->files->deleteDirectory($item);
                    $this->info('delete directory: '.$item);
                } elseif ($this->files->isFile($item)) {
                    $this->files->delete($item);
                    $this->info('delete file: '.$item);
                }
            });

        $this->line('');
    }
1022299
public function handle()
    {
        $name = $this->argument('name');
        $modelName = str_singular($name);
        $migrationName = str_plural(strtolower($name));
        $tableName = $migrationName;
        $viewName = strtolower($name);

        $routeGroup = $this->option('route-group');
        $this->routeName = ($routeGroup) ? $routeGroup . '/' . strtolower($name) : strtolower($name);

        $controllerNamespace = ($this->option('namespace')) ? $this->option('namespace') . '\\' : '';

        $fields = $this->option('fields');
        $primaryKey = $this->option('pk');
        $viewPath = $this->option('view-path');

        $fieldsArray = explode(',', $fields);
        $requiredFields = '';
        $requiredFieldsStr = '';

        foreach ($fieldsArray as $item) {
            $fillableArray[] = preg_replace("/(.*?):(.*)/", "$1", trim($item));

            $itemArray = explode(':', $item);
            $currentField = trim($itemArray[0]);
            $requiredFieldsStr .= (isset($itemArray[2])
                && (trim($itemArray[2]) == 'req'
                    || trim($itemArray[2]) == 'required'))
            ? "'$currentField' => 'required', " : '';
        }

        $commaSeparetedString = implode("', '", $fillableArray);
        $fillable = "['" . $commaSeparetedString . "']";

        $requiredFields = ($requiredFieldsStr != '') ? "[" . $requiredFieldsStr . "]" : '';

        $this->call('crud:controller', ['name' => $controllerNamespace . $name . 'Controller', '--crud-name' => $name, '--model-name' => $modelName, '--view-path' => $viewPath, '--required-fields' => $requiredFields, '--route-group' => $routeGroup]);
        $this->call('crud:model', ['name' => $modelName, '--fillable' => $fillable, '--table' => $tableName]);
        $this->call('crud:migration', ['name' => $migrationName, '--schema' => $fields, '--pk' => $primaryKey]);
        $this->call('crud:view', ['name' => $viewName, '--fields' => $fields, '--view-path' => $viewPath, '--route-group' => $routeGroup]);
        // For optimizing the class loader
        $this->callSilent('optimize');

        // Updating the Http/routes.php file old laravels app_path('Http/routes.php')
        $routeFile = config('crudgenerator.route'); //change it to config file
        if (file_exists($routeFile) && (strtolower($this->option('route')) === 'yes')) {
            $this->controller = ($controllerNamespace != '') ? $controllerNamespace . '\\' . $name . 'Controller' : $name . 'Controller';

            if (\App::VERSION() >= '5.2') {
                $isAdded = File::append($routeFile,
                    "\nRoute::group(['middleware' => ['web']], function () {"
                    . "\n\t" . implode("\n\t", $this->addRoutes())
                    . "\n});"
                );
            } else {
                $isAdded = File::append($routeFile, "\n".implode("\n", $this->addRoutes()));
            }

            if ($isAdded) {
                $this->info('Crud/Resource route added to ' . $routeFile);
            } else {
                $this->info('Unable to add the route to ' . $routeFile);
            }
        }
    }
246236
protected function _handle()
    {
        $request = $this->_request();
        $this->_configIndex($this->_table(), $request);
        $query = $this->_table()->find();
        $repository = $query->repository();

        $query->searchOptions(['ignore_unavailable' => true]);

        if ($request->query('type')) {
            $repository->name($request->query('type'));
        }

        if ($request->query('primary_key')) {
            $query->where(['primary_key' => $request->query('primary_key')]);
        }

        if ($request->query('transaction')) {
            $query->where(['transaction' => $request->query('transaction')]);
        }

        if ($request->query('user')) {
            $query->where(['meta.user' => $request->query('user')]);
        }

        if ($request->query('changed_fields')) {
            $query->where(function ($builder) use ($request) {
                $fields = explode(',', $request->query('changed_fields'));
                $fields = array_map(function ($f) { return 'changed.' . $f; }, array_map('trim', $fields));
                $fields = array_map([$builder, 'exists'], $fields);
                return $builder->and_($fields);
            });
        }

        if ($request->query('query')) {
            $query->where(function ($builder) use ($request) {
                return $builder->query(new \Elastica\Query\QueryString($request->query('query')));
            });
        }

        try {
            $this->addTimeConstraints($request, $query);
        } catch (\Exception $e) {
        }

        $subject = $this->_subject(['success' => true, 'query' => $query]);
        $this->_trigger('beforePaginate', $subject);

        $items = $this->_controller()->paginate($subject->query);
        $subject->set(['entities' => $items]);

        $this->_trigger('afterPaginate', $subject);
        $this->_trigger('beforeRender', $subject);
    }
790087
private function handle()
    {
        if (!$this->handle) {
            if (!($this->handle = @fopen($this->file, 'rb'))) {
                throw FileException::lastError();
            }
        }

        return $this->handle;
    }
1231285
public function handle()
	{
		$lemma   = $this->argument( 'lemma' );
		$folders = $this->manager->getPath( $this->folders );

		//////////////////////////////////////////////////
		// Display where translatations are searched in //
		//////////////////////////////////////////////////
		if ( $this->option( 'verbose' ) )
		{
			$this->writeLine( "Lemmas will be searched in the following directories:" );

			foreach ( $folders as $path )
			{
				$this->writeLine( '    <info>' . $path . '</info>' );
			}

			$this->writeLine( '' );
		}

		////////////////////////////////
		// Parse all lemmas from code //
		////////////////////////////////
		$files = $this->manager->findLemma( $lemma , $folders , $this->trans_methods , $this->option( 'regex' ) , $this->option( 'short' ) );

		if ( ( is_array( $files ) ) && ( count( $files ) > 0 ) )
		{
			$this->writeLine( 'Lemma <info>' . $lemma . '</info> has been found in:' );
			foreach ( $files as $file )
			{
				$this->writeLine( '    <info>' . $file . '</info>' );
			}

			return self::SUCCESS;
		}
		else
		{
			return self::ERROR;
		}
	}
514842
public function execute()
	{
		if (count($this->children) && count($this->input->args))
		{
			$name = $this->input->args[0];

			try
			{
				return $this->executeSubCommand($name);
			}
			catch (CommandNotFoundException $e)
			{
				$e->getCommand()->renderAlternatives($e->getChild(), $e);

				return $e->getCode();
			}
			catch (\Exception $e)
			{
				$this->renderException($e);

				return $e->getCode();
			}
		}

		if ($this->handler)
		{
			if ($this->handler instanceof \Closure)
			{
				$code = $this->handler;

				return $code($this);
			}
			elseif (is_callable($this->handler))
			{
				return call_user_func($this->handler, $this);
			}
		}

		return $this->doExecute();
	}
1084041
public function handle()
    {
        $name = $this->argument('name');
        $studly_name = studly_case($name);
        $human_readable = ucfirst(str_replace('_', ' ', $name));

        $html = file_get_contents(__DIR__.'/Stubs/AngularDialog/dialog.html.stub');
        $js = file_get_contents(__DIR__.'/Stubs/AngularDialog/dialog.js.stub');

        $html = str_replace('{{StudlyName}}', $studly_name, $html);
        $js = str_replace('{{StudlyName}}', $studly_name, $js);
        $html = str_replace('{{HumanReadableName}}', $human_readable, $html);

        $folder = base_path(config('generators.source.root')).'/'.config('generators.source.dialogs').'/'.$name;

        if (is_dir($folder)) {
            $this->info('Folder already exists');

            return false;
        }

        //create folder
        File::makeDirectory($folder, 0775, true);

        //create view (.html)
        File::put($folder.'/'.$name.config('generators.suffix.dialogView', '.html'), $html);

        //create controller (.js)
        File::put($folder.'/'.$name.config('generators.suffix.dialog'), $js);

        $this->info('Dialog created successfully.');
    }
1345429
def handle(text)
      text.gsub!(/^([ \t#]*):(\w+):\s*(.+)?\n/) do 
        prefix    = $1
        directive = $2.downcase
        param     = $3

        case directive
        when "include"
          filename = param.split[0]
          include_file(filename, prefix)

        else
          yield(directive, param)
        end
      end
    end
477742
public function handle()
    {
        $class = $this->argument( 'class' );
        if( ! class_exists( $class ) ) return $this->error( "Could not find class '{$class}'" );
        $reflection = new ReflectionClass( $class );

        $blueprints = array_keys( $reflection->getInterfaces() );
        $extendedClassName = '';
        if( $extendedClass = $reflection->getParentClass() ) {
            $extendedClassName = $extendedClass->getName();
        }
        if( ! $moduleName = $this->getModuleName( $class ) ) {
            return $this->error( "Could not find module name" );
        }
        $this->createOverridesFolder( $moduleName );
        $filePath = $this->createFoldersInOverridesFor( $moduleName, $class );
        $this->createOverridingFileContents( $filePath, $moduleName, $class, $extendedClassName, $blueprints );
    }