2017 © Pedro PelĆ”ez
 

library resource-manager

A library to manage resources

image

cekurte/resource-manager

A library to manage resources

  • Tuesday, May 3, 2016
  • by jpcercal
  • Repository
  • 1 Watchers
  • 1 Stars
  • 64 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 2 % Grown

The README.md

ResourceManager

Build Status Code Climate Coverage Status Latest Stable Version License SensioLabsInsight, (*1)

  • 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 =)., (*2)

Installation

composer require cekurte/resource-manager

Documentation

Currently is available one ResourceManager implementation that can be used with the Doctrine ORM., (*3)

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

<?php

namespace YourNamespace;

use Cekurte\ResourceManager\Contract\ResourceInterface;

class YourEntity implements ResourceInterface
{
    // ...
}

After that, you must retrieve an instance of ResourceManagerInterface:, (*5)

<?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., (*6)

<?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., (*7)

<?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., (*8)

<?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., (*9)

<?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., (*10)

<?php

use Cekurte\ResourceManager\Exception\ResourceManagerRefusedDeleteException;

// ...

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

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

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

The Versions

03/05 2016

dev-master

9999999-dev

A library to manage resources

  Sources   Download

MIT

The Requires

 

The Development Requires

service library doctrine resource manager resource manager doctrine service

03/05 2016

dev-develop

dev-develop

A library to manage resources

  Sources   Download

MIT

The Requires

 

The Development Requires

service library doctrine resource manager resource manager doctrine service

29/04 2016

v0.0.5

0.0.5.0

A library to manage resources

  Sources   Download

MIT

The Requires

 

The Development Requires

service library doctrine resource manager resource manager doctrine service

07/12 2015

v0.0.4

0.0.4.0

A library to manage resources

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

service library doctrine resource manager resource manager doctrine service

22/10 2015

v0.0.3

0.0.3.0

A library to manage resources

  Sources   Download

MIT

The Requires

  • php ^5.5

 

The Development Requires

service library doctrine resource manager resource manager doctrine service

20/10 2015

v0.0.2

0.0.2.0

A library to manage resources

  Sources   Download

MIT

The Requires

  • php ^5.5

 

The Development Requires

service library doctrine resource manager resource manager doctrine service

11/10 2015

v0.0.1

0.0.1.0

A library to manage resources

  Sources   Download

MIT

The Requires

  • php ^5.5

 

The Development Requires

service library doctrine resource manager resource manager doctrine service