Skip to content

Commit

Permalink
Add media render to media resource pages (fix #2058)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimsafley committed Jun 1, 2023
1 parent 6d1cae1 commit f4cf40d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion application/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Module extends AbstractModule
/**
* This Omeka version.
*/
const VERSION = '4.1.0-alpha';
const VERSION = '4.1.0-alpha5';

/**
* The vocabulary IRI used to define Omeka application data.
Expand Down
41 changes: 41 additions & 0 deletions application/data/migrations/20230601060113_AddMediaRender.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
namespace Omeka\Db\Migrations;

use Doctrine\DBAL\Connection;
use Laminas\ServiceManager\ServiceLocatorInterface;
use Omeka\Db\Migration\ConstructedMigrationInterface;

class AddMediaRender implements ConstructedMigrationInterface
{
private $em;

public static function create(ServiceLocatorInterface $services)
{
return new self($services->get('Omeka\EntityManager'));
}

public function __construct($em)
{
$this->em = $em;
}

public function up(Connection $conn)
{
// Add the mediaRender resource page block layout to media pages that
// only have the values block layout.
$query = $this->em->createQuery('SELECT s FROM Omeka\Entity\SiteSetting s WHERE s.id LIKE :id');
$query->setParameter('id', 'theme_settings_%');
$siteSettings = $query->getResult();
foreach ($siteSettings as $siteSetting) {
$value = $siteSetting->getValue();
if (isset($value['resource_page_blocks']['media']['main'])
&& 1 === count($value['resource_page_blocks']['media']['main'])
&& 'values' === reset($value['resource_page_blocks']['media']['main'])
) {
$value['resource_page_blocks']['media']['main'][] = 'mediaRender';
$siteSetting->setValue($value);
}
}
$this->em->flush();
}
}
1 change: 1 addition & 0 deletions application/src/Site/ResourcePageBlockLayout/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Manager extends AbstractPluginManager
'media' => [
'main' => [
'values',
'mediaRender',
],
],
];
Expand Down

0 comments on commit f4cf40d

Please sign in to comment.