for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the puli/manager package.
*
* (c) Bernhard Schussek <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Puli\Manager\Repository\Mapping;
use Puli\Manager\Api\Module\RootModuleFile;
use Puli\Manager\Api\Repository\PathMapping;
use Puli\Manager\Transaction\AtomicOperation;
/**
* Adds a path mapping to the root module file.
* @since 1.0
* @author Bernhard Schussek <[email protected]>
class AddPathMappingToModuleFile implements AtomicOperation
{
* @var PathMapping
private $mapping;
* @var RootModuleFile
private $rootModuleFile;
private $previousMapping;
public function __construct(PathMapping $mapping, RootModuleFile $rootModuleFile)
$this->mapping = $mapping;
$this->rootModuleFile = $rootModuleFile;
}
* {@inheritdoc}
public function execute()
$repositoryPath = $this->mapping->getRepositoryPath();
if ($this->rootModuleFile->hasPathMapping($repositoryPath)) {
$this->previousMapping = $this->rootModuleFile->getPathMapping($repositoryPath);
$this->rootModuleFile->addPathMapping($this->mapping);
public function rollback()
if ($this->previousMapping) {
$this->rootModuleFile->addPathMapping($this->previousMapping);
} else {
$this->rootModuleFile->removePathMapping($this->mapping->getRepositoryPath());