Execute the job.

@throws \InvalidArgumentException
@throws \Exception|\Throwable

@return Content
167289
public function handle()
    {
        $content = $this->dbTransaction(function () {
            $content = new Content();
            $content->fill([
                'type'               => $this->attributes['type'],
                'theme'              => $this->attributes['theme'],
                'weight'             => $this->attributes['weight'],
                'rating'             => $this->attributes['rating'],
                'is_on_home'         => $this->attributes['is_on_home'],
                'is_promoted'        => $this->attributes['is_promoted'],
                'is_sticky'          => $this->attributes['is_sticky'],
                'is_comment_allowed' => $this->attributes['is_comment_allowed'],
                'published_at'       => $this->attributes['published_at']
            ]);
            $content->author()->associate($this->author);

            if ($this->attributes['parent_id']) {
                $parent = Content::find($this->attributes['parent_id']);
                if (!$parent) {
                    throw new InvalidArgumentException('Parent not found');
                }

                $content->setChildOf($parent);
            } else {
                $content->setAsRoot();
            }

            $translation = new ContentTranslation();
            $translation->fill([
                'title'           => $this->title,
                'language_code'   => $this->language->code,
                'teaser'          => $this->attributes['teaser'],
                'body'            => $this->attributes['body'],
                'seo_title'       => $this->attributes['seo_title'],
                'seo_description' => $this->attributes['seo_description'],
                'is_active'       => true,
            ]);
            $translation->author()->associate($this->author);

            $content->translations()->save($translation);
            $content->createRoute($translation, $this->attributes['is_active']);

            event('content.created', [$content]);
            return $content;
        });
        return $content;
    }
1094610
public function handle()
    {
        $this->obsolete_regex = implode('|', array_map(function($key) {
            return preg_quote($key, '/');
        }, $this->config('never_obsolete_keys', [])));

        // Should commands display something
        $this->display = !$this->option('dirty');

        // Get all lemmas in a structured array
        $lemmas_structured = $this->getLemmasStructured();

        $this->line('');
        $this->line('Scan files:');

        foreach ($this->getLanguages() as $lang => $lang_path) {
            foreach ($lemmas_structured as $family => $array) {
                if ($this->option('verbose')) {
                    $this->line('');
                }

                // Set path to family file
                $file_lang_path = "{$lang_path}/{$family}.php";

                $this->line('    ' . $this->getShortPath($file_lang_path));

                // Get existing and new lemmas
                $old_lemmas = $this->getOldLemmas($file_lang_path);
                $new_lemmas = Arr::dot($array);

                // Reset the final lemma array
                $this->final_lemmas = [];
                $this->is_dirty = false;

                // Lemma processing
                $this->processNewLemmas($family, $new_lemmas, $old_lemmas);
                $this->processExistingLemmas($family, $old_lemmas, $new_lemmas);
                $this->processObsoleteLemmas($family, $old_lemmas, $new_lemmas);

                if ($this->is_dirty === true || $this->option('force')) {
                    // Sort final lemmas array by key
                    ksort($this->final_lemmas);

                    // Create a dumpy-dump
                    $this->jobs[$file_lang_path] = $this->dumpLemmas($this->final_lemmas);
                }
                else {
                    if ($this->option('verbose')) {
                        $this->line("        > <comment>Nothing to do for this file</comment>");
                    }
                }
            }
        }

        // For dirty mode, all the user wants is a return value from the
        // command. This is usually used for continuous integration.
        if ($this->option('dirty')) {
            return $this->has_new ? self::ERROR : self::SUCCESS;
        }

        // Save all lemmas
        $this->saveChanges();

        return self::SUCCESS;
    }
