bryanhenry/metrify-bundle

Convenience tools for quick symfony crud using Symfony, FOSRestBundle and Doctrine2

Installs: 12

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:symfony-bundle

1.0.x-dev 2017-06-19 21:26 UTC

This package is not auto-updated.

Last update: 2024-04-22 14:43:26 UTC


README

Simplify CRUD with Symfony, FOSRestBundle, and Doctrine.

Synopsis

This package aims to reduce some of the boiler plate when doing simple crud with FOSRestBundle and Symfony forms, but is not intended for complex interactions.

Usage

Create your entity, and implement the FormEntityInterface

namespace MyNameSpace;

class MyEntity extends FormEntityInterface {

	protected $id;

	public function getId() : ?int
	{

	    return $this->id;

	}

}

Create your controller, and extend the AbstractCrudController abstract class.

namespace MyNameSpace;

use BryanHenry\MetrifyBundle\Components\Controller\AbstractCrudController;
use MyNameSpace\MyEntity;
use MyNameSpace\MyEntityFormType;

/**
 * Set your prefix here, or through yml.
 * @RouteResource("item/definitions")
 */
class MyControllerController extends AbstractCrudController
{

    // Return the name of the form class here.
    protected function getFormName(): string
    {
        return MyEntityFormType::class;

    }

    // Return the name of the entity here, ensure that it implements the FormEntityInterface interface.
    protected function getEntityName(): string
    {
        return MyEntity::class;
    }

}

Inside of your entity's repository class, you must use the provided trait to provide pagination:

namespace MyNameSpace;

use Doctrine\ORM\EntityRepository;
use BryanHenry\MetrifyBundle\Components\Repository\RepositoryPaginateTrait;

class MyEntityRepository extends EntityRepository
{

    use RepositoryPaginateTrait;

}

Contributors

Bryan Henry bryan@misterflow.com

License

MIT