Bind any registered build listeners to this project.

This means adding the logger and any build listeners that were specified
with -listener arg.

@param  Project $project
@throws BuildException
@throws ConfigurationException
@return void
15722
private function addBuildListeners(Project $project)
    {
        // Add the default listener
        $project->addBuildListener($this->createLogger());

        foreach ($this->listeners as $listenerClassname) {
            try {
                $clz = Phing::import($listenerClassname);
            } catch (Exception $e) {
                $msg = "Unable to instantiate specified listener "
                    . "class " . $listenerClassname . " : "
                    . $e->getMessage();
                throw new ConfigurationException($msg);
            }

            $listener = new $clz();

            if ($listener instanceof StreamRequiredBuildLogger) {
                throw new ConfigurationException("Unable to add " . $listenerClassname . " as a listener, since it requires explicit error/output streams. (You can specify it as a -logger.)");
            }
            $project->addBuildListener($listener);
        }
    }
983144
public function init(?string $configuration = 'project'): void
    {
        $config = Core::i()->config->getConfiguration($configuration);
        if (isset($config['site_name'])) {
            $this->site_name = $config['site_name'];
        }
        if (isset($config['title_format'])) {
            $this->title_format = $config['title_format'];
        }
    }
260785
function (project) {
			if (project) {
				this._projectClient.getProjectLaunchConfigurations(project).then(function(launchConfigurations){
					if (project !== this._project) return;
					this._setLaunchConfigurations(launchConfigurations);
				}.bind(this));
			} else {
				this._setLaunchConfigurations(null);
			}
		}
539951
private function configureListeners(array $listenersConfig, ContainerBuilder $container): void
    {
        $container->getDefinition('fivelab.resource.event_listener.exception')
            ->replaceArgument(3, $listenersConfig['exception']['debug_parameter']);

        if ($this->isConfigEnabled($container, $listenersConfig['validation'])) {
            if (!interface_exists(ValidatorInterface::class)) {
                throw new \RuntimeException('The validation listener is enabled but the Symfony/Validator not installed. Please install Symfony/Validator package.');
            }
        } else {
            $container->removeDefinition('fivelab.resource.event_listener.validate_resource');
        }

        if ($this->isConfigEnabled($container, $listenersConfig['symfony_security'])) {
            if (!interface_exists(AuthorizationCheckerInterface::class)) {
                throw new \RuntimeException('The security listener is enabled but the Symfony/Security not installed. Please install Symfony/Security package.');
            }
        } else {
            $container->removeDefinition('fivelab.resource.serializer.event_listener.symfony_granted_relation');
            $container->removeDefinition('fivelab.resource.serializer.event_listener.symfony_granted_action');
        }
    }
1352779
public void registerListener(ConfigurationListener<T> listener) {
        Util.notNull(listener, "Configuration listener");
        listeners.add(listener);
    }
237989
protected function handleConfig(Builder $builder, $buildPath)
    {
        $build_config = null;

        // Try getting the project build config from the database:
        if (empty($build_config)) {
            $build_config = $this->getProject()->getBuildConfig();
        }

        // Try .phpci.yml
        if (is_file($buildPath . '/.phpci.yml')) {
            $build_config = file_get_contents($buildPath . '/.phpci.yml');
        }

        // Try phpci.yml first:
        if (empty($build_config) && is_file($buildPath . '/phpci.yml')) {
            $build_config = file_get_contents($buildPath . '/phpci.yml');
        }

        // Fall back to zero config plugins:
        if (empty($build_config)) {
            $build_config = $this->getZeroConfigPlugins($builder);
        }

        if (is_string($build_config)) {
            $yamlParser = new YamlParser();
            $build_config = $yamlParser->parse($build_config);
        }

        $builder->setConfigArray($build_config);
        return true;
    }
316342
protected function configure()
    {
        $this
            ->setName('detect')
            ->setDefinition(
                [
                    new InputArgument('path', InputArgument::OPTIONAL, 'path of the project', null),
                    new InputOption(
                        'config-file',
                        'c',
                        InputOption::VALUE_REQUIRED,
                        'File path of the configuration file'
                    ),
                    new InputOption(
                        'format',
                        'f',
                        InputOption::VALUE_REQUIRED,
                        sprintf('Output format (%s)', implode(', ', $this->formats)),
                        $this->formats[0]
                    ),
                ]
            )
            ->setDescription('Detect coupling rules')
            ->setHelp($this->loadHelpContent());
    }