1209727
protected function execute()
    {
        $this->bootstrap();

        // get the migration path from the config
        $path = $this->getMigrationPath();

        if (!file_exists($path) && $this->getPrompter()->confirm('Create migrations directory?', true)) {
            mkdir($path, 0755, true);
        }

        $this->verifyMigrationDirectory($path);

        $config = $this->getConfig();
        $namespace = $config->getMigrationNamespaceByPath($path);

        $path = realpath($path);
        $className = $this->getArgument('name');

        if (!Util::isValidPhinxClassName($className)) {
            throw new \InvalidArgumentException(sprintf(
                'The migration class name "%s" is invalid. Please use CamelCase format.',
                $className
            ));
        }

        if (!Util::isUniqueMigrationClassName($className, $path)) {
            throw new \InvalidArgumentException(sprintf(
                'The migration class name "%s%s" already exists',
                $namespace ? ($namespace . '\\') : '',
                $className
            ));
        }

        // Compute the file path
        $fileName = Util::mapClassNameToFileName($className);
        $filePath = $path . DIRECTORY_SEPARATOR . $fileName;

        if (is_file($filePath)) {
            throw new \InvalidArgumentException(sprintf(
                'The file "%s" already exists',
                $filePath
            ));
        }

        // Get the alternative template and static class options from the config, but only allow one of them.
        $defaultAltTemplate = $this->getConfig()->getTemplateFile();
        $defaultCreationClassName = $this->getConfig()->getTemplateClass();
        if ($defaultAltTemplate && $defaultCreationClassName) {
            throw new \InvalidArgumentException('Cannot define template:class and template:file at the same time');
        }

        // Get the alternative template and static class options from the command line, but only allow one of them.
        $altTemplate = $this->getOption('template');
        $creationClassName = $this->getOption('class');
        if ($altTemplate && $creationClassName) {
            throw new \InvalidArgumentException('Cannot use --template and --class at the same time');
        }

        // If no commandline options then use the defaults.
        if (!$altTemplate && !$creationClassName) {
            $altTemplate = $defaultAltTemplate;
            $creationClassName = $defaultCreationClassName;
        }

        // Verify the alternative template file's existence.
        if ($altTemplate && !is_file($altTemplate)) {
            throw new \InvalidArgumentException(sprintf(
                'The alternative template file "%s" does not exist',
                $altTemplate
            ));
        }

        // Verify that the template creation class (or the aliased class) exists and that it implements the required interface.
        $aliasedClassName = null;
        if ($creationClassName) {
            // Supplied class does not exist, is it aliased?
            if (!class_exists($creationClassName)) {
                $aliasedClassName = $this->getConfig()->getAlias($creationClassName);
                if ($aliasedClassName && !class_exists($aliasedClassName)) {
                    throw new \InvalidArgumentException(sprintf(
                        'The class "%s" via the alias "%s" does not exist',
                        $aliasedClassName,
                        $creationClassName
                    ));
                }

                if (!$aliasedClassName) {
                    throw new \InvalidArgumentException(sprintf(
                        'The class "%s" does not exist',
                        $creationClassName
                    ));
                }
            }

            // Does the class implement the required interface?
            if (!$aliasedClassName && !is_subclass_of($creationClassName, self::CREATION_INTERFACE)) {
                throw new \InvalidArgumentException(sprintf(
                    'The class "%s" does not implement the required interface "%s"',
                    $creationClassName,
                    self::CREATION_INTERFACE
                ));
            }

            if ($aliasedClassName && !is_subclass_of($aliasedClassName, self::CREATION_INTERFACE)) {
                throw new \InvalidArgumentException(sprintf(
                    'The class "%s" via the alias "%s" does not implement the required interface "%s"',
                    $aliasedClassName,
                    $creationClassName,
                    self::CREATION_INTERFACE
                ));
            }
        }

        // Use the aliased class.
        $creationClassName = $aliasedClassName ?: $creationClassName;

        // Determine the appropriate mechanism to get the template
        if ($creationClassName) {
            // Get the template from the creation class
            /** @var CreationInterface $creationClass */
            $creationClass = new $creationClassName($this);
            $contents = $creationClass->getMigrationTemplate();
        } else {
            // Load the alternative template if it is defined.
            $contents = file_get_contents($altTemplate ?: $this->getMigrationTemplateFilename());
        }

        // inject the class names appropriate to this migration
        $classes = [
            '$namespaceDefinition' => null !== $namespace ? ('namespace ' . $namespace . ';') : '',
            '$namespace' => $namespace,
            '$useClassName' => $this->getConfig()->getMigrationBaseClassName(false),
            '$className' => $className,
            '$version' => Util::getVersionFromFileName($fileName),
            '$baseClassName' => $this->getConfig()->getMigrationBaseClassName(true),
        ];
        $contents = strtr($contents, $classes);

        if (false === file_put_contents($filePath, $contents)) {
            throw new \RuntimeException(sprintf(
                'The file "%s" could not be written to',
                $path
            ));
        }

        // Do we need to do the post creation call to the creation class?
        if (isset($creationClass)) {
            $creationClass->postMigrationCreation($filePath, $className,
                $this->getConfig()->getMigrationBaseClassName());
        }

        $output = $this->getOutput();
        $output->write('using migration base class ', 'info');
        $output->writeln($classes['$useClassName']);

        if (!empty($altTemplate)) {
            $output->write('using alternative template ', 'info');
            $output->writeln($altTemplate);
        } elseif (!empty($creationClassName)) {
            $output->write('using template creation class ', 'info');
            $output->writeln($creationClassName);
        } else {
            $output->writeln('using default template', 'info');
        }

        $output->write('created ', 'info');
        $output->writeln(str_replace(getcwd() . DIRECTORY_SEPARATOR, '', $filePath));
    }
