The helper "main"

@return Head
166143
public function head($options = null) {
		if ($options !== null) {
			$this->setOptions($options, false, false);
		}
		
		return $this;
	}
426021
public function main()
    {
        $this->validate();

        try {
            if ($this->to !== null) {
                // create a file writer to append to "to" file.
                $writer = new FileWriter($this->to, $this->append);
            } else {
                $writer = new LogWriter($this);
            }

            if ($this->text !== null) {
                // simply append the text
                if ($this->to instanceof PhingFile) {
                    $this->log("Appending string to " . $this->to->getPath());
                }

                $text = $this->text;
                if ($this->filtering) {
                    $fr = $this->getFilteredReader(new StringReader($text));
                    $text = $fr->read();
                }

                $text = $this->appendHeader($text);
                $text = $this->appendFooter($text);
                $writer->write($text);
            } else {
                // append explicitly-specified file
                if ($this->file !== null) {
                    try {
                        $this->appendFile($writer, $this->file);
                    } catch (Exception $ioe) {
                        $this->log(
                            "Unable to append contents of file " . $this->file->getAbsolutePath() . ": " . $ioe->getMessage(),
                            Project::MSG_WARN
                        );
                    }
                }

                // append any files in filesets
                foreach ($this->filesets as $fs) {
                    try {
                        if ($fs instanceof Path) {
                            $files = $fs->listPaths();
                            $this->appendFiles($writer, $files);
                        } elseif ($fs instanceof FileSet) {
                            $files = $fs->getDirectoryScanner($this->project)->getIncludedFiles();
                            $this->appendFiles($writer, $files, $fs->getDir($this->project));
                        }
                    } catch (BuildException $be) {
                        if (strpos($be->getMessage(), 'is the same as the output file') === false) {
                            $this->log($be->getMessage(), Project::MSG_WARN);
                        } else {
                            throw new BuildException($be->getMessage());
                        }
                    } catch (IOException $ioe) {
                        throw new BuildException($ioe);
                    }
                }

                foreach ($this->filelists as $list) {
                    $dir = $list->getDir($this->project);
                    $files = $list->getFiles($this->project);
                    foreach ($files as $file) {
                        $this->appendFile($writer, new PhingFile($dir, $file));
                    }
                }
            }
        } catch (Exception $e) {
            throw new BuildException($e);
        }

        $writer->close();
    }
438256
public function getHead() {
		if ($this->_head === null) {
			$this->_head = new TablePart();
			$this->_head->setTag(self::TAG_HEAD);
			$this->_head->setHeadPart(true);
		}
		
		return $this->_head;
	}
800215
public Head createHead() {
        final Head head = new Head(getRoot(), "Head");
        getRoot().insert(head);
        return head;
    }
859504
public function out_head(){
		$this->frameworks_process();
		if($this->lazyload){
			$this->lazyload_prepare();
			}
		//Outputing
		$tab='  ';
		echo($tab.'<title>'.$this->title.'</title>'.PHP_EOL);
		if(!empty($this->link_canonical)){
			echo($tab.'<link rel="canonical" href="'.$this->link_canonical.'" />'.PHP_EOL);
			}
		//Add meta info...
		foreach($this->meta as $mi){
			echo($tab.'<meta');
			if(!empty($mi['name'])){
				echo(' name="'.$mi['name'].'"');
				}
			if(!empty($mi['http_equiv'])){
				echo(' http-equiv="'.$mi['http_equiv'].'"');
				}
			echo(' content="'.htmlspecialchars($mi['content']).'"');
			echo('>'.PHP_EOL);
			}
		//Add CSS, author, etc.
		foreach($this->link as $lnk){
			echo($tab.'<link');
			foreach($lnk as $key=>$value){
				echo(' '.$key.'="'.htmlspecialchars($value).'"');
				}
			echo(' />'.PHP_EOL);
			}
		//sort js with priority
		$this->js_sort();
		//Outputing style declaration...
		foreach($this->style as $style){
			echo($tab.'<style>');
			echo($style);
			echo($tab.'</style>'.PHP_EOL);
			}
		//Add javascript...
		foreach($this->js as $js){
			echo($tab.'<script type="text/javascript"');
			if(!empty($js['src'])){
				echo(' src="'.$js['src'].'"');
				}
			echo('>'.$js['val'].'</script>'.PHP_EOL);
			}
		}
