-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add media render to media resource pages (fix #2058)
- Loading branch information
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
application/data/migrations/20230601060113_AddMediaRender.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters