本文整理汇总了PHP中Phing::setCurrentProject方法的典型用法代码示例。如果您正苦于以下问题:PHP Phing::setCurrentProject方法的具体用法?PHP Phing::setCurrentProject怎么用?PHP Phing::setCurrentProject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phing
的用法示例。
在下文中一共展示了Phing::setCurrentProject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
/**
* Executes this task.
*/
public function main()
{
if ($this->file === null) {
throw new BuildException('The file attribute must be specified');
}
$return = getcwd();
try {
/* Resolve paths correctly: Everything we do as far as
* configuration is concerned should be relative to the
* new project file. */
chdir($this->file->getAbsoluteFile()->getParent());
$project = new AgaviProxyProject($this->project);
$project->addReference('phing.parsing.context', new AgaviProxyXmlContext($project));
$project->setUserProperty('phing.file', $this->file->getAbsolutePath());
$project->init();
Phing::setCurrentProject($project);
ProjectConfigurator::configureProject($project, $this->file);
foreach ($project->getTargets() as $name => $target) {
/* Make sure we don't add proxy targets back to our own project. */
if ($target instanceof AgaviProxyTarget && $target->getTarget()->getProject() === $this->project) {
continue;
}
if (array_key_exists($name, $this->project->getTargets())) {
throw new BuildException(sprintf('Target conflict: %s already exists in project (attempted to add from %s)', $name, $this->file->getAbsolutePath()));
}
$proxy = new AgaviProxyTarget();
$proxy->setName($name);
$proxy->setDescription($target->getDescription());
$proxy->setTarget($target);
$this->project->addTarget($name, $proxy);
}
Phing::setCurrentProject($this->project);
$this->log(sprintf('Importing external build file %s', $this->file->getAbsolutePath()), Project::MSG_INFO);
} catch (Exception $e) {
$this->log(sprintf('Could not read %s: %s (skipping)', $this->file->getAbsolutePath(), $e->getMessage()), Project::MSG_WARN);
}
/* Go back from whence we came. */
chdir($return);
}
示例2: main
/**
* Executes this target.
*/
public function main()
{
if ($this->name === null) {
throw new BuildException('The name attribute must be specified');
}
/* Words cannot describe how ridiculously fucking stupid this is. Phing
* seems to resolve properties only once, ever, so in order to run a
* target multiple times with different properties we'll have to create
* a new project, parse the build file all over again, copy everything
* over from the current project, execute the new target, and then copy
* everything back. Fuck. */
$project = new Project();
try {
foreach ($this->project->getBuildListeners() as $listener) {
$project->addBuildListener($listener);
}
$project->setInputHandler($this->project->getInputHandler());
$this->project->copyUserProperties($project);
$this->project->copyInheritedProperties($project);
foreach ($this->project->getProperties() as $name => $property) {
if ($project->getProperty($name) === null) {
$project->setNewProperty($name, $property);
}
}
$project->init();
ProjectConfigurator::configureProject($project, new PhingFile($this->project->getProperty('phing.file')));
Phing::setCurrentProject($project);
$project->executeTarget($this->name);
} catch (BuildException $be) {
if ($this->exceptionsFatal) {
throw $be;
} else {
$this->log('Ignoring build exception: ' . $be->getMessage(), Project::MSG_WARN);
$this->log('Continuing build', Project::MSG_INFO);
}
}
Phing::setCurrentProject($this->project);
$project->copyUserProperties($this->project);
$project->copyInheritedProperties($this->project);
foreach ($project->getProperties() as $name => $property) {
if ($this->project->getProperty($name) === null) {
$this->project->setNewProperty($name, $property);
}
}
/* Fuck. */
unset($project);
}
示例3: main
/**
* Executes this target.
*
* @author Noah Fontes <noah.fontes@bitextender.com>
* @since 1.0.0
*/
public function main()
{
$thisProject = $this->getProject();
$project = $this->target->getProject();
Phing::setCurrentProject($project);
chdir($project->getBasedir()->getAbsolutePath());
/* Assign properties for consistency. */
$thisProject->copyUserProperties($project);
$thisProject->copyInheritedProperties($project);
foreach ($thisProject->getProperties() as $name => $property) {
if (!AgaviProxyProject::isPropertyProtected($name) && $project->getProperty($name) === null) {
$project->setNewProperty($name, $property);
}
}
/* Execute the proxied target. */
$project->executeTarget($this->target->getName());
Phing::setCurrentProject($thisProject);
chdir($thisProject->getBasedir()->getAbsolutePath());
$project->copyUserProperties($thisProject);
$project->copyInheritedProperties($thisProject);
foreach ($project->getProperties() as $name => $property) {
if (!AgaviProxyProject::isPropertyProtected($name) && $thisProject->getProperty($name) === null) {
$thisProject->setNewProperty($name, $property);
}
}
}
示例4: AgaviProxyBuildLogger
$logger = new AgaviProxyBuildLogger(new $GLOBALS['LOGGER']());
$logger->setMessageOutputLevel($GLOBALS['VERBOSE'] ? Project::MSG_VERBOSE : Project::MSG_INFO);
$logger->setOutputStream($GLOBALS['OUTPUT']);
$logger->setErrorStream($GLOBALS['ERROR']);
$project->addBuildListener($logger);
$project->setInputHandler(new DefaultInputHandler());
$project->setUserProperty('phing.file', $GLOBALS['BUILD']->getAbsolutePath());
$project->setUserProperty('phing.version', Phing::getPhingVersion());
/* Phing fucks with the cwd. Really, brilliant. */
$project->setUserProperty('application.startdir', START_DIRECTORY);
foreach ($GLOBALS['PROPERTIES'] as $name => $value) {
$project->setUserProperty($name, $value);
}
$project->init();
ProjectConfigurator::configureProject($project, $GLOBALS['BUILD']);
Phing::setCurrentProject($project);
if ($GLOBALS['SHOW_LIST'] === true) {
input_help_display();
$GLOBALS['OUTPUT']->write(PHP_EOL);
$GLOBALS['OUTPUT']->write('Targets:' . PHP_EOL);
$size = 0;
$targets = array();
foreach ($project->getTargets() as $target) {
$name = $target->getName();
$nameSize = strlen($name);
$description = $target->getDescription();
if ($description !== null) {
$size = $nameSize > $size ? $nameSize : $size;
$targets[$name] = $description;
}
}