예제 #1
0
 public function getDataset($resource)
 {
     //get the dataset to a resource
     $metaData = $this->metadataFactory->create($resource);
     $entity = $metaData->getEntityName();
     $bundle = $metaData->getBundleName();
     $id = $resource->getId();
     $dataSet = $this->em->getRepository('EnhavoSearchBundle:Dataset')->findOneBy(array('type' => strtolower($entity), 'bundle' => $bundle, 'reference' => $id));
     //if there is no dataset create a new one
     if ($dataSet == null) {
         //create new dataset
         $dataSet = new Dataset();
         $dataSet->setType(strtolower($entity));
         $dataSet->setBundle($bundle);
         $dataSet->setReference($id);
         $dataSet->setReindex(1);
         $this->em->persist($dataSet);
         $this->em->flush();
     }
     return $dataSet;
 }
예제 #2
0
 protected function getResource(Dataset $dataset)
 {
     //get ressource of dataset
     return $this->em->getRepository($dataset->getBundle() . ':' . ucfirst($dataset->getType()))->find($dataset->getReference());
 }