Available notes

offset: -, limit: 5

  • No notes found

create new note

API documentation

Code behind this page

Controller Code


    /**
     * List all notes.
     *
     * @ApiDoc(
     *   resource = true,
     *   statusCodes = {
     *     200 = "Returned when successful"
     *   }
     * )
     *
     * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing notes.")
     * @Annotations\QueryParam(name="limit", requirements="\d+", default="5", description="How many notes to return.")
     *
     * @Annotations\View()
     *
     * @param Request               $request      the request object
     * @param ParamFetcherInterface $paramFetcher param fetcher service
     *
     * @return array
     */
    
public function getNotesAction(Request $requestParamFetcherInterface $paramFetcher)
    {
        
$offset $paramFetcher->get('offset');
        
$start null == $offset $offset 1;
        
$limit $paramFetcher->get('limit');

        
$notes $this->getNoteManager()->fetch($start$limit);

        return new 
NoteCollection($notes$offset$limit);
    }

Template Code

{% extends "AcmeDemoBundle::layout.html.twig" %}

{% block title "Symfony - Notes" %}

{% block content_header '' %}

{% block content %}
    <h1 class="title">{{ 'note.list.headline'|trans({}, 'AcmeDemoBundle') }}</h1>

    <p>
        {{ 'note.offset'|trans({}, 'AcmeDemoBundle') }}: {{ data.offset ?: '-' }}, {{ 'note.limit'|trans({}, 'AcmeDemoBundle') }}: {{ data.limit }}
    </p>

    <ul id="note-list">
        {% for id, note in data.notes %}
        <li>
            <a href="{{ path('get_note', {'id': id}) }}">{{ note }}</a>
            [<a href="{{ path('edit_notes', {'id': id}) }}">{{ 'note.edit.link'|trans({}, 'AcmeDemoBundle') }}</a>]
            [<a href="{{ path('remove_notes', {'id': id}) }}">{{ 'note.remove.link'|trans({}, 'AcmeDemoBundle') }}</a>]
        </li>
        {% else %}
        <li>{{ 'note.list.empty'|trans({}, 'AcmeDemoBundle') }}</li>
        {% endfor %}
    </ul>
    <p>
        <a href="{{ path('new_note') }}">{{ 'note.new.link'|trans({}, 'AcmeDemoBundle') }}</a>
    </p>
{% endblock %}