970452
public function fire()
    {
        if (! class_exists($model = $this->argument('model')))
        {
            throw new \InvalidArgumentException('Model does not exist!');
        }

        $this->generator->make(
            $model,
            $this->option('method'),
            $this->option('html')
        );
    }
325234
public function getContent()
    {
        if ($this->content === null) {
            if (is_array($this->variables)) {
                extract($this->variables);
            } else {
                if ($this->variables !== null) {
                    throw new \InvalidArgumentException('$variables argument should be null or an array');
                }
            }

            ob_start();
            include($this->path);
            $this->content = ob_get_clean();
        }

        return $this->content;
    }
61509
private function execute() {
        $curlResponse = curl_exec($this->curl);

        $error = $this->getError();
        if (!empty($error)) {
            return $this->curlException($error['error'], $error['error_no']);
        }

        return $curlResponse;
    }
523545
public function execute()
    {
        $data = $this->getRequest()->getPostValue();
        /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
        $resultRedirect = $this->resultRedirectFactory->create();

        if ($data) {
            $data = $this->dataProcessor->validateRequireEntry($data);

            if (isset($data['is_active']) && $data['is_active'] === 'true') {
                $data['is_active'] = TemplateActive::STATUS_ENABLED;
            }

            if (empty($data['template_id'])) {
                $data['template_id'] = null;
            }

            /** @var Pdfgenerator $model */

            $id = $this->getRequest()->getParam('template_id');
            if ($id) {
                /** @var Pdfgenerator $model */
                $model = $this->templateRepository->getById($id);
            } else {
                unset($data['template_id']);
                /** @var Pdfgenerator $model */
                $model = $this->pdfgeneratorFactory->create();
            }

            $model->setData($data);
            $model->setData('update_time', time());

            if (!$this->dataProcessor->validate($data)) {
                return $resultRedirect->setPath('*/*/edit', [
                    'template_id' => $model->getTemplateId(),
                    '_current' => true
                ]);
            }

            try {
                $this->templateRepository->save($model);
                $this->messageManager->addSuccessMessage(__('You saved the template.'));
                $this->dataPersistor->clear('pdfgenerator_template');

                if ($this->getRequest()->getParam('back')) {
                    return $resultRedirect->setPath('*/*/edit', [
                        'template_id' => $model->getTemplateId(),
                        '_current' => true
                    ]);
                }

                return $resultRedirect->setPath('*/*/');
            } catch (LocalizedException $e) {
                $this->messageManager->addErrorMessage($e->getMessage());
            } catch (\Exception $e) {
                $this->messageManager->addExceptionMessage(
                    $e,
                    __('Something went wrong while saving the template.')
                );
            }

            $this->dataPersistor->set('pdfgenerator_template', $data);
            return $resultRedirect->setPath('*/*/edit', [
                'template_id' => $this->getRequest()->getParam('template_id')
            ]);
        }

        return $resultRedirect->setPath('*/*/');
    }
276003
public function execute()
    {
        $this->content = curl_exec($this->handle);

        // If the execution wasn't successful, throw an exception.
        if ($this->isSuccessful() === false) {
            throw new CurlErrorException($this->getErrorMessage());
        }

        $this->executed = true;
    }
553383
public function handle()
    {
        $work = $this->work;
        $data = $this->data;

        $generator = new Generators\TextGenerator();

        $callback = function ($resource, array $data) use ($work, $generator) {
            $data = array_merge($this->data, $data);
            $data = array_merge($data, (array) Yaml::parse($generator->generateAndRender($work->data, $data)));

            $payload = json_decode(json_encode(Yaml::parse($generator->generateAndRender($work->payload, $data))));

            $worker = new $payload->class();
            $worker->execute($work, $payload, $data);
        };

        if ($work->data_builder) {
            $query = $work->data_builder->newInstanceQuery((array) $this->data);

            $work->data_builder->extract($query->get(), $callback);
        } else {
            $callback(null, []);
        }
    }
490304
public function execute()
    {
        $ch = curl_init();
        $this->setAuth($ch);
        try {
            switch (strtoupper($this->verb)) {
                case 'GET':
                    $this->executeGet($ch);
                    break;
                case 'POST':
                    $this->executePost($ch);
                    break;
                case 'PUT':
                    $this->executePut($ch);
                    break;
                case 'DELETE':
                    $this->executeDelete($ch);
                    break;
                default:
                    throw new \InvalidArgumentException(
                        'Current verb (' . $this->verb
                        . ') is an invalid REST verb.'
                    );
            }
        } catch (\InvalidArgumentException $e) {
            curl_close($ch);
            throw $e;
        } catch (\Exception $e) {
            curl_close($ch);
            throw $e;
        }

        /*
         * check and debug api request total time
         */
        $this->processDebugApi();

        return $this->responseBody;
    }
