openclassrooms/use-case-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

openclassrooms/use-case-bundle

Composer 安装命令:

composer require openclassrooms/use-case-bundle

包简介

Symfony Bundle for OpenClassrooms UseCase

关键字:

README 文档

README

Build Status SensioLabsInsight Coverage Status

UseCaseBundle provides OpenClassrooms\UseCase Library in a Symfony2 context. UseCase Library provides facilities to manage technical code over a Use Case in a Clean / Hexagonal / Use Case Architecture.

  • Security access
  • Cache management
  • Transactional context
  • Events

The goal is to have only functional code on the Use Case and manage technical code in an elegant way using annotations.

For usage of UseCase Library, please see the UseCase Library documentation.

Installation

This bundle can be installed using composer:

composer require openclassrooms/use-case-bundle or by adding the package to the composer.json file directly.

{
    "require": {
        "openclassrooms/use-case-bundle": "*"
    }
}

After the package has been installed, add the bundle to the AppKernel.php file:

// in AppKernel::registerBundles()
    $bundles = array(
        // ...
        new OpenClassrooms\Bundle\OpenClassroomsUseCaseBundle(),
        // ...
);

If cache facilities are needed, add the OpenClassrooms\CacheBundle to the AppKernel.php file:

// in AppKernel::registerBundles()
    $bundles = array(
        // ...
        new OpenClassrooms\Bundle\CacheBundle\OpenClassroomsCacheBundle(),
        new OpenClassrooms\Bundle\UseCaseBundle\OpenClassroomsUseCaseBundle(),
        // ...
);

Configuration

UseCaseBundle requires no initial configuration.

This is the default configuration:

# app/config/config.yml
openclassrooms_use_case:
    security: security_context               
    # an implementation of OpenClassrooms\UseCase\Application\Services\Security\Security
    transaction: doctrine.orm.entity_manager
    # an implementation of EntityManagerInterface or OpenClassrooms\UseCase\Application\Services\Transaction\Transaction
    event_sender: event_dispatcher
    # an implementation of EventDispatcherInterface or OpenClassrooms\UseCase\Application\Services\Event\EventSender
    event_factory: openclassrooms.use_case.event_factory
    # an implementation of OpenClassrooms\UseCase\Application\Services\Event\EventFactory

If cache facilities are needed, CacheBundle configuration MUST be set. See documentation for more details.

Furthermore, only needed services are used. It means, for example, if only security is used, the others services will never be called. Even if the services of the default configuration exist or not.

Usage

For usage of UseCase Library, please see the UseCase Library documentation.

Add the tag openclassrooms.use_case to the use case declaration to enable UseCase Library facilities.

Resources/config/services.xml

<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <parameters>
        <parameter key="a_project.a_use_case.class">AProject\BusinessRules\UseCases\AUseCase</parameter>
    </parameters>

    <services>
        <service id="a_project.a_use_case" class="a_project.a_use_case.class">
            <tag name="openclassrooms.use_case"/>
        </service>
    </services>
</container>

The different services used are those defined in the configuration file. For each tag and each facility, a specific service can be set:

        <service id="a_project.a_use_case" class="a_project.a_use_case.class">
            <tag name="openclassrooms.use_case" 
                    security="a.different.security_context" 
                    cache="a.different.cache" 
                    transaction="a.different.entity_manager"
                    event-sender="a.different.event_dipsatcher"
                    event-factory="a.different.event_factory"/>
        </service>
  • security parameter MUST be an implementation of OpenClassrooms\UseCase\Application\Services\Security\Security
  • cache parameter MUST be an implementation of OpenClassrooms\Cache\Cache\Cache
  • transaction parameter MUST be an implementation of EntityManagerInterface or OpenClassrooms\UseCase\Application\Services\Transaction\Transaction
  • event-sender parameter MUST be an implementation of EventDispatcherInterface or OpenClassrooms\UseCase\Application\Services\Event\EventSender
  • event-factory parameter MUST be an implementation of OpenClassrooms\UseCase\Application\Services\Event\EventFactory

统计信息

  • 总下载量: 413.27k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 6
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-06-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固