public function content($key, $type, array $arguments = array(), $default='') {

        $debugmessage = '';

        if ($this->env->isDebug()) {
            $debugmessage .= "<!--debug IbrowsSimpleCMS\n";
            $debugmessage .= "type=$type \n";
            $debugmessage .= "key=$key \n";
            $debugmessage .= "default=$default \n";
            $debugmessage .= "arguments=" . print_r($arguments, true) . " \n";
            $debugmessage .= '-->';

            if ($default == '') {
                $default = "$key-$type";
            }
        }

        $obj = $this->manager->find($type, $key);
        if ($obj) {
            $out = $debugmessage . $obj->toHTML($this, $arguments);
        } else {
            $out = $default;
        }


        
        $grant = $this->handler->isGranted('ibrows_simple_cms_content_edit_key', array('key'=> $key,'type'=>$type ));
        //$grant = $this->handler->isGranted('ibrows_simple_cms_content');
        if(!$grant){
          return $out;
        }
        

        return $this->wrapOutputForEdit($out, $key, $type, $arguments, $default);
    }
 public function contentCollection($key, $type, array $arguments = array(), $default = null, $noedit = false)
 {
     $debugmessage = '';
     if ($this->env->isDebug()) {
         $debugmessage .= "<!--debug IbrowsSimpleCMS Collection\n";
         $debugmessage .= "type={$type} \n";
         $debugmessage .= "key={$key} \n";
         $debugmessage .= "default={$default} \n";
         $debugmessage .= "arguments=" . print_r($arguments, true) . " \n";
         $debugmessage .= '-->';
         if ($default == null) {
             $default = "{$key}-{$type}";
         }
     }
     $objs = $this->manager->findAll($type, $key);
     $out = '';
     $grant = $this->handler->isGranted('ibrows_simple_cms_content');
     if ($noedit) {
         $grant = false;
     }
     $addkey = $this->manager->getNewGroupKey($key, $objs);
     if ($objs) {
         foreach ($objs as $objkey => $content) {
             /* @var $content \Ibrows\SimpleCMSBundle\Entity\ContentInterface */
             $outobj = $debugmessage . $content->toHTML($this, $arguments);
             if ($grant && $this->handler->isGranted('ibrows_simple_cms_content_edit_key', array('key' => $content->getKeyword(), 'type' => $type))) {
                 $outobj = $this->wrapOutputForEdit($outobj, $content->getKeyword(), $type, $arguments, $default);
             }
             $out .= $outobj;
         }
     } else {
         if (!$grant) {
             $out = $default;
         }
     }
     if (!$grant) {
         return $out;
     }
     $class = '';
     if (isset($arguments['inline']) && $arguments['inline'] == true) {
         $class = 'inline';
     }
     //addlink
     if ($this->handler->isGranted('ibrows_simple_cms_content_create', array('type' => $type))) {
         $editpath = $this->env->getExtension('routing')->getPath('ibrows_simple_cms_content_edit_key', array('key' => $addkey, 'type' => $type));
         $editpath .= "?args=" . urlencode(serialize($arguments));
         $editpath .= "&default=" . $default;
         $outadd = '<a href="' . $editpath . '" class="simplecms-editlink simplecms-addlink" > </a> ADD ' . $default . '';
         $outadd = "<div class=\"simplcms-{$addkey}-{$type} simplecms-edit simplecms-add {$class}\" id=\"simplcms-{$addkey}-{$type}\" >{$outadd}</div>";
     }
     return "<div class=\"simplcms-collection-{$key}-{$type} simplecms-edit-collection {$class}\" id=\"simplcms-collection-{$key}-{$type}\" >{$out}{$outadd}</div>";
 }