/* -----------------------------------------------------------------
|  Main Methods
| -----------------------------------------------------------------
499670
public function index($trashed = false)
    {
        $this->authorize(TagsPolicy::PERMISSION_LIST);

        $tags = $this->tag->with(['posts'])->when($trashed, function ($query) {
            return $query->onlyTrashed();
        })->paginate(30);

        $this->setTitle($title = trans('blog::tags.titles.tags-list'));
        $this->addBreadcrumb($title);

        return $this->view('admin.tags.index', compact('tags', 'trashed'));
    }
734008
public function execute()
    {
        $this->insertID = $this->table->insertOne($this->context + $this->data);
        parent::execute();
    }
43246
public function main()
    {
        $this->validate();

        $targetDatabase = $this->getTargetDatabase();

        $platform = $this->getGeneratorConfig()->getConfiguredPlatform();

        // Load the Data XML -> DB Name properties
        $map = new Properties();
        try {
            $map->load($this->getDataDbMap());
        } catch (IOException $ioe) {
            throw new BuildException("Cannot open and process the datadbmap!", $ioe);
        }

        // Parse each file in the data -> db map
        foreach ($map->keys() as $dataXMLFilename) {

            $dataXMLFile = new PhingFile($this->srcDir, $dataXMLFilename);

            // if file exists then proceed
            if ($dataXMLFile->exists()) {

                $dbname = $map->get($dataXMLFilename);

                $db = $this->getDatabase($dbname);

                if (!$db) {
                    throw new BuildException("Cannot find instantiated Database for name '$dbname' from datadbmap file.");
                }

                $db->setPlatform($platform);

                $outFile = $this->getMappedFile($dataXMLFilename);
                $sqlWriter = new FileWriter($outFile);

                $this->log("Creating SQL from XML data dump file: " . $dataXMLFile->getAbsolutePath());

                try {
                    $dataXmlParser = new XmlToDataSQL($db, $this->getGeneratorConfig(), $this->dbEncoding);
                    $dataXmlParser->transform($dataXMLFile, $sqlWriter);
                } catch (Exception $e) {
                    throw new BuildException("Exception parsing data XML: " . $e->getMessage());
                }

                // Place the generated SQL file(s)
                $p = new Properties();
                if ($this->getSqlDbMap()->exists()) {
                    $p->load($this->getSqlDbMap());
                }

                $p->setProperty($outFile->getName(), $db->getName());
                $p->store($this->getSqlDbMap(), "Sqlfile -> Database map");
            } else {
                $this->log("File '" . $dataXMLFile->getAbsolutePath() . "' in datadbmap does not exist, so skipping it.", Project::MSG_WARN);
            }
        } // foreach data xml file

    }
566027
public function main() {

        $content = '';

        $typo3Version = VersionNumberUtility::getNumericTypo3Version();
        if (VersionNumberUtility::convertVersionNumberToInteger($typo3Version) >= 8000000) {
            // If TYPO3 version is version 8 or higher
            $addresslist = $this->queryBuilder->select('uid', 'registeraddresshash', 'email')
                ->from('tt_address')
                ->where(
                    $this->queryBuilder->expr()->eq(
                        'registeraddresshash',
                        $this->queryBuilder->createNamedParameter('')
                    )
                )
                ->groupBy('uid')
                ->execute()->fetchAll();

            foreach ($addresslist as $fixAddress) {
                $content .= 'Updating tt_address uid:' . $fixAddress['uid'] . PHP_EOL;

                $rnd = microtime(true) . random_int(10000, 90000);
                $regHash = sha1($fixAddress['email'] . $rnd);

                $this->queryBuilder->update('tt_address')
                    ->set('registeraddresshash', $regHash)
                    ->where(
                        $this->queryBuilder->expr()->eq(
                            'uid',
                            $this->queryBuilder->createNamedParameter($fixAddress['uid'])
                        )
                    )
                    ->execute();
            }

        } else {
            // For TYPO3 Version 7 or lower
            $addresslist = $this->databaseConnection->exec_SELECTquery(
                'uid, registeraddresshash, email',
                'tt_address',
                'registeraddresshash=""'
            );

            foreach ($addresslist as $fixAddress) {
                $content .= 'Updating tt_address uid:' . $fixAddress['uid'] . PHP_EOL;

                $rnd = microtime(true) . random_int(10000, 90000);
                $regHash = sha1($fixAddress['email'] . $rnd);

                $this->databaseConnection->exec_UPDATEquery(
                    'tt_address',
                    'uid = "'.$fixAddress['uid'].'"',
                    ['registeraddresshash' => $regHash]
                );
            }
        }

        $content .= 'tt_address entries updates finished.' . PHP_EOL;

        return nl2br($content);

    }
1302158
public function init() {

		parent::init();

		$this->basePath	 		= 'post/default';
		$this->crudPermission	= CoreGlobal::PERM_USER;

		$this->layout			= CoreGlobalWeb::LAYOUT_PUBLIC;

		$this->modelService			= Yii::$app->factory->get( 'postService' );

		$this->templateService		= Yii::$app->factory->get( 'templateService' );

		$this->categoryService		= Yii::$app->factory->get( 'categoryService' );
		$this->tagService			= Yii::$app->factory->get( 'tagService' );

		$this->modelContentService	= Yii::$app->factory->get( 'modelContentService' );
		$this->modelCategoryService	= Yii::$app->factory->get( 'modelCategoryService' );

		$this->pageMetaService		= Yii::$app->factory->get( 'pageMetaService' );
	}
14364
public function main()
    {
        if ($this->getOwningTarget()->getName() === "") {
            $this->log("Cowardly refusing to call target '{$this->subTarget}' from the root", Project::MSG_WARN);
            return;
        }

        $this->log("Running PhingCallTask for target '" . $this->subTarget . "'", Project::MSG_DEBUG);
        if ($this->callee === null) {
            $this->init();
        }

        if ($this->subTarget === null) {
            throw new BuildException("Attribute target is required.", $this->getLocation());
        }

        $this->callee->setPhingFile($this->project->getProperty("phing.file"));
        $this->callee->setTarget($this->subTarget);
        $this->callee->setInheritAll($this->inheritAll);
        $this->callee->setInheritRefs($this->inheritRefs);
        $this->callee->main();
    }
1186406
protected static function init(): void
    {
        if (!static::$initialized) {
            $baseClass = Base::getInstance();
            static::$initialized = true;
            static::$newDirectoryMode = \octdec((string)$baseClass->Filesystem->newDirectoryMode);
            static::$newFileMode = \octdec((string)$baseClass->Filesystem->newFileMode);
            static::$writeLocks = (boolean)$baseClass->Filesystem->writeLocks;
            static::$hashFileDir = $baseClass->parsePath((string)$baseClass->Filesystem->hashFileDirectory);
            static::$hashFileDirDepth = (int)$baseClass->Filesystem->hashFileDirectoryDepth;
            static::$documentRoot = $baseClass->parsePath('%DOCUMENT_ROOT%').DIRECTORY_SEPARATOR;
        }
    }
684468
public function main()
    {
        $config = [];
        if ($this->token) {
            $config['token'] = $this->token;
        }
        
        $this->setClient(Service::factory($config));
    }
761962
public function main()
    {
        $this->setup('info');

        if ($this->oldVersion) {
            $output = $this->run(['--xml', '--incremental']);

            if (!($xmlObj = @simplexml_load_string($output))) {
                throw new BuildException("Failed to parse the output of 'svn info --xml'.");
            }

            $object = $xmlObj->{$this->element};

            if (!empty($this->subElement)) {
                $object = $object->{$this->subElement};
            }
        } else {
            $output = $this->run();

            if (empty($output) || !isset($output['entry'][0])) {
                throw new BuildException("Failed to parse the output of 'svn info'.");
            }

            $object = $output['entry'][0][$this->element];

            if (!empty($this->subElement)) {
                $object = $object[$this->subElement];
            }
        }

        $this->project->setProperty($this->getPropertyName(), (string) $object);
    }
472962
public function main()
    {
        $config = [
            'version'  => 'latest'
        ];

        if ($this->getRegion()) {
            $config['region'] = $this->getRegion();
        }

        if ($this->getKey() && $this->getSecret()) {
            $config['credentials'] = [
                'key' => $this->getKey(),
                'secret' => $this->getSecret(),
            ];
        } elseif ($this->getProfile()) {
            $config['profile'] = $this->getProfile();
        }

        $this->setServiceLocator(new Sdk($config));
    }
945487
public function main()
    {
        $logger = Log::engine($this->params['logger']);
        $engine = $this->getEngine($logger);
        $worker = $this->getWorker($engine, $logger);
        $worker->work();
    }
999180
public function main(): void
    {
        $args = getopt('t::');

        if (isset($args['t']) === false) {
            $this->showBasicExample();
            $this->showIncludedObjectsExample();
            $this->showSparseAndFieldSetsExample();
            $this->showTopLevelMetaAndLinksExample();
            $this->dynamicSchemaExample();
        } else {
            $num = $args['t'];
            $inv = empty($num) === true || is_numeric($num) === false || ctype_digit($num) == false || (int)$num <= 0;
            $num = $inv === true ? 1000 : (int)$num;

            $this->runPerformanceTestForSmallNestedResources($num);
            $this->runPerformanceTestForBigCollection($num);
        }
    }
580756
public function main()
    {
        // check to make sure task received all correct params
        $this->validate();

        $generatorConfig = $this->getGeneratorConfig();
        $totalNbFiles = 0;

        $dataModels = $this->getDataModels();
        $this->log('Generating PHP files...');

        foreach ($dataModels as $dataModel) {
            $this->log("Datamodel: " . $dataModel->getName(), Project::MSG_VERBOSE);

            foreach ($dataModel->getDatabases() as $database) {

                if ($this->getGeneratorConfig()->getBuildProperty('disableIdentifierQuoting')) {
                    $database->getPlatform()->setIdentifierQuoting(false);
                }

                $this->log(" - Database: " . $database->getName(), Project::MSG_VERBOSE);

                foreach ($database->getTables() as $table) {

                    if (!$table->isForReferenceOnly()) {

                        $nbWrittenFiles = 0;

                        $this->log("  + Table: " . $table->getName(), Project::MSG_VERBOSE);

                        // -----------------------------------------------------------------------------------------
                        // Create Peer, Object, and TableMap classes
                        // -----------------------------------------------------------------------------------------

                        // these files are always created / overwrite any existing files
                        foreach (array('peer', 'object', 'tablemap', 'query') as $target) {
                            $builder = $generatorConfig->getConfiguredBuilder($table, $target);
                            $nbWrittenFiles += $this->build($builder);
                        }

                        // -----------------------------------------------------------------------------------------
                        // Create [empty] stub Peer and Object classes if they don't exist
                        // -----------------------------------------------------------------------------------------

                        // these classes are only generated if they don't already exist
                        foreach (array('peerstub', 'objectstub', 'querystub') as $target) {
                            $builder = $generatorConfig->getConfiguredBuilder($table, $target);
                            $nbWrittenFiles += $this->build($builder, $overwrite = false);
                        }

                        // -----------------------------------------------------------------------------------------
                        // Create [empty] stub child Object classes if they don't exist
                        // -----------------------------------------------------------------------------------------

                        // If table has enumerated children (uses inheritance) then create the empty child stub classes if they don't already exist.
                        if ($col = $table->getChildrenColumn()) {
                            if ($col->isEnumeratedClasses()) {
                                foreach ($col->getChildren() as $child) {
                                    foreach (array('queryinheritance') as $target) {
                                        if (!$child->getAncestor()) {
                                            continue;
                                        }
                                        $builder = $generatorConfig->getConfiguredBuilder($table, $target);
                                        $builder->setChild($child);
                                        $nbWrittenFiles += $this->build($builder, $overwrite = true);
                                    }
                                    foreach (array('objectmultiextend', 'queryinheritancestub') as $target) {
                                        $builder = $generatorConfig->getConfiguredBuilder($table, $target);
                                        $builder->setChild($child);
                                        $nbWrittenFiles += $this->build($builder, $overwrite = false);
                                    }
                                } // foreach
                            } // if col->is enumerated
                        } // if tbl->getChildrenCol


                        // -----------------------------------------------------------------------------------------
                        // Create [empty] Interface if it doesn't exist
                        // -----------------------------------------------------------------------------------------

                        // Create [empty] interface if it does not already exist
                        if ($table->getInterface()) {
                            $builder = $generatorConfig->getConfiguredBuilder($table, 'interface');
                            $nbWrittenFiles += $this->build($builder, $overwrite = false);
                        }

                        // -----------------------------------------------------------------------------------------
                        // Create tree Node classes
                        // -----------------------------------------------------------------------------------------

                        if ($table->treeMode()) {
                            switch ($table->treeMode()) {
                                case 'NestedSet':
                                    foreach (array('nestedsetpeer', 'nestedset') as $target) {
                                        $builder = $generatorConfig->getConfiguredBuilder($table, $target);
                                        $nbWrittenFiles += $this->build($builder);
                                    }
                                    break;

                                case 'MaterializedPath':
                                    foreach (array('nodepeer', 'node') as $target) {
                                        $builder = $generatorConfig->getConfiguredBuilder($table, $target);
                                        $nbWrittenFiles += $this->build($builder);
                                    }

                                    foreach (array('nodepeerstub', 'nodestub') as $target) {
                                        $builder = $generatorConfig->getConfiguredBuilder($table, $target);
                                        $nbWrittenFiles += $this->build($builder, $overwrite = false);
                                    }
                                    break;

                                case 'AdjacencyList':
                                    // No implementation for this yet.
                                default:
                                    break;
                            }
                        } // if Table->treeMode()

                        // ----------------------------------
                        // Create classes added by behaviors
                        // ----------------------------------
                        if ($table->hasAdditionalBuilders()) {
                            foreach ($table->getAdditionalBuilders() as $builderClass) {
                                $builder = new $builderClass($table);
                                $builder->setGeneratorConfig($generatorConfig);
                                $nbWrittenFiles += $this->build($builder, isset($builder->overwrite) ? $builder->overwrite : true);
                            }
                        }

                        $totalNbFiles += $nbWrittenFiles;
                        if ($nbWrittenFiles == 0) {
                            $this->log("\t\t(no change)", Project::MSG_VERBOSE);
                        }
                    } // if !$table->isForReferenceOnly()

                } // foreach table

            } // foreach database

        } // foreach dataModel
        if ($totalNbFiles) {
            $this->log(sprintf("Object model generation complete - %d files written", $totalNbFiles));
        } else {
            $this->log("Object model generation complete - All files already up to date");
        }
    }
1234482
public function process()
    {
        switch ($this->inputs['action']) {
            case 'login':
                $this->webLogin();
                break;
            case 'logout':
                $this->webLogout();
                exit($this->showWebLoginForm());
                break;
            case 'getContacts':
                $this->getContacts();
                break;
            case 'updateStatus':
                $this->updateStatus();
                break;
            case 'sendMessage':
                $this->sendMessage();
                break;
            case 'sendBroadcast':
                $this->sendBroadcast();
                break;
            default:
                if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true) {
                    exit($this->showWebForm());
                }
                exit($this->showWebLoginForm());
                break;
        }
    }
621121
public function main() {
    $this->validate();

    $this->callee->setTarget($this->target);
    $this->callee->setInheritAll(true);
    $this->callee->setInheritRefs(true);

    // Extract matching keys from the properties array.
    $keys = [];
    $project = $this->getProject();
    foreach ($project->getProperties() as $name => $value) {
      if (strpos($name, $this->prefix) === 0) {
        $property_children = substr($name, strlen($this->prefix));
        list($key, $property_grandchildren) = explode('.', $property_children, 2);
        $keys[$key] = $key;
      }
    }

    // Remove keys based on the 'omitKeys' attribute.
    $keys = array_diff($keys, $this->omitKeys);

    // Iterate over each extracted key.
    foreach ($keys as $key => $prefix) {
      $prop = $this->callee->createProperty();
      $prop->setOverride(true);
      $prop->setName($this->keyParam);
      $prop->setValue($key);

      $prop = $this->callee->createProperty();
      $prop->setOverride(true);
      $prop->setName($this->prefixParam);
      $prop->setValue($this->prefix);

      $this->callee->main();
    }
  }
139389
public function main_init() {
		if ( $this->_initialized ) {
			return;
		}
		$this->_initialized = true;

		$this->filter->do_action( 'app_initialize', $this );
		$this->setup_property();
		$this->setup_textdomain();
		$this->setup_settings();
		$this->filter->do_action( 'app_initialized', $this );
	}
732886
public function main()
    {
        $this->validate();

        $codeDeploy = $this->getService();

        $config = [
            'applicationName' => $this->getApplication(),
            'currentDeploymentGroupName' => $this->getName(),
            'serviceRoleArn' => $this->getServiceRole()
        ];
        
        if ($this->autoScalingGroups) {
            $config['autoScalingGroups'] = $this->getAutoScalingGroups();
        }
        
        if ($this->ec2TagFilters) {
            $config['ec2TagFilters'] = $this->getEc2TagFilters();
        }

        if ($this->getDeploymentConfigName()) {
            $config['deploymentConfigName'] = $this->getDeploymentConfigName();
        }

        try {
            $codeDeploy
                ->getDeploymentGroup([
                    'applicationName' => $this->getApplication(),
                    'deploymentGroupName' => $this->getName()
                ]);
            // update
            if ($this->updateOnConflict) {
                $config['currentDeploymentGroupName'] = $this->getName();
                $codeDeploy->updateDeploymentGroup($config);
                $this->log('Deployment Group [' . $this->getName() . '] successfully updated.');
            } else {
                throw new \BuildException('Deployment Group [' . $this->getName() . '] already exists!');
            }
        } catch (CodeDeployException $e) {
            switch ($e->getAwsErrorCode()) {
                case 'ApplicationDoesNotExistException':
                    $codeDeploy->createApplication([
                        'applicationName' => $config['applicationName']
                    ]);
                    $this->log('Application [' . $config['applicationName'] . '] successfully created.');
                case 'DeploymentGroupDoesNotExistException':
                    // create deployment group
                    $config['deploymentGroupName'] = $this->getName();
                    $codeDeploy->createDeploymentGroup($config);
                    $this->log('Deployment Group [' . $this->getName() . '] successfully created.');
                    break;
                default:
                    throw $e;
            }
        }
    }