610514
public function handle()
    {
        $outputPath = config('apidoc.output');

        $documentarian = new Documentarian();

        if (! is_dir($outputPath)) {
            $this->error('There is no existing documentation available at '.$outputPath.'.');

            return false;
        }
        $this->info('Rebuilding API HTML code from '.$outputPath.'/source/index.md');

        $documentarian->generate($outputPath);

        $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html');
    }
592023
public function handle()
    {
        $this->parseKey();

        $this->files = $this->filesFromKey();

        try {
            $this->languages = $this->getLanguages();
        } catch (InvalidArgumentException $e) {
            $this->error($e->getMessage());

            return;
        }

        $this->table(
            array_merge(['key'], $this->languages),
            $this->tableRows()
        );
    }
738913
public function execute()
    {
        $command    = $this->getCommand();
        $broker     = $this->getServiceBroker();
        
        if (!$command->getIdentity()) {
            throw new RuntimeException(
                'Unable to execute Job: identity is not available');
        }
        
        $broker->dispatch($command);
    }
766979
public function handle()
    {
        $name = $this->argument('name');
        $createMigration = $this->option('m');
        $createResourceController = $this->option('c');

        if (empty($name)) {
            return $this->error("You need to specify an object to create");
        }

        $newObject = ucfirst($name).'.php';
        $newContract = ucfirst($name).'Repository.php';
        $newConcrete = 'Eloquent'.ucfirst($name).'Repository.php';

        $this->createObjectFiles($name, $newObject, $newContract, $newConcrete);

        $this->makeBindings($newContract, $newConcrete);

        $this->makeMigration($createMigration);

        $this->makeResourceController($createResourceController);

        return $this->info('Your structure has been created');
    }
753955
public function exec()
    {
        return $this->db->fetchAffected(
            $this->query->__toString(),
            $this->query->getBindValues()
        );
    }
98152
public function handle()
    {
        $content = $this->getFileContent($this->getMappingFile());
        $objects = json_decode($content, true);

        if (!is_array($objects)) {
            throw new Exception('The mapping-file does not contain a valid array.');
        }

        $validInputs = $this->getValidInputs($objects, $this->getCommandInput());

        foreach ($validInputs as $validInput) {
            $this->call(
                'create:resources',
                [
                    'model-name' => $validInput->modelName,
                    '--controller-name' => $validInput->controllerName,
                    '--controller-directory' => $validInput->controllerDirectory,
                    '--controller-extends' => $validInput->controllerExtends,
                    '--model-directory' => $validInput->modelDirectory,
                    '--views-directory' => $validInput->viewsDirectory,
                    '--resource-file' => $validInput->resourceFile,
                    '--routes-prefix' => $validInput->prefix,
                    '--models-per-page' => $validInput->perPage,
                    '--language-filename' => $validInput->languageFileName,
                    '--with-form-request' => $validInput->formRequest,
                    '--form-request-directory' => $validInput->formRequestDirectory,
                    '--with-auth' => $validInput->withAuth,
                    '--table-name' => $validInput->table,
                    '--primary-key' => $validInput->primaryKey,
                    '--with-soft-delete' => $validInput->withSoftDelete,
                    '--without-timestamps' => $validInput->withoutTimeStamps,
                    '--with-migration' => $validInput->withMigration,
                    '--migration-class-name' => $validInput->migrationClass,
                    '--connection-name' => $validInput->connectionName,
                    '--engine-name' => $validInput->engineName,
                    '--layout-name' => $validInput->layoutName,
                    '--template-name' => $validInput->template,
                    '--table-exists' => $validInput->tableExists,
                    '--translation-for' => $validInput->translationFor,
                    '--force' => $validInput->force,
                ]
            );

            $this->info('---------------------------------');
        }

        return $this->printInfo('All Done!');
    }
153137
public function execute() {
		$this->log->debug ( "AbstractCommand (" . get_class ( $this ) . "): command array: {" . implode ( ",", $this->cmd ) . "}" );
		$this->executeImpl ( $this->cmd );
		
		if ($this->response_to_source_channel) {
			$this->log->debug ( "AbstractCommand (" . get_class ( $this ) . "): requesting channel name for channel: " . $this->post ["channel_id"] );
			$this->result->setChannel ( Util::getChannelName ( $this->config, $this->post ["channel_id"] ) );
		}
		return $this->result;
	}