git=http://github.com/symfony/AsseticBundle.git
target=/bundles/Symfony/Bundle/AsseticBundle
version=v1.0.1
+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
-use Epnadmin\CoreBundle\Entity\Resource;
-
class DefaultController extends Controller
{
/**
- * @Route("/resource/new", name="epnadmincore_resource_new")
- * @Template()
- */
- public function newAction()
- {
- $resource = new Resource();
-
- $form = $this->createForm('epn_resource', $resource, array('parentChoice'=>Resource::getAllFormatted($this->getDoctrine()->getEntityManager())));
-
- $request = $this->getRequest();
- if ('POST' === $request->getMethod()) {
- $form->bindRequest($request);
- if ($form->isValid()) {
- $this->save($resource); //$form->getData());
- return $this->redirect(
- $this->generateUrl('epnadmincore_resource_show',
- array('id' => $resource->getId())
- )
- );
- //die('ok sauvé');
- }
- }
-
- return array('form' => $form->createView());
- }
-
- /**
- * @Route("/resource/{id}/edit", name="epnadmincore_resource_edit")
- * @Template()
- */
- public function editAction($id)
- {
- $resource = $this->getDoctrine()->getEntityManager()->getRepository('EpnadminCoreBundle:Resource')->find($id);
- if (! $resource) {
- throw $this->createNotFoundException('Impossible de trouver la resource.');
- }
- $form = $this->createForm('epn_resource', $resource);
-
- $request = $this->getRequest();
- if ('POST' === $request->getMethod()) {
- $form->bindRequest($request);
- if ($form->isValid()) {
- $this->save($form->getData());
- return $this->redirect(
- $this->generateUrl('epnadmincore_resource_show',
- array('id' => $resource->getId())
- )
- );
- //die('ok sauvé');
- }
- }
-
- return array(
- 'resource' => $resource,
- 'form' => $form->createView()
- );
- }
-
- /**
- * @Route("/resource/{id}/show", name="epnadmincore_resource_show")
- * @Template()
- */
- public function showAction($id)
- {
- $resource = $this->getDoctrine()->getEntityManager()->getRepository('EpnadminCoreBundle:Resource')->find($id);
- if (! $resource) {
- throw $this->createNotFoundException('Impossible de trouver la ressource.');
- }
- $deleteForm = $this->createDeleteForm($id);
-
- return array(
- 'resource' => $resource,
- 'delete_form' => $deleteForm->createView()
- );
- }
-
- /**
- * @Route("/resource/list", name="epnadmincore_resource_list")
- * @Template()
- */
- public function listAction()
- {
- //$resources = $this->getDoctrine()->getEntityManager()->getRepository('EpnadminCoreBundle:Resource')->findAll();
- $resources = $this->getDoctrine()->getEntityManager()->getRepository('EpnadminCoreBundle:Resource')->findBy(
- array('status'=>'actif'),
- array('name'=>'ASC')
- );
-
- return array(
- 'resources' => $resources
- );
- }
-
-
-
-
- /**
- * @Route("/resource", name="epnadmincore_resource_index")
+ * @Route("/", name="epnadmincore_index")
* @Template()
*/
public function indexAction()
{
-
-
- var_dump($list);
- exit;
return array();
}
-
-
- protected function save($obj)
- {
- $em = $this->getDoctrine()->getEntityManager();
- $em->persist($obj);
- $em->flush();
- }
-
- /**
- * Deletes a Message entity.
- *
- * @Route("/resource/{id}/delete", name="epnadmincore_resource_delete")
- * @ Method("post")
- */
- public function deleteAction($id)
- {
- $form = $this->createDeleteForm($id);
- $request = $this->getRequest();
-
- $form->bindRequest($request);
-
- if ($form->isValid()) {
- $em = $this->getDoctrine()->getEntityManager();
- $resource = $em->getRepository('EpnadminCoreBundle:Resource')->find($id);
-
- if (!$resource) {
- throw $this->createNotFoundException('Impossible de trouver la ressource.');
- }
-
- $em->remove($resource);
- $em->flush();
- }
-
- return $this->redirect($this->generateUrl('epnadmincore_resource_list'));
- }
-
- private function createDeleteForm($id)
- {
- return $this->createFormBuilder(array('id' => $id))
- ->add('id', 'hidden')
- ->getForm()
- ;
- }
-
}
--- /dev/null
+<?php
+
+namespace Epnadmin\CoreBundle\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
+
+use Epnadmin\CoreBundle\Entity\Resource;
+
+class ResourceController extends Controller
+{
+ /**
+ * @Route("/resource/new", name="epnadmincore_resource_new")
+ * @Template()
+ */
+ public function newAction()
+ {
+ $resource = new Resource();
+
+ $form = $this->createForm('epn_resource', $resource, array('parentChoice'=>Resource::getAllFormatted($this->getDoctrine()->getEntityManager())));
+
+ $request = $this->getRequest();
+ if ('POST' === $request->getMethod()) {
+ $form->bindRequest($request);
+ if ($form->isValid()) {
+ $this->save($resource); //$form->getData());
+ return $this->redirect(
+ $this->generateUrl('epnadmincore_resource_show',
+ array('id' => $resource->getId())
+ )
+ );
+ //die('ok sauvé');
+ }
+ }
+
+ return array('form' => $form->createView());
+ }
+
+ /**
+ * @Route("/resource/{id}/edit", name="epnadmincore_resource_edit")
+ * @Template()
+ */
+ public function editAction($id)
+ {
+ $resource = $this->getDoctrine()->getEntityManager()->getRepository('EpnadminCoreBundle:Resource')->find($id);
+ if (! $resource) {
+ throw $this->createNotFoundException('Impossible de trouver la resource.');
+ }
+ $form = $this->createForm('epn_resource', $resource);
+
+ $request = $this->getRequest();
+ if ('POST' === $request->getMethod()) {
+ $form->bindRequest($request);
+ if ($form->isValid()) {
+ $this->save($form->getData());
+ return $this->redirect(
+ $this->generateUrl('epnadmincore_resource_show',
+ array('id' => $resource->getId())
+ )
+ );
+ //die('ok sauvé');
+ }
+ }
+
+ return array(
+ 'resource' => $resource,
+ 'form' => $form->createView()
+ );
+ }
+
+ /**
+ * @Route("/resource/{id}/show", name="epnadmincore_resource_show")
+ * @Template()
+ */
+ public function showAction($id)
+ {
+ $resource = $this->getDoctrine()->getEntityManager()->getRepository('EpnadminCoreBundle:Resource')->find($id);
+ if (! $resource) {
+ throw $this->createNotFoundException('Impossible de trouver la ressource.');
+ }
+ $deleteForm = $this->createDeleteForm($id);
+
+ return array(
+ 'resource' => $resource,
+ 'delete_form' => $deleteForm->createView()
+ );
+ }
+
+ /**
+ * @Route("/resource/list", name="epnadmincore_resource_list")
+ * @Template()
+ */
+ public function listAction()
+ {
+ //$resources = $this->getDoctrine()->getEntityManager()->getRepository('EpnadminCoreBundle:Resource')->findAll();
+ $resources = $this->getDoctrine()->getEntityManager()->getRepository('EpnadminCoreBundle:Resource')->findBy(
+ array('status'=>'actif'),
+ array('name'=>'ASC')
+ );
+
+ return array(
+ 'resources' => $resources
+ );
+ }
+
+ /**
+ * @Route("/resource", name="epnadmincore_resource_index")
+ * @Template()
+ */
+ public function indexAction()
+ {
+ return array();
+ }
+
+
+ protected function save($obj)
+ {
+ $em = $this->getDoctrine()->getEntityManager();
+ $em->persist($obj);
+ $em->flush();
+ }
+
+ /**
+ * Deletes a Message entity.
+ *
+ * @Route("/resource/{id}/delete", name="epnadmincore_resource_delete")
+ * @ Method("post")
+ */
+ public function deleteAction($id)
+ {
+ $form = $this->createDeleteForm($id);
+ $request = $this->getRequest();
+
+ $form->bindRequest($request);
+
+ if ($form->isValid()) {
+ $em = $this->getDoctrine()->getEntityManager();
+ $resource = $em->getRepository('EpnadminCoreBundle:Resource')->find($id);
+
+ if (!$resource) {
+ throw $this->createNotFoundException('Impossible de trouver la ressource.');
+ }
+
+ $em->remove($resource);
+ $em->flush();
+ }
+
+ return $this->redirect($this->generateUrl('epnadmincore_resource_list'));
+ }
+
+ private function createDeleteForm($id)
+ {
+ return $this->createFormBuilder(array('id' => $id))
+ ->add('id', 'hidden')
+ ->getForm()
+ ;
+ }
+
+}
--- /dev/null
+<?php
+
+namespace Epnadmin\CoreBundle\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
+
+use Epnadmin\CoreBundle\Entity\Session;
+
+class SessionController extends Controller
+{
+ /**
+ * @Route("/session/new", name="epnadmincore_session_new")
+ * @Template()
+ */
+ public function newAction()
+ {
+ $session = new Session();
+
+ $form = $this->createForm('epn_session', $session);
+
+ $request = $this->getRequest();
+ if ('POST' === $request->getMethod()) {
+ $form->bindRequest($request);
+ if ($form->isValid()) {
+ $this->save($session);
+ return $this->redirect(
+ $this->generateUrl('epnadmincore_session_show',
+ array('id' => $session->getId())
+ )
+ );
+ }
+ }
+
+ return array('form' => $form->createView());
+ }
+
+ /**
+ * @Route("/session/{id}/edit", name="epnadmincore_session_edit")
+ * @Template()
+ */
+ public function editAction($id)
+ {
+ $session = $this->getDoctrine()->getEntityManager()->getRepository('EpnadminCoreBundle:Session')->find($id);
+ if (! $session) {
+ throw $this->createNotFoundException('Impossible de trouver la session.');
+ }
+ $form = $this->createForm('epn_session', $session);
+
+ $request = $this->getRequest();
+ if ('POST' === $request->getMethod()) {
+ $form->bindRequest($request);
+ if ($form->isValid()) {
+ $this->save($form->getData());
+ return $this->redirect(
+ $this->generateUrl('epnadmincore_session_show',
+ array('id' => $session->getId())
+ )
+ );
+ }
+ }
+
+ return array(
+ 'session' => $session,
+ 'form' => $form->createView()
+ );
+ }
+
+ /**
+ * @Route("/session/{id}/show", name="epnadmincore_session_show")
+ * @Template()
+ */
+ public function showAction($id)
+ {
+ $session = $this->getDoctrine()->getEntityManager()->getRepository('EpnadminCoreBundle:Session')->find($id);
+ if (! $session) {
+ throw $this->createNotFoundException('Impossible de trouver la session.');
+ }
+ $deleteForm = $this->createDeleteForm($id);
+
+ return array(
+ 'session' => $session,
+ 'delete_form' => $deleteForm->createView()
+ );
+ }
+
+ /**
+ * @Route("/session/list", name="epnadmincore_session_list")
+ * @Template()
+ */
+ public function listAction()
+ {
+ $sessions = $this->getDoctrine()->getEntityManager()->getRepository('EpnadminCoreBundle:Session')->findBy(
+ array('status'=>'valide'),
+ array('date_start'=>'ASC')
+ );
+
+ return array(
+ 'sessions' => $sessions
+ );
+ }
+
+ /**
+ * @Route("/session", name="epnadmincore_session_index")
+ * @Template()
+ */
+ public function indexAction()
+ {
+ return array();
+ }
+
+
+ protected function save($obj)
+ {
+ $em = $this->getDoctrine()->getEntityManager();
+ $em->persist($obj);
+ $em->flush();
+ }
+
+ /**
+ * Deletes a Message entity.
+ *
+ * @Route("/session/{id}/delete", name="epnadmincore_session_delete")
+ * @ Method("post")
+ */
+ public function deleteAction($id)
+ {
+ $form = $this->createDeleteForm($id);
+ $request = $this->getRequest();
+
+ $form->bindRequest($request);
+
+ if ($form->isValid()) {
+ $em = $this->getDoctrine()->getEntityManager();
+ $session = $em->getRepository('EpnadminCoreBundle:Session')->find($id);
+
+ if (!$session) {
+ throw $this->createNotFoundException('Impossible de trouver la session.');
+ }
+
+ $em->remove($session);
+ $em->flush();
+ }
+
+ return $this->redirect($this->generateUrl('epnadmincore_session_list'));
+ }
+
+ private function createDeleteForm($id)
+ {
+ return $this->createFormBuilder(array('id' => $id))
+ ->add('id', 'hidden')
+ ->getForm()
+ ;
+ }
+
+}
$list[ $resource->getId() ] = str_repeat(". ", $level). $resource->getName();
if (count($childern = $resource->getChildren())) {
foreach ($childern as $child) {
- $list = array_merge($list, self::returnChoice($child, $level+1));
+ $list = $list + self::returnChoice($child, $level+1);
}
}
return $list;
static public function getAllFormatted($em)
{
- $list = array();
+ $list = array(null=>null);
$resources = $em->getRepository('EpnadminCoreBundle:Resource')->findBy(
array('status'=>'actif','parent'=>null),
array('name'=>'ASC')
);
foreach($resources as $resource)
{
- $list = array_merge($list, self::returnChoice($resource));
+ $list = $list + self::returnChoice($resource);
}
return $list;
}
+
+ /**
+ * @ORM\ManyToMany(targetEntity="Session", mappedBy="resources", cascade={"persist"})
+ */
+ private $sessions;
+
+ /**
+ * Add sessions
+ *
+ * @param Epnadmin\CoreBundle\Entity\Session
+ */
+ public function addSession(\Epnadmin\CoreBundle\Entity\Session $session)
+ {
+ $session->addRessource($this);
+ $this->sessions[] = $session;
+ }
+
+ /**
+ * Get sessions
+ *
+ * @return Doctrine\Common\Collections\Collection
+ */
+ public function getSessions()
+ {
+ return $this->sessions;
+ }
}
+<?php
+
+namespace Epnadmin\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * Epnadmin\CoreBundle\Entity\Session
+ *
+ * @ORM\Table()
+ * @ORM\Entity
+ */
+class Session
+{
+ /**
+ * @var integer $id
+ *
+ * @ORM\Column(name="id", type="integer")
+ * @ORM\Id
+ * @ORM\GeneratedValue(strategy="AUTO")
+ */
+ private $id;
+
+ /**
+ * @var integer $resource_id
+ *
+ * @ORM\Column(name="resource_id", type="integer")
+ */
+ private $resource_id;
+
+ /**
+ * @var datetime $date_start
+ *
+ * @ORM\Column(name="date_start", type="datetime")
+ */
+ private $date_start;
+
+ /**
+ * @var datetime $date_stop
+ *
+ * @ORM\Column(name="date_stop", type="datetime")
+ */
+ private $date_stop;
+
+ /**
+ * @var string $title
+ *
+ * @ORM\Column(name="title", type="string", length=255)
+ */
+ private $title;
+
+ /**
+ * @var text $comment
+ *
+ * @ORM\Column(name="comment", type="text")
+ */
+ private $comment;
+
+ /**
+ * @var string $type
+ *
+ * @ORM\Column(name="type", type="string", length=255)
+ */
+ private $type;
+
+ /**
+ * @var string $status
+ *
+ * @ORM\Column(name="status", type="string", length=255)
+ */
+ private $status;
+
+ public function __construct()
+ {
+ $this->setStatus('valide');
+ }
+
+ /**
+ * Get id
+ *
+ * @return integer
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Set date_start
+ *
+ * @param datetime $dateStart
+ */
+ public function setDateStart($dateStart)
+ {
+ $this->date_start = $dateStart;
+ }
+
+ /**
+ * Get date_start
+ *
+ * @return datetime
+ */
+ public function getDateStart()
+ {
+ return $this->date_start;
+ }
+
+ /**
+ * Set date_stop
+ *
+ * @param datetime $dateStop
+ */
+ public function setDateStop($dateStop)
+ {
+ $this->date_stop = $dateStop;
+ }
+
+ /**
+ * Get date_stop
+ *
+ * @return datetime
+ */
+ public function getDateStop()
+ {
+ return $this->date_stop;
+ }
+
+ /**
+ * Set title
+ *
+ * @param string $title
+ */
+ public function setTitle($title)
+ {
+ $this->title = $title;
+ }
+
+ /**
+ * Get title
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Set comment
+ *
+ * @param text $comment
+ */
+ public function setComment($comment)
+ {
+ $this->comment = $comment;
+ }
+
+ /**
+ * Get comment
+ *
+ * @return text
+ */
+ public function getComment()
+ {
+ return $this->comment;
+ }
+
+ /**
+ * Set type
+ *
+ * @param string $type
+ */
+ public function setType($type)
+ {
+ $this->type = $type;
+ }
+
+ /**
+ * Get type
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * Set status
+ *
+ * @param string $status
+ */
+ public function setStatus($status)
+ {
+ $this->status = $status;
+ }
+
+ /**
+ * Get status
+ *
+ * @return string
+ */
+ public function getStatus()
+ {
+ return $this->status;
+ }
+
+ /**
+ * @ORM\ManyToMany(targetEntity="Resource", inversedBy="sessions", cascade={"persist"})
+ * @ORM\JoinTable(name="session_resource",
+ * joinColumns={@ORM\JoinColumn(name="session_id", referencedColumnName="id")},
+ * inverseJoinColumns={@ORM\JoinColumn(name="resource_id", referencedColumnName="id")}
+ * )
+ */
+ private $resources;
+
+ /**
+ * Add resources
+ *
+ * @param Epnadmin\CoreBundle\Entity\Resource $resource
+ */
+ public function addResource(\Epnadmin\CoreBundle\Entity\Resource $resource)
+ {
+ $this->resources[] = $resource;
+ }
+
+ /**
+ * Get resources
+ *
+ * @return Doctrine\Common\Collections\Collection
+ */
+ public function getResources()
+ {
+ return $this->resources;
+ }
+}
'label' => "Type*"
));
$builder->add('name', 'text', array(
+ 'required' => true,
'label'=>"Intitulé*"
));
- $builder->add('parent', 'choice', array(
+ $builder->add('parent', 'choise', array(
'choices' => $options['parentChoice'],
- 'required' => true,
+ 'required' => false,
'label' => "Dépend de"
));
+/*
+$builder->add('parent', null, array(
+ 'required' => false,
+ 'label' => "Dépend de"
+ ));*/
$builder->add('description', 'textarea', array(
'label'=>"Description"
--- /dev/null
+<h1>Ressources</h1>
+
+<ul class="record_actions">
+ <li>
+ <a href="{{ path('epnadmincore_resource_index') }}">
+ Sommaire
+ </a>
+ </li>
+ <li>
+ <a href="{{ path('epnadmincore_resource_list') }}">
+ Liste
+ </a>
+ </li>
+ <li>
+ <a href="{{ path('epnadmincore_resource_new') }}">
+ Nouveau
+ </a>
+ </li>
+</ul>