Skip to content

Moved the rest of Puli\Manager\Api\Package to Puli\Manager\Api\Module #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"puli/repository": "^1.0-beta9",
"puli/discovery": "^1.0-beta9",
"puli/url-generator": "^1.0-beta4",
"puli/manager": "^1.0-beta10",
"puli/manager": "^1.0-beta11@dev",
"webmozart/console": "^1.0-beta4",
"webmozart/path-util": "^2.2.2",
"webmozart/expression": "^1.0",
"webmozart/glob": "^4.0",
"webmozart/json": "^1.2.2",
"webmozart/json": "^1.2.2@dev",
"padraic/phar-updater": "^1.0.1"
},
"require-dev": {
Expand Down
100 changes: 50 additions & 50 deletions src/Handler/BindCommandHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
use Puli\Manager\Api\Discovery\BindingDescriptor;
use Puli\Manager\Api\Discovery\BindingState;
use Puli\Manager\Api\Discovery\DiscoveryManager;
use Puli\Manager\Api\Package\PackageCollection;
use Puli\Manager\Api\Package\RootPackage;
use Puli\Manager\Api\Module\ModuleList;
use Puli\Manager\Api\Module\RootModule;
use RuntimeException;
use Webmozart\Console\Api\Args\Args;
use Webmozart\Console\Api\IO\IO;
Expand All @@ -43,9 +43,9 @@ class BindCommandHandler
private $discoveryManager;

/**
* @var PackageCollection
* @var ModuleList
*/
private $packages;
private $modules;

/**
* @var string
Expand All @@ -55,40 +55,40 @@ class BindCommandHandler
/**
* Creates the handler.
*
* @param DiscoveryManager $discoveryManager The discovery manager.
* @param PackageCollection $packages The loaded packages.
* @param DiscoveryManager $discoveryManager The discovery manager
* @param ModuleList $modules The loaded modules
*/
public function __construct(DiscoveryManager $discoveryManager, PackageCollection $packages)
public function __construct(DiscoveryManager $discoveryManager, ModuleList $modules)
{
$this->discoveryManager = $discoveryManager;
$this->packages = $packages;
$this->modules = $modules;
}

/**
* Handles the "bind --list" command.
*
* @param Args $args The console arguments.
* @param IO $io The I/O.
* @param Args $args The console arguments
* @param IO $io The I/O
*
* @return int The status code.
* @return int The status code
*/
public function handleList(Args $args, IO $io)
{
$packageNames = ArgsUtil::getPackageNames($args, $this->packages);
$moduleNames = ArgsUtil::getModuleNames($args, $this->modules);
$bindingStates = $this->getBindingStates($args);

$printBindingState = count($bindingStates) > 1;
$printPackageName = count($packageNames) > 1;
$printHeaders = $printBindingState || $printPackageName;
$printModuleName = count($moduleNames) > 1;
$printHeaders = $printBindingState || $printModuleName;
$printAdvice = true;
$indentation = $printBindingState && $printPackageName ? 8
: ($printBindingState || $printPackageName ? 4 : 0);
$indentation = $printBindingState && $printModuleName ? 8
: ($printBindingState || $printModuleName ? 4 : 0);

foreach ($bindingStates as $bindingState) {
$bindingStatePrinted = !$printBindingState;

foreach ($packageNames as $packageName) {
$expr = Expr::method('getContainingPackage', Expr::method('getName', Expr::same($packageName)))
foreach ($moduleNames as $moduleName) {
$expr = Expr::method('getContainingModule', Expr::method('getName', Expr::same($moduleName)))
->andMethod('getState', Expr::same($bindingState));

$descriptors = $this->discoveryManager->findBindingDescriptors($expr);
Expand All @@ -104,9 +104,9 @@ public function handleList(Args $args, IO $io)
$bindingStatePrinted = true;
}

if ($printPackageName) {
if ($printModuleName) {
$prefix = $printBindingState ? ' ' : '';
$io->writeLine(sprintf('%sPackage: %s', $prefix, $packageName));
$io->writeLine(sprintf('%sModule: %s', $prefix, $moduleName));
$io->writeLine('');
}

Expand All @@ -128,9 +128,9 @@ public function handleList(Args $args, IO $io)
/**
* Handles the "bind <query> <type>" command.
*
* @param Args $args The console arguments.
* @param Args $args The console arguments
*
* @return int The status code.
* @return int The status code
*/
public function handleAdd(Args $args)
{
Expand Down Expand Up @@ -167,9 +167,9 @@ public function handleAdd(Args $args)
/**
* Handles the "bind --update <uuid>" command.
*
* @param Args $args The console arguments.
* @param Args $args The console arguments
*
* @return int The status code.
* @return int The status code
*/
public function handleUpdate(Args $args)
{
Expand All @@ -181,10 +181,10 @@ public function handleUpdate(Args $args)
$descriptorToUpdate = $this->getBindingByUuidPrefix($args->getArgument('uuid'));
$bindingToUpdate = $descriptorToUpdate->getBinding();

if (!$descriptorToUpdate->getContainingPackage() instanceof RootPackage) {
if (!$descriptorToUpdate->getContainingModule() instanceof RootModule) {
throw new RuntimeException(sprintf(
'Can only update bindings in the package "%s".',
$this->packages->getRootPackageName()
'Can only update bindings in the module "%s".',
$this->modules->getRootModuleName()
));
}

Expand Down Expand Up @@ -213,18 +213,18 @@ public function handleUpdate(Args $args)
/**
* Handles the "bind --delete" command.
*
* @param Args $args The console arguments.
* @param Args $args The console arguments
*
* @return int The status code.
* @return int The status code
*/
public function handleDelete(Args $args)
{
$bindingToRemove = $this->getBindingByUuidPrefix($args->getArgument('uuid'));

if (!$bindingToRemove->getContainingPackage() instanceof RootPackage) {
if (!$bindingToRemove->getContainingModule() instanceof RootModule) {
throw new RuntimeException(sprintf(
'Can only delete bindings from the package "%s".',
$this->packages->getRootPackageName()
'Can only delete bindings from the module "%s".',
$this->modules->getRootModuleName()
));
}

Expand All @@ -236,18 +236,18 @@ public function handleDelete(Args $args)
/**
* Handles the "bind --enable" command.
*
* @param Args $args The console arguments.
* @param Args $args The console arguments
*
* @return int The status code.
* @return int The status code
*/
public function handleEnable(Args $args)
{
$bindingToEnable = $this->getBindingByUuidPrefix($args->getArgument('uuid'));

if ($bindingToEnable->getContainingPackage() instanceof RootPackage) {
if ($bindingToEnable->getContainingModule() instanceof RootModule) {
throw new RuntimeException(sprintf(
'Cannot enable bindings in the package "%s".',
$bindingToEnable->getContainingPackage()->getName()
'Cannot enable bindings in the module "%s".',
$bindingToEnable->getContainingModule()->getName()
));
}

Expand All @@ -259,18 +259,18 @@ public function handleEnable(Args $args)
/**
* Handles the "bind --disable" command.
*
* @param Args $args The console arguments.
* @param Args $args The console arguments
*
* @return int The status code.
* @return int The status code
*/
public function handleDisable(Args $args)
{
$bindingToDisable = $this->getBindingByUuidPrefix($args->getArgument('uuid'));

if ($bindingToDisable->getContainingPackage() instanceof RootPackage) {
if ($bindingToDisable->getContainingModule() instanceof RootModule) {
throw new RuntimeException(sprintf(
'Cannot disable bindings in the package "%s".',
$bindingToDisable->getContainingPackage()->getName()
'Cannot disable bindings in the module "%s".',
$bindingToDisable->getContainingModule()->getName()
));
}

Expand All @@ -282,9 +282,9 @@ public function handleDisable(Args $args)
/**
* Returns the binding states selected in the console arguments.
*
* @param Args $args The console arguments.
* @param Args $args The console arguments
*
* @return int[] The selected {@link BindingState} constants.
* @return int[] The selected {@link BindingState} constants
*/
private function getBindingStates(Args $args)
{
Expand All @@ -306,12 +306,12 @@ private function getBindingStates(Args $args)
/**
* Prints a list of binding descriptors.
*
* @param IO $io The I/O.
* @param BindingDescriptor[] $descriptors The binding descriptors.
* @param int $indentation The number of spaces to indent.
* @param IO $io The I/O
* @param BindingDescriptor[] $descriptors The binding descriptors
* @param int $indentation The number of spaces to indent
* @param bool $enabled Whether the binding descriptors
* are enabled. If not, the output
* is printed in red.
* is printed in red
*/
private function printBindingTable(IO $io, array $descriptors, $indentation = 0, $enabled = true)
{
Expand Down Expand Up @@ -372,8 +372,8 @@ private function printBindingTable(IO $io, array $descriptors, $indentation = 0,
/**
* Prints the header for a binding state.
*
* @param IO $io The I/O.
* @param int $bindingState The {@link BindingState} constant.
* @param IO $io The I/O
* @param int $bindingState The {@link BindingState} constant
*/
private function printBindingStateHeader(IO $io, $bindingState)
{
Expand Down
28 changes: 14 additions & 14 deletions src/Handler/ConfigCommandHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Puli\Cli\Style\PuliTableStyle;
use Puli\Cli\Util\StringUtil;
use Puli\Manager\Api\Package\RootPackageFileManager;
use Puli\Manager\Api\Module\RootModuleFileManager;
use Webmozart\Console\Api\Args\Args;
use Webmozart\Console\Api\IO\IO;
use Webmozart\Console\UI\Component\Table;
Expand All @@ -28,27 +28,27 @@
class ConfigCommandHandler
{
/**
* @var RootPackageFileManager
* @var RootModuleFileManager
*/
private $manager;

/**
* Creates the handler.
*
* @param RootPackageFileManager $manager The root package file manager.
* @param RootModuleFileManager $manager The root module file manager
*/
public function __construct(RootPackageFileManager $manager)
public function __construct(RootModuleFileManager $manager)
{
$this->manager = $manager;
}

/**
* Handles the "config" command.
*
* @param Args $args The console arguments.
* @param IO $io The I/O.
* @param Args $args The console arguments
* @param IO $io The I/O
*
* @return int The status code.
* @return int The status code
*/
public function handleList(Args $args, IO $io)
{
Expand Down Expand Up @@ -77,10 +77,10 @@ public function handleList(Args $args, IO $io)
/**
* Handles the "config <key>" command.
*
* @param Args $args The console arguments.
* @param IO $io The I/O.
* @param Args $args The console arguments
* @param IO $io The I/O
*
* @return int The status code.
* @return int The status code
*/
public function handleShow(Args $args, IO $io)
{
Expand All @@ -95,9 +95,9 @@ public function handleShow(Args $args, IO $io)
/**
* Handles the "config <key> <value>" command.
*
* @param Args $args The console arguments.
* @param Args $args The console arguments
*
* @return int The status code.
* @return int The status code
*/
public function handleSet(Args $args)
{
Expand All @@ -111,9 +111,9 @@ public function handleSet(Args $args)
/**
* Handles the "config -r <key>" command.
*
* @param Args $args The console arguments.
* @param Args $args The console arguments
*
* @return int The status code.
* @return int The status code
*/
public function handleReset(Args $args)
{
Expand Down
Loading