/** * */ public function __construct(SimuResource $simuresource, $param, $userIds) { $this->simuresource = $simuresource; $this->userIds = $userIds; $this->details = array('simuparam1' => $param); parent::__construct($simuresource->getResourceNode(), $this->details); }
public function load(ObjectManager $manager) { $this->manager = $manager; //example of initial fixture for the resource entity $sr = new SimuResource(); $sr->setField('bunny'); $sr->setOtherfield(16); $sr->setOtherfield2(28); $this->manager->persist($sr); $this->manager->flush(); }
/** * @EXT\Route("/form/edit/{simuresource}", name="cpasimusante_simuresource_edit_form2") * the template for the form * @EXT\Template() * */ public function editFormAction(SimuResource $simuresource) { //Check access $collection = new ResourceCollection(array($simuresource->getResourceNode())); // $this->checkAccess('EDIT', $collection); return array('_resource' => $simuresource); }
/** * @DI\Observe("copy_cpasimusante_simuresource") * * @param CopyResourceEvent $event */ public function onCopy(CopyResourceEvent $event) { $em = $this->container->get('doctrine.orm.entity_manager'); $resource = $event->getResource(); //Retrieve the entity (as an object) from the repository $resourceNow = $em->getRepository('CPASimUSanteSimuResourceBundle:SimuResource')->find($resource->getId()); //Copy the entity into a new one $resourceNew = new SimuResource(); //custom entity fields $resourceNew->setField($resourceNow->getField()); $resourceNew->setOtherfield($resourceNow->getOtherfield()); //generic entity fields $resourceNew->setName($resourceNow->getName()); //Save the entity $em->persist($resourceNew); $em->flush(); //Set the copy (Claroline stuff) $event->setCopy($resourceNew); $event->stopPropagation(); }