]> source.dussan.org Git - nextcloud-server.git/commitdiff
check app dependencies on installation as well
authorThomas Müller <thomas.mueller@tmit.eu>
Thu, 11 Dec 2014 16:02:07 +0000 (17:02 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Thu, 11 Dec 2014 16:02:07 +0000 (17:02 +0100)
lib/private/app.php

index 86db8fd9f55e90853ef116e144c2ca2638aa7fa7..c84e9c5e98135f7085cc23ef2bb39de11f1eaf90 100644 (file)
@@ -25,6 +25,8 @@
  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
  *
  */
+use OC\App\DependencyAnalyzer;
+use OC\App\Platform;
 
 /**
  * This class manages the apps. It allows them to register and integrate in the
@@ -1082,6 +1084,7 @@ class OC_App {
         */
        public static function installApp($app) {
                $l = \OC::$server->getL10N('core');
+               $config = \OC::$server->getConfig();
                $appData=OC_OCSClient::getApplication($app);
 
                // check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string
@@ -1106,13 +1109,25 @@ class OC_App {
                                                array($info['name'])
                                        )
                                );
-                       }else{
-                               OC_Appconfig::setValue( $app, 'enabled', 'yes' );
-                               if(isset($appData['id'])) {
-                                       OC_Appconfig::setValue( $app, 'ocsid', $appData['id'] );
-                               }
-                               \OC_Hook::emit('OC_App', 'post_enable', array('app' => $app));
                        }
+
+                       // check for required dependencies
+                       $dependencyAnalyzer = new DependencyAnalyzer($app, new Platform($config), $l);
+                       $missing = $dependencyAnalyzer->analyze();
+                       if(!empty($missing)) {
+                               $missingMsg = join(PHP_EOL, $missing);
+                               throw new \Exception(
+                                       $l->t('App \"%s\" cannot be installed because the following dependencies are not fulfilled: %s',
+                                               array($info['name'], $missingMsg)
+                                       )
+                               );
+                       }
+
+                       $config->setAppValue($app, 'enabled', 'yes');
+                       if(isset($appData['id'])) {
+                               $config->setAppValue($app, 'ocsid', $appData['id'] );
+                       }
+                       \OC_Hook::emit('OC_App', 'post_enable', array('app' => $app));
                }else{
                        throw new \Exception($l->t("No app name specified"));
                }