<?php /** * Create optimized schema SQL for installation. * * Doctrine's schema-tool creates unoptimized schema SQL that takes an * inordinate time to install. Thankfully, mysqldump creates more highly * optimized SQL. That, along with toggling off foreign key checks, greatly * reduces installation time. */ require dirname(dirname(__DIR__)) . '/bootstrap.php'; // Initialize the Omeka application using the test database. $config = (require OMEKA_PATH . '/config/application.config.php'); $testConfig = ['connection' => parse_ini_file(OMEKA_PATH . '/application/test/config/database.ini')]; $application = Omeka\Mvc\Application::init(array_merge($config, $testConfig)); $entityManager = $application->getServiceManager()->get('Omeka\\EntityManager'); // Create new tables. dropTables($entityManager->getConnection()); $schemaTool = new Doctrine\ORM\Tools\SchemaTool($entityManager); $schemaTool->createSchema($entityManager->getMetadataFactory()->getAllMetadata()); // Build the schema SQL. $user = escapeshellarg($testConfig['connection']['user']); $password = escapeshellarg($testConfig['connection']['password']); $dbname = escapeshellarg($testConfig['connection']['dbname']); $schemaSql = 'SET FOREIGN_KEY_CHECKS = 0;' . PHP_EOL; $schemaSql .= shell_exec("mysqldump --compact --user {$user} --password={$password} {$dbname}"); $schemaSql .= 'SET FOREIGN_KEY_CHECKS = 1;' . PHP_EOL; $schemaSql = preg_replace('/\\/\\*.+\\*\\/;\\n/', '', $schemaSql); file_put_contents('data/install/schema.sql', $schemaSql); // Clean up. dropTables($entityManager->getConnection());
<?php /** * Perform a job. */ use Omeka\Entity\Job; require dirname(dirname(__DIR__)) . '/bootstrap.php'; $application = Omeka\Mvc\Application::init(require OMEKA_PATH . '/config/application.config.php'); $serviceLocator = $application->getServiceManager(); $entityManager = $serviceLocator->get('Omeka\\EntityManager'); $logger = $serviceLocator->get('Omeka\\Logger'); $options = getopt(null, ['job-id:', 'base-path:']); if (!isset($options['job-id'])) { $logger->err('No job ID given; use --job-id <id>'); exit; } if (!isset($options['base-path'])) { $logger->err('No base path given; use --base-path <basePath>'); exit; } $job = $entityManager->find('Omeka\\Entity\\Job', $options['job-id']); if (!$job) { $logger->err('There is no job with the given ID'); exit; } $serviceLocator->get('ViewHelperManager')->get('BasePath')->setBasePath($options['base-path']); // Set the job owner as the authenticated identity. $owner = $job->getOwner(); if ($owner) { $serviceLocator->get('Omeka\\AuthenticationService')->getStorage()->write($owner); }
<?php require 'bootstrap.php'; $application = Omeka\Mvc\Application::init(require 'config/application.config.php'); return \Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet($application->getServiceManager()->get('Omeka\\EntityManager'));