Commit 0c44c1cb authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Commit initial

parents
Loading
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+2 −0
Changes for .gitignore: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
.idea
./vendor/
 No newline at end of file

.gitlab-ci.yml

0 → 100644
+8 −0
Changes for .gitlab-ci.yml: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
stages:
  - publish

update-satis:
  stage: publish
  image: curlimages/curl
  script:
    - curl https://packagist.unicaen.fr/build?name=unicaen/db-import-exemple

Dockerfile

0 → 100644
+31 −0
Changes for Dockerfile: 31 added lines, 0 removed lines.
Original line number Diff line number Diff line
ARG PHP_VERSION

FROM unicaen-dev-php${PHP_VERSION}-apache

LABEL maintainer="Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>"

WORKDIR /var/www/html

ENV APACHE_CONF_DIR=/etc/apache2 \
    PHP_CONF_DIR=/etc/php/${PHP_VERSION}

## Installation de packages requis.
RUN apt-get update -qq && \
    apt-get install -y \
        php${PHP_VERSION}-pgsql

# Nettoyage
RUN apt-get autoremove -y && apt-get clean && rm -rf /tmp/* /var/tmp/*

# Symlink apache access and error logs to stdout/stderr so Docker logs shows them
RUN ln -sf /dev/stdout /var/log/apache2/access.log
RUN ln -sf /dev/stdout /var/log/apache2/other_vhosts_access.log
RUN ln -sf /dev/stderr /var/log/apache2/error.log

# Configuration Apache et FPM
ADD docker/apache/000-default.conf ${APACHE_CONF_DIR}/sites-available/
ADD docker/php/fpm/conf.d/*.ini ${PHP_CONF_DIR}/fpm/conf.d/
ADD docker/php/cli/conf.d/*.ini ${PHP_CONF_DIR}/cli/conf.d/

RUN a2enconf php${PHP_VERSION}-fpm.conf && \
    service php${PHP_VERSION}-fpm reload

Module.php

0 → 100755
+50 −0
Changes for Module.php: 50 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace UnicaenDbImportExemple;

use Laminas\Http\Request as HttpRequest;
use Laminas\Mvc\ModuleRouteListener;
use Laminas\Mvc\MvcEvent;
use Laminas\Stdlib\ArrayUtils;

class Module
{
    public function onBootstrap(MvcEvent $e): void
    {
        $application = $e->getApplication();
        $eventManager = $application->getEventManager();
        $moduleRouteListener = new ModuleRouteListener();
        $moduleRouteListener->attach($eventManager);

        /* Active un layout spécial si la requête est de type AJAX. Valable pour TOUS les modules de l'application. */
        $eventManager->getSharedManager()->attach('Laminas\Mvc\Controller\AbstractActionController', 'dispatch',
            function (MvcEvent $e) {
                $request = $e->getRequest();
                if ($request instanceof HttpRequest && $request->isXmlHttpRequest()) {
                    $e->getTarget()->layout('layout/ajax.phtml');
                }
            }
        );
    }

    public function getConfig(): array
    {
        return ArrayUtils::merge(
            include_once __DIR__ . '/config/module.config.php',
            include_once __DIR__ . '/config/db-import.global.config.php',
            include_once __DIR__ . '/config/db-import.local.config.php',
            true
        );
    }

    public function getAutoloaderConfig(): array
    {
        return [
            'Laminas\Loader\StandardAutoloader' => [
                'namespaces' => [
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                ],
            ],
        ];
    }
}

README.md

0 → 100644
+3 −0
Changes for README.md: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
# unicaen/exemple

Ce module rassemble des exemples d'utilisation de briques des bibliothèques Unicaen.
Loading