File: docs/serviceManager.rst

Recommend this page to a friend!
  Classes of Italo Lelis de Vietro  >  PHP Wunderlist API  >  docs/serviceManager.rst  >  Download  
File: docs/serviceManager.rst
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP Wunderlist API
Manage user lists using the Wunderlist API
Author: By
Last change:
Date: 5 years ago
Size: 1,574 bytes
 

Contents

Class file image Download
===============
Service Manager
===============

The service manager provides methods for easy access to API resources data data.
The manager tries to follow the same principle as a ObjectManager, from Doctrine, where you have a manager
to the repositories. Instead of a repository we have a service.

Create an instance of the resource service

.. code-block:: php

    $listsService = $wunderlist->getService(WList::class);

Get all records for a resource

.. code-block:: php

    $lists = $wunderlist->getService(WList::class)->all();

Get a specific resource

.. code-block:: php

    $list = $wunderlist->find(WList::class, 777);

Get a specific resource for a user

.. code-block:: php

    $user = $wunderlist->getService(User::class)->current();
    $lists = $wunderlist->forUser(WList::class, $user);

Get a specific resource for a list

.. code-block:: php

    $list = $wunderlist->find(WList::class, 777);
    $tasks = $wunderlist->forList(Task::class, $list);

Get a specific resource for a task

.. code-block:: php

    $task = $wunderlist->find(Task::class, 777);
    $subtasks = $wunderlist->forTask(Subtask::class, $task);

Create a resource

.. code-block:: php

    $list = new Wunderlist\Entity\WList();
    $list->setTitle('Bad Movies');
    $wunderlist->save($list);

Update a resource

.. code-block:: php

    $list = $wunderlist->find(WList::class, 777);
    $list->setTitle('Good Bad Movies');
    $wunderlist->save($list);

Delete a resource

.. code-block:: php

    $list = $wunderlist->find(WList::class, 777);
    $wunderlist->delete($list);

For more information send a message to info at phpclasses dot org.