50668
public function main()
    {
        if ($this->params['stagger']) {
            sleep(rand(0, $this->params['stagger']));
        }

        Configure::write('App.baseUrl', '/');
        $emailQueue = TableRegistry::getTableLocator()->get('EmailQueue', ['className' => EmailQueueTable::class]);
        $emails = $emailQueue->getBatch($this->params['limit']);

        $count = count($emails);
        foreach ($emails as $e) {
            $configName = $e->config === 'default' ? $this->params['config'] : $e->config;
            $template = $e->template === 'default' ? $this->params['template'] : $e->template;
            $layout = $e->layout === 'default' ? $this->params['layout'] : $e->layout;
            $headers = empty($e->headers) ? [] : (array)$e->headers;
            $theme = empty($e->theme) ? '' : (string)$e->theme;
            $viewVars = empty($e->template_vars) ? [] : $e->template_vars;
            $errorMessage = null;

            try {
                $email = $this->_newEmail($configName);

                if (!empty($e->from_email) && !empty($e->from_name)) {
                    $email->setFrom($e->from_email, $e->from_name);
                }

                $transport = $email->getTransport();

                if ($transport && $transport->getConfig('additionalParameters')) {
                    $from = key($email->getFrom());
                    $transport->setConfig(['additionalParameters' => "-f $from"]);
                }

                if (!empty($e->attachments)) {
                    $email->setAttachments($e->attachments);
                }

                $sent = $email
                    ->setTo($e->email)
                    ->setSubject($e->subject)
                    ->setEmailFormat($e->format)
                    ->addHeaders($headers)
                    ->setViewVars($viewVars)
                    ->setMessageId(false)
                    ->setReturnPath($email->getFrom());

                $email->viewBuilder()
                    ->setLayout($layout)
                    ->setTheme($theme)
                    ->setTemplate($template);

                $email->send();
            } catch (SocketException $exception) {
                $this->err($exception->getMessage());
                $errorMessage = $exception->getMessage();
                $sent = false;
            }

            if ($sent) {
                $emailQueue->success($e->id);
                $this->out('<success>Email ' . $e->id . ' was sent</success>');
            } else {
                $emailQueue->fail($e->id, $errorMessage);
                $this->out('<error>Email ' . $e->id . ' was not sent</error>');
            }
        }
        if ($count > 0) {
            $locks = collection($emails)->extract('id')->toList();
            $emailQueue->releaseLocks($locks);
        }
    }
419770
public function main()
    {
        $options = (array)$this->params;
        if (empty($options['use'])) {
            $this->err(__d('eav', 'You must indicate a table alias name using the "--use" option. Example: "Articles.Users"'));

            return false;
        }

        try {
            $table = TableRegistry::get($options['use']);
        } catch (\Exception $ex) {
            $table = false;
        }

        if (!$table) {
            $this->err(__d('eav', 'The specified table does not exists.'));

            return false;
        } elseif (!$table->behaviors()->has('Eav')) {
            $this->err(__d('eav', 'The specified table is not using EAV behavior.'));

            return false;
        } elseif (empty($options['name'])) {
            $this->err(__d('eav', 'You must indicate a table column.'));

            return false;
        } elseif (!preg_match('/^[a-z\d\-_]+$/', $options['name'])) {
            $this->err(__d('eav', 'Invalid column name, please use only lowercase letters, numbers, "-" and "_", e.g.: "user_age".'));

            return false;
        }

        $meta = [
            'type' => $options['type'],
            'bundle' => (empty($options['bundle']) ? null : (string)$options['bundle']),
            'searchable' => $options['searchable'],
            'overwrite' => $options['overwrite'],
        ];

        if ($options['action'] == 'drop') {
            return $table->dropColumn($options['name'], $meta['bundle']);
        }

        try {
            $errors = $table->addColumn($options['name'], $meta);
            if (!empty($errors)) {
                foreach ($errors as $message) {
                    $this->err($message);
                }

                return false;
            }

            return true;
        } catch (FatalErrorException $ex) {
            $this->err($ex->getMessage());

            return false;
        }
    }
1258774
public function main()
    {
        $table = $this->loadModel('Audits');
        $table->hasMany('AuditDeltas');
        $table->schema()->columnType('created', 'text');
        $map = [];
        $meta = [];

        $featureList = function ($element) {
            list($k, $v) = explode(':', $element);
            yield $k => $v;
        };

        if (!empty($this->params['type-map'])) {
            $map = explode(',', $this->params['type-map']);
            $map = collection($map)->unfold($featureList)->toArray();
        }

        if (!empty($this->params['extra-meta'])) {
            $meta = explode(',', $this->params['extra-meta']);
            $meta = collection($meta)->unfold($featureList)->toArray();
        }

        $from = (new Time($this->params['from']))->modify('midnight');
        $until = (new Time($this->params['until']))->modify('23:59:59');

        $currentId = null;
        $buffer = new \SplQueue();
        $buffer->setIteratorMode(\SplDoublyLinkedList::IT_MODE_DELETE);
        $queue = new \SplQueue();
        $queue->setIteratorMode(\SplDoublyLinkedList::IT_MODE_DELETE);
        $index = ConnectionManager::get('auditlog_elastic')->getConfig('index');

        $eventsFormatter = function ($audit) use ($index, $meta) {
            return $this->eventFormatter($audit, $index, $meta);
        };
        $changesExtractor = [$this, 'changesExtractor'];

        $query = $table->find()
            ->where(function ($exp) use ($from, $until) {
                return $exp->between('Audits.created', $from, $until, 'datetime');
            })
            ->where(function ($exp) {
                if (!empty($this->params['exclude-models'])) {
                    $exp->notIn('Audits.model', explode(',', $this->params['exclude-models']));
                }

                if (!empty($this->params['models'])) {
                    $exp->in('Audits.model', explode(',', $this->params['models']));
                }
                return $exp;
            })
            ->matching('AuditDeltas')
            ->order(['Audits.created', 'AuditDeltas.audit_id'])
            ->bufferResults(false)
            ->hydrate(false)
            ->unfold(function ($audit) use ($buffer, &$currentId) {
                if ($currentId && $currentId !== $audit['id']) {
                    yield collection($buffer)->toList();
                }
                $currentId = $audit['id'];
                $buffer->enqueue($audit);
            })
            ->map($changesExtractor)
            ->map($eventsFormatter)
            ->unfold(function ($audit) use ($queue) {
                $queue->enqueue($audit);

                if ($queue->count() >= 50) {
                    yield collection($queue)->toList();
                }
            });

        $query->each([$this, 'persistBulk']);

        // There are probably some un-yielded results, let's flush them
        $rest = collection(count($buffer) ? [collection($buffer)->toList()] : [])
            ->map($changesExtractor)
            ->map($eventsFormatter)
            ->append($queue);

        $this->persistBulk($rest->toList());

        return true;
    }
143608
public function main()
    {
        $worker = $this->gearmanWorker();

        $jobs = $this->_getJobs();

        foreach ($jobs as $job => $options) {
            $worker->addFunction($job, function (GearmanJob $job) use ($options) {
                $task = $this->Tasks->load($options['className']);

                // @codingStandardsIgnoreStart
                $workload = @unserialize($job->workload());
                // @codingStandardsIgnoreEnd
                if ($workload === false) {
                    $workload = $job->workload();
                }

                try {
                    $response = $task->main($workload, $job);
                } catch (\Exception $exception) {
                    $response = null;

                    $this->log($exception, LogLevel::ERROR);
                }

                if (is_array($response) || is_object($response)) {
                    $response = serialize($response);
                }

                return $response;
            });
        }

        while ($worker->work()) {
            if ($worker->returnCode() != GEARMAN_SUCCESS) {
                $this->out('return_code: ' . $worker->returnCode());
                break;
            }
        }
    }
1374706
public function main()
    {

        $sec           = 0;
        $target        = $this->getOwningTarget();
        $targetName    = $target->getName();
        $subTargetName = $this->subTarget;
        $allTargets    = $this->project->getTargets();

        $usedTargets   = array_filter(
            $allTargets,
            function ($key) {
                return strrpos($key, ".".$targetName) > 0;
            },
            ARRAY_FILTER_USE_KEY
        );

        // If the target was redefined outside of the starterkit.
        if (!empty($usedTargets)) {
            $sec       = 10;
            $newTarget = $targetName;
            $buildFile = "build.project.xml";
            $target    = $allTargets[$subTargetName];
        } else {
            // If a deprecated target is called without redefinition.
            $sec       = 5;
            $newTarget = $subTargetName;
            $buildFile = $this->project->getProperty("phing.file");
        }

        // Inform user of the deprecated target.
        $this->log(
            "Target '".$targetName."' has been replaced by '".$subTargetName."'.",
            Project::MSG_WARN
        );
        $this->log(
            "A ".$sec." second penalty is assigned usage of this target.",
            Project::MSG_WARN
        );
        $this->log(
            "Please use '".$subTargetName."' instead to avoid the penalty.",
            Project::MSG_WARN
        );
        $this->log(
            "Running PhingCallTask for target '".$subTargetName."'",
            Project::MSG_DEBUG
        );
        sleep($sec);

        if ($this->_callee === null) {
            $this->init();
        }

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

        $this->_callee->setPhingfile($buildFile);
        $this->_callee->setTarget($newTarget);
        $this->_callee->setOwningTarget($target);
        $this->_callee->setInheritAll($this->_inheritAll);
        $this->_callee->setInheritRefs($this->_inheritRefs);
        $this->_callee->main();

    }
579254
public function main()
    {
        $this->loadModel('System.Plugins');

        try {
            $plugin = plugin($this->params['plugin']);
            $existsInDb = (bool)$this->Plugins
                ->find()
                ->where(['name' => $this->params['plugin']])
                ->count();
        } catch (\Exception $e) {
            $plugin = $existsInDb = false;
        }

        if (!$plugin || !$existsInDb) {
            $this->err(__d('installer', 'Plugin "{0}" was not found.', $this->params['plugin']));

            return false;
        }

        if ($this->params['status'] === 'enable') {
            return $this->_enable($plugin);
        }

        return $this->_disable($plugin);
    }
214522
public function main()
    {
        $clone = $this->getFactoryInstance('log');

        if ($this->repository === '') {
            $project = $this->getProject();
            $dir = $project->getProperty('application.startdir');
        } else {
            $dir = $this->repository;
        }
        $clone->setCwd($dir);

        if ($this->maxCount !== null) {
            $max = filter_var($this->maxCount, FILTER_VALIDATE_INT);
            if ($max) {
                $max = (int) $this->maxCount;
            }
            if (!$max || (int) $this->maxCount <= 0) {
                throw new BuildException("maxcount should be a positive integer.");
            }
            $clone->setLimit('' . $this->maxCount);
        }

        if ($this->format !== null) {
            $clone->setTemplate($this->format);
        }

        if ($this->revision !== '') {
            $clone->setRev($this->revision);
        }

        try {
            $this->log("Executing: " . $clone->asString(), Project::MSG_INFO);
            $output = $clone->execute();
            if ($this->outputProperty !== null) {
                $this->project->setProperty($this->outputProperty, $output);
            } else {
                if ($output !== '') {
                    $this->log(PHP_EOL . $output);
                }
            }
        } catch (Exception $ex) {
            $msg = $ex->getMessage();
            $p = strpos($msg, 'hg returned:');
            if ($p !== false) {
                $msg = substr($msg, $p + 13);
            }
            throw new BuildException($msg);
        }
    }
1049304
public function main()
  {
    // Get base info about project.
    $this->prepareProjectData();

    // Get all info about source files.
    $this->getInfoSourceFiles();

    // Get all info about resource files.
    $this->getInfoResourceFiles();

    // Prepare all place holders.
    $this->preparePlaceHolders();

    // Replace references to resource files with references to optimized/minimized resource files.
    $this->processingSourceFiles();

    // Compress and rename files with hash.
    $this->processResourceFiles();

    // Create pre-compressed versions of the optimized/minimized resource files.
    if ($this->gzipFlag) $this->gzipCompressOptimizedResourceFiles();

    // Remove original resource files that are optimized/minimized.
    $this->unlinkResourceFiles();
  }
669914
public function main()
    {
        $clone = $this->getFactoryInstance('revert');
        $clone->setQuiet($this->getQuiet());
        $clone->setAll($this->all);
        if ($this->repository === '') {
            $project = $this->getProject();
            $dir = $project->getProperty('application.startdir');
        } else {
            $dir = $this->repository;
        }
        $cwd = getcwd();
        $this->checkRepositoryIsDirAndExists($dir);
        chdir($dir);
        if ($this->revision !== '') {
            $clone->setRev($this->revision);
        }
        if ($this->file !== null) {
            $clone->addName($this->file);
        }

        try {
            $this->log("Executing: " . $clone->asString(), Project::MSG_INFO);
            $output = $clone->execute();
            if ($output !== '') {
                $this->log(PHP_EOL . $output);
            }
        } catch (Exception $ex) {
            $msg = $ex->getMessage();
            $p = strpos($msg, 'hg returned:');
            if ($p !== false) {
                $msg = substr($msg, $p + 13);
            }
            throw new BuildException($msg);
        }
    }
1216066
public function main()
    {
        $this->setTaskName('spc');
        $map = $this->getMap();
        // Multiple symlinks
        foreach ($map as $directory => $symlinks) {
            $this->makeDirectory($directory);
            foreach ($symlinks as  $targetName => $symlink) {
                $this->symlink($symlink['target'], $symlink['link']);
            }
        }

        return true;
    }
868488
protected function buildMainFunction() {
        $functionPrefix = $this->options->getFunctionPrefix();
        $result = 'Void ' . $functionPrefix . '_Dummy() {}' . PHP_EOL
                . 'main() {' . PHP_EOL
                . $this->eventHandlerFactory->getHandler('Load')->getInlineCode()
                . '    yield;' . PHP_EOL
                . $this->eventHandlerFactory->getHandler('FirstLoop')->getInlineCode()
                . $this->buildEventLoop()
                . '}' . PHP_EOL;
        return $result;
    }
585590
public function front() {
        if (null === $this->queue) return null;
        if ($this->tail > $this->head) return null;
        return $this->queue[$this->tail];
    }