我有一个动态类别导航.在导航工厂,我想从路线获得一个参数.我怎样才能做到这一点?
在我看来
<?php echo $this->navigation('CategoryNavigation')->menu()->setUlClass('list-group'); ?>
Run Code Online (Sandbox Code Playgroud)
在我的module.php中:
public function getServiceConfig()
{
return array(
'factories' => array(
'CategoryNavigation' => 'Application\Navigation\CategoryNavigation',
)
);
}
Run Code Online (Sandbox Code Playgroud)
这是我的导航工厂.我需要从定义{{store slug}}(2x)的路线中获取slu ..
<?php
namespace Application\Navigation;
use Zend\ServiceManager\ServiceLocator;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Navigation\Service\DefaultNavigationFactory;
class CategoryNavigation extends DefaultNavigationFactory
{
protected $sl;
protected function getPages(ServiceLocatorInterface $serviceLocator)
{
if (null === $this->pages) {
$em = $serviceLocator->get('Doctrine\ORM\EntityManager');
$storerepository = $em->getRepository('ApplicationShared\Entity\Store');
$store = $storerepository->findOneBy(array('slug' => '{{ store slug }}'));
$fetchMenu = $store->getCategories();
$configuration['navigation'][$this->getName()] = $this->buildNavigation($fetchMenu);
if (!isset($configuration['navigation'])) {
throw new Exception\InvalidArgumentException('Could not find navigation …Run Code Online (Sandbox Code Playgroud) 我有一个C3.js图表,每分钟格式化的时间值为%H:%M.现在我想加载新数据,但是我想每小时显示数据,而不是每小时数据,以%d-%m显示.因此刻度格式需要改变,但我该怎么做?
用C3.js生成图表
chart = c3.generate({
bindto: element,
data: {
x: "keys",
xFormat: '%Y-%m-%d %H:%M:%S',
url: dataurl + '/today',
mimeType: 'json',
type: 'bar',
},
axis: {
x: {
type: 'timeseries',
tick: {
format: '%H:%M'
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
加载新数据
chart.load({
x: "keys",
xFormat: '%Y-%m-%d %H:%M:%S',
url: url,
mimeType: 'json',
});
Run Code Online (Sandbox Code Playgroud)