protected function execute(InputInterface $input, OutputInterface $output) { $db = \Database::connection(); $em = $db->getEntityManager(); $cacheDriver = $em->getConfiguration()->getMetadataCacheImpl(); $cacheDriver->flushAll(); $tool = new \Doctrine\ORM\Tools\SchemaTool($em); $schemas = []; /** * @var $sm MySqlSchemaManager */ $sm = $db->getSchemaManager(); $dbSchema = $sm->createSchema(); // core xml tables $schemas[] = Schema::getCoreXMLSchema(); // core entities $sm = new DatabaseStructureManager($em); $entities = $sm->getMetadatas(); $schemas[] = $tool->getSchemaFromMetadata($entities); // core, application and package block types $env = Environment::get(); $list = new BlockTypeList(); $list->includeInternalBlockTypes(); foreach ($list->get() as $bt) { $r = $env->getRecord(DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . '/' . FILENAME_BLOCK_DB, $bt->getPackageHandle()); if ($r->exists()) { $parser = Schema::getSchemaParser(simplexml_load_file($r->file)); $parser->setIgnoreExistingTables(false); $schemas[] = $parser->parse($db); } } // packages $packages = Package::getInstalledList(); foreach ($packages as $pkg) { $xmlFile = $pkg->getPackagePath() . '/' . FILENAME_BLOCK_DB; if (file_exists($xmlFile)) { $parser = Schema::getSchemaParser(simplexml_load_file($xmlFile)); $parser->setIgnoreExistingTables(false); $schemas[] = $parser->parse($db); } } // Finalize output. $comparator = new \Doctrine\DBAL\Schema\Comparator(); $saveQueries = array(); foreach ($schemas as $schema) { $schemaDiff = $comparator->compare($dbSchema, $schema); $saveQueries = array_merge($saveQueries, $schemaDiff->toSaveSql($db->getDatabasePlatform())); } $saveQueries = $this->filterQueries($saveQueries); if (count($saveQueries)) { $output->writeln(t2('%s query found', '%s queries found', count($saveQueries))); $i = 1; foreach ($saveQueries as $query) { $output->writeln(sprintf('%s: %s', $i, $query)); $i++; } } else { $output->writeln(t('No differences found between schema and database.')); } }
public function renderSearchField() { $form = \Core::make('helper/form'); $list = new BlockTypeList(); $html = $form->select('btID', array_reduce($list->get(), function ($types, $type) { $types[$type->getBlockTypeID()] = $type->getBlockTypeName(); return $types; }), $this->data['btID']); return $html; }
public function getResults(Request $request) { $list = new BlockTypeList(); $list->sortByMultiple('btID asc'); $list = $list->get(); $items = array(); foreach ($list as $type) { $blockType = new \PortlandLabs\Concrete5\MigrationTool\Entity\Export\BlockType(); $blockType->setItemId($type->getBlockTypeID()); $items[] = $blockType; } return $items; }
/** * Removes the block type. Also removes instances of content. */ public function delete() { $db = Loader::db(); $r = $db->Execute('select cID, cvID, b.bID, arHandle from CollectionVersionBlocks cvb inner join Blocks b on b.bID = cvb.bID where btID = ? union select cID, cvID, cvb.bID, arHandle from CollectionVersionBlocks cvb inner join btCoreScrapbookDisplay btCSD on cvb.bID = btCSD.bID inner join Blocks b on b.bID = btCSD.bOriginalID where btID = ?', array($this->getBlockTypeID(), $this->getBlockTypeID())); while ($row = $r->FetchRow()) { $nc = Page::getByID($row['cID'], $row['cvID']); if (!is_object($nc) || $nc->isError()) { continue; } $b = Block::getByID($row['bID'], $nc, $row['arHandle']); if (is_object($b)) { $b->deleteBlock(); } } $em = $db->getEntityManager(); $em->remove($this); $em->flush(); //Remove gaps in display order numbering (to avoid future sorting errors) BlockTypeList::resetBlockTypeDisplayOrder('btDisplayOrder'); }
public function run() { $this->x = new SimpleXMLElement("<concrete5-cif></concrete5-cif>"); $this->x->addAttribute('version', '1.0'); // First, attribute categories AttributeKeyCategory::exportList($this->x); // Features Feature::exportList($this->x); FeatureCategory::exportList($this->x); ConversationEditor::exportList($this->x); ConversationRatingType::exportList($this->x); // composer PageTypePublishTargetType::exportList($this->x); PageTypeComposerControlType::exportList($this->x); PageType::exportList($this->x); // attribute types AttributeType::exportList($this->x); // then block types BlockTypeList::exportList($this->x); // now block type sets (including user) BlockTypeSet::exportList($this->x); // gathering GatheringDataSource::exportList($this->x); GatheringItemTemplate::exportList($this->x); // now attribute keys (including user) AttributeKey::exportList($this->x); // now attribute keys (including user) AttributeSet::exportList($this->x); PageTemplate::exportList($this->x); // now theme PageTheme::exportList($this->x); // now packages PackageList::export($this->x); // permission access entity types PermissionAccessEntityType::exportList($this->x); // now task permissions PermissionKey::exportList($this->x); // workflow types WorkflowType::exportList($this->x); // now jobs Job::exportList($this->x); // now single pages $singlepages = $this->x->addChild("singlepages"); $db = Loader::db(); $r = $db->Execute('select cID from Pages where cFilename is not null and cFilename <> "" and cID not in (select cID from Stacks) order by cID asc'); while ($row = $r->FetchRow()) { $pc = Page::getByID($row['cID'], 'RECENT'); $pc->export($singlepages); } // now stacks/global areas StackList::export($this->x); // now content pages $pages = $this->x->addChild("pages"); $db = Loader::db(); $r = $db->Execute('select Pages.cID from Pages where cIsTemplate = 0 and cFilename is null or cFilename = "" order by cID asc'); while ($row = $r->FetchRow()) { $pc = Page::getByID($row['cID'], 'RECENT'); if ($pc->getPageTypeHandle() == STACKS_PAGE_TYPE) { continue; } $pc->export($pages); } SystemCaptchaLibrary::exportList($this->x); \Concrete\Core\Sharing\SocialNetwork\Link::exportList($this->x); \Concrete\Core\Page\Feed::exportList($this->x); \Concrete\Core\File\Image\Thumbnail\Type\Type::exportList($this->x); Config::exportList($this->x); Tree::exportList($this->x); }
public function getInstalledTargetItems(Batch $batch) { $list = new BlockTypeList(); $list->includeInternalBlockTypes(); $types = $list->get(); usort($types, function ($a, $b) { return strcasecmp($a->getBlockTypeName(), $b->getBlockTypeName()); }); $items = array(); foreach ($types as $type) { $item = new TargetItem($this); $item->setItemId($type->getBlockTypeHandle()); $item->setItemName($type->getBlockTypeName()); $items[] = $item; } return $items; }
public function getPackageItems(Package $package) { $list = new BlockTypeList(); $list->filterByPackage($package); return $list->get(); }
/** * Sets up a multiple columns to search by. Each argument is taken "as-is" (including asc or desc) and concatenated with commas * Note that this is overrides any previous sortByMultiple() call, and all sortBy() calls. Alternatively, you can pass a single * array with multiple columns to sort by as its values. * e.g. $list->sortByMultiple('columna desc', 'columnb asc'); * or $list->sortByMultiple(array('columna desc', 'columnb asc')); */ public function sortByMultiple() { return parent::sortByMultiple(); }