public function actionIndex() { $this->failIfNotAJsonRpcRequest(); Yii::beginProfile('service.request'); $request = $result = null; try { $request = json_decode(file_get_contents('php://input'), true); $this->failIfRequestIsInvalid($request); try { $class = new ReflectionClass($this->controller); if (!$class->hasMethod($request['method'])) { throw new JsonRpcException("Method not found", -32601); } $method = $class->getMethod($request['method']); ob_start(); Yii::beginProfile('service.request.action'); $result = $method->invokeArgs($this->controller, isset($request['params']) ? $request['params'] : null); Yii::endProfile('service.request.action'); $output = ob_get_clean(); if ($output) { Yii::log($output, CLogger::LEVEL_INFO, 'service.output'); } } catch (Exception $e) { Yii::log($e, CLogger::LEVEL_ERROR, 'service.error'); throw new JsonRpcException($e->getMessage(), -32603); } if (!empty($request['id'])) { echo json_encode(array('jsonrpc' => '2.0', 'id' => $request['id'], 'result' => $output)); } } catch (JsonRpcException $e) { echo json_encode(array('jsonrpc' => '2.0', 'id' => isset($request['id']) ? $request['id'] : null, 'error' => $e->getErrorAsArray())); } Yii::endProfile('service.request'); }
/** * @param DataEntityProvider[] $providers * @param ActionData $actionData * @param array $packed * @param array $providedKeys * * @return mixed */ public static function process($providers, &$actionData, &$packed, &$providedKeys) { $result = []; $providedKeys = []; foreach ($providers as $i => $provider) { $profileKey = "DataProviderProcessor: {$i}"; Yii::beginProfile($profileKey); //! @todo Add check for correct class names here /** @var DataEntityProvider $instance */ $instance = Yii::createObject($provider); $providerResult = $instance->getEntities($actionData); $keys = []; array_walk($providerResult, function ($materials, $regionKey) use(&$keys) { $result = []; array_walk($materials, function ($data, $materialIndex) use(&$result) { $result[$materialIndex] = array_keys($data); }); $keys[$regionKey] = $result; }); $providedKeys[$i] = $keys; $result = ArrayHelper::merge($result, $providerResult); $packed[$i] = $instance->pack(); Yii::endProfile($profileKey); } return $result; }
public function getData() { \Yii::beginProfile('admin-menu'); if ($this->isLoaded) { return (array) $this->groups; } $paths[] = \Yii::getAlias('@common/config/admin/menu.php'); $paths[] = \Yii::getAlias('@app/config/admin/menu.php'); foreach (\Yii::$app->extensions as $code => $data) { if ($data['alias']) { foreach ($data['alias'] as $code => $path) { $adminMenuFile = $path . '/config/admin/menu.php'; if (file_exists($adminMenuFile)) { $menuGroups = (array) (include_once $adminMenuFile); $this->groups = ArrayHelper::merge($this->groups, $menuGroups); } } } } foreach ($paths as $path) { if (file_exists($path)) { $menuGroups = (array) (include_once $path); $this->groups = ArrayHelper::merge($this->groups, $menuGroups); } } ArrayHelper::multisort($this->groups, 'priority'); $this->isLoaded = true; \Yii::endProfile('admin-menu'); return (array) $this->groups; }
public function actionUpdate($fid = 0, $gid = 0, $sort = '') { $timer = new CountTimer(); $cacheToken = 'cache-update'; Yii::beginProfile($cacheToken); ob_start(); // 生成版块列表缓存 $this->forward('forum/forumlist', false); // 生成帖子列表缓存 $sortArr = array('', 'new', 'marrow', 'top'); $fids = $this->_getFids($fid); $uids = $this->_getUidsByGid($gid); foreach ($sortArr as $sort) { foreach ($fids as $fid) { foreach ($uids as $uid) { $_GET = array_merge($_GET, array('hacker_uid' => $uid, 'boardId' => $fid, 'page' => 1, 'pageSize' => 10, 'sortby' => $sort)); $res = $this->forward('forum/topiclist', false); ob_clean(); } } } ob_end_clean(); var_dump($timer->stop()); Yii::endProfile($cacheToken); }
public function init() { $this->defaultAttributes = $this->attributes; \Yii::beginProfile("Init: " . $this->className()); $this->initSettings(); \Yii::endProfile("Init: " . $this->className()); }
/** * @param Event $event */ public function combineBundles(Event $event) { if (!$this->enabled) { return; } $token = 'Combine bundles for page'; \Yii::beginProfile($token, __METHOD__); $this->bundles = $this->owner->assetBundles; $this->setAssetManager($this->owner->getAssetManager()); // Assemble monolith assets foreach ($this->bundles as $name => $bundle) { // If this is monolith bundle if (ArrayHelper::getValue($bundle->publishOptions, 'monolith', false)) { // If it already processed and have no dependency if (empty($bundle->depends) && ArrayHelper::getValue($bundle->publishOptions, 'accProcessed', false)) { $this->registerMonolith($bundle); } else { $this->assembleMonolith([$name => $bundle], $bundle->jsOptions, $bundle->cssOptions); } } } // Assemble rest of the assets $this->assembleMonolith($this->bundles); $this->owner->assetBundles = []; \Yii::endProfile($token, __METHOD__); }
/** * @return string */ public function run() { if (YII_ENV == 'prod') { try { \Yii::beginProfile("Run: " . $this->_token); $content = $this->_run(); \Yii::endProfile("Run: " . $this->_token); } catch (\Exception $e) { $content = \Yii::t('app', 'Error widget {class}', ['class' => $this->className()]) . " (" . $this->descriptor->name . "): " . $e->getMessage(); } } else { \Yii::beginProfile("Run: " . $this->_token); $content = $this->_run(); \Yii::endProfile("Run: " . $this->_token); } \Yii::$app->cmsToolbar->initEnabled(); if (\Yii::$app->cmsToolbar->editWidgets == Cms::BOOL_Y && \Yii::$app->cmsToolbar->enabled) { $pre = ""; /*$pre = Html::tag('pre', Json::encode($this->attributes), [ 'style' => 'display: none;' ]);*/ $id = 'sx-infoblock-' . $this->getId(); $this->getView()->registerJs(<<<JS new sx.classes.toolbar.EditViewBlock({'id' : '{$id}'}); JS ); return Html::tag('div', $pre . (string) $content, ['class' => 'skeeks-cms-toolbar-edit-view-block', 'id' => $id, 'title' => \Yii::t('app', "Double-click on the block will open the settings manager"), 'data' => ['id' => $this->getId(), 'config-url' => $this->getEditUrl()]]); } return $content; }
private function runProfilingSampleLoop() { Yii::beginProfile('dummy method'); for ($i = 0; $i < 100; $i++) { $a = 1; } Yii::endProfile('dummy method'); }
/** * Returns amount of today comments. * * @return int Number of today comments. * @since 0.1.0 */ public function today() { $token = 'comment.today'; \Yii::beginProfile($token); $dateTime = new \DateTime(); $dateTime->sub(new \DateInterval('P1D')); $amount = (int) $this->count('created >= :today', array(':today' => $dateTime->format(\DateTime::ISO8601))); \Yii::endProfile($token); return $amount; }
/** * @return mixed * @throws Exception */ protected function tryToRunMethod() { $method = $this->getHandler(); Yii::beginProfile('service.request.action'); $output = $this->runMethod($method, $this->getParams($method)); Yii::endProfile('service.request.action'); Yii::info($method, 'service.output'); Yii::info($output, 'service.output'); return $output; }
public function actionIndex() { Yii::beginProfile('wishlist'); $criteria = PropertyWishlistApi::getCriteriaObjectForUser(Yii::app()->user->id); $count = Property::model()->count($criteria); $pages = new CPagination($count); $pages->pageSize = Yii::app()->params['resultsPerPage']; $pages->applyLimit($criteria); $properties = PropertyWishlistApi::searchWithCriteria($criteria); // $projects = ProjectWishlistApi::getWishlistProjectsByUserId(Yii::app()->user->id); $this->render('index', array('properties' => $properties, 'count' => $count, 'pages' => $pages)); Yii::endProfile('wishlist'); }
public function actionIndex() { Yii::trace('example trace message', 'example'); Yii::log('info', CLogger::LEVEL_INFO, 'example'); Yii::log('error', CLogger::LEVEL_ERROR, 'example'); Yii::log('trace', CLogger::LEVEL_TRACE, 'example'); Yii::log('warning', CLogger::LEVEL_WARNING, 'example'); Yii::beginProfile('preg_replace', 'example'); for ($i = 0; $i < 10000; $i++) { preg_replace('~^[ a-z]+~', '', 'test it'); } Yii::endProfile('preg_replace', 'example'); echo 'done'; }
public function actionView($id) { Yii::beginProfile('message_view'); $message = PmbApi::getMessageById($id); if (!$message) { throw new CHttpException(404, 'The requested page does not exist.'); } if ($message->from_user_id != Yii::app()->user->id && $message->to_user_id != Yii::app()->user->id) { $this->redirect('/messages'); } $read = PmbApi::markRead(array($id)); $unread = PmbApi::getUnreadInboxCount(Yii::app()->user->id); $this->render('view', array('message' => $message, 'unread' => $unread, 'id' => $id)); Yii::endProfile('message_view'); }
public function init() { parent::init(); if ($this->module) { // $this->migrateUp(); // $this->loadClassMap(); // $this->loadControllerMap(); // $this->loadViewPathMap(); // $this->loadCustomConfig(); foreach (['loadClassMap', 'loadCustomConfig', 'migrateUp'] as $func) { \Yii::beginProfile(get_called_class() . '->' . $func, __METHOD__); $this->{$func}(); \Yii::endProfile(get_called_class() . '->' . $func, __METHOD__); } } }
public function init() { Yii::beginProfile(__CLASS__); $path = Yii::getPathOfAlias('app.widgets.NewsSocials.libs.share42'); $assetsUrl = app()->getAssetManager()->publish($path, FALSE, -1, YII_DEBUG); js($assetsUrl . '/share42.js', CClientScript::POS_END); // Обрезаю description if (!empty($this->params['data-description'])) { $this->params['data-description'] = strip_tags($this->params['data-description']); if (mb_strlen($this->params['data-description']) > $this->charLimit) { $this->params['data-description'] = characterLimiter($this->params['data-description'], $this->charLimit, ' ...'); } } echo CHtml::openTag('div', $this->params + array('class' => 'share42init')) . CHtml::closeTag('div'); Yii::endProfile(__CLASS__); }
public function __toString() { if (!$this->parent instanceof self) { $this->activeForm = CMap::mergeArray($this->defaultActiveFormSettings, $this->activeForm); try { //profile form $profile_id = 'Form::' . $this->activeForm['id']; Yii::beginProfile($profile_id); $res = parent::__toString(); Yii::endProfile($profile_id); return $res; } catch (Exception $e) { Yii::app()->handleException($e); } } }
/** * Validates JSON-RPC request, initializes controller action parameters and runs the action * @param array $requestData * @return array Controller action response */ protected function processRequest($requestData) { $responseData = ['jsonrpc' => '2.0']; try { $method = ArrayHelper::getValue($requestData, 'method', '-'); \Yii::trace('Running JSON-RPC 2.0 method: ' . $method, 'jsonrpc\\Action::processRequest'); \Yii::beginProfile('jsonrpc.controller.rpc.' . $method); $requestModel = $this->getRequestModel($requestData); $responseData['id'] = $requestModel->id; $reflectionMethod = $this->getControllerMethod($requestModel->method); $methodParams = $this->getMethodParams($reflectionMethod, $requestModel->params); $responseData['result'] = $this->runControllerAction($reflectionMethod->getName(), $methodParams); \Yii::endProfile('jsonrpc.controller.rpc.' . ArrayHelper::getValue($requestData, 'method', '-')); } catch (\Exception $ex) { unset($responseData['result']); $responseData['error'] = ['code' => $ex->getCode(), 'message' => $ex->getMessage(), 'data' => $ex instanceof ValidationException ? $ex->getData() : null]; } return $responseData; }
/** * @brief ESphinxSearchResult constructor * @param array $data * @param objecy $criteria */ public function __construct(array $data, $criteria) { if ($this->enableProfiling) { Yii::beginProfile("Init ESphinxSearchResult", 'CEXT.ESearch.ESphinxSearchResult.init'); } $this->criteria = $criteria; $ar = array(); foreach ($data['matches'] as $id => $data) { $resData = new stdClass(); foreach ($data['attrs'] as $key => $value) { $resData->{$key} = $value; } $resData->id = $id; $resData->_weight = $data['weight']; $ar[$id] = $resData; } $this->setIdList($ar); if ($this->enableProfiling) { Yii::endProfile("Init ESphinxSearchResult", 'CEXT.ESearch.ESphinxSearchResult.init'); } }
public function init() { parent::init(); if ($this->requestIsAdmin()) { if (!$this->noImage) { $this->noImage = AdminAsset::getAssetUrl("images/no-photo.gif"); //$this->noImage = \Yii::$app->getAssetManager()->getAssetUrl(AdminAsset::register(\Yii::$app->view), "images/no-photo.gif"); } \Yii::beginProfile('admin loading'); //Загрузка всех компонентов. $components = \Yii::$app->getComponents(); foreach ($components as $id => $data) { try { \Yii::$app->get($id); } catch (\Exception $e) { continue; } } \Yii::$app->trigger(self::EVENT_READY, new Event(['name' => self::EVENT_READY])); \Yii::endProfile('admin loading'); } }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { Yii::log("Mi primer log", "info", "application.controllers.SiteController"); Yii::log("eeeeee error", "error", "application.controllers.SiteController"); Yii::log("wwwwwwwwww warning", "warning", "application.controllers.SiteController"); Yii::log("Mi primer trace", "trace", "application.controllers.SiteController"); Yii::log("001#Venta en el sitio tal 1", "info", "application.controllers.SiteController.ref"); Yii::log("003#Venta en el sitio tal 2", "info", "application.controllers.SiteController.ref"); Yii::log("002#Venta en el sitio tal 3", "info", "application.controllers.SiteController.ref"); Yii::beginProfile("miProfileBucleFor", "application.controllers.SiteController"); for ($x = 0; $x < 100; $x++) { echo ""; } Yii::endProfile("miProfileBucleFor", "application.controllers.SiteController"); Yii::beginProfile("miProfileBucleFor", "application.controllers.SiteController"); sleep(1); Yii::endProfile("miProfileBucleFor", "application.controllers.SiteController"); Yii::app()->db->createCommand("SELECT * FROM test")->queryAll(); Test::model()->findAll(); // renders the view file 'protected/views/site/index.php' // using the default layout 'protected/views/layouts/main.php' $this->render('index'); }
private function queryInternal($method, $mode, $params = array()) { $params = array_merge($this->params, $params); if ($this->_connection->enableParamLogging && ($pars = array_merge($this->_paramLog, $params)) !== array()) { $p = array(); foreach ($pars as $name => $value) { $p[$name] = $name . '=' . var_export($value, true); } $par = '. Bound with ' . implode(', ', $p); } else { $par = ''; } if ($this->_connection->queryCachingCount > 0 && $method !== '' && $this->_connection->queryCachingDuration > 0 && $this->_connection->queryCacheID !== false && ($cache = Yii::app()->getComponent($this->_connection->queryCacheID)) !== null) { $this->_connection->queryCachingCount--; $cacheKey = 'yii:dbquery' . $this->_connection->connectionString . ':' . $this->_connection->username; $cacheKey .= ':' . $this->getText() . ':' . serialize(array_merge($this->_paramLog, $params)); if (($result = $cache->get($cacheKey)) !== false) { return $result[0]; } } try { if ($this->_connection->enableProfiling) { Yii::beginProfile('system.db.CDbCommand.query(' . $this->getText() . $par . ')', 'system.db.CDbCommand.query'); } $this->prepare(); if ($params === array()) { $this->_statement->execute(); } else { $this->_statement->execute($params); } if ($method === '') { $result = new CDbDataReader($this); } else { $mode = (array) $mode; call_user_func_array(array($this->_statement, 'setFetchMode'), $mode); $result = $this->_statement->{$method}(); $this->_statement->closeCursor(); } if ($this->_connection->enableProfiling) { Yii::endProfile('system.db.CDbCommand.query(' . $this->getText() . $par . ')', 'system.db.CDbCommand.query'); } if (isset($cache, $cacheKey)) { $cache->set($cacheKey, array($result), $this->_connection->queryCachingDuration, $this->_connection->queryCachingDependency); } return $result; } catch (Exception $e) { if ($this->_connection->enableProfiling) { Yii::endProfile('system.db.CDbCommand.query(' . $this->getText() . $par . ')', 'system.db.CDbCommand.query'); } $errorInfo = $e instanceof PDOException ? $e->errorInfo : null; $message = $e->getMessage(); Yii::log(Yii::t('yii', 'CDbCommand::{method}() failed: {error}. The SQL statement executed was: {sql}.', array('{method}' => $method, '{error}' => $message, '{sql}' => $this->getText() . $par)), CLogger::LEVEL_ERROR, 'system.db.CDbCommand'); if (YII_DEBUG) { $message .= '. The SQL statement executed was: ' . $this->getText() . $par; } throw new CDbException(Yii::t('yii', 'CDbCommand failed to execute the SQL statement: {error}', array('{error}' => $message)), (int) $e->getCode(), $errorInfo); } }
//$this->widget("TbBreadcrumbs", array("links" => $this->breadcrumbs)) ?> <div class="clearfix"> <div class="btn-toolbar pull-left"> <div class="btn-group"> <h1> <i class="icon-file-text-alt"></i> <?php echo Yii::t('D2finvModule.model', 'Finv Invoices'); ?> </h1> </div> <div class="btn-group"> <?php $this->widget('bootstrap.widgets.TbButton', array('label' => Yii::t('D2finvModule.crud_static', 'Incoming'), 'icon' => 'icon-plus', 'size' => 'large', 'type' => 'success', 'url' => array('create', 'finv_type' => FinvInvoice::FINV_TYPE_IN), 'visible' => Yii::app()->user->checkAccess('D2finv.FinvInvoice.*') || Yii::app()->user->checkAccess('D2finv.FinvInvoice.Create'), "htmlOptions" => array("data-toggle" => "tooltip", "title" => Yii::t("TrucksModule.crud", "Create Incoming Invoice")))); $this->widget('bootstrap.widgets.TbButton', array('label' => Yii::t('D2finvModule.crud_static', 'Outgoing'), 'icon' => 'icon-plus', 'size' => 'large', 'type' => 'success', 'url' => array('create', 'finv_type' => FinvInvoice::FINV_TYPE_OUT), 'visible' => Yii::app()->user->checkAccess('D2finv.FinvInvoice.*') || Yii::app()->user->checkAccess('D2finv.FinvInvoice.Create'), "htmlOptions" => array("data-toggle" => "tooltip", "title" => Yii::t("TrucksModule.crud", "Create Outgoing Invoice")))); ?> </div> </div> </div> <?php Yii::beginProfile('FinvInvoice.view.grid'); ?> <?php $this->widget('TbGridView', array('id' => 'finv-invoice-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'template' => '{summary}{pager}{items}{pager}', 'pager' => array('class' => 'TbPager', 'displayFirstAndLast' => true), 'afterAjaxUpdate' => 'reinstallDatePicker', 'columns' => array(array('class' => 'editable.EditableColumn', 'name' => 'finv_number', 'editable' => array('url' => $this->createUrl('/d2finv/finvInvoice/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'finv_ccmp_id', 'value' => 'CHtml::value($data, \'finvCcmp.itemLabel\')', 'filter' => CHtml::listData(CcmpCompany::model()->findAll(array('limit' => 1000, 'order' => 'ccmp_name')), 'ccmp_id', 'itemLabel'), 'editable' => array('type' => 'select', 'url' => $this->createUrl('/d2finv/finvInvoice/editableSaver'), 'source' => CHtml::listData(CcmpCompany::model()->findAll(array('limit' => 1000)), 'ccmp_id', 'itemLabel'))), array('class' => 'editable.EditableColumn', 'name' => 'finv_date', 'editable' => array('type' => 'date', 'url' => $this->createUrl('/d2finv/finvInvoice/editableSaver')), 'filter' => $this->widget('vendor.dbrisinajumi.DbrLib.widgets.TbFilterDateRangePicker', array('model' => $model, 'attribute' => 'finv_date_range', 'options' => array('ranges' => array('today', 'yesterday', 'this_week', 'last_week', 'this_month', 'last_month', 'this_year'))), TRUE)), array('htmlOptions' => array('class' => 'numeric-column'), 'name' => 'finv_amt', 'footer' => $model->getTotals('finv_amt'), 'footerHtmlOptions' => array('class' => 'total-row numeric-column')), array('htmlOptions' => array('class' => 'numeric-column'), 'name' => 'finv_vat', 'footer' => $model->getTotals('finv_vat'), 'footerHtmlOptions' => array('class' => 'total-row numeric-column')), array('htmlOptions' => array('class' => 'numeric-column'), 'name' => 'finv_total', 'footer' => $model->getTotals('finv_total'), 'footerHtmlOptions' => array('class' => 'total-row numeric-column')), array('class' => 'editable.EditableColumn', 'name' => 'finv_stst_id', 'value' => 'CHtml::value($data, \'finvStst.itemLabel\')', 'filter' => CHtml::listData(StstState::model()->findAll(array('limit' => 1000)), 'stst_id', 'itemLabel'), 'editable' => array('type' => 'select', 'url' => $this->createUrl('/d2finv/finvInvoice/editableSaver'), 'source' => CHtml::listData(StstState::model()->findAll(array('limit' => 1000)), 'stst_id', 'itemLabel'))), array('class' => 'editable.EditableColumn', 'name' => 'finv_paid', 'editable' => array('type' => 'select', 'url' => $this->createUrl('/d2finv/finvInvoice/editableSaver'), 'source' => $model->getEnumFieldLabels('finv_paid')), 'filter' => $model->getEnumFieldLabels('finv_paid')), array('class' => 'TbButtonColumn', 'template' => '{view} {update} {delete} {copy}', 'buttons' => array('view' => array('visible' => '!Yii::app()->user->checkAccess("InvoiceEdit")'), 'update' => array('visible' => 'Yii::app()->user->checkAccess("InvoiceEdit")'), 'delete' => array('visible' => 'Yii::app()->user->checkAccess("InvoiceEdit")'), 'copy' => array('label' => Yii::t('D2finvModule.crud_static', 'Copy'), 'icon' => 'copy', 'url' => 'Yii::app()->controller->createUrl("copy", array("finv_id" => $data->finv_id))', 'visible' => 'Yii::app()->user->checkAccess("InvoiceEdit")')), 'viewButtonUrl' => 'Yii::app()->controller->createUrl("view", array("finv_id" => $data->finv_id))', 'updateButtonUrl' => 'Yii::app()->controller->createUrl("view", array("finv_id" => $data->finv_id))', 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("delete", array("finv_id" => $data->finv_id))', 'viewButtonOptions' => array('data-toggle' => 'tooltip'), 'updateButtonOptions' => array('data-toggle' => 'tooltip'), 'deleteButtonOptions' => array('data-toggle' => 'tooltip'))))); Yii::endProfile('FinvInvoice.view.grid');
public static function sendMessageToLongPool(&$arrUsers, &$arrData) { Yii::log("sendMessageToLongPool start", "info"); Yii::beginProfile('sendMessageToLongPool'); if (isset(Yii::app()->params['comet_messages_url_publisher']) && strlen(Yii::app()->params['comet_messages_url_publisher']) > 0) { if (is_array($arrUsers) && count($arrUsers)) { $mh = curl_multi_init(); $arrCh = []; try { foreach ($arrUsers as $k => $v) { $arrCh[$k] = curl_init(); curl_setopt($arrCh[$k], CURLOPT_URL, Yii::app()->params['comet_messages_url_publisher'] . $v); curl_setopt($arrCh[$k], CURLOPT_TIMEOUT, 5); curl_setopt($arrCh[$k], CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($arrCh[$k], CURLOPT_POST, 1); curl_setopt($arrCh[$k], CURLOPT_POSTFIELDS, json_encode($arrData) . '<!-- s -->'); curl_setopt($arrCh[$k], CURLOPT_RETURNTRANSFER, 1); curl_multi_add_handle($mh, $arrCh[$k]); } $active = null; do { curl_multi_exec($mh, $active); curl_multi_select($mh); } while ($active > 0); $arrRet = []; foreach ($arrCh as $kch => $vch) { $arrRet[$kch] = curl_multi_getcontent($vch); } Yii::log("sendMessageToLongPool arrRet=[" . print_r($arrRet, true) . "]", "info"); } finally { foreach ($arrCh as $vch) { curl_multi_remove_handle($mh, $vch); } curl_multi_close($mh); } } } Yii::endProfile('sendMessageToLongPool'); Yii::log("sendMessageToLongPool end", "info"); }
/** * @param ActiveDataProvider $activeDataProvider */ public function search(ActiveDataProvider $activeDataProvider, $tableName = 'cms_content_element') { $classSearch = $this->propertyElementClassName; /** * @var $activeQuery ActiveQuery */ $activeQuery = $activeDataProvider->query; $elementIdsGlobal = []; $applyFilters = false; foreach ($this->toArray() as $propertyCode => $value) { //TODO: add to validator related properties if ($propertyCode == 'properties') { continue; } if ($property = $this->getProperty($propertyCode)) { if ($property->property_type == \skeeks\cms\relatedProperties\PropertyType::CODE_NUMBER) { $elementIds = []; $query = $classSearch::find()->select(['element_id'])->where(["property_id" => $property->id])->indexBy('element_id'); if ($fromValue = $this->{$this->getAttributeNameRangeFrom($propertyCode)}) { $applyFilters = true; $query->andWhere(['>=', 'value_num', (double) $fromValue]); } if ($toValue = $this->{$this->getAttributeNameRangeTo($propertyCode)}) { $applyFilters = true; $query->andWhere(['<=', 'value_num', (double) $toValue]); } if (!$fromValue && !$toValue) { continue; } $elementIds = $query->all(); } else { if (!$value) { continue; } $applyFilters = true; if ($property->property_type == \skeeks\cms\relatedProperties\PropertyType::CODE_STRING) { $elementIds = $classSearch::find()->select(['element_id'])->where(["property_id" => $property->id])->andWhere(['like', 'value', $value])->indexBy('element_id')->all(); } else { $elementIds = $classSearch::find()->select(['element_id'])->where(["value" => $value, "property_id" => $property->id])->indexBy('element_id')->all(); } } $elementIds = array_keys($elementIds); \Yii::beginProfile('array_intersect'); if (!$elementIds) { $elementIdsGlobal = []; } if ($elementIdsGlobal) { $elementIdsGlobal = array_intersect($elementIds, $elementIdsGlobal); } else { $elementIdsGlobal = $elementIds; } \Yii::endProfile('array_intersect'); } } if ($applyFilters) { $activeQuery->andWhere([$tableName . '.id' => $elementIdsGlobal]); } }
<?php $this->setPageTitle(Yii::t('EdifactDataModule.model', 'Containers')); ?> <div class="clearfix"> <div class="btn-toolbar pull-left"> <div class="btn-group"> <h1> <i class="icon-th-large"></i> <?php echo Yii::t('EdifactDataModule.model', 'Containers'); ?> </h1> </div> </div> </div> <?php Yii::beginProfile('EcprContainerProcesing.view.grid'); $this->widget('TbGridView', array('id' => 'ecpr-container-procesing-grid', 'dataProvider' => $model->searchExt(), 'filter' => $model, 'template' => '{items}{pager}', 'pager' => array('class' => 'TbPager', 'displayFirstAndLast' => true), 'columns' => array(array('name' => 'ecnt_terminal', 'type' => 'raw', 'value' => 'Chtml::tag("span" , array("class" => $data->getTerminalClass() ), $data->ecnt_terminal)'), array('name' => 'ecnt_container_nr'), array('name' => 'ecnt_statuss'), array('name' => 'ecnt_length', 'htmlOptions' => array('class' => 'numeric-column')), array('name' => 'ecnt_datetime'), array('name' => 'action_amt', 'htmlOptions' => array('class' => 'numeric-column')), array('name' => 'time_amt', 'htmlOptions' => array('class' => 'numeric-column')), array('class' => 'TbButtonColumn', 'buttons' => array('view' => array('visible' => 'Yii::app()->user->checkAccess("Edifactdata.EcprContainerProcesing.View")'), 'update' => array('visible' => 'FALSE'), 'delete' => array('visible' => 'FALSE')), 'viewButtonUrl' => 'Yii::app()->controller->createUrl("view", array("ecpr_id" => $data->ecpr_id))', 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("delete", array("ecpr_id" => $data->ecpr_id))', 'deleteConfirmation' => Yii::t('`crud', 'Do you want to delete this item?'), 'viewButtonOptions' => array('data-toggle' => 'tooltip'), 'deleteButtonOptions' => array('data-toggle' => 'tooltip'))))); Yii::endProfile('EcprContainerProcesing.view.grid');
/** * @param string method of PDOStatement to be called * @param mixed the first parameter to be passed to the method * @param array input parameters (name=>value) for the SQL execution. This is an alternative * to {@link bindParam} and {@link bindValue}. If you have multiple input parameters, passing * them in this way can improve the performance. Note that you pass parameters in this way, * you cannot bind parameters or values using {@link bindParam} or {@link bindValue}, and vice versa. * binding methods and the input parameters this way can improve the performance. * This parameter has been available since version 1.0.10. * @return mixed the method execution result */ private function queryInternal($method, $mode, $params = array()) { if ($this->_connection->enableParamLogging && ($pars = array_merge($this->_params, $params)) !== array()) { $p = array(); foreach ($pars as $name => $value) { $p[$name] = $name . '=' . $value; } $par = '. Bind with parameter ' . implode(', ', $p); } else { $par = ''; } Yii::trace('Querying SQL: ' . $this->getText() . $par, 'system.db.CDbCommand'); try { if ($this->_connection->enableProfiling) { Yii::beginProfile('system.db.CDbCommand.query(' . $this->getText() . ')', 'system.db.CDbCommand.query'); } $this->prepare(); if ($params === array()) { $this->_statement->execute(); } else { $this->_statement->execute($params); } if ($method === '') { $result = new CDbDataReader($this); } else { $result = $this->_statement->{$method}($mode); $this->_statement->closeCursor(); } if ($this->_connection->enableProfiling) { Yii::endProfile('system.db.CDbCommand.query(' . $this->getText() . ')', 'system.db.CDbCommand.query'); } return $result; } catch (Exception $e) { if ($this->_connection->enableProfiling) { Yii::endProfile('system.db.CDbCommand.query(' . $this->getText() . ')', 'system.db.CDbCommand.query'); } Yii::log('Error in querying SQL: ' . $this->getText() . $par, CLogger::LEVEL_ERROR, 'system.db.CDbCommand'); $errorInfo = $e instanceof PDOException ? $e->errorInfo : null; throw new CDbException(Yii::t('yii', 'CDbCommand failed to execute the SQL statement: {error}', array('{error}' => $e->getMessage())), (int) $e->getCode(), $errorInfo); } }
/** * @param \cookyii\modules\Media\media\ResourceInterface $Resource * @return static * @throws \Exception */ public static function push($Resource) { $id = basename($Resource->getTemp()); \Yii::beginProfile(sprintf('pushing file `%s`', $id), __METHOD__); /** @var static $NewModel */ $NewModel = new static(); $NewModel->path = $Resource->getTemp(); $Model = static::find()->bySha1($Resource->getSha1())->one(); if ($Model instanceof static) { $NewModel = $Model; } else { $result = $Resource->moveToUpload(); if (false !== $result) { $NewModel->name = basename($result); $NewModel->origin_name = $Resource->getName(); $NewModel->path = $result; $NewModel->insert(); } else { throw new \RuntimeException(\Yii::t('cookyii.media', 'Failed to bring the resource directory of uploaded files.')); } } \Yii::endProfile('pushing file `' . $id . '`', __METHOD__); return $NewModel; }
protected function createDataArray() { \Yii::beginProfile('createDataArray'); $data = []; Yii::beginProfile('getData'); if (!$this->config['serverSide']) { $paginator = $this->dataProvider->getPagination(); if ($this->dataProvider instanceof \CActiveDataProvider) { $this->dataProvider->criteria->order = ''; } $this->dataProvider->setPagination(false); $source = $this->dataProvider->getData(true); $this->dataProvider->setPagination($paginator); } else { $source = $this->dataProvider->getData(); } Yii::endProfile('getData'); Yii::beginProfile('renderCells'); // Get column name map. $names = array_map([$this, 'getColumnName'], $this->columns); foreach ($source as $i => $r) { $row = []; foreach ($this->columns as $j => $column) { $name = $names[$j]; $row[$name] = $column->getDataCellContent($i); } $metaRow = []; if ($this->addMetaData !== false) { Yii::beginProfile('addMetaData'); if (is_callable([$r, 'getKeyString'])) { $metaRow['data-key'] = call_user_func([$r, 'getKeyString']); } if (is_array($this->addMetaData)) { foreach ($this->addMetaData as $field) { $metaRow["data-{$field}"] = \CHtml::value($r, $field); } } Yii::endProfile('addMetaData'); } if (isset($this->rowCssClassExpression)) { $metaRow['class'] = $this->evaluateExpression($this->rowCssClassExpression, array('row' => $i, 'data' => $r)); } $row['metaData'] = $metaRow; $data[] = $row; } \Yii::endProfile('renderCells'); \Yii::endProfile('createDataArray'); return $data; }
<div class="alert alert-error"><?php echo $grid_error; ?> </div> <?php } if (!empty($grid_warning)) { ?> <div class="alert alert-warning"><?php echo $grid_warning; ?> </div> <?php } $model = new VtrdTrailerDoc(); $model->vtrd_vtrl_id = $modelMain->primaryKey; // render grid view $this->widget('TbGridView', array('id' => 'vtrd-trailer-doc-grid', 'dataProvider' => $model->search(), 'template' => '{summary}{items}', 'summaryText' => ' ', 'htmlOptions' => array('class' => 'rel-grid-view'), 'columns' => array(array('class' => 'editable.EditableColumn', 'name' => 'vtrd_vtdt_id', 'editable' => array('type' => 'select', 'url' => $this->createUrl('//trucks/vtrdTrailerDoc/editableSaver'), 'source' => CHtml::listData(VtdtTruckDocType::model()->findAll(array('limit' => 1000)), 'vtdt_id', 'itemLabel'))), array('header' => Yii::t('TrucksModule.model', 'Exp.Postion'), 'type' => 'raw', 'value' => '!empty($data->vtrd_fixr_id)? $data->vtrdFixr->fixrFiit->fiitFinv->finv_number. " ". CHtml::link( "<i class=\\"icon-external-link\\"></i>", array( "/d2fixr/FixrFiitXRef/viewFinv", "finv_id"=>$data->vtrdFixr->fixrFiit->fiit_finv_id ), array("target" => "_blank") ) :"-"'), array('class' => 'editable.EditableColumn', 'name' => 'vtrd_number', 'editable' => array('url' => $this->createUrl('//trucks/vtrdTrailerDoc/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'vtrd_issue_date', 'editable' => array('type' => 'date', 'url' => $this->createUrl('//trucks/vtrdTrailerDoc/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'vtrd_expire_date', 'editable' => array('type' => 'date', 'url' => $this->createUrl('//trucks/vtrdTrailerDoc/editableSaver'))), array('class' => 'editable.EditableColumn', 'name' => 'vtrd_notes', 'editable' => array('type' => 'textarea', 'url' => $this->createUrl('//trucks/vtrdTrailerDoc/editableSaver'))), array('class' => 'TbButtonColumn', 'buttons' => array('view' => array('visible' => 'FALSE'), 'update' => array('visible' => 'FALSE'), 'delete' => array('visible' => 'empty($data->vtrd_fixr_id) && Yii::app()->user->checkAccess("Trucks.VtrlTrailer.DeletevtrdTrailerDocs")')), 'deleteButtonUrl' => 'Yii::app()->controller->createUrl("/trucks/vtrdTrailerDoc/delete", array("vtrd_id" => $data->vtrd_id))', 'deleteConfirmation' => Yii::t('TrucksModule.crud', 'Do you want to delete this item?'), 'deleteButtonOptions' => array('data-toggle' => 'tooltip'))))); Yii::endProfile('vtrd_vtrl_id.view.grid'); }
public function actionProfile($id) { Yii::beginProfile('account_profile'); $userProfile = UserApi::getUser($id); if (!$userProfile) { throw new CHttpException(404, 'The requested page does not exist.'); } $userProfile = UserApi::getUserProfileDetails($id); $userAddress = DbUtils::getAddress($userProfile->city_id); $userImages = UserPhotosApi::getAllImages($id); $agentAddress = ""; $agentImage = ""; $agentProfile = AgentProfileApi::getAgentDetails($id); if ($agentProfile) { $agentAddress = DbUtils::getAddress($agentProfile->city_id); $agentImage = AgentProfileApi::getImage($id); } $builderAddress = ""; $builderImage = ""; $builderProfile = BuilderProfileApi::getBuilderDetails($id); if ($builderProfile) { $builderAddress = DbUtils::getAddress($builderProfile->city_id); $builderImage = BuilderProfileApi::getImage($id); } $specialistAddress = ""; $specialistImage = ""; $specialistProfile = SpecialistProfileApi::getSpecialistDetails($id); $specialistProjects = ""; if ($specialistProfile) { $specialistAddress = DbUtils::getAddress($specialistProfile->city_id); $specialistImage = SpecialistProfileApi::getImage($id); $specialistProjects = SpecialistApi::getSpecialistProjects($id); } $this->render('profile', array('userProfile' => $userProfile, 'userAddress' => $userAddress, 'userImages' => $userImages, 'agentProfile' => $agentProfile, 'agentAddress' => $agentAddress, 'builderProfile' => $builderProfile, 'builderAddress' => $builderAddress, 'specialistProfile' => $specialistProfile, 'specialistAddress' => $specialistAddress, 'specialistProjects' => $specialistProjects, 'agentImage' => $agentImage, 'builderImage' => $builderImage, 'specialistImage' => $specialistImage)); Yii::endProfile('account_profile'); }