public function import(\SimpleXMLElement $sx) { $em = \Database::connection()->getEntityManager(); $em->getClassMetadata('Concrete\\Core\\Entity\\Express\\Entity')->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator()); if (isset($sx->expressentities)) { foreach ($sx->expressentities->entity as $entityNode) { $entity = $em->find('Concrete\\Core\\Entity\\Express\\Entity', (string) $entityNode['id']); if (!is_object($entity)) { $entity = new Entity(); $entity->setId((string) $entityNode['id']); } $entity->setPluralHandle((string) $entityNode['plural_handle']); $entity->setHandle((string) $entityNode['handle']); $entity->setDescription((string) $entityNode['description']); $entity->setName((string) $entityNode['name']); if ((string) $entityNode['include_in_public_list'] == '') { $entity->setIncludeInPublicList(false); } $entity->setHandle((string) $entityNode['handle']); $tree = ExpressEntryResults::get(); $node = $tree->getNodeByDisplayPath((string) $entityNode['results-folder']); $node = \Concrete\Core\Tree\Node\Type\ExpressEntryResults::add((string) $entityNode['name'], $node); $entity->setEntityResultsNodeId($node->getTreeNodeID()); $indexer = $entity->getAttributeKeyCategory()->getSearchIndexer(); if (is_object($indexer)) { $indexer->createRepository($entity->getAttributeKeyCategory()); } $em->persist($entity); } } $em->flush(); $em->getClassMetadata('Concrete\\Core\\Entity\\Express\\Entity')->setIdGenerator(new UuidGenerator()); }
public function updateRepository(Entity $previousEntity, Entity $newEntity) { $previousTable = $previousEntity->getAttributeKeyCategory()->getIndexedSearchTable(); $newTable = $newEntity->getAttributeKeyCategory()->getIndexedSearchTable(); if ($this->connection->tableExists($previousTable)) { $this->connection->execute(sprintf('alter table %s rename %s', $previousTable, $newTable)); } }
public function __construct(Entity $entity) { $this->category = $entity->getAttributeKeyCategory(); $this->entity = $entity; parent::__construct(null); if ($entity->supportsCustomDisplayOrder()) { $this->setItemsPerPage(-1); $this->sortByDisplayOrderAscending(); } }