22568
public function maybeConfigure(Project $project)
    {
        if ($this->proxyConfigured) {
            return;
        }

        $id = null;

        // DataType configured in ProjectConfigurator
        //        if ( is_a($this->wrappedObject, "DataType") )
        //            return;

        if ($this->attributes || (isset($this->characters) && $this->characters != '')) {
            ProjectConfigurator::configure($this->wrappedObject, $this->attributes, $project);

            if (isset($this->attributes["id"])) {
                $id = $this->attributes["id"];
            }

            if (isset($this->characters) && $this->characters != '') {
                ProjectConfigurator::addText($project, $this->wrappedObject, (string) $this->characters);
            }
            if ($id !== null) {
                $project->addReference($id, $this->wrappedObject);
            }
        }

        /*if ( is_array($this->children) && !empty($this->children) ) {
            // Configure all child of this object ...
            foreach ($this->children as $child) {
                $child->maybeConfigure($project);
                ProjectConfigurator::storeChild($project, $this->wrappedObject, $child->wrappedObject, strtolower($child->getElementTag()));
            }
        }*/

        $this->proxyConfigured = true;
    }
1303173
public function onBuildView(CollectViewParametersEvent $event): void
    {
        $view = $event->getView();
        if (!$view instanceof LayoutViewInterface) {
            return;
        }

        if ($view->getContext() !== ViewInterface::CONTEXT_ADMIN) {
            return;
        }

        $event->addParameter('http_cache_enabled', $this->cacheEnabled);
    }
1132715
@Override
  public void execute() throws BuildException {
    validate();

    String seedValue = Strings.emptyToNull(getProject().getProperty(propertyName)); 
    if (seedValue == null) {
      seedValue = SeedUtils.formatSeed(new Random().nextLong());
      log("Picking master seed for property '" + propertyName + "': "
          + seedValue, Project.MSG_VERBOSE);
      getProject().setProperty(propertyName, seedValue);
    } else {
      log("Seed property '" + propertyName + "' already defined: "
          + seedValue, Project.MSG_INFO);
    }
  }
883006
public function main()
    {
        if (method_exists($this->proxy, "setLocation")) {
            try { // try to set location
                $this->proxy->setLocation($this->getLocation());
            } catch (Exception $ex) {
                $this->log("Error setting location in " . get_class($this->proxy) . Project::MSG_ERR);
                throw new BuildException($ex);
            }
        } else {
            throw new Exception("Error setting location in class " . get_class($this->proxy));
        }

        if (method_exists($this->proxy, "setProject")) {
            try { // try to set project
                $this->proxy->setProject($this->project);
            } catch (Exception $ex) {
                $this->log("Error setting project in " . get_class($this->proxy) . Project::MSG_ERR);
                throw new BuildException($ex);
            }
        } else {
            throw new Exception("Error setting project in class " . get_class($this->proxy));
        }

        try { //try to call main
            DispatchUtils::main($this->proxy);
        } catch (BuildException $be) {
            throw $be;
        } catch (Exception $ex) {
            $this->log("Error in " . get_class($this->proxy), Project::MSG_ERR);
            throw new BuildException("Error in " . get_class($this->proxy), $ex);
        }
    }
1230118
public function perform(): void
    {
        $reason = null;
        try { // try executing task
            $this->project->fireTaskStarted($this);
            $this->maybeConfigure();
            DispatchUtils::main($this);
        } catch (\BuildException $ex) {
            $loc = $ex->getLocation();
            if ($loc === null || (string) $loc === '') {
                $ex->setLocation($this->getLocation());
            }
            $reason = $ex;
            throw $ex;
        } catch (\Exception $ex) {
            $reason = $ex;
            $be = new \BuildException($ex);
            $be->setLocation($this->getLocation());
            throw $be;
        } catch (\Error $ex) {
            $reason = $ex;
            throw $ex;
        } finally {
            $this->project->fireTaskFinished($this, $reason);
        }
    }
933425
public function main()
    {
        $exc = null;

        if (empty($this->tryContainer)) {
            throw new BuildException('A nested <try> element is required');
        }

        try {
            $this->tryContainer->perform();
        } catch (BuildException $e) {
            if (!empty($this->propertyName)) {
                $this->project->setProperty($this->propertyName, $e->getMessage());
            }

            if (!empty($this->referenceName)) {
                $this->project->addReference($this->referenceName, $e);
            }

            if (!empty($this->catchContainer)) {
                $this->catchContainer->perform();
            } else {
                $exc = $e;
            }
        }

        if (!empty($this->finallyContainer)) {
            $this->finallyContainer->perform();
        }

        if (!empty($exc)) {
            throw $exc;
        }
    }
