Example #1
0
 /**
  * Store a record driver object and return this object so that the appropriate
  * template can be rendered.
  *
  * @param \VuFind\RecordDriver\AbstractBase|string $driver Record
  * driver object or record id.
  *
  * @return Record
  */
 public function __invoke($driver)
 {
     if (is_string($driver)) {
         $driver = $this->loader->load($driver);
     }
     return parent::__invoke($driver);
 }
Example #2
0
 /**
  * @param string $format Format text to convert into CSS class
  *
  * @return string
  */
 public function getFormatClass($format)
 {
     if (!$this->driver instanceof \Swissbib\RecordDriver\SolrMarc || !$this->driver->getUseMostSpecificFormat()) {
         return parent::getFormatClass($format);
     }
     $mediatypesIconsConfig = $this->driver->getServiceLocator()->get('VuFind\\Config')->get('mediatypesicons');
     $mediaType = $mediatypesIconsConfig->MediatypesIcons->{$format};
     return pathinfo($mediaType, PATHINFO_FILENAME);
 }
Example #3
0
 /**
  * Set up expectations for a template
  *
  * @param Record $record    Record helper
  * @param string $tpl       Template to expect
  * @param string $response  Response to send
  * @param int    $resolveAt Position at which to expect resolve calls
  * @param int    $rendereAt Position at which to expect render calls
  *
  * @return void
  */
 protected function setSuccessTemplate($record, $tpl, $response = 'success', $resolveAt = 0, $renderAt = 1)
 {
     $expectResolve = $resolveAt === '*' ? $this->any() : $this->at($resolveAt);
     $record->getView()->resolver()->expects($expectResolve)->method('resolve')->with($this->equalTo($tpl))->will($this->returnValue(true));
     $expectRender = $renderAt === '*' ? $this->any() : $this->at($renderAt);
     $record->getView()->expects($expectRender)->method('render')->with($this->equalTo($tpl))->will($this->returnValue($response));
 }
Example #4
0
 /**
  * Get a Record object ready for testing.
  *
  * @param \VuFind\RecordDriver\AbstractBase $driver    Record driver
  * @param array|Config                      $config    Configuration
  * @param \VuFind\View\Helper\Root\Context  $context   Context helper
  * @param bool|string                       $url       Should we add a URL helper? False if no, expected timing + : + expected route if yes.
  * @param bool|int                          $serverurl Should we add a ServerURL helper? False if no, expected timing if yes.
  *
  * @return Record
  */
 protected function getRecord($driver, $config = [], $context = null, $url = false, $serverurl = false)
 {
     if (null === $context) {
         $context = $this->getMockContext();
     }
     $view = $this->getMock('Zend\\View\\Renderer\\PhpRenderer');
     $view->expects($this->at(0))->method('plugin')->with($this->equalTo('context'))->will($this->returnValue($context));
     if ($url) {
         list($at, $route) = explode(':', $url);
         $view->expects($this->at($at))->method('plugin')->with($this->equalTo('url'))->will($this->returnValue($this->getMockUrl($route)));
     }
     if (false !== $serverurl) {
         $view->expects($this->at($serverurl))->method('plugin')->with($this->equalTo('serverurl'))->will($this->returnValue($this->getMockServerUrl()));
     }
     $config = is_array($config) ? new \Zend\Config\Config($config) : $config;
     $record = new Record($config);
     $record->setView($view);
     return $record->__invoke($driver);
 }
Example #5
0
 /**
  * Construct the Record helper.
  *
  * @param ServiceManager $sm Service manager.
  *
  * @return Record
  */
 public static function getRecord(ServiceManager $sm)
 {
     $helper = new Record($sm->getServiceLocator()->get('VuFind\\Config')->get('config'));
     $helper->setCoverRouter($sm->getServiceLocator()->get('VuFind\\Cover\\Router'));
     return $helper;
 }