Skip to content
Snippets Groups Projects
Select Git revision
  • 3405c4b1c0d204a64081f9d66889e7e2766e6410
  • master default protected
  • php84
  • detached7
  • detached6
  • detached5
  • detached
  • detached2
  • detached3
  • detached4
  • 4.x
  • origin/1.0.3
  • origin/1.0.2
  • 6.1.0
  • 6.0.6
  • 6.0.5
  • 6.0.4
  • 6.0.3
  • 6.0.2
  • 6.0.1
  • 6.0.0
  • 4.0.3
  • 4.0.2
  • 4.0.1
  • 4.0
  • 3.1.7
  • 3.1.6
  • 3.1.5
  • 3.1.4
  • 3.1.3
  • 3.1.2
  • 3.1.1
  • 3.1.0
33 results

DifferentielController.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    DifferentielController.php 3.18 KiB
    <?php
    
    namespace UnicaenImport\Controller;
    
    use UnicaenImport\Entity\Differentiel\Query;
    use UnicaenImport\Provider\Privilege\Privileges;
    use UnicaenImport\Service\Traits\DifferentielServiceAwareTrait;
    use UnicaenImport\Service\Traits\QueryGeneratorServiceAwareTrait;
    use UnicaenImport\Service\Traits\SchemaServiceAwareTrait;
    use Laminas\Mvc\Controller\AbstractActionController;
    use Laminas\View\Model\JsonModel;
    
    
    /**
     * Description of DifferentielController
     *
     * @author LECLUSE Laurent <laurent.lecluse at unicaen.fr>
     */
    class DifferentielController extends AbstractActionController
    {
        use SchemaServiceAwareTrait;
        use QueryGeneratorServiceAwareTrait;
        use DifferentielServiceAwareTrait;
    
    
    
        public function indexAction()
        {
            $sc = $this->getServiceSchema();
    
            $tables = $sc->getImportTables();
            $mviews = $sc->getImportMviews();
    
            return compact('tables', 'mviews');
        }
    
    
    
        public function synchronisationAction()
        {
            $errors  = [];
            $success = [];
    
            $table  = $this->params()->fromRoute('table');
            $action = $this->params()->fromPost('action');
    
            /* Mise à jour */
            if ($this->isAllowed(Privileges::getResourceId(Privileges::IMPORT_MAJ))) {
                if ('vue-materialisee' === $action) {
                    try {
                        $sq = $this->getServiceQueryGenerator();
                        $sq->execMajVM($table);
                        $success[] = 'Vue matérialisée mise à jour avec succès';
                    } catch (\Exception $e) {
                        $errors = [$e->getMessage()];
                    }
                } elseif ($action) {
                    $sq    = $this->getServiceQueryGenerator();
                    $query = new Query($table);
                    $query->addDefaultSyncFiltre($sq);
                    if ($action != 'all') $query->setAction($action);
    
                    /* Mise à jour des données et récupération des éventuelles erreurs */
                    try {
                        $errors = $sq->syncTable($query);
                        if (!$errors) {
                            $success[] = 'Synchronisation effectuée avec succès';
                        }
                    } catch (\Exception $e) {
                        $errors = [$e->getMessage()];