170944
public function addText(Project $project, $element, $text)
    {
        if ($this->methodAddText === null) {
            $msg = $this->getElementName($project, $element) . " doesn't support nested text data.";
            throw new BuildException($msg);
        }
        try {
            $method = $this->methodAddText;
            $method->invoke($element, $text);
        } catch (Exception $exc) {
            throw new BuildException($exc->getMessage(), $exc);
        }
    }
347585
public function execute(ProjectDescriptor $project)
    {
        Dispatcher::getInstance()->dispatch(
            self::EVENT_PRE_TRANSFORM,
            PreTransformEvent::createInstance($this)->setProject($project)
        );

        $transformations = $this->getTemplates()->getTransformations();
        $this->initializeWriters($project, $transformations);
        $this->transformProject($project, $transformations);

        Dispatcher::getInstance()->dispatch(self::EVENT_POST_TRANSFORM, PostTransformEvent::createInstance($this));

        $this->log('Finished transformation process');
    }
841949
public function onBuildView(CollectViewParametersEvent $event): void
    {
        $view = $event->getView();
        if (!$view instanceof LayoutViewInterface) {
            return;
        }

        if ($view->getContext() !== ViewInterface::CONTEXT_ADMIN) {
            return;
        }

        $ruleCount = 0;
        if ($view->getLayout()->isPublished()) {
            $ruleCount = $this->layoutResolverService->getRuleCount($view->getLayout());
        }

        $event->addParameter('rule_count', $ruleCount);
    }
999377
public function runBuild()
    {
        if (!$this->readyToRun) {
            return;
        }

        $project = new Project();

        self::setCurrentProject($project);
        set_error_handler(['Phing', 'handlePhpError']);

        $error = null;

        $this->addBuildListeners($project);
        $this->addInputHandler($project);

        // set this right away, so that it can be used in logging.
        $project->setUserProperty("phing.file", $this->buildFile->getAbsolutePath());
        $project->setUserProperty("phing.dir", dirname($this->buildFile->getAbsolutePath()));

        try {
            $project->fireBuildStarted();
            $project->init();
        } catch (Exception $exc) {
            $project->fireBuildFinished($exc);
            throw $exc;
        }

        $project->setKeepGoingMode($this->keepGoingMode);

        $project->setUserProperty("phing.version", static::getPhingVersion());

        $e = self::$definedProps->keys();
        while (count($e)) {
            $arg = (string) array_shift($e);
            $value = (string) self::$definedProps->getProperty($arg);
            $project->setUserProperty($arg, $value);
        }
        unset($e);

        $project->setUserProperty("phing.file", $this->buildFile->getAbsolutePath());

        // first use the Configurator to create the project object
        // from the given build file.

        try {
            ProjectConfigurator::configureProject($project, $this->buildFile);
        } catch (Exception $exc) {
            $project->fireBuildFinished($exc);
            restore_error_handler();
            self::unsetCurrentProject();
            throw $exc;
        }

        // Set the project mode
        $project->setStrictMode(StringHelper::booleanValue($this->strictMode));

        // make sure that we have a target to execute
        if (count($this->targets) === 0) {
            $this->targets[] = $project->getDefaultTarget();
        }

        // make sure that minimum required phing version is satisfied
        try {
            $this->comparePhingVersion($project->getPhingVersion());
        } catch (Exception $exc) {
            $project->fireBuildFinished($exc);
            restore_error_handler();
            self::unsetCurrentProject();
            throw $exc;
        }

        // execute targets if help param was not given
        if (!$this->projectHelp) {
            try {
                $project->executeTargets($this->targets);
            } catch (Exception $exc) {
                $project->fireBuildFinished($exc);
                restore_error_handler();
                self::unsetCurrentProject();
                throw $exc;
            }
        }
        // if help is requested print it
        if ($this->projectHelp) {
            try {
                $this->printDescription($project);
                $this->printTargets($project);
            } catch (Exception $exc) {
                $project->fireBuildFinished($exc);
                restore_error_handler();
                self::unsetCurrentProject();
                throw $exc;
            }
        }

        // finally {
        if (!$this->projectHelp) {
            $project->fireBuildFinished(null);
        }

        restore_error_handler();
        self::unsetCurrentProject();
    }