code
stringlengths
31
1.39M
docstring
stringlengths
23
16.8k
func_name
stringlengths
1
126
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
166
url
stringlengths
50
220
license
stringclasses
7 values
public function upgradeDatabase() { $type = Type::getByHandle('select'); $em = $this->connection->getEntityManager(); if ($type) { /* * @var $type \Concrete\Core\Entity\Attribute\Type */ $type->setAttributeTypeName('Option List'); $em->persist($type); $em->flush(); } $this->refreshEntities([ 'Concrete\Core\Entity\Attribute\Key\Settings\SelectSettings', ]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20170915000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20170915000000.php
MIT
public function upgradeDatabase() { $this->connection->executeQuery("UPDATE btSearch SET postTo_cID = NULL WHERE postTo_cID IS NOT NULL AND postTo_cID = ''"); foreach ([ "postTo_cID NOT REGEXP '^[1-9][0-9]*$'", 'IFNULL(postTo_cID + 0, 0) < 1', 'IFNULL(CAST(postTo_cID AS SIGNED), 0) < 1', ] as $try) { try { $this->connection->executeQuery('UPDATE btSearch SET postTo_cID = NULL WHERE postTo_cID IS NOT NULL AND ' . $try); break; } catch (Exception $foo) { } } $this->refreshBlockType('search'); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20170926000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20170926000000.php
MIT
public function upgradeDatabase() { $this->refreshEntities([ DateTimeSettings::class, ]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20171012000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20171012000000.php
MIT
public function upgradeDatabase() { $pkg = Package::getByHandle('document_library'); if ($pkg) { // First, we update the block type record that we have from the document library // add-on so that it's using the core code base. $this->connection->executeQuery('update BlockTypes set pkgID = 0 where pkgID = ?', [$pkg->getPackageID()]); // Now we uninstall the package. $pkg->uninstall(); } else { $bt = BlockType::getByHandle('document_library'); if (!$bt) { $bt = BlockType::installBlockType('document_library'); $multimediaSet = \Concrete\Core\Block\BlockType\Set::getByHandle('multimedia'); if ($multimediaSet) { $multimediaSet->addBlockType($bt); } } } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20171025000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20171025000000.php
MIT
public function upgradeDatabase() { $this->refreshBlockType('image'); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20171109000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20171109000000.php
MIT
public function upgradeDatabase() { $this->refreshEntities([ SelectSettings::class, ]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20171109065758.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20171109065758.php
MIT
public function upgradeDatabase() { if ($this->connection->getSchemaManager()->tablesExist('CalendarEventVersions')) { $events = (int) $this->connection->fetchColumn('select count(*) from CalendarEventVersions'); } else { $events = null; } if ($events === null || $events === 0) { $this->migrateCalendar(); } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20171110032423.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20171110032423.php
MIT
public function upgradeSchema(Schema $schema) { $table = $schema->getTable('FileImageThumbnailPaths'); if ($table->hasIndex('thumbnailPathID')) { $table->dropIndex('thumbnailPathID'); } if (!$table->hasColumn('thumbnailFormat')) { $table->addColumn( 'thumbnailFormat', 'string', [ 'notnull' => true, 'default' => '', 'length' => 5, ] ); $table->setPrimaryKey([ 'fileID', 'fileVersionID', 'thumbnailTypeHandle', 'storageLocationID', 'thumbnailFormat', ]); } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeSchema()
upgradeSchema
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20171121000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20171121000000.php
MIT
public function upgradeDatabase() { $db = $this->connection; $db->executeQuery("UPDATE FileImageThumbnailPaths SET thumbnailFormat = ? WHERE thumbnailFormat = '' AND (path LIKE '%.jpg' OR path LIKE '%.jpeg' OR path LIKE '%.pjpg' OR path LIKE '%.pjpeg')", [BitmapFormat::FORMAT_JPEG]); $db->executeQuery("UPDATE FileImageThumbnailPaths SET thumbnailFormat = ? WHERE thumbnailFormat = ''", [BitmapFormat::FORMAT_PNG]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20171121000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20171121000000.php
MIT
public function getDescription(): string { return '8.3.0'; }
{@inheritdoc} @see \Doctrine\Migrations\AbstractMigration::getDescription()
getDescription
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20171129190607.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20171129190607.php
MIT
public function upgradeDatabase() { $this->createSinglePage('/dashboard/system/calendar/import', 'Import Calendar Data'); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20171129190607.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20171129190607.php
MIT
public function getDescription(): string { return '8.3.1'; }
{@inheritdoc} @see \Doctrine\Migrations\AbstractMigration::getDescription()
getDescription
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20171218000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20171218000000.php
MIT
public function upgradeSchema(Schema $schema) { $this->addColumnIfMissing($schema); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeSchema()
upgradeSchema
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20171218000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20171218000000.php
MIT
public function upgradeDatabase() { $this->migrateDrafts(); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20171218000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20171218000000.php
MIT
public function upgradeDatabase() { // Cut and pasting code from an earlier migration to ensure that it runs $app = Facade::getFacadeApplication(); // I think this has to be in postUp because it's a completely new table that's not in Schema at all? Bleh. $this->refreshEntities([ Geolocator::class, ]); $glService = $app->make(GeolocatorService::class); /* @var GeolocatorService $glService */ if ($glService->getByHandle('geoplugin') === null) { $geolocator = Geolocator::create( 'geoplugin', 'geoPlugin' ); $geolocator ->setGeolocatorConfiguration([ 'url' => 'http://www.geoplugin.net/json.gp?ip=[[IP]]', ]) ; $glService->setCurrent($geolocator); $em = $glService->getEntityManager(); $em->persist($geolocator); $em->flush($geolocator); } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20171221194440.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20171221194440.php
MIT
public function upgradeDatabase() { $this->refreshEntities([ CalendarEventVersion::class, ExpressEntity::class, ExpressForm::class, Package::class, ]); $this->refreshDatabaseTables([ 'Workflows', ]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180119000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180119000000.php
MIT
public function getDescription(): string { return '8.3.2'; }
{@inheritdoc} @see \Doctrine\Migrations\AbstractMigration::getDescription()
getDescription
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180122213656.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180122213656.php
MIT
public function upgradeDatabase() { $app = Facade::getFacadeApplication(); $categoryService = $app->make(CategoryService::class); /* @var CategoryService $categoryService */ $typeFactory = $app->make(TypeFactory::class); /* @var TypeFactory $typeFactory */ $em = $app->make(EntityManager::class); $type = $typeFactory->getByHandle('express'); if (!$type) { $type = $typeFactory->add('express', 'Express Entity'); } foreach (['collection', 'user', 'file', 'site'] as $handle) { $category = $categoryService->getByHandle($handle); if ($category !== null) { $categoryTypes = $category->getAttributeTypes(); if (!$categoryTypes->contains($type)) { $categoryTypes->add($type); } } } $em->flush(); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180122213656.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180122213656.php
MIT
public function upgradeDatabase() { $this->createSinglePage('/dashboard/system/mail/addresses', 'System Email Addresses', ['meta_keywords' => 'mail settings, mail configuration, email, sender']); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180122220813.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180122220813.php
MIT
public function upgradeDatabase() { $this->refreshBlockType('calendar'); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180123000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180123000000.php
MIT
public function upgradeDatabase() { $this->refreshEntities([ Version::class, ]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180130000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180130000000.php
MIT
public function upgradeDatabase() { $job = Job::getByHandle('fill_thumbnails_table'); if ($job === null) { Job::installByHandle('fill_thumbnails_table'); $job = Job::getByHandle('fill_thumbnails_table'); if ($job !== null) { $set = Set::getByName('Default'); if ($set !== null) { $set->addJob($job); } } } $sp = Page::getByPath('/dashboard/system/files/image_uploading'); if (is_object($sp) && !$sp->isError()) { $sp->update([ 'cName' => 'Image Options', ]); if ($this->isAttributeHandleValid(PageCategory::class, 'meta_keywords')) { $sp->setAttribute('meta_keywords', 'uploading, upload, images, image, resizing, manager, exif, rotation, rotate, quality, compression, png, jpg, jpeg'); } } $config = $this->app->make('config'); $restrict_uploaded_image_sizes = $config->get('concrete.file_manager.restrict_uploaded_image_sizes'); if ($restrict_uploaded_image_sizes !== null) { if (!$restrict_uploaded_image_sizes) { $config->save('concrete.file_manager.restrict_max_width', null); $config->save('concrete.file_manager.restrict_max_height', null); } $config->set('concrete.file_manager.restrict_uploaded_image_sizes', null); $config->save('concrete.file_manager.restrict_uploaded_image_sizes', null); } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180212000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180212000000.php
MIT
public function upgradeDatabase() { $pk = Key::getByHandle('edit_topic_tree'); if (!$pk instanceof Key) { $pk = Key::add('admin', 'edit_topic_tree', 'Edit Topic Tree', 'Controls whether a user can edit a topic tree name.', false, false); $pa = $pk->getPermissionAccessObject(); if (!is_object($pa)) { $pa = Access::create($pk); } $adminGroup = Group::getByID(ADMIN_GROUP_ID); if ($adminGroup) { $adminGroupEntity = GroupEntity::getOrCreate($adminGroup); $pa->addListItem($adminGroupEntity); $pt = $pk->getPermissionAssignmentObject(); $pt->assignPermissionAccess($pa); } } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180403143200.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180403143200.php
MIT
public function upgradeDatabase() { $this->refreshBlockType('image'); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180524000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180524000000.php
MIT
public function upgradeDatabase() { $factory = $this->app->make(TypeFactory::class); // check if an attribute with the 'page_selector' handle exists $pageSelectorAttribute = $factory->getByHandle('page_selector'); if (is_object($pageSelectorAttribute)) { // unlink the attribute type from any package and change its name $pageSelectorAttribute->setPackage(null); $pageSelectorAttribute->setAttributeTypeName(t('Page Selector')); $em = $this->app->make(EntityManager::class); $em->persist($pageSelectorAttribute); $em->flush(); } else { // add the 'page_selector' attribute $type = $factory->add('page_selector', t('Page Selector')); // associate the 'page_selector' attribute to collection category $category = Category::getByHandle('collection')->getController(); $category->associateAttributeKeyType($type); // associate the 'page_selector' attribute to site category $category = Category::getByHandle('site')->getController(); $category->associateAttributeKeyType($type); } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180609000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180609000000.php
MIT
public function upgradeDatabase() { // add desktop_draft_list block type $bt = BlockType::getByHandle('desktop_draft_list'); if (!is_object($bt)) { $bt = BlockType::installBlockType('desktop_draft_list'); } // add core_desktop block type set $desktopSet = BlockTypeSet::getByHandle('core_desktop'); if (!is_object($desktopSet)) { $desktopSet = BlockTypeSet::add('core_desktop', 'Desktop'); } // add desktop_draft_list block type to core_desktop set $desktopSet->addBlockType($bt); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180615000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180615000000.php
MIT
public function upgradeDatabase() { $this->refreshEntities([ 'Concrete\Core\Entity\Search\SavedExpressSearch', ]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180617000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180617000000.php
MIT
public function upgradeDatabase() { $this->refreshBlockType('express_form'); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180717000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180717000000.php
MIT
public function upgradeDatabase() { // We do not need to install this singlepage any longer. //$this->createSinglePage('/dashboard/system/permissions/security', 'Security Options', ['meta_keywords' => 'login, logout, user, agent, ip, change']); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180907091500.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180907091500.php
MIT
public function upgradeDatabase() { $this->refreshEntities([ OneAssociation::class, ManyAssociation::class, AssociationEntry::class, Entry::class, Entry\Association::class, ]); // Migrate data from old entries table to new if ($this->connection->tableExists('ExpressEntityAssociationSelectedEntries')) { $this->connection->transactional(function ($db) { $r = $db->query('select * from ExpressEntityAssociationSelectedEntries'); while ($row = $r->fetch()) { $db->insert('ExpressEntityAssociationEntries', [ 'association_id' => $row['id'], 'exEntryID' => $row['exSelectedEntryID'] ]); } $this->connection->Execute('alter table ExpressEntityAssociationSelectedEntries rename _ExpressEntityAssociationSelectedEntries'); }); } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180910000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180910000000.php
MIT
public function upgradeDatabase() { $factory = $this->app->make(TypeFactory::class); // check if an attribute with the 'user_selector' handle exists $userSelectorAttribute = $factory->getByHandle('user_selector'); if (is_object($userSelectorAttribute)) { // unlink the attribute type from any package and change its name $userSelectorAttribute->setPackage(null); $userSelectorAttribute->setAttributeTypeName(t('User Selector')); $em = $this->app->make(EntityManager::class); $em->persist($userSelectorAttribute); $em->flush(); } else { // add the 'user_selector' attribute $type = $factory->add('user_selector', t('User Selector')); // associate the 'user_selector' attribute to collection category $category = Category::getByHandle('collection')->getController(); $category->associateAttributeKeyType($type); // associate the 'user_selector' attribute to site category $category = Category::getByHandle('site')->getController(); $category->associateAttributeKeyType($type); // associate the 'user_selector' attribute to user category $category = Category::getByHandle('user')->getController(); $category->associateAttributeKeyType($type); // associate the 'user_selector' attribute to file category $category = Category::getByHandle('file')->getController(); $category->associateAttributeKeyType($type); // associate the 'user_selector' attribute to file category $category = Category::getByHandle('event')->getController(); $category->associateAttributeKeyType($type); } $db = $this->connection; if ($db->tableExists('atUserSelector')) { // This is the name of the user selector attribute table in some implementations of the user selector attribute // We need to take this data and place it into atNumber. $db->query(<<<EOT insert into atNumber (avID, value) select atUserSelector.avID, atUserSelector.value from atUserSelector inner join AttributeValues on atUserSelector.avID = AttributeValues.avID left join atNumber on atUserSelector.avID = atNumber.avID where atNumber.avID is null EOT ); } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180926000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180926000000.php
MIT
private function fixAttributeIndexTable(Schema $schema, $indexTableName, $indexColumnName, $foreignTableName, $foreignColumn) { $this->output("Fixing attribute index table {$indexTableName}..."); $sm = $this->connection->getSchemaManager(); $schemaTables = $sm->listTableNames(); if (in_array($indexTableName, $schemaTables)) { $this->deleteInvalidForeignKey($indexTableName, $indexColumnName, $foreignTableName, $foreignColumn); $indexTable = $schema->getTable($indexTableName); $indexColumn = $indexTable->getColumn($indexColumnName); $indexColumn->setDefault(null); $indexTable->addForeignKeyConstraint( $foreignTableName, [$indexColumnName], [$foreignColumn], ['onUpdate' => 'CASCADE', 'onDelete' => 'CASCADE'] ); } else { $this->output(t('Could not locate table %s, skipping...', $indexTableName)); } }
@param \Doctrine\DBAL\Schema\Schema $schema @param string $indexTableName @param string $indexColumnName @param string $foreignTableName @param string $foreignColumn
fixAttributeIndexTable
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180926070300.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180926070300.php
MIT
private function fixExpressEntityAttributeIndexTable(Schema $schema, ExpressEntity $expressEntity) { $this->output('Fixing express index table for ' . $expressEntity->getName() . '...'); $attributeCategory = $expressEntity->getAttributeKeyCategory(); /* @var \Concrete\Core\Attribute\Category\ExpressCategory $attributeCategory */ $indexTableName = $attributeCategory->getIndexedSearchTable(); $indexTable = $schema->getTable($indexTableName); $exEntryIDColumn = $indexTable->getColumn('exEntryID'); $exEntryIDColumn->setUnsigned(false); $this->fixAttributeIndexTable( $schema, $indexTableName, 'exEntryID', 'ExpressEntityEntries', 'exEntryID' ); }
@param \Doctrine\DBAL\Schema\Schema $schema @param \Concrete\Core\Entity\Express\Entity $expressEntity
fixExpressEntityAttributeIndexTable
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20180926070300.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20180926070300.php
MIT
public function upgradeDatabase() { $this->refreshDatabaseTables([ 'Blocks', 'CollectionVersions', 'Collections', 'UserGroups', ]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20181006212300.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20181006212300.php
MIT
public function upgradeDatabase() { $config = $this->app->make('config'); $resolver = $this->app->make(Resolver::class); $error = null; try { list($characterSet, $collation) = $resolver ->setCharacterSet((string) $config->get('database.preferred_character_set')) ->setCollation((string) $config->get('database.preferred_collation')) ->resolveCharacterSetAndCollation($this->connection) ; } catch (CharacterSetCollationException $x) { try { list($characterSet, $collation) = $resolver ->setCharacterSet((string) $config->get('database.fallback_character_set')) ->setCollation((string) $config->get('database.fallback_collation')) ->resolveCharacterSetAndCollation($this->connection) ; } catch (Exception $x) { $error = $x; } } catch (Throwable $x) { $error = $x; } if ($error !== null) { $this->output(t('Failed to resolve the database character set and collation: %s', $error->getMessage())); return; } $params = $this->connection->getParams(); if (isset($params['character_set']) && $params['character_set'] === $characterSet && isset($params['collation']) && $params['collation'] === $collation) { return; } $manager = $this->app->make(Manager::class); try { $manager->apply( $characterSet, $collation, '', '', function ($message) { $this->output($message); } ); } catch (Exception $x) { $this->output(t('Failed to set character sets: %s', $x->getMessage())); } catch (Throwable $x) { $this->output(t('Failed to set character sets: %s', $x->getMessage())); } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20181006212400.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20181006212400.php
MIT
public function upgradeDatabase() { $this->output(t('Refreshing table FileImageThumbnailPaths...')); \Concrete\Core\Database\Schema\Schema::refreshCoreXMLSchema([ 'FileImageThumbnailPaths', ]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20181105102800.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20181105102800.php
MIT
public function upgradeDatabase() { $this->ensureCollectionVersionPublicDates(); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20181116072400.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20181116072400.php
MIT
protected function fixPublishStartEndDates() { $this->connection->executeQuery( <<<EOT UPDATE CollectionVersions SET cvPublishDate = (@publishDate:=cvPublishDate), cvPublishDate = cvPublishEndDate, cvPublishEndDate = @publishDate WHERE cvPublishDate IS NOT NULL AND cvPublishEndDate IS NOT NULL AND cvPublishDate > cvPublishEndDate EOT ); }
Be sure that cvPublishDate is not greater than cvPublishEndDate.
fixPublishStartEndDates
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20181116072400.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20181116072400.php
MIT
protected function fixOverlappingStartEndDates() { $rs = $this->connection->executeQuery(<<<'EOT' select cv1.cID, cv1.cvID from CollectionVersions as cv1 inner join CollectionVersions as cv2 on cv1.cID = cv2.cID and cv1.cvID <> cv2.cvID and cv1.cvIsApproved = cv2.cvIsApproved where cv1.cvIsApproved = 1 and ifnull(cv1.cvPublishDate, '0000-00-00 00:00:00') <= ifnull(cv1.cvPublishEndDate, '9999-99-99 99:99:99') and ifnull(cv1.cvPublishEndDate, '9999-99-99 99:99:99') >= ifnull(cv2.cvPublishDate, '0000-00-00 00:00:00') order by cv1.cID, cv1.cvID desc EOT ); $page = null; while (($row = $rs->fetch(PDO::FETCH_ASSOC)) !== false) { if ($page === null || $page->getCollectionID() != $row['cID']) { $page = Page::getByID($row['cID'], $row['cvID']); } else { $page->loadVersionObject($row['cvID']); } $version = $page->getVersionObject(); // Force fixing other collection version publish date/time interval $version->setPublishInterval($version->getPublishDate(), $version->getPublishDate()); } }
Be sure that there are not approved collection versions with overlapping publish dates.
fixOverlappingStartEndDates
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20181116072400.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20181116072400.php
MIT
public function upgradeSchema(Schema $schema) { if ($schema->hasTable('OAuth2AccessToken')) { $table = $schema->getTable('OAuth2AccessToken'); $foreignKeys = $table->getForeignKeys(); foreach ($foreignKeys as $foreignKey) { $localColumns = array_map('strtolower', $foreignKey->getLocalColumns()); if (in_array('refreshtoken', $localColumns, true)) { $table->removeForeignKey($foreignKey->getName()); } } } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeSchema()
upgradeSchema
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20190225184524.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20190225184524.php
MIT
public function upgradeDatabase() { $this->refreshEntities([ AccessToken::class, ]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20190225184524.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20190225184524.php
MIT
public function upgradeDatabase() { $this->fixDuplicatedStacks(); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20190301133300.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20190301133300.php
MIT
public function upgradeSchema(Schema $schema) { // Create the TreeFileFolderNodes table if (!$schema->hasTable('TreeFileFolderNodes')) { $treeFileFolderNodesTable = $schema->createTable('TreeFileFolderNodes'); $treeFileFolderNodesTable->addColumn('treeNodeID', 'integer', ['notnull' => true, 'unsigned' => true, 'autoincrement' => true]); $treeFileFolderNodesTable->addColumn('fslID', 'integer', ['notnull' => true, 'unsigned' => true]); $treeFileFolderNodesTable->setPrimaryKey(['treeNodeID']); $treeFileFolderNodesTable->addIndex(['fslID'], 'fslID'); } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeSchema()
upgradeSchema
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20190309000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20190309000000.php
MIT
public function upgradeDatabase() { // Add any existing folder to the default storage location $db = $this->connection; $defaultStorageLocationID = $db->fetchColumn('SELECT fslID FROM FileStorageLocations WHERE fslIsDefault = 1'); $folderTreeNodeTypeID = $db->fetchColumn('SELECT treeNodeTypeID FROM TreeNodeTypes WHERE treeNodeTypeHandle = ?', [ 'file_folder' ]); $folders = $db->fetchAll('SELECT treeNodeID FROM TreeNodes WHERE treeNodeID NOT IN (SELECT treeNodeID FROM TreeFileFolderNodes) AND treeNodeTypeID = ?', [ $folderTreeNodeTypeID ]); foreach ($folders as $folder) { $db->executeQuery('INSERT INTO TreeFileFolderNodes (treeNodeID, fslID) VALUES (?, ?)', [ $folder['treeNodeID'], $defaultStorageLocationID ]); } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20190309000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20190309000000.php
MIT
public function upgradeDatabase() { $app = Facade::getFacadeApplication(); $categoryService = $app->make(CategoryService::class); /* @var CategoryService $categoryService */ $typeFactory = $app->make(TypeFactory::class); /* @var TypeFactory $typeFactory */ $em = $app->make(EntityManager::class); $type = $typeFactory->getByHandle('user_group'); if (!$type) { $type = $typeFactory->add('user_group', 'User Group'); } foreach (['site', 'site_type'] as $handle) { $category = $categoryService->getByHandle($handle); if ($category !== null) { $categoryTypes = $category->getAttributeTypes(); if (!$categoryTypes->contains($type)) { $categoryTypes->add($type); } } } $em->flush(); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20190504005632.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20190504005632.php
MIT
public function upgradeDatabase() { $manager = $this->app->make(Manager::class); try { $manager->reapply( $this->connection, function ($message) { $this->output($message); } ); } catch (Exception $x) { $this->output(t('Failed to set character sets: %s', $x->getMessage())); } catch (Throwable $x) { $this->output(t('Failed to set character sets: %s', $x->getMessage())); } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20190509000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20190509000000.php
MIT
public function upgradeDatabase() { $this->fixWorkflowsPackage(); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20190625177700.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20190625177700.php
MIT
public function upgradeDatabase() { $this->refreshEntities([ IpAccessControlCategory::class, IpAccessControlRange::class, IpAccessControlEvent::class, ]); $this->createFailedLoginCategory(); $this->createSinglePage( '/dashboard/system/permissions/blacklist/configure', 'Configure IP Blocking', ['exclude_nav' => true] ); $rangePage = Page::getByPath('/dashboard/system/permissions/blacklist/range'); if ($rangePage && !$rangePage->isError()) { if ($this->isAttributeHandleValid(PageCategory::class, 'exclude_nav')) { $rangePage->setAttribute('exclude_nav', true); } } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20190708000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20190708000000.php
MIT
public function upgradeDatabase() { $ci = new ContentImporter(); $ci->importContentFile(DIR_BASE_CORE . '/config/install/upgrade/captcha.xml'); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20190717090600.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20190717090600.php
MIT
public function upgradeSchema(Schema $schema) { $this->fixCookieTable($schema); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeSchema()
upgradeSchema
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20190822160700.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20190822160700.php
MIT
public function upgradeDatabase() { if ($this->shouldUpdateCollectionVersions()) { $this->updateCollectionVersions(); } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20200116115000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20200116115000.php
MIT
private function shouldUpdateCollectionVersions(): bool { $config = $this->app->make('config'); $lastPerformedMigrationID = (string) $config->get('concrete.version_db_installed'); if ($lastPerformedMigrationID === '') { return true; } $thisMigrationID = preg_replace('/.*Version(\d+)$/', '${1}', __CLASS__); return $thisMigrationID > $lastPerformedMigrationID; }
Should we update the CollectionVersions database table? This is needed if we are re-executing this migration. @return bool
shouldUpdateCollectionVersions
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20200116115000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20200116115000.php
MIT
private function updateCollectionVersions(): void { $this->connection->executeUpdate( <<<'EOT' UPDATE CollectionVersions INNER JOIN Pages ON CollectionVersions.cID = Pages.cID SET CollectionVersions.cvName = '' WHERE Pages.cPointerID IS NOT NULL AND Pages.cPointerID <> 0 EOT ); }
Clear the cvName field of the CollectionVersions table for aliases, so that concrete5 knows that users want the current name of the aliased page.
updateCollectionVersions
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20200116115000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20200116115000.php
MIT
public function upgradeDatabase() { // Delete DownloadStatistics records not associated to file entities $this->connection->executeUpdate( <<<'EOT' DELETE DownloadStatistics FROM DownloadStatistics LEFT JOIN Files ON DownloadStatistics.fID = Files.fID WHERE Files.fID IS NULL EOT ); // Refresh the table definition $this->refreshEntities([ File::class, DownloadStatistics::class, ]); // Set to NULL the uID column with a value of 0 $this->connection->update('DownloadStatistics', ['uID' => null], ['uID' => 0]); // Set to NULL the rcID column with a value of 0 $this->connection->update('DownloadStatistics', ['rcID' => null], ['rcID' => 0]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20200610162600.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20200610162600.php
MIT
public function upgradeDatabase() { $this->refreshEntities([ Site::class, ]); $this->createSinglePage( '/dashboard/files/details', 'File Details', [ 'exclude_nav' => true, ] ); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20200611161800.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20200611161800.php
MIT
public function upgradeSchema(Schema $schema) { // add new multilingual tables. if (!$schema->hasTable('UserPrivateMessagesAttachments')) { $mpr = $schema->createTable('UserPrivateMessagesAttachments'); $mpr->addColumn('msgID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => 0]); $mpr->addColumn('fID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => 0]); $mpr->setPrimaryKey(['msgID', 'fID']); } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeSchema()
upgradeSchema
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20201229143500.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20201229143500.php
MIT
public function upgradeSchema(Schema $schema) { // Create the TreeFileFolderNodes table if (!$schema->hasTable('TreeGroupFolderNodes')) { $treeFileFolderNodesTable = $schema->createTable('TreeGroupFolderNodes'); $treeFileFolderNodesTable->addColumn('treeNodeID', 'integer', ['notnull' => true, 'unsigned' => true, 'autoincrement' => true]); $treeFileFolderNodesTable->addColumn('contains', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => '0']); $treeFileFolderNodesTable->setPrimaryKey(['treeNodeID']); } // Create the TreeFileFolderNodes table if (!$schema->hasTable('TreeGroupFolderNodeSelectedGroupTypes')) { $treeGroupFolderNodeSelectedGroupTypesTable = $schema->createTable('TreeGroupFolderNodeSelectedGroupTypes'); $treeGroupFolderNodeSelectedGroupTypesTable->addColumn('id', 'integer', ['notnull' => true, 'unsigned' => true, 'autoincrement' => true]); $treeGroupFolderNodeSelectedGroupTypesTable->addColumn('treeNodeID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => '0']); $treeGroupFolderNodeSelectedGroupTypesTable->addColumn('gtID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => '0']); $treeGroupFolderNodeSelectedGroupTypesTable->setPrimaryKey(['id']); } // Create the GroupTypes table if (!$schema->hasTable('GroupTypes')) { $groupTypesTable = $schema->createTable('GroupTypes'); $groupTypesTable->addColumn('gtID', 'integer', ['notnull' => true, 'unsigned' => true, 'autoincrement' => true]); $groupTypesTable->addColumn('gtName', 'string', ['notnull' => true, 'default' => '', 'length' => 128]); $groupTypesTable->addColumn('gtPetitionForPublicEntry', 'boolean', ['notnull' => true, 'default' => '0']); $groupTypesTable->addColumn('gtDefaultRoleID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => '0']); $groupTypesTable->setPrimaryKey(['gtID']); } // Create the GroupRoles table if (!$schema->hasTable('GroupRoles')) { $groupRolesTable = $schema->createTable('GroupRoles'); $groupRolesTable->addColumn('grID', 'integer', ['notnull' => true, 'unsigned' => true, 'autoincrement' => true]); $groupRolesTable->addColumn('grName', 'string', ['notnull' => true, 'default' => '', 'length' => 128]); $groupRolesTable->addColumn('grIsManager', 'boolean', ['notnull' => true, 'default' => '0']); $groupRolesTable->setPrimaryKey(['grID']); } // Create the GroupSelectedRoles table if (!$schema->hasTable('GroupSelectedRoles')) { $groupSelectedRolesTable = $schema->createTable('GroupSelectedRoles'); $groupSelectedRolesTable->addColumn('gID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => '0']); $groupSelectedRolesTable->addColumn('grID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => '0']); $groupSelectedRolesTable->setPrimaryKey(['gID', 'grID']); } // Create the GroupSelectedRoles table if (!$schema->hasTable('GroupTypeSelectedRoles')) { $groupTypeSelectedRolesTable = $schema->createTable('GroupTypeSelectedRoles'); $groupTypeSelectedRolesTable->addColumn('gtID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => '0']); $groupTypeSelectedRolesTable->addColumn('grID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => '0']); $groupTypeSelectedRolesTable->setPrimaryKey(['gtID', 'grID']); } // Create the GroupJoinRequests table if (!$schema->hasTable('GroupJoinRequests')) { $groupJoinRequestsTable = $schema->createTable('GroupJoinRequests'); $groupJoinRequestsTable->addColumn('uID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => '0']); $groupJoinRequestsTable->addColumn('gID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => '0']); $groupJoinRequestsTable->addColumn('gjrRequested', 'datetime', ['notnull' => false]); $groupJoinRequestsTable->setPrimaryKey(['uID', 'gID']); } // Extend the Groups table $groupsTable = $schema->getTable('Groups'); if (!$groupsTable->hasColumn('gThumbnailFID')) { $groupsTable->addColumn('gThumbnailFID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => '0']); } if (!$groupsTable->hasColumn('gtID')) { $groupsTable->addColumn('gtID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => '0']); } if (!$groupsTable->hasColumn('gPetitionForPublicEntry')) { $groupsTable->addColumn('gPetitionForPublicEntry', 'boolean', ['notnull' => true, 'default' => '0']); } if (!$groupsTable->hasColumn('gOverrideGroupTypeSettings')) { $groupsTable->addColumn('gOverrideGroupTypeSettings', 'boolean', ['notnull' => true, 'default' => '0']); } if (!$groupsTable->hasColumn('gDefaultRoleID')) { $groupsTable->addColumn('gDefaultRoleID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => '0']); } if (!$groupsTable->hasColumn('gAuthorID')) { $groupsTable->addColumn('gAuthorID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => '0']); } // Extend the User Groups table $userGroupsTable = $schema->getTable('UserGroups'); if (!$userGroupsTable->hasColumn('grID')) { $userGroupsTable->addColumn('grID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => '0']); } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeSchema()
upgradeSchema
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20210216184000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20210216184000.php
MIT
public function upgradeDatabase() { $this->refreshDatabaseTables(['Logs']); Page::getByPath("/dashboard/users/points")->delete(); Page::getByPath("/dashboard/users/points/actions")->delete(); Page::getByPath("/dashboard/users/points/assign")->delete(); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20210331213100.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20210331213100.php
MIT
public function upgradeDatabase() { $this->refreshEntities(['Concrete\Core\Entity\StyleCustomizer\Inline\StyleSet']); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20220307105409.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20220307105409.php
MIT
public function upgradeDatabase() { /** @var Service $site */ $site = $this->app->make(Service::class); $sites = $site->getList(); foreach ($sites as $site) { $config = $site->getConfigRepository(); if ($config->has('editor.ckeditor4.plugins.selected')) { $selected = $config->get('editor.ckeditor4.plugins.selected', []); if (($key = array_search('wsc', $selected)) !== false) { unset($selected[$key]); $config->save('editor.ckeditor4.plugins.selected', $selected); } } } }
Web Spell Checker ended support on December 31st, 2011, and was removed from CKEditor4 since 4.18.0 @return void
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20220408000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20220408000000.php
MIT
public function upgradeDatabase() { $this->refreshBlockType('video'); }
Refresh video block type for new title field @return void
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20220503000000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20220503000000.php
MIT
public function upgradeDatabase() { $this->createSinglePage( '/dashboard/system/files/uploads', 'Upload Settings', [ 'meta_keywords' => 'files, upload, parallel, upload_max_filesize, post_max_size, limit, resize, chunk' ] ); $navigationCache = $this->app->make(NavigationCache::class); $navigationCache->clear(); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20220908074900.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20220908074900.php
MIT
public function upgradeDatabase() { $this->refreshBlockType('event_list'); }
Refresh event list block type with sort order functionality @return void
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20220909300000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20220909300000.php
MIT
public function upgradeDatabase() { // Before we used the admin's email as the default address: // let's avoid BC breaks by restoring that behaviour. $adminAddress = $this->getAdminAddress(); if ($adminAddress === '') { $this->write(t('Default system email address not updated because we failed to retrieve the admin email address.')); return; } $config = $this->app->make(Repository::class); $defaultAddress = (string) $config->get(self::DEFAULT_SENDER_KEY); if ($defaultAddress === $adminAddress) { $this->write(t("We don't have to update the system email addresses because the default address doesn't change.")); return; } foreach (self::OTHER_SENDER_KEYS as $key) { if ((string) $config->get($key) !== '') { // This configuration key is configured: we don't need to restore the previous address continue; } $this->write(t('Updating email sender key: %s', $key)); $config->set($key, $adminAddress); $config->save($key, $adminAddress); } }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20221219220600.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20221219220600.php
MIT
public function upgradeDatabase() { $this->refreshEntities([ User::class, ]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20230107185800.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20230107185800.php
MIT
public function upgradeDatabase() { $this->refreshEntities([ // Fix deleting rows in UserFavoriteFolders table when deleting a user. FavoriteFolder::class, ]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20231002142400.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20231002142400.php
MIT
public function upgradeDatabase() { $this->refreshEntities([ // Fix deleting rows in UserFavoriteFolders table when deleting a user. AnnouncementUserView::class, ]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20231207100748.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20231207100748.php
MIT
public function upgradeDatabase() { $this->refreshEntities([ // Fix creating (and maintaining) index on cPath PagePath::class, ]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20240618202000.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20240618202000.php
MIT
public function upgradeDatabase() { $this->output(t('Updating table: %s', 'Pages')); $this->connection->executeStatement( <<<'EOT' UPDATE Pages AS ExternalLinkPages INNER JOIN Pages AS ParentPages ON ExternalLinkPages.cParentID = ParentPages.cID SET ExternalLinkPages.siteTreeID = ParentPages.siteTreeID WHERE -- Apply to external links only COALESCE(ExternalLinkPages.cPointerExternalLink, '') <> '' -- Apply only to external links with wrong site tree AND ExternalLinkPages.siteTreeID <> ParentPages.siteTreeID -- This shouldn't be needed, but it doesn't hurt AND COALESCE(ParentPages.siteTreeID, 0) > 0 EOT ); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20241115093300.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20241115093300.php
MIT
public function upgradeDatabase() { $page = Page::getByPath('/dashboard/system/basics/social'); if ($page && !$page->isError()) { $page->delete(); } $this->createSinglePage('/dashboard/system/social', 'Social &amp; Sharing'); $this->createSinglePage('/dashboard/system/social/social_links', 'Social Links', ['meta_keywords' => 'sharing, facebook, twitter']); $this->createSinglePage('/dashboard/system/social/opengraph', 'Open Graph', ['meta_keywords' => 'sharing, opengraph, schema']); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20241204161559.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20241204161559.php
MIT
public function upgradeDatabase() { $this->refreshEntities([Version::class]); }
{@inheritdoc} @see \Concrete\Core\Updater\Migrations\AbstractMigration::upgradeDatabase()
upgradeDatabase
php
concretecms/concretecms
concrete/src/Updater/Migrations/Migrations/Version20241210181033.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Updater/Migrations/Migrations/Version20241210181033.php
MIT
public function __construct(ResolverManagerInterface $resolver, Numbers $valn, $includedQuerystringParameters) { $this->resolver = $resolver; $this->valn = $valn; $this->includedQuerystringParameters = $includedQuerystringParameters ?: []; }
Initialize the instance. @param ResolverManagerInterface $resolver the instance of the class that builds page URLs @param Numbers $valn the instance of the numbers validator @param string[]|\Traversable $includedQuerystringParameters the list of query string parameters to be included from generated canonical URLs
__construct
php
concretecms/concretecms
concrete/src/Url/SeoCanonical.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/SeoCanonical.php
MIT
public function getPageCanonicalURL($page, $querystring = null) { $result = null; if ($page) { if ($this->valn->integer($page, 1)) { $page = Page::getByID($page); } if ($page instanceof Page && !$page->isError()) { $cID = $page->getCollectionID(); $originalCID = $page->getCollectionPointerOriginalID(); if (!empty($originalCID) && $originalCID != $cID) { $result = $this->getPageCanonicalURL($cID, $querystring); } else { $args = [$page]; if ($pathArguments = $this->getPathArguments()) { $args = array_merge($args, $pathArguments); } $result = $this->resolver->resolve($args); $query = null; if ($querystring instanceof Query) { $query = clone $querystring; } elseif ($querystring instanceof Request) { $query = new Query($querystring->query->all()); } elseif ($querystring instanceof ParameterBag) { $query = new Query($querystring->all()); } elseif (is_array($querystring)) { $query = new Query($querystring); } elseif (is_string($querystring)) { if ($querystring !== '') { $query = new Query($querystring); } } if ($query !== null && $query->count() > 0) { foreach ($query as $key => $value) { if (!in_array($key, $this->includedQuerystringParameters)) { $query->offsetUnset($key); } } $result = $result->setQuery($query); } } } } return $result; }
Generate the canonical URL of a page. @param Page|int $page The Page instance (or its collection ID) @param Request|ParameterBag|Query|array|string|null $querystring Optional query string parameters @return \League\URL\URLInterface|null
getPageCanonicalURL
php
concretecms/concretecms
concrete/src/Url/SeoCanonical.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/SeoCanonical.php
MIT
public function getPageCanonicalURLTag($page, $querystring = null) { $result = null; $url = $this->getPageCanonicalURL($page, $querystring); if ($url !== null) { $result = new \HtmlObject\Element( 'link', null, [ 'rel' => 'canonical', 'href' => $url, ] ); $result->setIsSelfClosing(true); } return $result; }
Generate the <meta rel="canonical" href="..."> tag of a page. @param Page|int $page The Page instance (or its collection ID) @param Request|ParameterBag|Query|array|string|null $querystring Optional query string parameters @return \HtmlObject\Element|null
getPageCanonicalURLTag
php
concretecms/concretecms
concrete/src/Url/SeoCanonical.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/SeoCanonical.php
MIT
public function getPathArguments() { return $this->pathArguments; }
Get path arguments to append canonical URLs @return string[]|null
getPathArguments
php
concretecms/concretecms
concrete/src/Url/SeoCanonical.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/SeoCanonical.php
MIT
public function setPathArguments($pathArguments) { $this->pathArguments = $pathArguments; }
Set path arguments to append canonical URLs @param string[] $pathArguments
setPathArguments
php
concretecms/concretecms
concrete/src/Url/SeoCanonical.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/SeoCanonical.php
MIT
public function addIncludedQuerystringParameter(string $parameter) { $this->includedQuerystringParameters[] = $parameter; }
@since 9.0.3 @param string $parameter @return void
addIncludedQuerystringParameter
php
concretecms/concretecms
concrete/src/Url/SeoCanonical.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/SeoCanonical.php
MIT
public function setPortIfNecessary($port) { return $this->setPort($port); }
@param integer $port @deprecated Use `->setPort($port)` @return UrlInterface
setPortIfNecessary
php
concretecms/concretecms
concrete/src/Url/Url.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Url.php
MIT
protected static function sanitizeUrl($url) { if (strpos($url, '/') === 0) { return $url; } return parent::sanitizeUrl($url); }
Overridden to allow paths be passed in and out @param $url @return null|string
sanitizeUrl
php
concretecms/concretecms
concrete/src/Url/Url.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Url.php
MIT
public function setPortIfNecessary($port) { return $this->setPort($port); }
@param integer $port @deprecated Use `->setPort($port)` @return UrlInterface
setPortIfNecessary
php
concretecms/concretecms
concrete/src/Url/UrlImmutable.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/UrlImmutable.php
MIT
protected static function sanitizeUrl($url) { if (strpos($url, '/') === 0) { return $url; } return parent::sanitizeUrl($url); }
Overridden to allow paths be passed in and out @param $url @return null|string
sanitizeUrl
php
concretecms/concretecms
concrete/src/Url/UrlImmutable.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/UrlImmutable.php
MIT
public function register() { $this->app->singleton('Concrete\Core\Url\Resolver\CanonicalUrlResolver'); $this->app->bind('url/canonical/resolver', '\Concrete\Core\Url\Resolver\CanonicalUrlResolver'); $this->app->bind('url/canonical', function ($app) { return $app->make('Concrete\Core\Url\Resolver\CanonicalUrlResolver')->resolve(array()); }); // Share the path url resolver $this->app->singleton('Concrete\Core\Url\Resolver\PathUrlResolver'); $this->app->bind('url/resolver/path', 'Concrete\Core\Url\Resolver\PathUrlResolver'); // Share the Page url resolver $this->app->singleton('Concrete\Core\Url\Resolver\PageUrlResolver'); $this->app->bind('url/resolver/page', 'Concrete\Core\Url\Resolver\PageUrlResolver'); // Share the route url resolver $this->app->singleton('Concrete\Core\Url\Resolver\RouterUrlResolver'); $this->app->bind('url/resolver/route', 'Concrete\Core\Url\Resolver\RouterUrlResolver'); $this->app->bindShared('Concrete\Core\Url\Resolver\Manager\ResolverManager', function ($app, $default_handle = '', $default_resolver = null) { $manager = new ResolverManager($default_handle ?: 'concrete.path', $default_resolver); $manager->addResolver('concrete.path', $app->make('Concrete\Core\Url\Resolver\PathUrlResolver')); $manager->addResolver('concrete.page', $app->make('Concrete\Core\Url\Resolver\PageUrlResolver')); $manager->addResolver('concrete.route', $app->make('Concrete\Core\Url\Resolver\RouterUrlResolver')); $manager->addResolver('concrete.user', $app->make('Concrete\Core\Url\Resolver\UserInfoUrlResolver')); return $manager; }); $this->app->bind('Concrete\Core\Url\Resolver\Manager\ResolverManagerInterface', 'Concrete\Core\Url\Resolver\Manager\ResolverManager'); $this->app->bind('url/manager', 'Concrete\Core\Url\Resolver\Manager\ResolverManager'); $this->app ->when(SeoCanonical::class) ->needs('$includedQuerystringParameters') ->give(function($app) { $site = $app->make('site')->getSite(); $config = $site->getConfigRepository(); return $config->get('seo.canonical_tag.included_querystring_parameters'); }); $this->app->singleton(SeoCanonical::class, SeoCanonical::class); }
Registers the services provided by this provider.
register
php
concretecms/concretecms
concrete/src/Url/UrlServiceProvider.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/UrlServiceProvider.php
MIT
public function __construct($data, $trailing_slash = false) { $this->set($data); $this->trail = (bool) $trailing_slash; }
@param \League\Url\Components\Path $old_path @param bool $trailing_slash
__construct
php
concretecms/concretecms
concrete/src/Url/Components/Path.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Components/Path.php
MIT
public function normalizePath($path) { $path = new Path('/' . trim($path, '/ '), true); return "/" . (string)$path->withoutDispatcher(); }
Trim trailing slash, ensure there's a leading slash @param string $path @return string
normalizePath
php
concretecms/concretecms
concrete/src/Url/DomainMapper/Map/Normalizer.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/DomainMapper/Map/Normalizer.php
MIT
public function __construct($resolver) { $this->setResolver($resolver); }
@param callable $resolver @see \Concrete\Core\Url\Resolver\CallableUrlResolver::setResolver() for a description of $resolver
__construct
php
concretecms/concretecms
concrete/src/Url/Resolver/CallableUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/CallableUrlResolver.php
MIT
public function setResolver(/* callable */ $resolver) { if (!is_callable($resolver)) { throw new \InvalidArgumentException( 'Resolver not callable'); } $this->resolver = $resolver; }
@param callable $resolver A Callable that receives three arguments CallableUrlResolver $resolver, array $arguments, string|null $resolved
setResolver
php
concretecms/concretecms
concrete/src/Url/Resolver/CallableUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/CallableUrlResolver.php
MIT
public function resolve(array $arguments, $resolved = null) { return $this->resolver ? call_user_func($this->resolver, $this, $arguments, $resolved) : null; }
{@inheritdoc} @see \Concrete\Core\Url\Resolver\UrlResolverInterface::resolve()
resolve
php
concretecms/concretecms
concrete/src/Url/Resolver/CallableUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/CallableUrlResolver.php
MIT
public function __construct(Application $app, Request $request) { $this->app = $app; $this->request = $request; }
CanonicalUrlResolver constructor. @param \Concrete\Core\Application\Application $app @param \Concrete\Core\Http\Request $request
__construct
php
concretecms/concretecms
concrete/src/Url/Resolver/CanonicalUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/CanonicalUrlResolver.php
MIT
public function resolve(array $arguments, $resolved = null) { $page = null; $site = null; // Canonical urls for pages can be different than for the entire site if (isset($arguments[0]) && $arguments[0] instanceof Page) { $page = head($arguments); $tree = $page->getSiteTreeObject(); if ($tree instanceof SiteTree) { $site = $tree->getSite(); } } elseif ($this->cached) { return $this->cached; } /* @var \Concrete\Core\Page\Page|null $page */ // Get the site from the current site tree if ($site === null && $this->app->isInstalled()) { $site = $this->app->make('site')->getSite(); } /* @var \Concrete\Core\Entity\Site\Site|null $site */ // Determine trailing slash setting $trailing_slashes = $this->app->make('config')->get('concrete.seo.trailing_slash') ? Url::TRAILING_SLASHES_ENABLED : Url::TRAILING_SLASHES_DISABLED; $url = UrlImmutable::createFromUrl('', $trailing_slashes); $url = $url->setHost(null); $url = $url->setScheme(null); if ($site && $configUrl = $site->getSiteCanonicalURL()) { $requestScheme = strtolower($this->request->getScheme()); $canonical = UrlImmutable::createFromUrl($configUrl, $trailing_slashes); $canonicalToUse = $canonical; if ($configUrlAlternative = $site->getSiteAlternativeCanonicalURL()) { $canonical_alternative = UrlImmutable::createFromUrl($configUrlAlternative, $trailing_slashes); if ( strtolower($canonical->getScheme()) !== $requestScheme && strtolower($canonical_alternative->getScheme()) === $requestScheme ) { $canonicalToUse = $canonical_alternative; } } $url = $url->setScheme($canonicalToUse->getScheme()); $url = $url->setHost($canonicalToUse->getHost()); if ((int) $canonicalToUse->getPort()->get() > 0) { $url = $url->setPort($canonicalToUse->getPort()); } if ((string) $canonicalToUse->getPath() !== '') { $url = $url->setPath($canonicalToUse->getPath()); } } else { // This fallthrough is dangerous. Make sure that you define your canonical URL so that we don't have to guess! $host = $this->request->getHost(); $scheme = $this->request->getScheme(); if ($scheme && $host) { $url = $url->setScheme($scheme) ->setHost($host) ->setPort($this->request->getPort()); } } if ($relative_path = $this->app['app_relative_path']) { $url = $url->setPath($relative_path); } // Don't cache page specific canonical urls if (!$page) { $this->cached = $url; } return $url; }
{@inheritdoc} @see \Concrete\Core\Url\Resolver\UrlResolverInterface::resolve()
resolve
php
concretecms/concretecms
concrete/src/Url/Resolver/CanonicalUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/CanonicalUrlResolver.php
MIT
public function resolve(array $arguments, $resolved = null) { if ($resolved) { // We don't need to do any post processing on urls. return $resolved; } $page = $arguments ? head($arguments) : null; if (isset($page) && $page instanceof Page) { if ($externalUrl = $page->getCollectionPointerExternalLink()) { return $this->resolveWithResolver($externalUrl, []); } $tree = $page->getSiteTreeObject(); if (is_object($tree) && $tree instanceof SkeletonTree) { return $this->resolveWithPageId($page, $arguments); } if ($path = $page->getCollectionPath()) { return $this->resolveWithResolver($path, $arguments); } // if there's no path but it's the home page if ($page->isHomePage()) { return $this->resolveWithResolver('/', $arguments); } // otherwise, it's a page object with no path yet, which happens when pages aren't yet approved return $this->resolveWithPageId($page, $arguments); } return null; }
{@inheritdoc} @see \Concrete\Core\Url\Resolver\UrlResolverInterface::resolve()
resolve
php
concretecms/concretecms
concrete/src/Url/Resolver/PageUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/PageUrlResolver.php
MIT
protected function resolveWithResolver($path, $arguments) { array_unshift($arguments, $path); return $this->pathUrlResolver->resolve($arguments); }
@param string $path @param array $arguments @return \League\URL\URLInterface
resolveWithResolver
php
concretecms/concretecms
concrete/src/Url/Resolver/PageUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/PageUrlResolver.php
MIT
public function __construct(Repository $repository, CanonicalUrlResolver $canonical_resolver, Dashboard $dashboard) { $this->config = $repository; $this->canonical = $canonical_resolver; $this->dashboard = $dashboard; }
PathUrlResolver constructor. @param \Concrete\Core\Config\Repository\Repository $repository @param \Concrete\Core\Url\Resolver\CanonicalUrlResolver $canonical_resolver @param \Concrete\Core\Application\Service\Dashboard $dashboard
__construct
php
concretecms/concretecms
concrete/src/Url/Resolver/PathUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/PathUrlResolver.php
MIT
public function resolve(array $arguments, $resolved = null) { if ($resolved) { // We don't need to do any post processing on urls. return $resolved; } $page = null; foreach ($arguments as $key => $argument) { if ($argument instanceof Page) { $page = $argument; break; } } if ($page) { unset($arguments[$key]); } $args = $arguments; $path = array_shift($args); if (is_scalar($path) || (is_object($path) && method_exists($path, '__toString'))) { $path = rtrim($path, '/'); $url = $this->canonical->resolve([$page]); $url = $this->handlePath($url, $path, $args); return $url; } return null; }
{@inheritdoc} @see \Concrete\Core\Url\Resolver\UrlResolverInterface::resolve()
resolve
php
concretecms/concretecms
concrete/src/Url/Resolver/PathUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/PathUrlResolver.php
MIT
protected function handlePath(UrlInterface $url, $path, $args) { $path_object = $this->basePath($url, $path, $args); $components = parse_url($path); $reset = false; // Were we passed a built URL? If so, just return it. if ($string = array_get($components, 'scheme')) { try { $url = Url::createFromUrl($path); $path_object = $url->getPath(); $reset = true; } catch (\Exception $e) { } } if (!$reset) { if ($string = array_get($components, 'path')) { $path_object->append($string); } if ($string = array_get($components, 'query')) { $url = $url->setQuery($string); } if ($string = array_get($components, 'fragment')) { $url = $url->setFragment($string); } } foreach ($args as $segment) { if (!is_array($segment)) { $segment = (string) $segment; // sometimes integers foul this up when we pass them in as URL arguments. } $path_object->append($segment); } if (!$reset) { $url_path = $url->getPath(); $url_path->append($path_object); } else { $url_path = $path_object; } return $url->setPath($url_path); }
@param \Concrete\Core\Url\UrlInterface $url @param string $path @param array $args @return \Concrete\Core\Url\UrlInterface|\League\Url\Url
handlePath
php
concretecms/concretecms
concrete/src/Url/Resolver/PathUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/PathUrlResolver.php
MIT
protected function basePath($url, $path, $args) { $config = $this->config; $path_object = new Path(''); $rewriting = $config->get('concrete.seo.url_rewriting'); $rewrite_all = $config->get('concrete.seo.url_rewriting_all'); $in_dashboard = $this->dashboard->inDashboard($path); // If rewriting is disabled, or all_rewriting is disabled and we're // in the dashboard, add the dispatcher. if (!$rewriting || (!$rewrite_all && $in_dashboard)) { $path_object->prepend(DISPATCHER_FILENAME); } return $path_object; }
@param \Concrete\Core\Url\UrlInterface $url @param string $path @param array $args @return \Concrete\Core\Url\Components\Path
basePath
php
concretecms/concretecms
concrete/src/Url/Resolver/PathUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/PathUrlResolver.php
MIT
public function getGenerator() { return $this->router->getGenerator(); }
Get the url generator from the router. @return \Symfony\Component\Routing\Generator\UrlGeneratorInterface
getGenerator
php
concretecms/concretecms
concrete/src/Url/Resolver/RouterUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/RouterUrlResolver.php
MIT
public function getRouteList() { return $this->router->getRoutes(); }
Get the RouteCollection from the router. @return \Symfony\Component\Routing\RouteCollection
getRouteList
php
concretecms/concretecms
concrete/src/Url/Resolver/RouterUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/RouterUrlResolver.php
MIT
public function resolve(array $arguments, $resolved = null) { if (count($arguments) < 3) { $route_handle = array_shift($arguments); $route_parameters = count($arguments) ? array_shift($arguments) : []; // If param1 is a string that starts with "route/" and param2 is an array... if (is_string($route_handle) && strtolower(substr($route_handle, 0, 6)) == 'route/' && is_array($route_parameters)) { $resolved = $this->resolveRoute(substr($route_handle, 6), $route_parameters); } } return $resolved; }
Resolve urls from the list of registered routes takes a string. [code] $url = \URL::to('route/user_route', array('id' => 1)); [/code] OR [code] // Register a route $route_list->register('/users/{id}', '\My\Application\User\Controller::view', 'user_route'); // Create a resolver $route_url_resolver = new \Concrete\Core\Url\Resolver\RouteUrlResolver($generator, $route_list); // Retrieve the URL $url = $route_url_resolver->resolve(array('route/user_route', array('id' => 1))); [/code] @param array $arguments [ string $handle, array $parameters = array() ] The first parameter MUST be prepended with "route/" for it to be tested @param \League\URL\URLInterface|null $resolved @return \League\URL\URLInterface|null
resolve
php
concretecms/concretecms
concrete/src/Url/Resolver/RouterUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/RouterUrlResolver.php
MIT
private function resolveRoute($route_handle, $route_parameters) { $list = $this->getRouteList(); if ($list->get($route_handle)) { $generator = $this->getGenerator(); if ($path = $generator->generate($route_handle, $route_parameters, UrlGeneratorInterface::ABSOLUTE_PATH)) { return $this->pathUrlResolver->resolve([$path]); } } }
Resolve the route. @param string $route_handle @param array $route_parameters @return \League\URL\URLInterface|null
resolveRoute
php
concretecms/concretecms
concrete/src/Url/Resolver/RouterUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/RouterUrlResolver.php
MIT
public function getGenerator() { return $this->generator; }
@return \Symfony\Component\Routing\Generator\UrlGeneratorInterface
getGenerator
php
concretecms/concretecms
concrete/src/Url/Resolver/RouteUrlResolver.php
https://github.com/concretecms/concretecms/blob/master/concrete/src/Url/Resolver/RouteUrlResolver.php
MIT