Commit 1c926251 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Intégration de laminas-mvc-console

parent 15c3b5d7
Loading
Loading
Loading
Loading
Loading
+5 −109
Original line number Diff line number Diff line
# Changelog
CHANGELOG
=========

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 2.8.1 - TBD

### Added

- Nothing.

### Changed

- Nothing.

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- Nothing.

## 2.8.0 - 2019-02-04

### Added

- [zendframework/zend-console#41](https://github.com/zendframework/zend-console/pull/41) adds support for PHP 7.3.

### Changed

- Nothing.

### Deprecated

- Nothing.

### Removed

- [zendframework/zend-console#41](https://github.com/zendframework/zend-console/pull/41) removes support for laminas-stdlib v2 releases.

### Fixed

- [zendframework/zend-console#44](https://github.com/zendframework/zend-console/pull/44) fixes usage of `array_unique()` within the `DefaultRouteMatcher` to
  properly re-assign the array when invoked.

## 2.7.0 - 2018-01-25

### Added

- [zendframework/zend-console#32](https://github.com/zendframework/zend-console/pull/32) adds a new route
  match type, the "catch-all". Such types are always optional (thus, appear in
  `[]` sets), and are specified using `...` within: `command [...options]`.

  Parameters matched this way will always be returned as an array of values.

- [zendframework/zend-console#39](https://github.com/zendframework/zend-console/pull/39) adds support for
  PHP 7.2.

### Changed

- Nothing.

### Deprecated

- Nothing.

### Removed

- [zendframework/zend-console#39](https://github.com/zendframework/zend-console/pull/39) removes support
  for PHP 5.5.

- [zendframework/zend-console#39](https://github.com/zendframework/zend-console/pull/39) removes support
  for HHVM.

### Fixed

- [zendframework/zend-console#19](https://github.com/zendframework/zend-console/pull/19) updated link
  to the documentation in the [README](README.md)

## 2.6.0 - 2016-02-9

### Added

- [zendframework/zend-console#16](https://github.com/zendframework/zend-console/pull/16) updates,
  reorganizes, and publishes the documentation to
  https://docs.laminas.dev/laminas-console

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- [zendframework/zend-console#13](https://github.com/zendframework/zend-console/pull/13) updates the
  component to make it forwards-compatible with the laminas-stdlib and
  laminas-servicemanager v3 versions.
- [zendframework/zend-console#4](https://github.com/zendframework/zend-console/pull/4) fixes an error in
  `getTitle()` whereby the `$output` array was being incorrectly used as a
  string.
- [zendframework/zend-console#12](https://github.com/zendframework/zend-console/pull/12) updates the
  `Laminas\Console\Prompt\Char::show()` method to call on the composed adapter's
  `write()`/`writeLine()` methods instead of calling `echo()`.
1.0.0
-----
- Reprise et fusion du code de Laminas-console et laminas-mvc-console
 No newline at end of file

COPYRIGHT.md

deleted100644 → 0
+0 −1
Original line number Diff line number Diff line
Copyright (c) 2020 Laminas Project a Series of LF Projects, LLC. (https://getlaminas.org/)

LICENSE.md

deleted100644 → 0
+0 −26
Original line number Diff line number Diff line
Copyright (c) 2020 Laminas Project a Series of LF Projects, LLC.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

- Neither the name of Laminas Foundation nor the names of its contributors may
  be used to endorse or promote products derived from this software without
  specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

src/ConfigProvider.php

0 → 100644
+94 −0
Original line number Diff line number Diff line
<?php

/**
 * @see       https://github.com/laminas/laminas-mvc-console for the canonical source repository
 * @copyright https://github.com/laminas/laminas-mvc-console/blob/master/COPYRIGHT.md
 * @license   https://github.com/laminas/laminas-mvc-console/blob/master/LICENSE.md New BSD License
 */

namespace Unicaen\Console;

use Laminas\Mvc\SendResponseListener;
use Laminas\Router\RouteStackInterface;
use Laminas\ServiceManager\Factory\InvokableFactory;

class ConfigProvider
{
    /**
     * Provide configuration for this component.
     *
     * @return array
     */
    public function __invoke()
    {
        return [
            'controller_plugins' => $this->getPluginConfig(),
            'dependencies'       => $this->getDependencyConfig(),
        ];
    }

    /**
     * Provide dependency configuration for this component.
     *
     * @return array
     */
    public function getDependencyConfig()
    {
        return [
            'aliases' => [
                'console'                         => 'ConsoleAdapter',
                'Console'                         => 'ConsoleAdapter',
                'ConsoleDefaultRenderingStrategy' => View\DefaultRenderingStrategy::class,
                'ConsoleRenderer'                 => View\Renderer::class,

                // Legacy Zend Framework aliases
                \Zend\Mvc\Console\View\DefaultRenderingStrategy::class => View\DefaultRenderingStrategy::class,
                \Zend\Mvc\Console\View\Renderer::class => View\Renderer::class,
            ],
            'delegators' => [
                'ControllerManager'         => [ Service\ControllerManagerDelegatorFactory::class ],
                'Request'                   => [ Service\ConsoleRequestDelegatorFactory::class ],
                'Response'                  => [ Service\ConsoleResponseDelegatorFactory::class ],
                RouteStackInterface::class  => [ Router\ConsoleRouterDelegatorFactory::class ],
                SendResponseListener::class => [ Service\ConsoleResponseSenderDelegatorFactory::class ],
                'ViewHelperManager'         => [ Service\ConsoleViewHelperManagerDelegatorFactory::class ],
                'ViewManager'               => [ Service\ViewManagerDelegatorFactory::class ],
            ],
            'factories' => [
                'ConsoleAdapter'               => Service\ConsoleAdapterFactory::class,
                'ConsoleExceptionStrategy'     => Service\ConsoleExceptionStrategyFactory::class,
                'ConsoleRouteNotFoundStrategy' => Service\ConsoleRouteNotFoundStrategyFactory::class,
                'ConsoleRouter'                => Router\ConsoleRouterFactory::class,
                'ConsoleViewManager'           => Service\ConsoleViewManagerFactory::class,
                View\DefaultRenderingStrategy::class => Service\DefaultRenderingStrategyFactory::class,
                View\Renderer::class           => InvokableFactory::class,
            ],
        ];
    }

    /**
     * Provide controller plugin configuration for this component.
     *
     * @return array
     */
    public function getPluginConfig()
    {
        // @codingStandardsIgnoreStart
        return [
            'aliases' => [
                'CreateConsoleNotFoundModel' => Controller\Plugin\CreateConsoleNotFoundModel::class,
                'createConsoleNotFoundModel' => Controller\Plugin\CreateConsoleNotFoundModel::class,
                'createconsolenotfoundmodel' => Controller\Plugin\CreateConsoleNotFoundModel::class,
                'Laminas\Mvc\Controller\Plugin\CreateConsoleNotFoundModel::class' => Controller\Plugin\CreateConsoleNotFoundModel::class,

                // Legacy Zend Framework aliases
                'Zend\Mvc\Controller\Plugin\CreateConsoleNotFoundModel::class' => 'Laminas\Mvc\Controller\Plugin\CreateConsoleNotFoundModel::class',
                \Zend\Mvc\Console\Controller\Plugin\CreateConsoleNotFoundModel::class => Controller\Plugin\CreateConsoleNotFoundModel::class,
            ],
            'factories' => [
                Controller\Plugin\CreateConsoleNotFoundModel::class => InvokableFactory::class,
            ],
        ];
        // @codingStandardsIgnoreEnd
    }
}
+74 −0
Original line number Diff line number Diff line
<?php

/**
 * @see       https://github.com/laminas/laminas-mvc-console for the canonical source repository
 * @copyright https://github.com/laminas/laminas-mvc-console/blob/master/COPYRIGHT.md
 * @license   https://github.com/laminas/laminas-mvc-console/blob/master/LICENSE.md New BSD License
 */

namespace Unicaen\Console\Controller;

use Unicaen\Console\Adapter\AdapterInterface as ConsoleAdapter;
use Unicaen\Console\Request as ConsoleRequest;
use Unicaen\Console\Exception\InvalidArgumentException;
use Unicaen\Console\View\ViewModel;
use Unicaen\Mvc\Controller\AbstractActionController;
use Laminas\Stdlib\RequestInterface;
use Laminas\Stdlib\ResponseInterface;

/**
  * @method \Unicaen\Console\View\ViewModel createConsoleNotFoundModel()
 */
abstract class AbstractConsoleController extends AbstractActionController
{
    /**
     * @var ConsoleAdapter
     */
    protected $console;

    /**
     * @param ConsoleAdapter $console
     */
    public function setConsole(ConsoleAdapter $console)
    {
        $this->console = $console;
        return $this;
    }

    /**
     * @return ConsoleAdapter
     */
    public function getConsole()
    {
        return $this->console;
    }

    /**
     * {@inheritdoc}
     */
    public function dispatch(RequestInterface $request, ResponseInterface $response = null)
    {
        if (! $request instanceof ConsoleRequest) {
            throw new InvalidArgumentException(sprintf(
                '%s can only dispatch requests in a console environment',
                get_called_class()
            ));
        }
        return parent::dispatch($request, $response);
    }

    /**
     * Action called if matched action does not exist.
     *
     * @return ViewModel
     */
    public function notFoundAction()
    {
        $event = $this->getEvent();
        $routeMatch = $event->getRouteMatch();
        $routeMatch->setParam('action', 'not-found');

        $helper = $this->plugin('createConsoleNotFoundModel');
        return $helper();
    }
}
Loading