sidlerbiz/todo-bundle

Provides possibility for work with simple Todo list

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

dev-master 2019-02-10 19:39 UTC

This package is auto-updated.

Last update: 2024-05-11 14:02:48 UTC


README

Installation

Step 1: Bundle upload

Open the console and go to the project directory. Run the following command to load the most suitable stable version of this bundle.

    composer require neo/todo-bundle

This command implies that Composer installed and available globally.

Step 2: Hook up bundle

Next step will be turn on the bundle by adding it to the list of registered bundles in app/AppKernel.php :

<?php
// config/bundles.php

return [
    // ...
    Neo\Bundle\TodoBundle\NeoTodoBundle::class => ['all' => true],
];

Configuration

Pre-configuration is required to start using the bundle.

neo_todo:
    entity_name: Acme\Entity\Todo

Using

Creating a trait based entity:

<?php

namespace Acme\Entity;

use Doctrine\ORM\Mapping as ORM;
use Neo\Bundle\TodoBundle\Entity\TodoEntityInterface;
use Neo\Bundle\TodoBundle\Entity\TodoEntityTrait;

/**
 * @ORM\Entity()
 * @ORM\HasLifecycleCallbacks()
 */
class Todo implements TodoEntityInterface
{
    use TodoEntityTrait;

    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id()
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;
    
    // ...
}

Using the TODO list management service:

<?php 

/** @var $todoService \Neo\Bundle\TodoBundle\Service\TodoService*/

// get instance
$entity = $todoService->getById('15');

// get instances list 
$todoService->getList();

// change Todo status 
$todoService->changeStatus('15', true);

// Remove todo
$todoService->remove('15');


// create/update instance
$todoService->save($entity);

// create/update instances list
$todoService->saveList([$entity]);

Using Form:

<?php

class CreateTodoType extends \Neo\Bundle\TodoBundle\FormType\AbstractCreateTodoType
{

    public function configureOptions(\Symfony\Component\OptionsResolver\OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => 'Acme\Entity\Todo',
        ]);
    }
}

class EditTodoType extends \Neo\Bundle\TodoBundle\FormType\AbstractEditTodoType
{
    public function configureOptions(\Symfony\Component\OptionsResolver\OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => 'Acme\Entity\Todo',
        ]);
    }
}