PHP code example of naoned / oai-pmh-server-bundle
1. Go to this page and download the library: Download naoned/oai-pmh-server-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
naoned / oai-pmh-server-bundle example snippets
public function registerBundles()
{
$bundles = array(
...
new Naoned\OaiPmhServer\NaonedOaiPmhServerBundle(),
...
);
...
}
namespace [YOUR_VENDOR]\[YOUR_BUNDLE]\[YOUR_PATH];
use Naoned\OaiPmhServerBundle\DataProvider\DataProviderInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
class [YOUR_CLASS] extends ContainerAware implements DataProviderInterface
{
/**
* @return string Repository name
*/
public function getRepositoryName()
{
return 'My super Oai-Pmh Server';
}
/**
* @return string Repository admin email
*/
public function getAdminEmail()
{
return '[email protected]';
}
/**
* @return \DateTime|string Repository earliest update change on data
*/
public function getEarliestDatestamp()
{
return "2015-01-01";
}
/**
* @param string $identifier [description]
* @return array
*/
public function getRecord($identifier)
{
return array(
'title' => 'Dummy content',
'description' => 'Some more dummy content',
'sets' => array('seta', 'setb'),
);
}
/**
* must return an array of arrays with keys «identifier» and «name»
* @return array List of all sets, with identifier and name
*/
public function getSets()
{
return array(
array(
'identifier' => 'seta',
'name' => 'THE set number A',
),
array(
'identifier' => 'setb',
'name' => 'THE set identified by B',
)
);
}
/**
* Search for records
* @param String|null $setTitle Title of wanted set
* @param \DateTime|null $from Date of last change «from»
* @param \DataTime|null $until Date of last change «until»
* @return array|ArrayObject List of items
*/
public function getRecords($setTitle = null, \DateTime $from = null, \DataTime $until = null)
{
return array(
array(
'identifier' => '1W1',
'title' => 'Dummy content 1',
'description' => 'Some more dummy content',
'last_change' => '2015-10-12',
'sets' => array('seta', 'setb'),
),
array(
'identifier' => '1W2',
'title' => 'Dummy content 2',
'description' => 'Some more dummy content',
'last_change' => '2015-10-12',
'sets' => array('seta'),
),
array(
'identifier' => '1W3',
'title' => 'Dummy content 3',
'description' => 'Some more dummy content',
'last_change' => '2015-10-12',
'sets' => array('seta'),
),
array(
'identifier' => '1W4',
'title' => 'Dummy content 4',
'description' => 'Some more dummy content',
'last_change' => '2015-10-12',
'sets' => array('setc'),
),
array(
'identifier' => '1W5',
'title' => 'Dummy content 5',
'description' => 'Some more dummy content',
'last_change' => '2015-10-12',
'sets' => array('setd'),
),
);
}
/**
* Tell me, this «record», in which «set» is it ?
* @param any $record An item of elements furnished by getRecords method
* @return array List of sets, the record belong to
*/
public function getSetsForRecord($record)
{
return $record['sets'];
}
/**
* Transform the provided record in an array with Dublin Core, «dc_title» style
* @param any $record An item of elements furnished by getRecords method
* @return array Dublin core data
*/
public static function dublinizeRecord($record)
{
return array(
'dc_identifier' => $record['identifier'],
'dc_title' => $record['title'],
'dc_description' => $record['description'],
);
}
/**
* Check if sets are supported by data provider
* @return boolean check
*/
public function checkSupportSets()
{
return true;
}
/**
* Get identifier of id
* @param any $record An item of elements furnished by getRecords method
* @return string Record Id
*/
public static function getRecordId($record)
{
return $record['identifier'];
}
/**
* Get last change date
* @param any $record An item of elements furnished by getRecords method
* @return \DateTime|string Record last change
*/
public static function getRecordUpdated($record)
{
return $record['last_change'];
}
}
namespace [YOUR_VENDOR]\[YOUR_BUNDLE]\[YOUR_PATH];
use Naoned\OaiPmhServerBundle\DataProvider\DataProviderInterface
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
class [YOUR_CLASS] implements DataProviderInterface
{
use ContainerAwareTrait;
...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.