Browse Source

Update installer bundle, avoid deprecations, add docs

jmontoyaa 8 years ago
parent
commit
bbad3a8f78

+ 11 - 1
app/Resources/docs/installation.md

@@ -46,6 +46,10 @@ git checkout --track origin/master
 git config --global push.default current
 ```
 
+### Create database
+
+You should have a MariaDB/MySQL user and database created before hand.
+
 ### Update dependencies using Composer
 
 From the Chamilo folder (in which you should be now if you followed the previous steps), launch:
@@ -54,7 +58,13 @@ From the Chamilo folder (in which you should be now if you followed the previous
 composer update
 ```
 
-If you face issues related to missing JS libraries, you might need to ensure
+Composer update will ask for the database credentials in order to create a configuration file in:
+
+```
+app/config/parameters.yml.dist
+```
+
+If you face issues related to missing CSS/JS files, you might need to ensure
 that your web/assets folder is completely re-generated.
 Use this set of commands to do that:
 ```

+ 5 - 1
app/SymfonyRequirements.php

@@ -780,7 +780,11 @@ class SymfonyRequirements extends RequirementCollection
     {
         $size = ini_get('realpath_cache_size');
         $size = trim($size);
-        $unit = strtolower(substr($size, -1, 1));
+        $unit = '';
+        if (!ctype_digit($size)) {
+            $unit = strtolower(substr($size, -1, 1));
+            $size = (int) substr($size, 0, -1);
+        }
         switch ($unit) {
             case 'g':
                 return $size * 1024 * 1024 * 1024;

+ 0 - 1
app/bootstrap.php.cache

@@ -1341,4 +1341,3 @@ return $clientIps ? array_reverse($clientIps) : array($firstTrustedIp);
 }
 }
 }
-namespace {require __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/ClassLoader/ApcClassLoader.php';}

+ 0 - 1
src/Chamilo/InstallerBundle/Command/InstallCommand.php

@@ -71,7 +71,6 @@ class InstallCommand extends ContainerAwareCommand
             && $this->getContainer()->getParameter('installed');
 
         if ($isInstalled && !$forceInstall) {
-
             $output->writeln(
                 '<comment>ATTENTION</comment>: Chamilo is already installed.'
             );

+ 2 - 2
src/Chamilo/InstallerBundle/Command/PlatformUpdateCommand.php → src/Chamilo/InstallerBundle/Command/UpgradeCommand.php

@@ -11,11 +11,11 @@ use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
 use Chamilo\InstallerBundle\CommandExecutor;
 
 /**
- * Class PlatformUpdateCommand
+ * Class UpgradeCommand
  * * Based in OroInstallBundlePlatformUpdateCommand
  * @package Chamilo\InstallerBundle\Command
  */
-class PlatformUpdateCommand extends ContainerAwareCommand
+class UpgradeCommand extends ContainerAwareCommand
 {
     /**
      * @inheritdoc

+ 5 - 0
src/Chamilo/InstallerBundle/DependencyInjection/ChamiloInstallerExtension.php

@@ -1,4 +1,5 @@
 <?php
+/* For licensing terms, see /license.txt */
 
 namespace Chamilo\InstallerBundle\DependencyInjection;
 
@@ -7,6 +8,10 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
 use Symfony\Component\Config\FileLocator;
 use Symfony\Component\DependencyInjection\Loader;
 
+/**
+ * Class ChamiloInstallerExtension
+ * @package Chamilo\InstallerBundle\DependencyInjection
+ */
 class ChamiloInstallerExtension extends Extension
 {
     public function load(array $config, ContainerBuilder $container)

+ 1 - 0
src/Chamilo/InstallerBundle/EventListener/RequestListener.php

@@ -1,4 +1,5 @@
 <?php
+/* For licensing terms, see /license.txt */
 
 namespace Chamilo\InstallerBundle\EventListener;
 

+ 14 - 7
src/Chamilo/InstallerBundle/Form/Type/Configuration/DatabaseType.php

@@ -4,6 +4,10 @@
 namespace Chamilo\InstallerBundle\Form\Type\Configuration;
 
 use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
+use Symfony\Component\Form\Extension\Core\Type\IntegerType;
+use Symfony\Component\Form\Extension\Core\Type\PasswordType;
+use Symfony\Component\Form\Extension\Core\Type\TextType;
 use Symfony\Component\Form\FormBuilderInterface;
 use Symfony\Component\OptionsResolver\OptionsResolverInterface;
 use Symfony\Component\Validator\Constraints as Assert;
@@ -14,7 +18,10 @@ use Symfony\Component\Validator\Constraints as Assert;
  */
 class DatabaseType extends AbstractType
 {
-     public function buildForm(FormBuilderInterface $builder, array $options)
+    /**
+     * {@inheritdoc}
+     */
+    public function buildForm(FormBuilderInterface $builder, array $options)
     {
         $builder
             /*->add(
@@ -35,7 +42,7 @@ class DatabaseType extends AbstractType
             )*/
             ->add(
                 'chamilo_installer_database_host',
-                'text',
+                TextType::class,
                 array(
                     'label' => 'form.configuration.database.host',
                     'constraints' => array(
@@ -45,7 +52,7 @@ class DatabaseType extends AbstractType
             )
             ->add(
                 'chamilo_installer_database_port',
-                'integer',
+                IntegerType::class,
                 array(
                     'label' => 'form.configuration.database.port',
                     'required' => false,
@@ -56,7 +63,7 @@ class DatabaseType extends AbstractType
             )
             ->add(
                 'chamilo_installer_database_name',
-                'text',
+                TextType::class,
                 array(
                     'label' => 'form.configuration.database.name',
                     'constraints' => array(
@@ -66,7 +73,7 @@ class DatabaseType extends AbstractType
             )
             ->add(
                 'chamilo_installer_database_user',
-                'text',
+                TextType::class,
                 array(
                     'label' => 'form.configuration.database.user',
                     'constraints' => array(
@@ -76,7 +83,7 @@ class DatabaseType extends AbstractType
             )
             ->add(
                 'chamilo_installer_database_password',
-                'password',
+                PasswordType::class,
                 array(
                     'label' => 'form.configuration.database.password',
                     'required' => false,
@@ -84,7 +91,7 @@ class DatabaseType extends AbstractType
             )
             ->add(
                 'chamilo_installer_database_drop_full',
-                'checkbox',
+                CheckboxType::class,
                 array(
                     'label' => 'form.configuration.database.drop_full',
                     'required' => false,

+ 10 - 4
src/Chamilo/InstallerBundle/Form/Type/Configuration/MailerType.php

@@ -4,11 +4,14 @@
 namespace Chamilo\InstallerBundle\Form\Type\Configuration;
 
 use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\Extension\Core\Type\IntegerType;
+use Symfony\Component\Form\Extension\Core\Type\PasswordType;
 use Symfony\Component\Form\FormInterface;
 use Symfony\Component\Form\FormBuilderInterface;
 use Symfony\Component\Validator\Constraints as Assert;
 use Symfony\Component\OptionsResolver\OptionsResolverInterface;
 use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
+use Symfony\Component\Form\Extension\Core\Type\TextType;
 
 /**
  * Class MailerType
@@ -16,6 +19,9 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  */
 class MailerType extends AbstractType
 {
+    /**
+     * {@inheritdoc}
+     */
     public function buildForm(FormBuilderInterface $builder, array $options)
     {
         $builder
@@ -38,7 +44,7 @@ class MailerType extends AbstractType
             )
             ->add(
                 'chamilo_installer_mailer_host',
-                'text',
+                TextType::class,
                 array(
                     'label' => 'form.configuration.mailer.host',
                     'constraints' => array(
@@ -48,7 +54,7 @@ class MailerType extends AbstractType
             )
             ->add(
                 'chamilo_installer_mailer_port',
-                'integer',
+                IntegerType::class,
                 array(
                     'label' => 'form.configuration.mailer.port',
                     'required' => false,
@@ -79,7 +85,7 @@ class MailerType extends AbstractType
             )
             ->add(
                 'chamilo_installer_mailer_user',
-                'text',
+                TextType::class,
                 array(
                     'label' => 'form.configuration.mailer.user',
                     'required' => false,
@@ -87,7 +93,7 @@ class MailerType extends AbstractType
             )
             ->add(
                 'chamilo_installer_mailer_password',
-                'password',
+                PasswordType::class,
                 array(
                     'label' => 'form.configuration.mailer.password',
                     'required' => false,

+ 1 - 2
src/Chamilo/InstallerBundle/Form/Type/Configuration/SystemType.php

@@ -14,8 +14,7 @@ use Symfony\Component\Validator\Constraints as Assert;
 class SystemType extends AbstractType
 {
     /**
-     * @param FormBuilderInterface $builder
-     * @param array $options
+     * {@inheritdoc}
      */
     public function buildForm(FormBuilderInterface $builder, array $options)
     {

+ 9 - 5
src/Chamilo/InstallerBundle/Form/Type/ConfigurationType.php

@@ -3,10 +3,11 @@
 
 namespace Chamilo\InstallerBundle\Form\Type;
 
+use Chamilo\InstallerBundle\Form\Type\Configuration\DatabaseType;
+use Chamilo\InstallerBundle\Form\Type\Configuration\MailerType;
+use Chamilo\InstallerBundle\Form\Type\Configuration\SystemType;
 use Symfony\Component\Form\AbstractType;
 use Symfony\Component\Form\FormBuilderInterface;
-use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
-
 use Chamilo\InstallerBundle\Validator\Constraints as Assert;
 
 /**
@@ -15,13 +16,16 @@ use Chamilo\InstallerBundle\Validator\Constraints as Assert;
  */
 class ConfigurationType extends AbstractType
 {
+    /**
+     * {@inheritdoc}
+     */
     public function buildForm(FormBuilderInterface $builder, array $options)
     {
         // See class DatabaseConnectionValidator to see the validator.
         $builder
             ->add(
                 'database',
-                'chamilo_installer_configuration_database',
+                DatabaseType::class,
                 array(
                     'label' => 'form.configuration.database.header',
                     'constraints' => array(
@@ -31,14 +35,14 @@ class ConfigurationType extends AbstractType
             )
             ->add(
                 'mailer',
-                'chamilo_installer_configuration_mailer',
+                MailerType::class,
                 array(
                     'label' => 'form.configuration.mailer.header',
                 )
             )
             ->add(
                 'system',
-                'chamilo_installer_configuration_system',
+                SystemType::class,
                 array(
                     'label' => 'form.configuration.system.header',
                 )

+ 8 - 0
src/Chamilo/InstallerBundle/Form/Type/Setup/AdminType.php

@@ -16,11 +16,19 @@ class AdminType extends AbstractType
 {
     protected $dataClass;
 
+    /**
+     * AdminType constructor.
+     * @param $dataClass
+     */
     public function __construct($dataClass)
     {
         $this->dataClass = $dataClass;
     }
 
+    /**
+     * @param FormBuilderInterface $builder
+     * @param array $options
+     */
     public function buildForm(FormBuilderInterface $builder, array $options)
     {
         $builder

+ 13 - 6
src/Chamilo/InstallerBundle/Form/Type/Setup/PortalType.php

@@ -4,6 +4,10 @@
 namespace Chamilo\InstallerBundle\Form\Type\Setup;
 
 use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
+use Symfony\Component\Form\Extension\Core\Type\TextType;
+use Symfony\Component\Form\Extension\Core\Type\TimezoneType;
+use Symfony\Component\Form\Extension\Core\Type\UrlType;
 use Symfony\Component\Form\FormBuilderInterface;
 use Symfony\Component\Validator\Constraints as Assert;
 use Symfony\Component\OptionsResolver\OptionsResolverInterface;
@@ -14,12 +18,15 @@ use Symfony\Component\OptionsResolver\OptionsResolverInterface;
  */
 class PortalType extends AbstractType
 {
+    /**
+     * {@inheritdoc}
+     */
     public function buildForm(FormBuilderInterface $builder, array $options)
     {
         $builder
             ->add(
                 'institution',
-                'text',
+                TextType::class,
                 array(
                     'label' => 'form.setup.portal.institution',
                     'mapped' => false,
@@ -31,7 +38,7 @@ class PortalType extends AbstractType
             )
             ->add(
                 'site_name',
-                'text',
+                TextType::class,
                 array(
                     'label' => 'form.setup.portal.site_name',
                     'mapped' => false,
@@ -40,7 +47,7 @@ class PortalType extends AbstractType
             )
             ->add(
                 'institution_url',
-                'url',
+                UrlType::class,
                 array(
                     'label' => 'form.setup.portal.institution_url',
                     'mapped' => false,
@@ -49,7 +56,7 @@ class PortalType extends AbstractType
             )
             ->add(
                 'allow_self_registration',
-                'choice',
+                ChoiceType::class,
                 array(
                     'label' => 'form.setup.portal.allow_self_registration',
                     'mapped' => false,
@@ -62,7 +69,7 @@ class PortalType extends AbstractType
             )
             ->add(
                 'allow_self_registration_as_trainer',
-                'choice',
+                ChoiceType::class,
                 array(
                     'label' => 'form.setup.portal.allow_self_registration_as_trainer',
                     'mapped' => false,
@@ -75,7 +82,7 @@ class PortalType extends AbstractType
             )
             ->add(
                 'timezone',
-                'timezone',
+                TimezoneType::class,
                 array(
                     'label' => 'form.setup.portal.timezone',
                     'mapped' => false,

+ 7 - 2
src/Chamilo/InstallerBundle/Form/Type/SetupType.php

@@ -3,6 +3,8 @@
 
 namespace Chamilo\InstallerBundle\Form\Type;
 
+use Chamilo\InstallerBundle\Form\Type\Setup\AdminType;
+use Chamilo\InstallerBundle\Form\Type\Setup\PortalType;
 use Symfony\Component\Form\AbstractType;
 use Symfony\Component\Form\FormBuilderInterface;
 use Symfony\Component\Validator\Constraints as Assert;
@@ -13,19 +15,22 @@ use Symfony\Component\Validator\Constraints as Assert;
  */
 class SetupType extends AbstractType
 {
+    /**
+     * {@inheritdoc}
+     */
     public function buildForm(FormBuilderInterface $builder, array $options)
     {
         $builder
             ->add(
                 'admin',
-                'chamilo_installer_setup_admin',
+                AdminType::class,
                 array(
                     'label' => 'form.setup.admin.header',
                 )
             )
             ->add(
                 'portal',
-                'chamilo_installer_setup_portal',
+                PortalType::class,
                 array(
                     'label' => 'form.setup.portal.header',
                 )

+ 10 - 1
src/Chamilo/InstallerBundle/Process/InstallScenario.php

@@ -1,13 +1,22 @@
 <?php
+/* For licensing terms, see /license.txt */
 
 namespace Chamilo\InstallerBundle\Process;
 
 use Sylius\Bundle\FlowBundle\Process\Builder\ProcessBuilderInterface;
 use Sylius\Bundle\FlowBundle\Process\Scenario\ProcessScenarioInterface;
 use Symfony\Component\DependencyInjection\ContainerAware;
+use Symfony\Component\DependencyInjection\ContainerAwareInterface;
+use Symfony\Component\DependencyInjection\ContainerAwareTrait;
 
-class InstallScenario extends ContainerAware implements ProcessScenarioInterface
+/**
+ * Class InstallScenario
+ * @package Chamilo\InstallerBundle\Process
+ */
+class InstallScenario implements ProcessScenarioInterface, ContainerAwareInterface
 {
+    use ContainerAwareTrait;
+
     /**
      * {@inheritdoc}
      */

+ 5 - 0
src/Chamilo/InstallerBundle/Process/PhpExecutableFinder.php

@@ -1,9 +1,14 @@
 <?php
+/* For licensing terms, see /license.txt */
 
 namespace Chamilo\InstallerBundle\Process;
 
 use Symfony\Component\Process\PhpExecutableFinder as BasePhpExecutableFinder;
 
+/**
+ * Class PhpExecutableFinder
+ * @package Chamilo\InstallerBundle\Process
+ */
 class PhpExecutableFinder extends BasePhpExecutableFinder
 {
     /**

+ 3 - 2
src/Chamilo/InstallerBundle/Process/Step/ConfigureStep.php

@@ -3,6 +3,7 @@
 
 namespace Chamilo\InstallerBundle\Process\Step;
 
+use Chamilo\InstallerBundle\Form\Type\ConfigurationType;
 use Sylius\Bundle\FlowBundle\Process\Context\ProcessContextInterface;
 
 /**
@@ -43,7 +44,7 @@ class ConfigureStep extends AbstractStep
      */
     public function forwardAction(ProcessContextInterface $context)
     {
-        set_time_limit(600);
+        //set_time_limit(600);
         $form = $this->createConfigurationForm();
         $request = $context->getRequest();
         $upgrade = $this->isCommonUpgrade();
@@ -88,7 +89,7 @@ class ConfigureStep extends AbstractStep
         $data['is_upgrade'] = $upgrade;
 
         return $this->createForm(
-            'chamilo_installer_configuration',
+            ConfigurationType::class,
             empty($data) ? null : $data,
             $options
         );

+ 1 - 2
src/Chamilo/InstallerBundle/Process/Step/UpgradeStep.php

@@ -28,9 +28,8 @@ class UpgradeStep extends AbstractStep
 
         switch ($action) {
             case 'upgrade':
-
                 $configurationFile = $this->container->get('kernel')->getConfigurationFile();
-                // If configuration.php exists then rename to configuratio.php.bak
+                // If configuration.php exists then rename to configuration.php.bak
                 if (file_exists($configurationFile)) {
                     $fs = new Filesystem();
                     $fs->rename($configurationFile, $configurationFile.".bak");

+ 9 - 1
src/Chamilo/InstallerBundle/Process/UpgradeScenario.php

@@ -1,13 +1,21 @@
 <?php
+/* For licensing terms, see /license.txt */
 
 namespace Chamilo\InstallerBundle\Process;
 
 use Sylius\Bundle\FlowBundle\Process\Builder\ProcessBuilderInterface;
 use Sylius\Bundle\FlowBundle\Process\Scenario\ProcessScenarioInterface;
 use Symfony\Component\DependencyInjection\ContainerAware;
+use Symfony\Component\DependencyInjection\ContainerAwareInterface;
+use Symfony\Component\DependencyInjection\ContainerAwareTrait;
 
-class UpgradeScenario extends ContainerAware implements ProcessScenarioInterface
+/**
+ * Class UpgradeScenario
+ * @package Chamilo\InstallerBundle\Process
+ */
+class UpgradeScenario implements ProcessScenarioInterface, ContainerAwareInterface
 {
+    use ContainerAwareTrait;
     /**
      * {@inheritdoc}
      */

+ 7 - 7
src/Chamilo/InstallerBundle/Resources/config/form.yml

@@ -9,38 +9,38 @@ parameters:
 
 services:
     chamilo_installer.form.type.configuration:
-        class: %chamilo_installer.form.type.configuration.class%
+        class: '%chamilo_installer.form.type.configuration.class%'
         tags:
             - { name: form.type, alias: chamilo_installer_configuration }
 
     chamilo_installer.form.type.configuration.database:
-        class: %chamilo_installer.form.type.configuration.database.class%
+        class: '%chamilo_installer.form.type.configuration.database.class%'
         tags:
             - { name: form.type, alias: chamilo_installer_configuration_database }
 
     chamilo_installer.form.type.configuration.mailer:
-        class: %chamilo_installer.form.type.configuration.mailer.class%
+        class: '%chamilo_installer.form.type.configuration.mailer.class%'
         tags:
             - { name: form.type, alias: chamilo_installer_configuration_mailer }
 
     chamilo_installer.form.type.configuration.system:
-        class: %chamilo_installer.form.type.configuration.system.class%
+        class: '%chamilo_installer.form.type.configuration.system.class%'
         tags:
             - { name: form.type, alias: chamilo_installer_configuration_system }
 
     chamilo_installer.form.type.setup:
-        class: %chamilo_installer.form.type.setup.class%
+        class: '%chamilo_installer.form.type.setup.class%'
         tags:
             - { name: form.type, alias: chamilo_installer_setup }
 
     chamilo_installer.form.type.setup.admin:
-        class: %chamilo_installer.form.type.setup.admin.class%
+        class: '%chamilo_installer.form.type.setup.admin.class%'
         arguments:
             - Chamilo\UserBundle\Entity\User
         tags:
             - { name: form.type, alias: chamilo_installer_setup_admin }
 
     chamilo_installer.form.type.setup.portal:
-        class: %chamilo_installer.form.type.setup.portal.class%
+        class: '%chamilo_installer.form.type.setup.portal.class%'
         tags:
             - { name: form.type, alias: chamilo_installer_setup_portal }

+ 12 - 12
src/Chamilo/InstallerBundle/Resources/config/services.yml

@@ -7,33 +7,33 @@ parameters:
 
 services:
     chamilo_installer.install.scenario:
-        class: %chamilo_installer.install.scenario.class%
+        class: '%chamilo_installer.install.scenario.class%'
         calls:
-          - [ setContainer, ["@service_container"] ]
+          - [ setContainer, ['@service_container'] ]
         tags:
           - { name: sylius.process.scenario, alias: chamilo_install }
 
     chamilo_installer.upgrade.scenario:
-        class: %chamilo_installer.upgrade.scenario.class%
+        class: '%chamilo_installer.upgrade.scenario.class%'
         calls:
-          - [ setContainer, ["@service_container"] ]
+          - [ setContainer, ['@service_container'] ]
         tags:
           - { name: sylius.process.scenario, alias: chamilo_upgrade }
 
     chamilo_installer.yaml_persister:
-        class: %chamilo_installer.yaml_persister.class%
+        class: '%chamilo_installer.yaml_persister.class%'
         arguments:
             - %kernel.root_dir%/config
-            - %kernel.environment%
+            - '%kernel.environment%'
 
     kernel.listener.install.event:
-        class: %chamilo_installer.listener.request.class%
+        class: '%chamilo_installer.listener.request.class%'
         arguments:
-            - "@router"
-            - %installed%
-            - %kernel.debug%
+            - '@router'
+            - '%installed%'
+            - '%kernel.debug%'
 
     chamilo_installer.script_manager:
-        class: %chamilo_installer.script_manager.class%
+        class: '%chamilo_installer.script_manager.class%'
         arguments:
-            - @kernel
+            - '@kernel'