cekurte/resource-manager 问题修复 & 功能扩展

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

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

cekurte/resource-manager

最新稳定版本:v0.0.5

Composer 安装命令:

composer require cekurte/resource-manager

包简介

A library to manage resources

README 文档

README

Build Status Code Climate Coverage Status Latest Stable Version License SensioLabsInsight

  • A Resource Manager to PHP (with all methods covered by php unit tests), with this library you can perform queries and manage resources using a unique interface. Now, you can increase the power of your resources, contribute with this project!.

If you liked of this library, give me a star =).

Installation

composer require cekurte/resource-manager

Documentation

Currently is available one ResourceManager implementation that can be used with the Doctrine ORM.

So, to use this library you must create your entity class and implement the ResourceInterface:

<?php

namespace YourNamespace;

use Cekurte\ResourceManager\Contract\ResourceInterface;

class YourEntity implements ResourceInterface
{
    // ...
}

After that, you must retrieve an instance of ResourceManagerInterface:

<?php

use Cekurte\ResourceManager\Driver\DoctrineDriver;
use Cekurte\ResourceManager\ResourceManager;
use Cekurte\ResourceManager\Service\DoctrineResourceManager;

$resourceManager = ResourceManager::create('doctrine', [
    'em'     => $entityManager,
    'entity' => 'YourNamespace\YourEntity',
]);

// OR ...
$resourceManager = ResourceManager::create(new DoctrineDriver([
    'em'     => $entityManager,
    'entity' => 'YourNamespace\YourEntity',
]));

// OR ...
$resourceManager = new DoctrineResourceManager(new DoctrineDriver([
    'em'     => $entityManager,
    'entity' => 'YourNamespace\YourEntity',
]));

Getting resources

To retrieve the resources you must call the method findResources passing as argument an implementation of ExprQueue. This method will return an array of resources.

<?php

use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\EqExpr;

// ...

$queue = new ExprQueue();
$queue->enqueue(new EqExpr('alias.field', 'value'));

$resources = $resourceManager->findResources($queue);

// You can call this method without any expression
// to retrive all resources...
// $resources = $resourceManager->findResources();

Getting one resource

To retrieve one resource you must call the method findResource passing as argument an implementation of ExprQueue. This method will throw an exception if the resource can not be found.

<?php

use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\EqExpr;
use Cekurte\ResourceManager\Exception\ResourceDataNotFoundException;

// ...

$queue = new ExprQueue();
$queue->enqueue(new EqExpr('alias.field', 'value'));

try {
    $resource = $resourceManager->findResource($queue);
} catch (ResourceDataNotFoundException $e) {
    // ...
}

Creating a resource

To create one resource you must call the method writeResource passing as argument an implementation of ResourceInterface.

<?php

use Cekurte\ResourceManager\Exception\ResourceManagerRefusedWriteException;

// ...

try {
    $resourceManager->writeResource($resource);
} catch (ResourceManagerRefusedWriteException $e) {
    // ...
}

Updating a resource

To update one resource you must call the method updateResource passing as argument an implementation of ResourceInterface.

<?php

use Cekurte\ResourceManager\Exception\ResourceManagerRefusedUpdateException;

// ...

try {
    $resourceManager->updateResource($resource);
} catch (ResourceManagerRefusedUpdateException $e) {
    // ...
}

Removing a resource

To remove one resource you must call the method deleteResource passing as argument an implementation of ResourceInterface.

<?php

use Cekurte\ResourceManager\Exception\ResourceManagerRefusedDeleteException;

// ...

try {
    $resourceManager->deleteResource($resource);
} catch (ResourceManagerRefusedDeleteException $e) {
    // ...
}

If you liked of this library, give me a star =).

Contributing

  1. Give me a star =)
  2. Fork it
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Make your changes
  5. Run the tests, adding new ones for your own code if necessary (vendor/bin/phpunit)
  6. Commit your changes (git commit -am 'Added some feature')
  7. Push to the branch (git push origin my-new-feature)
  8. Create new Pull Request

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-13