public function getWorkflowStateAction(Layout $layout)
    {
        $layout_states = $this->getApplication()->getEntityManager()
            ->getRepository('BackBee\Workflow\State')
            ->getWorkflowStatesForLayout($layout)
        ;

        $states = array(
            'online'  => array(),
            'offline' => array(),
        );

        foreach ($layout_states as $state) {
            if (0 < $code = $state->getCode()) {
                $states['online'][$code] = array(
                    'label' => $state->getLabel(),
                    'code'  => '1_'.$code,
                );
            } else {
                $states['offline'][$code] = array(
                    'label' => $state->getLabel(),
                    'code'  => '0_'.$code,
                );
            }
        }

        $translator = $this->getApplication()->getContainer()->get('translator');

        $states = array_merge(
            array('0' => array('label' => $translator->trans('offline'), 'code' => '0')),
            $states['offline'],
            array('1' => array('label' => $translator->trans('online'), 'code' => '1')),
            $states['online']
        );

        return $this->createJsonResponse(array_values($states), 200, array(
            'Content-Range' => '0-'.(count($states) - 1).'/'.count($states),
        ));
    }