/** * Force creation of a singleton * * @param ObjectConfig $config A ObjectConfig object with configuration options * @param ObjectManagerInterface $manager A ObjectInterface object * @return DispatcherInterface */ public static function getInstance(ObjectConfigInterface $config, ObjectManagerInterface $manager) { //Add the object alias to allow easy access to the singleton $manager->registerAlias($config->object_identifier, 'dispatcher.fragment'); //Merge alias configuration into the identifier $config->append($manager->getIdentifier('dispatcher.fragment')->getConfig()); //Instantiate the class $instance = new static($config); return $instance; }
/** * Return the data * * If the data being passed is an instance of ObjectConfigInterface the data will be transformed to an associative array. * * @param mixed|ObjectConfigInterface $data * @return mixed|array */ public static function unbox($data) { return $data instanceof ObjectConfig ? $data->toArray() : $data; }
/** * Render a page link * * @param ObjectConfigInterface $page The page data * @param HttpUrlInterface $url The base url to create the link * @return string Html */ public function page(ObjectConfigInterface $page, HttpUrlInterface $url) { $page->append(array('title' => '', 'current' => false, 'active' => false, 'offset' => 0, 'limit' => 0, 'rel' => '', 'attribs' => array())); //Set the offset and limit $url->query['limit'] = $page->limit; $url->query['offset'] = $page->offset; $rel = !empty($page->rel) ? 'rel="' . $page->rel . '"' : ''; $html = '<li ' . $this->buildAttributes($page->attribs) . '>'; $html .= '<a href="' . $url . '" ' . $rel . '>' . $this->getObject('translator')->translate($page->title) . '</a>'; $html .= '</li>'; return $html; }