本文整理汇总了PHP中Mautic\CoreBundle\Helper\DateTimeHelper::modify方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeHelper::modify方法的具体用法?PHP DateTimeHelper::modify怎么用?PHP DateTimeHelper::modify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mautic\CoreBundle\Helper\DateTimeHelper
的用法示例。
在下文中一共展示了DateTimeHelper::modify方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getListFilterExpr
/**
* @param $filters
* @param $parameters
* @param \Doctrine\DBAL\Query\QueryBuilder $q
* @param bool|false $not
* @param null|int $leadId
*
* @return \Doctrine\DBAL\Query\Expression\CompositeExpression
*/
public function getListFilterExpr($filters, &$parameters, QueryBuilder $q, $not = false, $leadId = null)
{
static $leadTable;
if (!count($filters)) {
return $q->expr()->andX();
}
// Get table columns
if (null === $leadTable) {
$schema = $this->_em->getConnection()->getSchemaManager();
/** @var \Doctrine\DBAL\Schema\Column[] $leadTable */
$leadTable = $schema->listTableColumns(MAUTIC_TABLE_PREFIX . 'leads');
}
$options = $this->getFilterExpressionFunctions();
$groups = array();
$groupExpr = $q->expr()->andX();
foreach ($filters as $k => $details) {
$column = isset($leadTable[$details['field']]) ? $leadTable[$details['field']] : false;
//DBAL does not have a not() function so we have to use the opposite
$func = !$not ? $options[$details['operator']]['expr'] : $options[$details['operator']]['negate_expr'];
$field = "l.{$details['field']}";
// Format the field based on platform specific functions that DBAL doesn't support natively
if ($column) {
$formatter = AbstractFormatter::createFormatter($this->_em->getConnection());
$columnType = $column->getType();
switch ($details['type']) {
case 'datetime':
if (!$columnType instanceof UTCDateTimeType) {
$field = $formatter->toDateTime($field);
}
break;
case 'date':
if (!$columnType instanceof DateType && !$columnType instanceof UTCDateTimeType) {
$field = $formatter->toDate($field);
}
break;
case 'time':
if (!$columnType instanceof TimeType && !$columnType instanceof UTCDateTimeType) {
$field = $formatter->toTime($field);
}
break;
case 'number':
if (!$columnType instanceof IntegerType && !$columnType instanceof FloatType) {
$field = $formatter->toNumeric($field);
}
break;
}
}
//the next one will determine the group
$glue = isset($filters[$k + 1]) ? $filters[$k + 1]['glue'] : $details['glue'];
if ($glue == "or" || $details['glue'] == 'or') {
// Create a new group of andX expressions
if ($groupExpr->count()) {
$groups[] = $groupExpr;
$groupExpr = $q->expr()->andX();
}
}
$parameter = $this->generateRandomParameterName();
$exprParameter = ":{$parameter}";
$ignoreAutoFilter = false;
// Special handling of relative date strings
if ($details['type'] == 'datetime' || $details['type'] == 'date') {
$relativeDateStrings = $this->getRelativeDateStrings();
// Check if the column type is a date/time stamp
$isTimestamp = $columnType instanceof UTCDateTimeType || $details['type'] == 'datetime';
$getDate = function (&$string) use($isTimestamp, $relativeDateStrings, &$details, &$func, $not) {
$key = array_search($string, $relativeDateStrings);
$dtHelper = new DateTimeHelper('midnight today', null, 'local');
$requiresBetween = in_array($func, array('eq', 'neq')) && $isTimestamp;
$timeframe = str_replace('mautic.lead.list.', '', $key);
$modifier = false;
$isRelative = true;
switch ($timeframe) {
case 'today':
case 'tomorrow':
case 'yesterday':
if ($timeframe == 'yesterday') {
$dtHelper->modify('-1 day');
} elseif ($timeframe == 'tomorrow') {
$dtHelper->modify('+1 day');
}
// Today = 2015-08-28 00:00:00
if ($requiresBetween) {
// eq:
// field >= 2015-08-28 00:00:00
// field < 2015-08-29 00:00:00
// neq:
// field < 2015-08-28 00:00:00
// field >= 2015-08-29 00:00:00
$modifier = '+1 day';
} else {
// lt:
//.........这里部分代码省略.........