本文整理汇总了PHP中ObjectConfig::append方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectConfig::append方法的具体用法?PHP ObjectConfig::append怎么用?PHP ObjectConfig::append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectConfig
的用法示例。
在下文中一共展示了ObjectConfig::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initialize
/**
* Initializes the config for the object
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param ObjectConfig $config An optional ObjectConfig object with configuration options
* @return void
*/
protected function _initialize(ObjectConfig $config)
{
//Clone the identifier
$identifier = clone $this->getIdentifier();
$config->append(array('data' => array(), 'layout' => '', 'template' => $this->getName(), 'template_filters' => array('shorttag', 'function', 'url', 'decorator'), 'auto_assign' => true));
parent::_initialize($config);
}
示例2: _initialize
/**
* Initializes the options for the object
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param ObjectConfig $config An optional ObjectConfig object with configuration options
* @return void
*/
protected function _initialize(ObjectConfig $config)
{
if (empty($config->resolvers)) {
$config->append(array('resolvers' => array('extension')));
}
parent::_initialize($config);
}
示例3: _initialize
/**
* Initializes the default configuration for the object
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param ObjectConfig $config An optional ObjectConfig object with configuration options.
* @return void
*/
protected function _initialize(ObjectConfig $config)
{
//Create permission identifier
$permission = clone $this->getIdentifier();
$permission->path = array('controller', 'permission');
$config->append(array('view' => $this->getIdentifier()->name, 'behaviors' => array($permission)));
parent::_initialize($config);
}
示例4: _initialize
/**
* Initializes the options for the object
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param ObjectConfig $config An optional ObjectConfig object with configuration options
*/
protected function _initialize(ObjectConfig $config)
{
$self = $this;
$config->append(array('autoescape' => true, 'strict_variables' => false, 'optimizations' => -1, 'functions' => array('import' => function ($url, $data) use($self) {
return $self->renderPartial($url, $data);
})));
parent::_initialize($config);
}
示例5: _initialize
/**
* Initializes the options for the object
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param ObjectConfig $config An optional ObjectConfig object with configuration options.
* @return void
*/
protected function _initialize(ObjectConfig $config)
{
//Create permission identifier
$permission = clone $this->getIdentifier();
$permission->path = array('dispatcher', 'permission');
$config->append(array('controller' => $this->getIdentifier()->package, 'request' => 'lib:dispatcher.request', 'response' => 'lib:dispatcher.response', 'user' => 'lib:dispatcher.user', 'behaviors' => array($permission)));
parent::_initialize($config);
}
示例6: preview
/**
* Generates an HTML image preview listbox
*
* $config options:
*
* name string column name of helper
* directory string image directory (relative to docroot)
* width int image width
* height int image height
* border int border width
* style string style string
* selected string currently selected vallue
*
* @param array $config An optional array with configuration options
* @return string Html
*/
public function preview($config = array())
{
$config = new ObjectConfig($config);
$config->append(array('name' => 'image_name', 'directory' => JPATH_IMAGES . '/stories', 'width' => 80, 'height' => 80, 'border' => 2, 'style' => 'margin: 10px 0;'))->append(array('selected' => $config->{$config->name}));
$image = $this->getObject('request')->getBasePath() . str_replace(JPATH_ROOT, '', $config->directory) . '/' . $config->selected;
$path = $config->selected ? $image : 'media://images/blank.png';
$html = '<img ' . $this->_buildAttributes(array('src' => $path, 'id' => $config->name . '-preview', 'class' => 'preview', 'width' => $config->width, 'height' => $config->height, 'border' => $config->border, 'alt' => \JText::_('Preview'), 'style' => $config->style)) . ' />';
return $html;
}
示例7: _initialize
/**
* Initializes the default configuration for the object
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param ObjectConfig $config An optional ObjectConfig object with configuration options.
* @return void
*/
protected function _initialize(ObjectConfig $config)
{
$toolbars = array();
if ($config->dispatched && $config->user->isAuthentic()) {
$toolbars[] = $this->getIdentifier()->name;
}
$config->append(array('toolbars' => $toolbars, 'model' => $this->getIdentifier()->name));
parent::_initialize($config);
}
示例8: humanize
/**
* Returns human readable date.
*
* @param array $config An optional array with configuration options.
* @return string Formatted date.
*/
public function humanize($config = array())
{
$config = new ObjectConfig($config);
$config->append(array('date' => 'now', 'timezone' => date_default_timezone_get(), 'default' => \JText::_('Never'), 'smallest_period' => 'second'));
$result = $config->default;
if (!in_array($config->date, array('0000-00-00 00:00:00', '0000-00-00'))) {
$periods = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year');
$lengths = array(60, 60, 24, 7, 4.35, 12, 10);
$now = new \DateTime();
try {
$date = new Date(array('date' => $config->date, 'timezone' => 'UTC'));
$date->setTimezone(new \DateTimeZone($config->timezone));
if ($now != $date) {
// TODO: Use DateTime::getTimeStamp().
if ($now > $date) {
$difference = $now->format('U') - $date->format('U');
$tense = 'ago';
} else {
$difference = $date->format('U') - $now->format('U');
$tense = 'from now';
}
for ($i = 0; $difference >= $lengths[$i] && $i < 6; $i++) {
$difference /= $lengths[$i];
}
$difference = round($difference);
$period_index = array_search($config->smallest_period, $periods);
$omitted_periods = $periods;
array_splice($omitted_periods, $period_index);
if (in_array($periods[$i], $omitted_periods)) {
$difference = 1;
$i = $period_index;
}
if ($periods[$i] == 'day' && ($difference == 1 || $difference == 2)) {
if ($difference == 1) {
$result = \JText::_('Today');
} else {
$result = $tense == 'ago' ? \JText::_('Yesterday') : \JText::_('Tomorrow');
}
} else {
if ($difference != 1) {
$periods[$i] .= 's';
}
$result = sprintf(\JText::_('%d ' . $periods[$i] . ' ' . $tense), $difference);
}
} else {
$result = \JText::_('Now');
}
} catch (\Exception $e) {
}
}
return $result;
}
示例9: options
/**
* Generates a select option list
*
* @param array $config An optional array with configuration options
* @return array An array of objects containing the option attributes
*/
public function options($config = array())
{
$config = new ObjectConfig($config);
$config->append(array('entity' => array(), 'name' => 'id', 'value' => 'id', 'label' => 'id', 'disabled' => null, 'attribs' => array()));
$options = array();
foreach ($config->entity as $entity) {
$option = array('id' => isset($entity->{$config->name}) ? $entity->{$config->name} : null, 'name' => $config->name, 'disabled' => $config->disabled, 'attribs' => ObjectConfig::unbox($config->attribs), 'value' => $entity->{$config->value}, 'label' => $entity->{$config->label});
if ($config->entity instanceof \RecursiveIteratorIterator) {
$option['level'] = $config->entity->getDepth() + 1;
}
$options[] = $this->option($option);
}
return $options;
}
示例10: humanize
/**
* Returns human readable date.
*
* @param array $config An optional array with configuration options.
* @return string Formatted date.
*/
public function humanize($config = array())
{
$config = new ObjectConfig($config);
$config->append(array('date' => 'now', 'timezone' => date_default_timezone_get(), 'default' => $this->getObject('translator')->translate('Never'), 'period' => 'second'));
$result = $config->default;
if (!in_array($config->date, array('0000-00-00 00:00:00', '0000-00-00'))) {
try {
$date = $this->getObject('date', array('date' => $config->date, 'timezone' => 'UTC'));
$date->setTimezone(new \DateTimeZone($config->timezone));
$result = $date->humanize($config->period);
} catch (Exception $e) {
}
}
return $result;
}
示例11: humanize
/**
* Returns human readable date.
*
* @param array $config An optional array with configuration options.
* @return string Formatted date.
*/
public function humanize($config = array())
{
$config = new ObjectConfig($config);
$config->append(array('date' => 'now', 'timezone' => date_default_timezone_get(), 'default' => $this->translate('Never'), 'smallest_period' => 'second'));
$result = $config->default;
if (!in_array($config->date, array('0000-00-00 00:00:00', '0000-00-00'))) {
$periods = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year');
$lengths = array(60, 60, 24, 7, 4.35, 12, 10);
$now = new \DateTime();
try {
$date = new Date(array('date' => $config->date, 'timezone' => 'UTC'));
$date->setTimezone(new \DateTimeZone($config->timezone));
$result = $date->humanize($config->period);
} catch (\Exception $e) {
}
}
return $result;
}
示例12: _initialize
/**
* Initializes the options for the date object
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param object An optional ObjectConfig object with configuration options.
* @return void
*/
protected function _initialize(ObjectConfig $config)
{
$config->append(array('date' => 'now', 'timezone' => date_default_timezone_get()));
}
示例13: _initialize
/**
* Initializes the options for the object
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param ObjectConfig $config An optional ObjectConfig object with configuration options.
* @return void
*/
protected function _initialize(ObjectConfig $config)
{
$config->append(array('content' => null, 'transports' => array('redirect', 'json', 'http')));
parent::_initialize($config);
}
示例14: _initialize
/**
* Initializes the options for the object
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param ObjectConfig $config An optional ObjectConfig object with configuration options
* @return void
*/
protected function _initialize(ObjectConfig $config)
{
$config->append(array('priority' => self::PRIORITY_NORMAL));
parent::_initialize($config);
}
示例15: _initialize
/**
* Initializes the options for the object
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param ObjectConfig $config An optional ObjectConfig object with configuration options
* @return void
*/
protected function _initialize(ObjectConfig $config)
{
$config->append(array('version' => '1.0', 'disposition' => 'inline', 'quote' => '"', 'separator' => ',', 'eol' => "\n"))->append(array('mimetype' => 'text/csv; version=' . $config->version));
parent::_initialize($config);
}