本文整理汇总了PHP中Sonata\BlockBundle\Model\BlockInterface::getTtl方法的典型用法代码示例。如果您正苦于以下问题:PHP BlockInterface::getTtl方法的具体用法?PHP BlockInterface::getTtl怎么用?PHP BlockInterface::getTtl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sonata\BlockBundle\Model\BlockInterface
的用法示例。
在下文中一共展示了BlockInterface::getTtl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefaultSettings
/**
* @param OptionsResolverInterface $optionsResolver
* @param BlockInterface $block
*/
protected function setDefaultSettings(OptionsResolverInterface $optionsResolver, BlockInterface $block)
{
// defaults for all blocks
$optionsResolver->setDefaults(array('use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => false, 'ttl' => (int) $block->getTtl()));
$optionsResolver->addAllowedTypes(array('use_cache' => array('bool'), 'extra_cache_keys' => array('array'), 'attr' => array('array'), 'ttl' => array('int'), 'template' => array('string', 'bool')));
// add type and class settings for block
$class = ClassUtils::getClass($block);
$settingsByType = isset($this->settingsByType[$block->getType()]) ? $this->settingsByType[$block->getType()] : array();
$settingsByClass = isset($this->settingsByClass[$class]) ? $this->settingsByClass[$class] : array();
$optionsResolver->setDefaults(array_merge($settingsByType, $settingsByClass));
}
示例2: configureSettings
protected function configureSettings(OptionsResolver $optionsResolver, BlockInterface $block)
{
// defaults for all blocks
$optionsResolver->setDefaults(array('use_cache' => true, 'extra_cache_keys' => array(), 'attr' => array(), 'template' => false, 'ttl' => (int) $block->getTtl()));
// TODO: Remove it when bumping requirements to SF 2.6+
if (method_exists($optionsResolver, 'setDefined')) {
$optionsResolver->addAllowedTypes('use_cache', 'bool')->addAllowedTypes('extra_cache_keys', 'array')->addAllowedTypes('attr', 'array')->addAllowedTypes('ttl', 'int')->addAllowedTypes('template', array('string', 'bool'));
} else {
$optionsResolver->addAllowedTypes(array('use_cache' => array('bool'), 'extra_cache_keys' => array('array'), 'attr' => array('array'), 'ttl' => array('int'), 'template' => array('string', 'bool')));
}
// add type and class settings for block
$class = ClassUtils::getClass($block);
$settingsByType = isset($this->settingsByType[$block->getType()]) ? $this->settingsByType[$block->getType()] : array();
$settingsByClass = isset($this->settingsByClass[$class]) ? $this->settingsByClass[$class] : array();
$optionsResolver->setDefaults(array_merge($settingsByType, $settingsByClass));
}