本文整理汇总了PHP中Magento\Framework\Module\ModuleListInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ModuleListInterface类的具体用法?PHP ModuleListInterface怎么用?PHP ModuleListInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ModuleListInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param LoggerInterface $log
* @param ModuleListInterface $moduleList
* @param SetupFileResolver $fileResolver
* @param string $moduleName
* @param \Magento\Framework\App\Resource $resource
* @param string $connectionName
*/
public function __construct(LoggerInterface $log, ModuleListInterface $moduleList, SetupFileResolver $fileResolver, $moduleName, \Magento\Framework\App\Resource $resource, $connectionName = SetupInterface::DEFAULT_SETUP_CONNECTION)
{
parent::__construct($resource, $connectionName);
$this->logger = $log;
$this->fileResolver = $fileResolver;
$this->moduleConfig = $moduleList->getOne($moduleName);
$this->resource = new Resource($resource);
$this->resourceName = $this->fileResolver->getResourceCode($moduleName);
}
开发者ID:ViniciusAugusto,项目名称:magento2,代码行数:19,代码来源:SetupModule.php
示例2: setUp
protected function setUp()
{
$this->filePermissions = $this->getMock('Magento\Framework\Setup\FilePermissions', [], [], '', false);
$this->configWriter = $this->getMock('Magento\Framework\App\DeploymentConfig\Writer', [], [], '', false);
$this->configReader = $this->getMock('Magento\Framework\App\DeploymentConfig\Reader', [], [], '', false);
$this->config = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false);
$this->moduleList = $this->getMockForAbstractClass('Magento\Framework\Module\ModuleListInterface');
$this->moduleList->expects($this->any())->method('getOne')->willReturn(
['setup_version' => '2.0.0']
);
$this->moduleList->expects($this->any())->method('getNames')->willReturn(
['Foo_One', 'Bar_Two']
);
$this->moduleLoader = $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false);
$this->directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false);
$this->adminFactory = $this->getMock('Magento\Setup\Model\AdminAccountFactory', [], [], '', false);
$this->logger = $this->getMockForAbstractClass('Magento\Framework\Setup\LoggerInterface');
$this->random = $this->getMock('Magento\Framework\Math\Random', [], [], '', false);
$this->connection = $this->getMockForAbstractClass('Magento\Framework\DB\Adapter\AdapterInterface');
$this->maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false);
$this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false);
$this->objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface');
$this->contextMock = $this->getMock('Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false);
$this->configModel = $this->getMock('Magento\Setup\Model\ConfigModel', [], [], '', false);
$this->cleanupFiles = $this->getMock('Magento\Framework\App\State\CleanupFiles', [], [], '', false);
$this->dbValidator = $this->getMock('Magento\Setup\Validator\DbValidator', [], [], '', false);
$this->setupFactory = $this->getMock('Magento\Setup\Module\SetupFactory', [], [], '', false);
$this->dataSetupFactory = $this->getMock('Magento\Setup\Module\DataSetupFactory', [], [], '', false);
$this->sampleDataState = $this->getMock('Magento\Framework\Setup\SampleData\State', [], [], '', false);
$this->componentRegistrar = $this->getMock('Magento\Framework\Component\ComponentRegistrar', [], [], '', false);
$this->phpReadinessCheck = $this->getMock('Magento\Setup\Model\PhpReadinessCheck', [], [], '', false);
$this->object = $this->createObject();
}
开发者ID:rafaelstz,项目名称:magento2,代码行数:34,代码来源:InstallerTest.php
示例3: testExecute
public function testExecute()
{
$this->moduleList->expects($this->once())->method('getNames')->willReturn([]);
$commandTester = new CommandTester($this->command);
$commandTester->execute([]);
$this->assertContains('List of active modules', $commandTester->getDisplay());
}
开发者ID:jeremyBass,项目名称:wsumage_command,代码行数:7,代码来源:CheckActiveModulesCommandTest.php
示例4: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('<info>List of active modules:<info>');
foreach ($this->moduleList->getNames() as $moduleName) {
$output->writeln('<info>' . $moduleName . '<info>');
}
}
开发者ID:jeremyBass,项目名称:wsumage_command,代码行数:10,代码来源:CheckActiveModulesCommand.php
示例5: determineOmittedNamespace
/**
* Determine whether provided name begins from any available modules, according to namespaces priority
* If matched, returns as the matched module "factory" name or a fully qualified module name
*
* @param string $name
* @param bool $asFullModuleName
* @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function determineOmittedNamespace($name, $asFullModuleName = false)
{
if (null === $this->_moduleNamespaces) {
$this->_moduleNamespaces = [];
foreach ($this->_moduleList->getNames() as $moduleName) {
$module = strtolower($moduleName);
$this->_moduleNamespaces[substr($module, 0, strpos($module, '_'))][$module] = $moduleName;
}
}
$explodeString = strpos($name, '\\') === false ? '_' : '\\';
$name = explode($explodeString, strtolower($name));
$partsNum = count($name);
$defaultNamespaceFlag = false;
foreach ($this->_moduleNamespaces as $namespaceName => $namespace) {
// assume the namespace is omitted (default namespace only, which comes first)
if ($defaultNamespaceFlag === false) {
$defaultNamespaceFlag = true;
$defaultNS = $namespaceName . '_' . $name[0];
if (isset($namespace[$defaultNS])) {
return $asFullModuleName ? $namespace[$defaultNS] : $name[0];
// return omitted as well
}
}
// assume namespace is qualified
if (isset($name[1])) {
$fullNS = $name[0] . '_' . $name[1];
if (2 <= $partsNum && isset($namespace[$fullNS])) {
return $asFullModuleName ? $namespace[$fullNS] : $fullNS;
}
}
}
return '';
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:43,代码来源:NamespaceResolver.php
示例6: getDisabledModules
/**
* Retrieve all disabled modules from the configuration
*
* @return array
*/
protected function getDisabledModules()
{
$allModules = $this->fullModuleList->getNames();
$enabledModules = $this->moduleList->getNames();
$disabledModules = array_diff($allModules, $enabledModules);
return $disabledModules;
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:Collect.php
示例7: execute
public function execute()
{
$greeting = "Hello world! I am a Magento2 extension.<br/>\n";
$title = 'Hello World';
$moduleNames = implode("<br/>\n", $this->moduleList->getNames());
$body = "\n<html>\n <head>\n <title>{$title}</title>\n </head>\n <body>{$greeting}<br/>Modules Installed:<br/>{$moduleNames}</body>\n</html>";
$this->_response->setBody($body);
}
开发者ID:Robin-bms,项目名称:m2extension,代码行数:8,代码来源:SayHello.php
示例8: render
/**
* Return info block html
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$m = $this->moduleList->getOne($this->getModuleName());
$html = '<div style="padding:10px;background-color:#f8f8f8;border:1px solid #ddd;margin-bottom:7px;">
Login As Customer Extension v' . $m['setup_version'] . ' was developed by <a href="http://magefan.com/" target="_blank">MageFan</a>.
</div>';
return $html;
}
开发者ID:magefan,项目名称:module-login-as-customer,代码行数:13,代码来源:Info.php
示例9: execute
/**
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$time = microtime(true);
$ignoreDataUpdate = $input->getOption('ignore-data');
$headers = array('Setup', 'Module', 'DB', 'Data', 'Status');
if ($ignoreDataUpdate) {
unset($headers[array_search('Data', $headers)]);
}
$errorCounter = 0;
$table = array();
foreach ($this->moduleList->getAll() as $moduleName => $moduleInfo) {
$moduleVersion = $moduleInfo['setup_version'];
$dbVersion = $this->resource->getDbVersion($moduleName);
if (!$ignoreDataUpdate) {
$dataVersion = $this->resource->getDataVersion($moduleName);
}
$ok = $dbVersion == $moduleVersion;
if ($ok && !$ignoreDataUpdate) {
$ok = $dataVersion == $moduleVersion;
}
if (!$ok) {
$errorCounter++;
}
$row = array('Module' => $moduleName, 'DB' => $dbVersion, 'Data' => $dataVersion);
if (!$ignoreDataUpdate) {
$row['Data-Version'] = $dataVersion;
}
$row['Status'] = $ok ? 'OK' : 'Error';
$table[] = $row;
}
//if there is no output format
//highlight the status
//and show error'd rows at bottom
if (!$input->getOption('format')) {
usort($table, function ($a, $b) {
return $a['Status'] !== 'OK';
});
array_walk($table, function (&$row) {
$status = $row['Status'];
$availableStatus = array('OK' => 'info', 'Error' => 'error');
$statusString = sprintf('<%s>%s</%s>', $availableStatus[$status], $status, $availableStatus[$status]);
$row['Status'] = $statusString;
});
}
if ($input->getOption('log-junit')) {
$this->logJUnit($table, $input->getOption('log-junit'), microtime($time) - $time);
} else {
$this->getHelper('table')->setHeaders($headers)->renderByFormat($output, $table, $input->getOption('format'));
//if no output format specified - output summary line
if (!$input->getOption('format')) {
if ($errorCounter > 0) {
$this->writeSection($output, sprintf('%s error%s %s found!', $errorCounter, $errorCounter === 1 ? '' : 's', $errorCounter === 1 ? 'was' : 'were'), 'error');
} else {
$this->writeSection($output, 'No setup problems were found.', 'info');
}
}
}
}
开发者ID:brentwpeterson,项目名称:n98-magerun2,代码行数:63,代码来源:CompareVersionsCommand.php
示例10: prepareModuleNamespaces
/**
* Prepare module namespaces
*
* @return void
*/
protected function prepareModuleNamespaces()
{
if (null === $this->moduleNamespaces) {
$this->moduleNamespaces = [];
foreach ($this->moduleList->getNames() as $moduleName) {
$module = strtolower($moduleName);
$this->moduleNamespaces[substr($module, 0, strpos($module, '_'))][$module] = $moduleName;
}
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:NamespaceResolver.php
示例11: getMagefanModules
/**
* Get Magefan Modules Info
*
* @return $this
*/
protected function getMagefanModules()
{
$modules = array();
foreach ($this->_moduleList->getAll() as $moduleName => $module) {
if (strpos($moduleName, 'Magefan_') !== false && $this->_moduleManager->isEnabled($moduleName)) {
$modules[$moduleName] = $module;
}
}
return $modules;
}
开发者ID:magefan,项目名称:module-login-as-customer,代码行数:15,代码来源:AdminNotificationFeed.php
示例12: prepareModuleList
protected function prepareModuleList($vendor)
{
$this->moduleList = [];
foreach ($this->moduleListObject->getAll() as $moduleName => $info) {
// First index is (probably always) vendor
$moduleNameData = explode('_', $moduleName);
if (!is_null($vendor) && strtolower($moduleNameData[0]) !== strtolower($vendor)) {
continue;
}
$this->moduleList[] = [$info['name'], $info['setup_version']];
}
}
开发者ID:brentwpeterson,项目名称:n98-magerun2,代码行数:12,代码来源:ListCommand.php
示例13: getModuleName
/**
* Retrieve fully-qualified module name, path belongs to
*
* @param string $path Full path to file or directory
* @return string|null
*/
public function getModuleName($path)
{
$path = str_replace('\\', '/', $path);
foreach ($this->_moduleList->getNames() as $moduleName) {
$moduleDir = $this->_moduleDirs->getDir($moduleName);
$moduleDir = str_replace('\\', '/', $moduleDir);
if ($path == $moduleDir || strpos($path, $moduleDir . '/') === 0) {
return $moduleName;
}
}
return null;
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:ReverseResolver.php
示例14: toOptionArray
/**
* Options getter
*
* @return array
*/
public function toOptionArray()
{
$output = [];
$modules = $this->_moduleList->getNames();
sort($modules);
foreach ($modules as $k => $v) {
if (preg_match("/Ves/", $v)) {
$output[$k] = ['value' => $v, 'label' => $v];
}
}
return $output;
}
开发者ID:rustamveer,项目名称:magento2,代码行数:17,代码来源:VesModules.php
示例15: getObservers
/**
* @return array
*/
public function getObservers()
{
if (!is_null($this->observers)) {
return $this->observers;
}
$this->observers = [];
foreach ($this->moduleList->getNames() as $module) {
$parts = explode('_', $module);
$class = 'Magento\\Tools\\SampleData\\Module\\' . $parts[1] . '\\Observer';
if (class_exists($class)) {
$this->observers[] = $this->objectManager->get($class);
}
}
return $this->observers;
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:ObserverManager.php
示例16: run
/**
* {@inheritdoc}
*/
public function run()
{
$this->logger->log('Installing categories:');
$this->isMediaInstalled();
foreach ($this->moduleList->getNames() as $moduleName) {
$fileName = substr($moduleName, strpos($moduleName, "_") + 1) . '/categories.csv';
$fileName = $this->fixtureHelper->getPath($fileName);
if (!$fileName) {
continue;
}
$csvReader = $this->csvReaderFactory->create(['fileName' => $fileName, 'mode' => 'r']);
foreach ($csvReader as $row) {
$this->createCategory($row);
}
}
}
开发者ID:vinai-drive-by-commits,项目名称:magento2-sample-data,代码行数:19,代码来源:Category.php
示例17: testGetModuleDataRefreshOrStatement
/**
* Tests modules data returns array and saving in DB
*
* @dataProvider itemDataProvider
* @return void
*/
public function testGetModuleDataRefreshOrStatement($data)
{
$moduleCollectionMock = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\ResourceModel\\Module\\Collection')->disableOriginalConstructor()->getMock();
/** @var \Magento\NewRelicReporting\Model\Module|\PHPUnit_Framework_MockObject_MockObject $itemMock */
$itemMock = $this->getMock('Magento\\NewRelicReporting\\Model\\Module', ['getName', 'getData', 'setData', 'getState', 'save'], [], '', false);
$modulesMockArray = ['Module_Name1' => ['name' => 'Module_Name1', 'setup_version' => '2.0.0', 'sequence' => []]];
$itemMock->setData($data);
$testChangesMockArray = ['entity_id' => '3', 'name' => 'Name', 'active' => 'false', 'state' => 'enabled', 'setup_version' => '2.0.0', 'some_param' => 'some_value', 'updated_at' => '2015-09-02 18:38:17'];
$itemMockArray = [$itemMock];
$enabledModulesMockArray = ['Module_Name2'];
$allModulesMockArray = ['Module_Name1', 'Module_Name2'];
$this->moduleCollectionFactoryMock->expects($this->any())->method('create')->willReturn($moduleCollectionMock);
$this->moduleFactoryMock->expects($this->any())->method('create')->willReturn($itemMock);
$itemMock->expects($this->any())->method('setData')->willReturnSelf();
$itemMock->expects($this->any())->method('save')->willReturnSelf();
$itemMock->expects($this->any())->method('getState')->willReturn($data['state']);
$itemMock->expects($this->any())->method('getName')->willReturn($data['name']);
$moduleCollectionMock->expects($this->any())->method('getItems')->willReturn($itemMockArray);
$itemMock->expects($this->any())->method('getData')->willReturn($testChangesMockArray);
$this->fullModuleListMock->expects($this->once())->method('getAll')->willReturn($modulesMockArray);
$this->fullModuleListMock->expects($this->any())->method('getNames')->willReturn($allModulesMockArray);
$this->moduleListMock->expects($this->any())->method('getNames')->willReturn($enabledModulesMockArray);
$this->moduleManagerMock->expects($this->any())->method('isOutputEnabled')->will($this->returnValue(true));
$this->assertInternalType('array', $this->model->getModuleData());
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:31,代码来源:CollectTest.php
示例18: run
/**
* Run installation in context of the specified admin user
*
* @param $userName
* @param array $modules
* @return void
* @throws \Exception
*/
public function run($userName, array $modules = [])
{
set_time_limit(0);
/** @var \Magento\User\Model\User $user */
$user = $this->userFactory->create()->loadByUsername($userName);
if (!$user->getId()) {
throw new \Exception('Invalid admin user provided');
}
$this->state->start();
$this->session->setUser($user);
$this->deploy->run();
$resources = $this->initResources($modules);
$this->state->clearErrorFlag();
try {
foreach ($this->moduleList->getNames() as $moduleName) {
if (isset($resources[$moduleName])) {
$resourceType = $resources[$moduleName];
$this->setupFactory->create($resourceType)->run();
$this->postInstaller->addModule($moduleName);
}
}
$this->session->unsUser();
$this->postInstaller->run();
$this->state->finish();
} catch (\Exception $e) {
$this->state->setError();
$this->logger->log($e->getMessage());
}
}
开发者ID:vinai-drive-by-commits,项目名称:magento2-sample-data,代码行数:37,代码来源:Installer.php
示例19: addHeadInclude
/**
* Add Link to Head
*
* @return void
*/
protected function addHeadInclude()
{
$styleContent = '';
foreach ($this->moduleList->getNames() as $moduleName) {
$fileName = substr($moduleName, strpos($moduleName, "_") + 1) . '/styles.css';
$fileName = $this->fixtureHelper->getPath($fileName);
if (!$fileName) {
continue;
}
$style = file_get_contents($fileName);
$styleContent .= preg_replace('/^\\/\\*[\\s\\S]+\\*\\//', '', $style);
}
if (empty($styleContent)) {
return;
}
$mediaDir = $this->directoryList->getPath(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
file_put_contents("{$mediaDir}/styles.css", $styleContent);
$linkTemplate = '<link rel="stylesheet" type="text/css" media="all" href="%sstyles.css" />';
$baseUrl = $this->baseUrl->getBaseUrl(['_type' => \Magento\Framework\UrlInterface::URL_TYPE_MEDIA]);
$linkText = sprintf($linkTemplate, $baseUrl);
$miscScriptsNode = 'design/head/includes';
$miscScripts = $this->scopeConfig->getValue($miscScriptsNode);
if (!$miscScripts || strpos($miscScripts, $linkText) === false) {
$this->configWriter->save($miscScriptsNode, $miscScripts . $linkText);
$this->configCacheType->clean();
}
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:32,代码来源:Setup.php
示例20: getVersion
/**
* Magento version
*
* @return string
*/
public function getVersion()
{
$module = $this->moduleList->getOne('Magento_Backend');
if (is_array($module) && isset($module['setup_version'])) {
return $module['setup_version'];
}
return '2.0.0';
}
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:License.php
注:本文中的Magento\Framework\Module\ModuleListInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论