public function testApplyTo()
 {
     $fields = array("title" => 'p.name', "_identifier_" => 'p.id');
     $r = new Renderer($this->_container, array(1 => array('view' => 'AliDatatableBundle:Renderers:_actions.html.twig', 'params' => array('edit_route' => 'alidatatable_test_edit', 'delete_route' => 'alidatatable_test_delete', 'delete_form_prototype' => $this->_datatable->getPrototype('delete_form')))), $fields);
     $data = array(array('something', 'eee'));
     $r->applyTo($data, array((object) array()));
     $this->assertContains('form', $data[0][1]);
 }
 /**
  * Converts a string to time
  * 
  * @param string $string
  * @return int 
  */
 public function datatable($options)
 {
     if (!isset($options['id'])) {
         $options['id'] = 'ali-dta_' . md5(rand(1, 100));
     }
     $dt = Datatable::getInstance($options['id']);
     $config = $dt->getConfiguration();
     $options['js_conf'] = json_encode($config['js']);
     $options['js'] = json_encode($options['js']);
     $options['action'] = $dt->getHasAction();
     $options['action_twig'] = $dt->getHasRendererAction();
     $options['fields'] = $dt->getFields();
     $options['delete_form'] = $this->createDeleteForm('_id_')->createView();
     $options['search'] = $dt->getSearch();
     $options['search_fields'] = $dt->getSearchFields();
     $options['multiple'] = $dt->getMultiple();
     $options['sort'] = is_null($dt->getOrderField()) ? NULL : array(array_search($dt->getOrderField(), array_values($dt->getFields())), $dt->getOrderType());
     $main_template = 'AliDatatableBundle:Main:index.html.twig';
     if (isset($options['main_template'])) {
         $main_template = $options['main_template'];
     }
     $session = $this->_container->get('session');
     $rawjs = $this->_container->get('templating')->render('AliDatatableBundle:Internal:script.html.twig', $options);
     $sess_dtb = $session->get('datatable', array());
     $sess_dtb[$options['id']] = $rawjs;
     $session->set('datatable', $sess_dtb);
     return $this->_container->get('templating')->render($main_template, $options);
 }
 public function testSetDoctrineQueryBuilder()
 {
     $d = $this->_datatable->setEntity('Ali\\DatatableBundle\\Tests\\TestBundle\\Entity\\Product', 'p')->setFields(array("title" => 'p.name', "_identifier_" => 'p.id'));
     $qb = $d->getQueryBuilder();
     $dqb = $this->_em->createQueryBuilder();
     $qb->setDoctrineQueryBuilder($dqb);
     $this->assertEquals($dqb, $qb->getDoctrineQueryBuilder());
 }
 /**
  * Converts a string to time
  *
  * @param string $string
  * @return int
  */
 public function datatable($options)
 {
     if (!isset($options['id'])) {
         $options['id'] = 'ali-dta_' . md5(str_replace("/", '-', $options['js']['sAjaxSource']));
     }
     $dt = Datatable::getInstance($options['id']);
     $config = $dt->getConfiguration();
     $options['js_conf'] = json_encode($config['js']);
     $options['js'] = json_encode($options['js']);
     $options['action'] = $dt->getHasAction();
     $options['action_twig'] = $dt->getHasRendererAction();
     $options['fields'] = $dt->getFields();
     $options['delete_form'] = $this->createDeleteForm('_id_')->createView();
     $options['search'] = $dt->getSearch();
     $options['search_fields'] = $dt->getSearchFields();
     $options['multiple'] = $dt->getMultiple();
     $options['sort'] = is_null($dt->getOrderField()) ? NULL : array(array_search($dt->getOrderField(), array_values($dt->getFields())), $dt->getOrderType());
     $main_template = 'AliDatatableBundle:Main:index.html.twig';
     if (isset($options['main_template'])) {
         $main_template = $options['main_template'];
     }
     return $this->_container->get('templating')->render($main_template, $options);
 }
 public function test_setRenderders()
 {
     $out = $this->_datatable->setEntity('Ali\\DatatableBundle\\Entity\\Feature', 'f')->setFields(array("title" => 'f.name', "_identifier_" => 'f.id'))->setRenderers(array(1 => array('view' => 'AliDatatableBundle:Renderers:_actions.html.twig', 'params' => array('edit_route' => '_edit', 'delete_route' => '_delete', 'delete_form_prototype' => $this->_datatable->getPrototype('delete_form')))))->execute();
     $json = (array) json_decode($out->getContent());
     $this->assertContains('form', $json['aaData'][0][1]);
 }