当前位置: 首页>>代码示例>>PHP>>正文


PHP LogHelper::log_warn方法代码示例

本文整理汇总了PHP中LogHelper::log_warn方法的典型用法代码示例。如果您正苦于以下问题:PHP LogHelper::log_warn方法的具体用法?PHP LogHelper::log_warn怎么用?PHP LogHelper::log_warn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LogHelper的用法示例。


在下文中一共展示了LogHelper::log_warn方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepareLocale

    protected function prepareLocale() {
        global $conf;
        global $language;

        $country = isset($conf['site_default_country']) ? trim($conf['site_default_country']) : '';
        if ($country === '') {
            $country = 'us';
            LogHelper::log_warn(t("Default country was not defined. Go to 'Configuration' | 'Regional and language' | 'Regional settings' to set default country"));
        }

        $localeSubTags = array('language' => $language->language, 'region' => $country);

        return Locale::composeLocale($localeSubTags);
    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:14,代码来源:Environment.php

示例2: ContentTypeDatasetSourceAssembler_nodereference

/**
* This file is part of the Checkbook NYC financial transparency software.
* 
* Copyright (C) 2012, 2013 New York City
* 
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU Affero General Public License for more details.
* 
* You should have received a copy of the GNU Affero General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
function ContentTypeDatasetSourceAssembler_nodereference(DatasetSourceAssembler $assembler, DataControllerCallContext $callcontext, $parameterNames, $statement, $tableIndex, $supportedField)
{
    $tableAlias = $assembler->prepareTableAlias($tableIndex);
    $field = $assembler->config->drupal['fields'][$supportedField->original_name];
    // preparing referenceable content type
    $referenceableContentTypes = array_keys(array_filter($field['referenceable_types']));
    if (count($referenceableContentTypes) != 1) {
        $message = t("Unsupported configuration for referenced types for '@supportedFieldName' field: [@contentTypes]", array('@supportedFieldName' => $supportedField->name, '@contentTypes' => implode(', ', $referenceableContentTypes)));
        LogHelper::log_warn($message);
        return;
    }
    $referenceableContentType = $referenceableContentTypes[0];
    $referenceableContentTypeKey = 'nid';
    // preparing list of parameters which should be supported by the referenceable content type
    // if parameter names are not defined we should return all available parameters
    $contentTypeParameterNames = NULL;
    if (isset($parameterNames)) {
        $parameterNamePrefix = $supportedField->name . '_';
        foreach ($parameterNames as $parameterName) {
            if (strpos($parameterName, $parameterNamePrefix) === 0) {
                $contentTypeParameterName = substr($parameterName, strlen($parameterNamePrefix));
                $contentTypeParameterNames[] = $contentTypeParameterName;
            }
        }
        if (!isset($contentTypeParameterNames)) {
            return;
        }
    }
    if (isset($contentTypeParameterNames)) {
        // we will use the field to link with parent content type
        $contentTypeParameterNames[] = $referenceableContentTypeKey;
    }
    // adding check to prevent recursive/circular references
    if ($assembler->registerContentTypeInStack($callcontext, $referenceableContentType)) {
        // requesting SQL sections related to the content type
        $contentTypeDatasetName = DrupalContentTypeMetaModelLoader::getDatasetName($referenceableContentType);
        $contentTypeDataset = $callcontext->metamodel->getDataset($contentTypeDatasetName);
        $contentTypeTableAliasPrefix = $assembler->prepareColumnAlias($supportedField->name);
        $contentTypeAssembler = new ContentTypeDatasetSourceAssembler($contentTypeDataset->source->assembler->config, $contentTypeTableAliasPrefix);
        $contentTypeStatement = $contentTypeAssembler->assemble($callcontext, $contentTypeParameterNames);
        // adding condition to join with 'main' statement
        $contentTypeTableSection = $contentTypeStatement->tables[0];
        $contentTypeTableSection->conditions[] = new JoinConditionSection($referenceableContentTypeKey, new TableColumnConditionSectionValue($tableAlias, $supportedField->column));
        // merging with 'main' statement
        $statement->merge($contentTypeStatement);
        $assembler->unregisterContentTypeFromStack($callcontext, $referenceableContentType);
    }
}
开发者ID:ecs-hk,项目名称:Checkbook,代码行数:66,代码来源:nodereference.php

示例3: getExportColumnName

    public static function getExportColumnName ( $uiMetaDataName, MetaModel $metamodel ) {

        if ( trim($uiMetaDataName) == '' ) {
            $message = t('Empty columnName discovered');
            drupal_set_message($message, 'warning');
            LogHelper::log_warn($message);

            return $uiMetaDataName;
        }


        list($elementNameSpace, $name) = AbstractDatasetUIMetaDataGenerator::splitElementUIMetaDataName($uiMetaDataName);
        switch ( $elementNameSpace ) {

            case AbstractAttributeUIMetaData::NAME_SPACE:
                list($referencedDimensionName, $dimensionColumnName) = ParameterNameHelper::split($name);
                list($datasetName, $dimensionName) = ReferencePathHelper::splitReference($referencedDimensionName);
                if (isset($datasetName)) {
                    $adjustedReferencedDimensionName = ReferencePathHelper::assembleReference(self::getExportDatasetName($datasetName,$metamodel), $dimensionName);
                    $name = ParameterNameHelper::assemble($adjustedReferencedDimensionName, $dimensionColumnName);
                }
                break;

            case AbstractMeasureUIMetaData::NAME_SPACE:
                list($datasetName, $measureName) = ReferencePathHelper::splitReference($name);
                if (isset($datasetName)) {
                    $name = ReferencePathHelper::assembleReference(self::getExportDatasetName($datasetName,$metamodel), $measureName);
                }
                break;

            case FormulaUIMetaData::NAME_SPACE:
                list($datasetName, $formulaName) = ReferencePathHelper::splitReference($name);
                if (isset($datasetName)) {
                    $name = ReferencePathHelper::assembleReference(self::getExportDatasetName($datasetName,$metamodel), $formulaName);
                }
                break;

            default:
                $message = t('Unsupported UI Meta Data name space: @uiMetaDataName', array('@uiMetaDataName' => $uiMetaDataName));
                LogHelper::log_error($message);
                throw new UnsupportedOperationException($message);
        }

        return AbstractDatasetUIMetaDataGenerator::prepareElementUIMetaDataName($elementNameSpace, $name);
    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:45,代码来源:DatasetExportHelper.php

示例4: processReferences

    protected function processReferences(SystemTableMetaModelLoaderCallContext $callcontext, DataSourceMetaData $datasource) {
        $foreignKeyConstraintCount = 0;

        $constraintsProperties = $this->loadReferenceConstraintsProperties($callcontext, $datasource);
        if (isset($constraintsProperties)) {
            $constraintsColumnsPropertyFormatter = new QueryKeyResultFormatter(array(self::CN_TABLE_OWNER, self::CN_OBJECT_NAME), FALSE);
            $constraintsColumnsProperties = $constraintsColumnsPropertyFormatter->formatRecords(
                $this->loadConstraintColumnsProperties(
                    $callcontext, $datasource,
                    array(self::CONSTRAINT_TYPE__PRIMARY_KEY, self::CONSTRAINT_TYPE__REFERENCE)));

            foreach ($constraintsProperties as $constraintProperties) {
                $tableOwner = $this->adjustOwnerName($constraintProperties[self::CN_TABLE_OWNER]);

                // ---------- preparing referring constraint properties
                $constraintName = $constraintProperties[self::CN_OBJECT_NAME];
                $constraintAccessKey = ArrayHelper::prepareCompositeKey(array($tableOwner, $constraintName));
                // for some reason we do not have access to column configuration for referring constraint
                if (!isset($constraintsColumnsProperties[$constraintAccessKey])) {
                    continue;
                }
                $constraintColumnsProperties = $constraintsColumnsProperties[$constraintAccessKey];
                // we do not support composite references yet
                if (count($constraintColumnsProperties) > 1) {
                    continue;
                }

                // ----------- preparing referenced constraint properties
                $refConstraintName = $constraintProperties[self::CN_REFERENCED_OBJECT_NAME];
                $refConstraintAccessKey = ArrayHelper::prepareCompositeKey(array($tableOwner, $refConstraintName));
                // for some reason we do not have access to column configuration for referenced constraint
                if (!isset($constraintsColumnsProperties[$refConstraintAccessKey])) {
                    continue;
                }

                $constraintColumnProperties = $constraintColumnsProperties[0];
                $tableName = $this->adjustTableName($constraintColumnProperties[self::CN_TABLE_NAME]);
                $tableAccessKey = ArrayHelper::prepareCompositeKey(array($tableOwner, $tableName));
                if (!isset($callcontext->datasets[$tableAccessKey])) {
                    continue;
                }

                $refConstraintColumnProperties = $constraintsColumnsProperties[$refConstraintAccessKey][0];
                $refTableName = $this->adjustTableName($refConstraintColumnProperties[self::CN_TABLE_NAME]);
                $refTableAccessKey = ArrayHelper::prepareCompositeKey(array($tableOwner, $refTableName));
                if (!isset($callcontext->datasets[$refTableAccessKey])) {
                    continue;
                }

                $columnName = $this->adjustColumnName($constraintColumnProperties[self::CN_COLUMN_NAME]);
                $refColumnName = $this->adjustColumnName($refConstraintColumnProperties[self::CN_COLUMN_NAME]);

                if ($tableName == $refTableName) {
                    LogHelper::log_warn(t(
                        "Self-reference is not supported yet: @tableName(@columnName)",
                        array('@tableName' => $tableName, '@columnName' => $columnName)));
                    continue;
                }

                $dataset = $callcontext->datasets[$tableAccessKey];
                $column = $dataset->findColumn($columnName);
                if (!isset($column)) {
                    continue;
                }

                $refDataset = $callcontext->datasets[$refTableAccessKey];
                $refColumn = $refDataset->findColumn($refColumnName);
                if (!isset($refColumn)) {
                    continue;
                }

                $logicalApplicationType = ReferencePathHelper::assembleReference($refDataset->name, $refColumnName);
                if (isset($column->type->logicalApplicationType)) {
                    LogHelper::log_warn(t(
                        "Multi-reference is not supported yet for '@columnName' column from '@tableName' table: [@referenceExisting, @referenceNew]",
                        array(
                            '@tableName' => $tableName,
                            '@columnName' => $columnName,
                            '@referenceExisting' => $column->type->logicalApplicationType,
                            '@referenceNew' => $logicalApplicationType)));
                    continue;
                }

                $column->type->logicalApplicationType = $logicalApplicationType;
                $foreignKeyConstraintCount++;
            }
        }

        LogHelper::log_info(t(
            'Processed system meta data about @constraintCount foreign key constraint(s)',
            array('@constraintCount' => $foreignKeyConstraintCount)));
    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:92,代码来源:AbstractSystemTableMetaModelGenerator.php

示例5: processConfig

    protected function processConfig ( $export ) {
        $metamodel = data_controller_get_metamodel();

        // replace report nid with report uuid
        foreach ( $export->config->items as $key => $item ) {
            if ( $item->type == 'report' ) {
                $reportNode = node_load($item->content);
                $export->config->items[$key]->content = get_node_field_value($reportNode,'field_report_uuid',0,'value',true);
            }
        }

        // array cast to deal with json decoder creating objects for arrays with missing keys
        $export->config->drilldowns = (array) $export->config->drilldowns;

        // replace report nid with report uuid
        // replace dashboard nid with dashboard uuid
        // replace dataset column reference with dataset uuid
        $updated_drilldowns = array();
        foreach ( $export->config->drilldowns as $drilldown ) {

            $reportNode = gd_report_get_by_nid($drilldown->report);
            $dashboardNode = gd_dashboard_get_by_nid($drilldown->dashboard);

            if ( !$reportNode || !$dashboardNode ) {
                $message = t('Skipping corrupt drilldown for node: @nodeId.',array('@nodeId' => $export->id));
                drupal_set_message($message, 'warning');
                LogHelper::log_warn($message);
            } else {
                $updated_drilldown = $drilldown;
                $updated_drilldown->report = get_node_field_value($reportNode,'field_report_uuid',0,'value',true);
                $updated_drilldown->column = DatasetExportHelper::getExportColumnName($drilldown->column,$metamodel);
                $updated_drilldown->dashboard = get_node_field_value($dashboardNode,'field_dashboard_uuid',0,'value',true);
                $updated_drilldown->id = count($updated_drilldowns);
                $updated_drilldowns[] = $updated_drilldown;
            }
        }

        $export->config->drilldowns = $updated_drilldowns;
    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:39,代码来源:DashboardExport.php

示例6: load

 public function load(AbstractMetaModelFactory $factory, AbstractMetaModel $metamodel, array $filters = NULL, $finalAttempt)
 {
     LogHelper::log_notice(t('Creating Meta Model using Drupal Content Types...'));
     $datasetCounter = 0;
     $contentTypes = content_types();
     if (isset($contentTypes)) {
         foreach ($contentTypes as $contentTypeName => $contentType) {
             // preparing list of tables which could be supported by our code
             $supportedTables = NULL;
             foreach ($contentType['fields'] as $field) {
                 $fieldName = $field['field_name'];
                 if ($field['multiple'] > 0) {
                     $message = t('Multiple values are not supported yet: @contentTypeName.@fieldName', array('@contentTypeName' => $contentTypeName, '@fieldName' => $fieldName));
                     LogHelper::log_warn($message);
                     continue;
                     // UnsupportedOperationException
                 }
                 // preparing table name where the field is stored
                 $fieldStorage = $field['db_storage'];
                 switch ($fieldStorage) {
                     case CONTENT_DB_STORAGE_PER_CONTENT_TYPE:
                         $tableName = _content_tablename($field['type_name'], $fieldStorage);
                         break;
                     case CONTENT_DB_STORAGE_PER_FIELD:
                         break;
                         $tableName = _content_tablename($fieldName, $fieldStorage);
                     default:
                         $message = t("Unsupported storage type - '@fieldStorage' for the field: @fieldName", array('@fieldStorage' => $fieldStorage, '@fieldName' => $fieldName));
                         LogHelper::log_warn($message);
                         continue;
                         // UnsupportedOperationException
                 }
                 // calculating number of 'visible' suffixes
                 $visibleSuffixCount = 0;
                 foreach ($field['columns'] as $columnAttributes) {
                     if (isset($columnAttributes['views'])) {
                         if ($columnAttributes['views'] === TRUE) {
                             $visibleSuffixCount++;
                         }
                     } else {
                         $visibleSuffixCount++;
                     }
                 }
                 // generating fields for all 'visible' suffixes
                 foreach ($field['columns'] as $columnSuffix => $columnAttributes) {
                     if (isset($columnAttributes['views']) && $columnAttributes['views'] === FALSE) {
                         continue;
                     }
                     $supportedField = new stdClass();
                     // required flag
                     $supportedField->required = $field->required == 1;
                     // original name of the field
                     $supportedField->original_name = $fieldName;
                     // calculating name of database column
                     $supportedField->column = $fieldName . '_' . $columnSuffix;
                     // field name
                     if ($visibleSuffixCount === 1) {
                         $supportedField->name = $fieldName;
                     } else {
                         $supportedField->name = $supportedField->column;
                     }
                     if (isset($supportedTables[$tableName]->storage)) {
                         $previousStorage = $supportedTables[$tableName]->storage;
                         if ($fieldStorage != $previousStorage) {
                             $message = t("Inconsistent storage for '@tableName' table([@fieldStorage1, @fieldStorage2]) for the field: @fieldName", array('@tableName' => $tableName, '@fieldName' => $fieldName, '@fieldStorage1' => $previousStorage, '@fieldStorage2' => $fieldStorage));
                             LogHelper::log_warn($message);
                             continue;
                             // IllegalStateException
                         }
                     } else {
                         $supportedTables[$tableName]->storage = $fieldStorage;
                     }
                     $supportedTables[$tableName]->supportedFields[$supportedField->name] = $supportedField;
                 }
             }
             // preparing dataset source
             $datasetSource = new stdClass();
             $datasetSource->assembler->type = ContentTypeDatasetSourceAssembler::$DATASET_SOURCE_ASSEMBLER__TYPE;
             $datasetSource->assembler->config->drupal = $contentType;
             if (isset($supportedTables)) {
                 $datasetSource->assembler->config->supportedTables = $supportedTables;
             }
             // preparing & registering dataset
             $dataset = new DatasetMetaData();
             $dataset->name = $this->getDatasetName($contentTypeName);
             $dataset->description = $contentType['description'];
             $dataset->datasourceName = AbstractDrupalDataSourceQueryProxy::$DATASOURCE_NAME__DEFAULT;
             $dataset->source = $datasetSource;
             // FIXME Populate list of columns and mark the dataset as complete
             $dataset->registerColumn('nid')->key = TRUE;
             $metamodel->registerDataset($dataset);
             $datasetCounter++;
         }
     }
     LogHelper::log_info(t('Processed @datasetCount datasets', array('@datasetCount' => $datasetCounter)));
     return self::LOAD_STATE__SUCCESSFUL;
 }
开发者ID:ecs-hk,项目名称:Checkbook,代码行数:97,代码来源:DrupalContentTypeMetaModelLoader.php

示例7: oci_free_statement

    public static function oci_free_statement($connection, $statement) {
        self::checkOCIExtension('oci_free_statement');

        $result = @oci_free_statement($statement);
        if ($result === FALSE) {
            $error = self::oci_error($statement);
            LogHelper::log_warn(t(
                'Could not free all resources associated with statement or cursor: @error',
                array('@error' => t($error['message']))));
        }
    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:11,代码来源:OCIImplHelper.php

示例8: applyPagination

    protected function applyPagination($url, AbstractQueryRequest $request) {
        if (isset($request->startWith) && ($request->startWith > 0)) {
            $url .= ((strpos($url, '?') === FALSE) ? '?' : '&') . "skip=$request->startWith";
        }

        $limit = $request->limit;
        // if keys and limit are not set it could be just a bug. We cannot load all data.
        // The database can be huge. We will load limited (preset) number of records
        if (!isset($limit)) {
            $keys = $this->prepareDocumentIdentifiers($request);
            if (!isset($keys)) {
                $limit = self::$MAX_LOADED_DOCUMENTS;
                LogHelper::log_warn(t(
                	'Loading maximum @limit records for the request: @datasetName',
                    array('@limit' => $limit, '@datasetName' => $request->getDatasetName())));
            }
        }
        if (isset($limit)) {
            $url .= ((strpos($url, '?') === FALSE) ? '?' : '&') . "limit=$limit";
        }

        return $url;
    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:23,代码来源:AbstractCouchDBDataSourceHandler.php

示例9: getQueryFilters

    protected function getQueryFilters () {
        $query_filters = array();
        foreach ( $this->filters as $f ) {

            if ( empty($f->column) || empty($f->name) ) {
                LogHelper::log_warn('Missing filter name or column.');
                continue;
            }

            //  if a filter is pre-apply, generate an operator for it.
            if ( !$f->exposed ) {
                //  If there is a value, then format it otherwise leave it as null
                $value = isset($f->value) ? $this->formatFilterValue($f->value, $this->getColumn($f->column)) : null;
                $query_filters[$f->column][] = OperatorFactory::getInstance()->initiateHandler($f->operator,$value);
            }

            if ( $f->exposed ) {
                $requestFilter = FALSE;
                //  Check for query filters next
                if ( !empty($_REQUEST['t']) ) {
                    foreach ( $_REQUEST['t'] as $dashboardId => $requestFilters ) {
                        if ($dashboardId == $this->dashboard) {
                            foreach ($requestFilters as $filterName => $filterParams) {
                                if ( $f->name == $filterName && is_array($filterParams) ) {
                                    $requestFilter = TRUE;
                                    //  If there is a value, then format it otherwise leave it as null
                                    $value = isset($filterParams['v']) ? $this->formatFilterValue($filterParams['v'], $this->getColumn($f->column)) : null;
                                    $query_filters[$f->column][] = OperatorFactory::getInstance()->initiateHandler($filterParams['o'],$value);
                                }
                            }
                        }
                    }
                }

                if ( !empty($f->operator) && !$requestFilter) {
                    //  If a filter is exposed and has a default value for it, set it
                    $value = isset($f->value) ? $this->formatFilterValue($f->value, $this->getColumn($f->column)) : null;
                    $query_filters[$f->column][] = OperatorFactory::getInstance()->initiateHandler($f->operator,$value);
                }
            }
        }

        return $query_filters;
    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:44,代码来源:ReportConfig.php

示例10: registerFactMeasure

 protected static function registerFactMeasure(CubeMetaData $cube, ColumnMetaData $column, $functionName, $additivity, $selectedApplicationType = NULL)
 {
     $measureName = StarSchemaNamingConvention::getFactRelatedMeasureName($column->name, $functionName);
     $measure = $cube->registerMeasure($measureName);
     $measure->publicName = t($functionName);
     $measure->description = t("System generated '@functionName' measure for '@columnName' column", array('@functionName' => $measure->publicName, '@columnName' => $column->publicName));
     $measure->used = FALSE;
     $expression = FALSE;
     if ($column->persistence == FormulaMetaData::PERSISTENCE__CALCULATED) {
         if ($column->isUsed()) {
             try {
                 $expressionAssembler = new FormulaExpressionAssembler($cube->factsDataset);
                 $expression = $expressionAssembler->assemble($column);
                 $measure->used = TRUE;
             } catch (Exception $e) {
                 $message = t("@functionName measure assembled with errors. @error", array('@functionName' => $functionName, '@error' => $e->getMessage()));
                 $measure->functionError = $message;
                 LogHelper::log_warn($message);
             }
         } else {
             $measure->functionError = t("@functionName measure was not assembled for the unused column", array('@functionName' => $functionName));
         }
     } else {
         $formulaExpressionParser = new FormulaExpressionParser(SQLFormulaExpressionHandler::LANGUAGE__SQL);
         $expression = $formulaExpressionParser->assemble($column->name);
         $measure->used = TRUE;
     }
     $measure->function = $expression === FALSE ? FALSE : $functionName . '(' . $expression . ')';
     $measure->additivity = $additivity;
     $measure->type->applicationType = isset($selectedApplicationType) ? $selectedApplicationType : $column->type->applicationType;
     $measure->type->scale = $column->type->scale;
 }
开发者ID:REI-Systems,项目名称:GovDashboard-Community,代码行数:32,代码来源:StarSchemaCubeMetaData.php

示例11: publishExceptions

    protected function publishExceptions($abort) {
        $originalExceptionCount = $this->exceptionCount;

        if (isset($this->exceptionPool)) {
            foreach ($this->exceptionPool as $recordNumber => $columnsException) {
                foreach ($columnsException as $columnPublicName => $exceptionInfo) {
                    $message = $exceptionInfo['message'] . t(
                        ' [column: @columnName] [line: @lineNumber]',
                        array('@columnName' => $columnPublicName, '@lineNumber' => $recordNumber));

                    LogHelper::log_warn(t(
                        '@message at @file:@line',
                        array('@message' => $message, '@file' => $exceptionInfo['file'], '@line' => $exceptionInfo['line'])));

                    drupal_set_message($message, 'error');
                }
            }
        }
        $this->cleanInternalState();

        if ($abort && ($originalExceptionCount > 0)) {
            throw new DataParserException(t(
                'Found %exceptionCount issue(s) while parsing data',
                array('%exceptionCount' => $originalExceptionCount)));
        }
    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:26,代码来源:ColumnValueTypeAdjuster.php

示例12: parse

    public function parse(AbstractDataProvider $dataProvider, array $dataSubmitters = NULL) {
        $skippedRecordCount = 0;
        $loadedRecordCount = 0;

        $timeStart = microtime(TRUE);
        if ($dataProvider->openResource()) {
            LogHelper::log_notice(t(
                'Parsing @limitRecordCount records. Skipping first @skipRecordCount records (memory usage: @memoryUsed) ...',
                array(
                    '@skipRecordCount' => $this->skipRecordCount,
                    '@limitRecordCount' => (isset($this->limitRecordCount) ? $this->limitRecordCount : t('all')),
                    '@memoryUsed' => memory_get_usage())));

            try {
                if ($this->initializeProcessing($dataSubmitters)) {
                    // preparing list of columns
                    $this->prepareMetaData($dataProvider, $dataSubmitters);

                    $metadataColumnCount = $this->metadata->getColumnCount(FALSE, TRUE);

                    if ((!isset($this->limitRecordCount) || ($this->limitRecordCount > 0))
                            && $this->executeBeforeProcessingRecords($dataSubmitters, $dataProvider)) {
                        // processing records
                        $fileProcessedCompletely = FALSE;
                        while (!isset($this->limitRecordCount) || ($loadedRecordCount < $this->limitRecordCount)) {
                            $dataProvider->startReading();
                            $record = $this->parseNextRecord($dataProvider, $dataSubmitters);

                            // number of loaded columns should match number of columns in meta data
                            if (isset($record)) {
                                $attempt = 1;
                                while (TRUE) {
                                    $recordColumnCount = count($record);
                                    if ($recordColumnCount == $metadataColumnCount) {
                                        break;
                                    }
                                    else {
                                        if ($attempt > self::$MAX_ATTEMPTS_TO_RESOLVE_PARSING_ISSUES) {
                                            $dataProvider->endReading();
                                            LogHelper::log_debug($this->metadata);
                                            LogHelper::log_debug($record);
                                            throw new DataParserException(t(
                                                'Expected to load values for %metadataColumnCount columns. Loaded %loadedColumnCount [line: %lineNumber]',
                                                array('%metadataColumnCount' => $metadataColumnCount, '%loadedColumnCount' => $recordColumnCount, '%lineNumber' => $dataProvider->getCurrentLineNumber())));
                                        }

                                        $dataProvider->rollbackReading();
                                        $dataProvider->startReading();
                                        $record = $this->parseNextRecord($dataProvider, $dataSubmitters, $attempt);

                                        $attempt++;
                                    }
                                }
                            }
                            $dataProvider->endReading();

                            // checking if we reached the end
                            if (!isset($record)) {
                                $fileProcessedCompletely  = TRUE;
                                break;
                            }

                            // skipping required number of records
                            if ($skippedRecordCount < $this->skipRecordCount) {
                                $skippedRecordCount++;
                                continue;
                            }

                            $this->postProcessColumnValues($record);

                            // checking if we need to skip processing the record
                            $recordNumber = $dataProvider->getCurrentLineNumber();
                            if ($this->executeBeforeRecordSubmitted($dataSubmitters, $recordNumber, $record)) {
                                $this->submitRecord($dataSubmitters, $recordNumber, $record);
                                $this->executeAfterRecordSubmitted($dataSubmitters, $recordNumber, $record);

                                $loadedRecordCount++;
                                if (($loadedRecordCount % 1000) == 0) {
                                    LogHelper::log_info(t(
                                        'Processed @recordCount records so far (memory usage: @memoryUsed)',
                                        array('@recordCount' => $loadedRecordCount, '@memoryUsed' => memory_get_usage())));
                                }
                            }
                        }

                        $this->executeAfterProcessingRecords($dataSubmitters, $fileProcessedCompletely);
                    }

                    $this->finishProcessing($dataSubmitters);
                }
            }
            catch (DataParserException $e) {
                LogHelper::log_warn(t('Place of original exception @file:@line', array('@file' => $e->getFile(), '@line' => $e->getLine())));

                try {
                    $this->abortProcessing($dataSubmitters);
                }
                catch (Exception $ne) {
                    // we do not need to rethrow this exception. We need to preserve and rethrow original exception
                    LogHelper::log_error($ne);
//.........这里部分代码省略.........
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:101,代码来源:DelimiterDataParser.php


注:本文中的LogHelper::log_warn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。