本文整理汇总了PHP中Magento\Setup\Model\ObjectManagerProvider::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManagerProvider::get方法的具体用法?PHP ObjectManagerProvider::get怎么用?PHP ObjectManagerProvider::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Setup\Model\ObjectManagerProvider
的用法示例。
在下文中一共展示了ObjectManagerProvider::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Get instance of DateTime
*
* @return \Magento\Framework\Stdlib\DateTime\DateTime
*/
public function get()
{
if (!$this->dateTime) {
$this->dateTime = $this->objectManagerProvider->get()->create('Magento\\Framework\\Stdlib\\DateTime\\DateTime', ['localeDate' => $this->tzProvider->get()]);
}
return $this->dateTime;
}
示例2: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$this->deploymentConfig->isAvailable()) {
$output->writeln("<info>No information is available: the Magento application is not installed.</info>");
return;
}
/** @var DbVersionInfo $dbVersionInfo */
$dbVersionInfo = $this->objectManagerProvider->get()->get('Magento\\Framework\\Module\\DbVersionInfo');
$outdated = $dbVersionInfo->getDbVersionErrors();
if (!empty($outdated)) {
$output->writeln("<info>The module code base doesn't match the DB schema and data.</info>");
$versionParser = new VersionParser();
$codebaseUpdateNeeded = false;
foreach ($outdated as $row) {
if (!$codebaseUpdateNeeded && $row[DbVersionInfo::KEY_CURRENT] !== 'none') {
// check if module code base update is needed
$currentVersion = $versionParser->parseConstraints($row[DbVersionInfo::KEY_CURRENT]);
$requiredVersion = $versionParser->parseConstraints('>' . $row[DbVersionInfo::KEY_REQUIRED]);
if ($requiredVersion->matches($currentVersion)) {
$codebaseUpdateNeeded = true;
}
}
$output->writeln(sprintf("<info>%20s %10s: %11s -> %-11s</info>", $row[DbVersionInfo::KEY_MODULE], $row[DbVersionInfo::KEY_TYPE], $row[DbVersionInfo::KEY_CURRENT], $row[DbVersionInfo::KEY_REQUIRED]));
}
if ($codebaseUpdateNeeded) {
$output->writeln('<info>Some modules use code versions newer or older than the database. ' . "First update the module code, then run 'setup:upgrade'.</info>");
// we must have an exit code higher than zero to indicate something was wrong
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
} else {
$output->writeln("<info>Run 'setup:upgrade' to update your DB schema and data.</info>");
}
} else {
$output->writeln('<info>All modules are up to date.</info>');
}
}
示例3: get
/**
* Get instance of Timezone
*
* @return \Magento\Framework\Stdlib\DateTime\Timezone
*/
public function get()
{
if (!$this->timezone) {
$this->timezone = $this->objectManagerProvider->get()->create('Magento\\Framework\\Stdlib\\DateTime\\Timezone', ['scopeType' => ScopeConfigInterface::SCOPE_TYPE_DEFAULT]);
}
return $this->timezone;
}
示例4: testGet
public function testGet()
{
$this->locator->expects($this->once())->method('get')->with(InitParamListener::BOOTSTRAP_PARAM)->willReturn([]);
$objectManager = $this->object->get();
$this->assertInstanceOf('Magento\\Framework\\ObjectManagerInterface', $objectManager);
$this->assertSame($objectManager, $this->object->get());
}
示例5: create
/**
* Creates setup
*
* @param ResourceConnection $appResource
* @return Setup
*/
public function create(ResourceConnection $appResource = null)
{
$objectManager = $this->objectManagerProvider->get();
if ($appResource === null) {
$appResource = $objectManager->get('Magento\\Framework\\App\\ResourceConnection');
}
return new Setup($appResource);
}
示例6: __construct
/**
* Constructor
*
* @param \Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @param \Magento\Setup\Model\Cron\Status $status
* @param array $name
* @param array $params
*/
public function __construct(\Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider, \Symfony\Component\Console\Output\OutputInterface $output, \Magento\Setup\Model\Cron\Status $status, $name, $params = [])
{
$this->cleanupFiles = $objectManagerProvider->get()->get('Magento\\Framework\\App\\State\\CleanupFiles');
$this->cache = $objectManagerProvider->get()->get('Magento\\Framework\\App\\Cache');
$this->output = $output;
$this->status = $status;
parent::__construct($output, $status, $objectManagerProvider, $name, $params);
}
示例7: indexAction
/**
* @return ViewModel
*/
public function indexAction()
{
if ($this->moduleList->has('Magento_SampleData')) {
/** @var \Magento\Framework\Setup\SampleData\State $sampleData */
$sampleData = $this->objectManagerProvider->get()->get('Magento\\Framework\\Setup\\SampleData\\State');
$isSampleDataErrorInstallation = $sampleData->hasError();
} else {
$isSampleDataErrorInstallation = false;
}
$view = new ViewModel(['isSampleDataErrorInstallation' => $isSampleDataErrorInstallation]);
$view->setTerminal(true);
return $view;
}
示例8: __construct
/**
* Constructor
*
* @param ObjectManagerProvider $objectManagerProvider
* @param \Magento\Framework\Composer\Remove $remove
* @param UninstallCollector $collector
* @param \Magento\Setup\Module\SetupFactory $setupFactory
*/
public function __construct(ObjectManagerProvider $objectManagerProvider, \Magento\Framework\Composer\Remove $remove, UninstallCollector $collector, \Magento\Setup\Module\SetupFactory $setupFactory)
{
$this->objectManager = $objectManagerProvider->get();
$this->remove = $remove;
$this->collector = $collector;
$this->setupFactory = $setupFactory;
}
示例9: __construct
/**
* Constructor
*
* @param MagentoComposerApplicationFactory $applicationFactory
* @param \Magento\Framework\Filesystem $filesystem
* @param ComposerInformation $composerInformation
* @param ObjectManagerProvider $objectManagerProvider
* @throws \Exception
*/
public function __construct(MagentoComposerApplicationFactory $applicationFactory, Filesystem $filesystem, ComposerInformation $composerInformation, ObjectManagerProvider $objectManagerProvider)
{
$this->application = $applicationFactory->create();
$this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
$this->objectManager = $objectManagerProvider->get();
$this->composerInformation = $composerInformation;
}
示例10: __construct
/**
* Constructor
*
* @param ObjectManagerProvider $objectManagerProvider
* @param WebLogger $logger
* @param DirectoryList $directoryList
* @param Filesystem $fileSystem
*/
public function __construct(ObjectManagerProvider $objectManagerProvider, WebLogger $logger, DirectoryList $directoryList, Filesystem $fileSystem)
{
$objectManager = $objectManagerProvider->get();
$this->backupHandler = $objectManager->create('Magento\\Framework\\Setup\\BackupRollback', ['log' => $logger]);
$this->directoryList = $directoryList;
$this->fileSystem = $fileSystem;
}
示例11: getPackageAvailableVersions
/**
* Retrieve all available versions for a package
*
* @param string $package
* @return array
* @throws \RuntimeException
*/
private function getPackageAvailableVersions($package)
{
$magentoRepositories = $this->composerInformation->getRootRepositories();
// Check we have only one repo.magento.com repository
if (count($magentoRepositories) === 1 && strpos($magentoRepositories[0], $this->packagesAuth->getCredentialBaseUrl())) {
$packagesJsonData = $this->getPackagesJson();
if ($packagesJsonData) {
$packagesJsonData = json_decode($packagesJsonData, true);
} else {
$packagesJsonData['packages'] = [];
}
if (isset($packagesJsonData['packages'][$package])) {
$packageVersions = $packagesJsonData['packages'][$package];
uksort($packageVersions, 'version_compare');
$packageVersions = array_reverse($packageVersions);
return array_keys($packageVersions);
}
} else {
$versionsPattern = '/^versions\\s*\\:\\s(.+)$/m';
$commandParams = [self::PARAM_COMMAND => self::COMPOSER_SHOW, self::PARAM_PACKAGE => $package, self::PARAM_AVAILABLE => true];
$applicationFactory = $this->objectManagerProvider->get()->get('Magento\\Framework\\Composer\\MagentoComposerApplicationFactory');
/** @var \Magento\Composer\MagentoComposerApplication $application */
$application = $applicationFactory->create();
$result = $application->runComposerCommand($commandParams);
$matches = [];
preg_match($versionsPattern, $result, $matches);
if (isset($matches[1])) {
return explode(', ', $matches[1]);
}
}
throw new \RuntimeException(sprintf('Couldn\'t get available versions for package %s', $package));
}
示例12: indexAction
/**
* @return ViewModel
*/
public function indexAction()
{
$sampleDataDeployed = $this->moduleList->has('Magento_SampleData');
if ($sampleDataDeployed) {
/** @var \Magento\Framework\Setup\SampleData\State $sampleData */
$sampleData = $this->objectManagerProvider->get()->get('Magento\\Framework\\Setup\\SampleData\\State');
$isSampleDataInstalled = $sampleData->isInstalled();
$isSampleDataErrorInstallation = $sampleData->hasError();
} else {
$isSampleDataInstalled = false;
$isSampleDataErrorInstallation = false;
}
$view = new ViewModel(['timezone' => $this->list->getTimezoneList(), 'currency' => $this->list->getCurrencyList(), 'language' => $this->list->getLocaleList(), 'isSampleDataInstalled' => $isSampleDataInstalled, 'isSampleDataErrorInstallation' => $isSampleDataErrorInstallation]);
$view->setTerminal(true);
return $view;
}
示例13: __construct
/**
* Inject dependencies
*
* @param InstallerFactory $installerFactory
* @param DeploymentConfig $deploymentConfig
* @param ObjectManagerProvider $objectManagerProvider
*/
public function __construct(InstallerFactory $installerFactory, DeploymentConfig $deploymentConfig, ObjectManagerProvider $objectManagerProvider)
{
$this->installerFactory = $installerFactory;
$this->deploymentConfig = $deploymentConfig;
$this->objectManager = $objectManagerProvider->get();
parent::__construct();
}
示例14: __construct
/**
* Constructor
*
* @param ObjectManagerProvider $objectManagerProvider
* @param MaintenanceMode $maintenanceMode
* @param DeploymentConfig $deploymentConfig
*/
public function __construct(ObjectManagerProvider $objectManagerProvider, MaintenanceMode $maintenanceMode, DeploymentConfig $deploymentConfig)
{
$this->objectManager = $objectManagerProvider->get();
$this->maintenanceMode = $maintenanceMode;
$this->backupRollbackFactory = $this->objectManager->get('Magento\\Framework\\Setup\\BackupRollbackFactory');
$this->deploymentConfig = $deploymentConfig;
parent::__construct();
}
示例15: __construct
/**
* Constructor
*
* @param ModuleLoader $moduleLoader
* @param DeploymentConfig $deploymentConfig
* @param ObjectManagerProvider $objectManagerProvider
*/
public function __construct(ModuleLoader $moduleLoader, DeploymentConfig $deploymentConfig, ObjectManagerProvider $objectManagerProvider)
{
$this->allModules = $moduleLoader->load();
foreach (array_keys($this->allModules) as $module) {
$this->allModules[$module]['selected'] = true;
$this->allModules[$module]['disabled'] = true;
}
$this->deploymentConfig = $deploymentConfig;
$this->dependencyChecker = $objectManagerProvider->get()->get('Magento\\Framework\\Module\\DependencyChecker');
}