Skip to content
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
6 changes: 6 additions & 0 deletions apps/dav/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,10 @@
<step>OCA\DAV\Migration\GenerateBirthdays</step>
</live-migration>
</repair-steps>
<commands>
<command>OCA\DAV\Command\CreateAddressBook</command>
<command>OCA\DAV\Command\CreateCalendar</command>
<command>OCA\DAV\Command\SyncBirthdayCalendar</command>
<command>OCA\DAV\Command\SyncSystemAddressBook</command>
</commands>
</info>
39 changes: 0 additions & 39 deletions apps/dav/appinfo/register_command.php

This file was deleted.

4 changes: 4 additions & 0 deletions apps/federation/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@
<settings>
<admin>OCA\Federation\Settings\Admin</admin>
</settings>

<commands>
<command>OCA\Federation\Command\SyncFederationAddressBooks</command>
</commands>
</info>
27 changes: 0 additions & 27 deletions apps/federation/appinfo/register_command.php

This file was deleted.

6 changes: 6 additions & 0 deletions apps/files/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@
<settings>
<admin>OCA\Files\Settings\Admin</admin>
</settings>

<commands>
<command>OCA\Files\Command\Scan</command>
<command>OCA\Files\Command\DeleteOrphanedFiles</command>
<command>OCA\Files\Command\TransferOwnership</command>
</commands>
</info>
34 changes: 0 additions & 34 deletions apps/files/appinfo/register_command.php

This file was deleted.

5 changes: 5 additions & 0 deletions apps/files_trashbin/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ To prevent a user from running out of disk space, the Deleted files app will not
<background-jobs>
<job>OCA\Files_Trashbin\BackgroundJob\ExpireTrash</job>
</background-jobs>

<commands>
<command>OCA\Files_Trashbin\Command\CleanUp</command>
<command>OCA\Files_Trashbin\Command\ExpireTrash</command>
</commands>
</info>
36 changes: 0 additions & 36 deletions apps/files_trashbin/appinfo/register_command.php

This file was deleted.

6 changes: 5 additions & 1 deletion apps/files_versions/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<description>
This application automatically maintains older versions of files that are changed. When enabled, a hidden versions folder is provisioned in every user’s directory and is used to store old file versions. A user can revert to an older version through the web interface at any time, with the replaced file becoming a version. The app automatically manages the versions folder to ensure the user doesn’t run out of Quota because of versions.
In addition to the expiry of versions, the versions app makes certain never to use more than 50% of the user’s currently available free space. If stored versions exceed this limit, the app will delete the oldest versions first until it meets this limit. More information is available in the Versions documentation.

</description>
<version>1.4.0</version>
<types>
Expand All @@ -25,4 +24,9 @@ In addition to the expiry of versions, the versions app makes certain never to u
<background-jobs>
<job>OCA\Files_Versions\BackgroundJob\ExpireVersions</job>
</background-jobs>

<commands>
<command>OCA\Files_Versions\Command\CleanUp</command>
<command>OCA\Files_Versions\Command\ExpireVersions</command>
</commands>
</info>
34 changes: 0 additions & 34 deletions apps/files_versions/appinfo/register_command.php

This file was deleted.

6 changes: 6 additions & 0 deletions lib/private/App/InfoParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public function parse($file) {
if (!array_key_exists('two-factor-providers', $array)) {
$array['two-factor-providers'] = [];
}
if (!array_key_exists('commands', $array)) {
$array['commands'] = [];
}

if (array_key_exists('types', $array)) {
if (is_array($array['types'])) {
Expand Down Expand Up @@ -138,6 +141,9 @@ public function parse($file) {
if (isset($array['background-jobs']['job']) && is_array($array['background-jobs']['job'])) {
$array['background-jobs'] = $array['background-jobs']['job'];
}
if (isset($array['commands']['command']) && is_array($array['commands']['command'])) {
$array['commands'] = $array['commands']['command'];
}

if(!is_null($this->cache)) {
$this->cache->set($fileCacheKey, json_encode($array));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
use OCP\AppFramework\IApi;
use OCP\AppFramework\IAppContainer;
use OCP\Files\IAppData;

use OCP\Files\Mount\IMountManager;

class DIContainer extends SimpleContainer implements IAppContainer {

Expand Down Expand Up @@ -309,6 +309,9 @@ public function __construct($appName, $urlParams = array()){
$this->registerService('OCP\\AppFramework\\IAppContainer', function ($c) {
return $c;
});
$this->registerService(IMountManager::class, function () {
return $this->getServer()->getMountManager();
});

// commonly used attributes
$this->registerService('UserId', function ($c) {
Expand Down
25 changes: 23 additions & 2 deletions lib/private/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
namespace OC\Console;

use OC_App;
use OCP\AppFramework\QueryException;
use OCP\Console\ConsoleEvent;
use OCP\Defaults;
use OCP\IConfig;
use OCP\IRequest;
use Symfony\Component\Console\Application as SymfonyApplication;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -103,6 +102,12 @@ public function loadCommands(InputInterface $input, OutputInterface $output) {
if($appPath === false) {
continue;
}
// load commands using info.xml
$info = \OC_App::getAppInfo($app);
if (isset($info['commands'])) {
$this->loadCommandsFromInfoXml($info['commands']);
}
// load from register_command.php
\OC_App::registerAutoloading($app, $appPath);
$file = $appPath . '/appinfo/register_command.php';
if (file_exists($file)) {
Expand Down Expand Up @@ -149,4 +154,20 @@ public function run(InputInterface $input = null, OutputInterface $output = null
));
return $this->application->run($input, $output);
}

private function loadCommandsFromInfoXml($commands) {
foreach ($commands as $command) {
try {
$c = \OC::$server->query($command);
} catch (QueryException $e) {
if (class_exists($command)) {
$c = new $command();
} else {
throw new \Exception("Console command '$command' is unknown and could not be loaded");
}
}

$this->application->add($c);
}
}
}
3 changes: 2 additions & 1 deletion tests/data/app/expected-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@
"uninstall": []
},
"background-jobs": [],
"two-factor-providers": []
"two-factor-providers": [],
"commands": []
}
7 changes: 7 additions & 0 deletions tests/lib/InfoXmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,12 @@ public function testClasses($app) {
$this->assertInstanceOf($migration, \OC::$server->query($migration));
}
}

if (isset($appInfo['commands'])) {
foreach ($appInfo['commands'] as $command) {
$this->assertTrue(class_exists($command), 'Asserting command "'. $command . '"exists');
$this->assertInstanceOf($command, \OC::$server->query($command));
}
}
}
}