Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1176666
BuildClassMapCommand.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Oct 7, 12:28 AM
Size
3 KB
Mime Type
text/x-php
Expires
Thu, Oct 9, 12:28 AM (1 d, 18 h)
Engine
blob
Format
Raw Data
Handle
763404
Attached To
rINP In-Portal
BuildClassMapCommand.php
View Options
<?php
/**
* @version $Id: BuildClassMapCommand.php 16283 2015-09-27 11:22:39Z alex $
* @package In-Portal
* @copyright Copyright (C) 1997 - 2015 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
namespace
InPortal\Core\kernel\Console\Command
;
use
InPortal\Core\kernel\utility\ClassDiscovery\ClassMapBuilder
;
use
Stecman\Component\Symfony\Console\BashCompletion\CompletionContext
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Input\InputOption
;
use
Symfony\Component\Console\Output\OutputInterface
;
defined
(
'FULL_PATH'
)
or
die
(
'restricted access!'
);
class
BuildClassMapCommand
extends
AbstractCommand
{
/**
* Configures the current command.
*
* @return void
*/
protected
function
configure
()
{
$this
->
setName
(
'classmap:rebuild'
)
->
setDescription
(
'Rebuilds the class map'
)
->
addOption
(
'module'
,
null
,
InputOption
::
VALUE_OPTIONAL
|
InputOption
::
VALUE_IS_ARRAY
,
'Module name to build class map for'
);
}
/**
* Executes the current command.
*
* @param InputInterface $input An InputInterface instance.
* @param OutputInterface $output An OutputInterface instance.
*
* @return null|integer
*/
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
$user_modules
=
$this
->
io
->
getOption
(
'module'
);
if
(
$user_modules
)
{
$modules_filter
=
array
();
$valid_modules
=
$this
->
getModules
();
foreach
(
$user_modules
as
$module_name
)
{
if
(
!
in_array
(
$module_name
,
$valid_modules
)
)
{
throw
new
\InvalidArgumentException
(
'Module "'
.
$module_name
.
'" not found or installed'
);
}
$modules_filter
[
$module_name
]
=
$this
->
Application
->
ModuleInfo
[
$module_name
];
}
}
else
{
$modules_filter
=
null
;
}
$table_rows
=
array
();
foreach
(
ClassMapBuilder
::
createBuilders
(
$modules_filter
)
as
$class_map_builder
)
{
$table_rows
[]
=
$class_map_builder
->
build
();
}
// Needed because we aggregate class map from installed modules in unit config cache.
$this
->
Application
->
HandleEvent
(
new
\kEvent
(
'adm:OnResetParsedData'
));
$table
=
$this
->
getHelper
(
'table'
);
$table
->
setHeaders
(
array
(
'Path'
,
'Scanned in'
,
'Parsed in'
))
->
setRows
(
$table_rows
);
$table
->
render
(
$this
->
io
->
getOutput
());
return
0
;
}
/**
* Return possible values for the named option
*
* @param string $optionName Option name.
* @param CompletionContext $context Completion context.
*
* @return array
*/
public
function
completeOptionValues
(
$optionName
,
CompletionContext
$context
)
{
$suggestions
=
parent
::
completeOptionValues
(
$optionName
,
$context
);
if
(
$optionName
===
'module'
)
{
return
$this
->
getModules
();
}
return
$suggestions
;
}
/**
* Returns possible module names.
*
* @return array
*/
protected
function
getModules
()
{
$modules
=
array_keys
(
$this
->
Application
->
ModuleInfo
);
return
array_diff
(
$modules
,
array
(
'In-Portal'
));
}
}
Event Timeline
Log In to Comment