本文整理汇总了PHP中yii::trace方法的典型用法代码示例。如果您正苦于以下问题:PHP yii::trace方法的具体用法?PHP yii::trace怎么用?PHP yii::trace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii
的用法示例。
在下文中一共展示了yii::trace方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkpermission
/**
* example:
* $permissionName can be
* action
* controller/action
* module/controller/action
* @param string $permissionName Permisssion Name
* @return array Array of formated Data
*/
protected function checkpermission($permissionName)
{
$return = [];
$pm_list = explode('/', $permissionName);
if (is_array($pm_list)) {
$count = count($pm_list);
switch ($count) {
case 1:
if ($permissionName == \Yii::$app->controller->module->id) {
$return = ['module' => \Yii::$app->controller->module->id];
} else {
$return = ['module' => \Yii::$app->controller->module->id, 'controller' => \Yii::$app->controller->id, 'action' => $permissionName];
}
break;
case 2:
$return = ['module' => \Yii::$app->controller->module->id, 'controller' => $pm_list[0], 'action' => $pm_list[1]];
break;
case 3:
$controller = $pm_list[1];
$module = $pm_list[0];
$action = $pm_list[2];
$return = ['module' => $pm_list[0], 'controller' => $pm_list[1], 'action' => $pm_list[2]];
break;
}
\yii::trace(print_r($return, true));
} else {
$controller = \Yii::$app->controller;
$module = $controller->module->id;
$action = $permissionName;
$return = ['module' => $module, 'controller' => $controller, 'action' => $action];
}
return $return;
}
示例2: upload
/**
*
* @param arry $data
* @return array
* @throws InvalidConfigException
*/
public function upload($data = [], $path = '')
{
foreach ($this->converters as $i => $convert) {
\yii::trace('running converter' . $convert);
$this->converters[$i] = $convert = Yii::createObject($convert);
if (!$convert instanceof UploaderInterface) {
throw new InvalidConfigException(get_class($convert) . ' must implement common\\modules\\media\\uploader\\UploaderInterface');
}
$mediadata = $convert->convert($this->model, $data, $path);
if ($mediadata !== null) {
return $mediadata;
}
}
}
示例3: actionSaveasdraft
/**
* Save as Draft ActiveRecord model.
* If save is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionSaveasdraft($id = 0)
{
\yii::trace('in action draft: ' . __METHOD__, 'theater');
$model = $this->findModel($id);
\Yii::trace(print_r($model, true), __METHOD__);
if ($model->load(Yii::$app->request->post()) && $model->saveAsDraft()) {
//return $this->redirect(['view', 'id' => $model->Id]);
\yii::trace('in action save model: ' . __METHOD__, 'theater');
\Yii::trace(print_r(Yii::$app->request->post(), true), __METHOD__);
header("content-type:application/json");
echo \yii\helpers\Json::encode(['status' => true]);
Yii::$app->end();
} else {
header("content-type:application/json");
echo \yii\helpers\Json::encode(['status' => false]);
Yii::$app->end();
}
}
示例4: init
public function init()
{
if (is_array($this->module)) {
foreach ($this->module as $module => $urlmap) {
if ($module == 'site') {
continue;
}
//\yii::trace('permission to check:'.$strmap);
//if(\Yii::$app->user->can($strmap)){
if (isset($this->url[0][$urlmap]['items']) && count($this->url[0][$urlmap]['items'])) {
$anymenu = false;
foreach ($this->url[0][$urlmap]['items'] as $id => $item) {
//if(!isset($item['url'])) continue;
if (isset($item['permission'])) {
if (!\Yii::$app->user->can($item['permission'])) {
unset($this->url[0][$urlmap]['items'][$id]);
} else {
$anymenu = true;
}
unset($this->url[0][$urlmap]['items'][$id]['permission']);
} else {
$url = trim($item['url'][0], '/');
\yii::trace('permission to check:' . $url);
if (!\Yii::$app->user->can($url)) {
unset($this->url[0][$urlmap]['items'][$id]);
} else {
$anymenu = true;
}
}
}
if (!$anymenu) {
unset($this->url[0][$urlmap]);
}
}
/*}else{
unset($this->url[0][$urlmap]);
}//*/
}
}
}
示例5: convert
/**
* @inheritdoc
*/
public function convert($model, $data = [], $path = '')
{
//to check single file upload or not.
\yii::trace('running file upload');
if ($path) {
$path = '/' . $path . '/' . date('Y') . '/' . date('M');
} else {
$path = '/' . date('Y') . '/' . date('M');
}
$uploadPath = Yii::getAlias($this->uploadPath) . $path;
\yii::trace($uploadPath);
FileHelper::createDirectory($uploadPath, 0777);
$uri = $path;
if (isset($_FILES[$this->uploadvar]) && isset($_FILES[$this->uploadvar]['name'])) {
$file = UploadedFile::getInstanceByName($this->uploadvar);
$newfilename = time() . '-' . $file->name;
if ($file->saveAs($uploadPath . '/' . $newfilename)) {
//Now save file data to database
$model = $this->getModel($model);
$model->filename = $file->name;
$model->path = $this->uploadPath . $path . '/' . $newfilename;
$model->uri = $uri . '/' . $newfilename;
$model->description = '';
$model->mimetype = $file->type;
$model->source = 'upload';
$model->mediahash = md5_file($uploadPath . '/' . $newfilename);
$model->status = 1;
try {
$exifReader = new ExifReader();
$exifReader->file = $model->path;
$data = $exifReader->getExifData(array(array('FILE', array('SectionsFound')), 'COMPUTED', 'THUMBNAIL', 'GPS', array('IFD0', array('UndefinedTag:0xC4A5')), array('EXIF', array('MakerNote'))));
$data = \yii\helpers\Json::encode($data);
$model->metainfo = $data;
} catch (Exception $e) {
}
$model->save();
return $model;
}
}
}
示例6: editsave
public function editsave($runValidation = true, $attributeNames = null)
{
\yii::trace($this->hasAttribute('state'), 'checkState');
if ($this->hasAttribute('state')) {
$this->state = self::STATUS_UNPUBLISH;
\yii::trace('set State::' . $this->statenames[$this->state], 'setState');
}
$this->status = self::STATUS_PUBLISH;
\yii::trace('set Status::' . $this->statusnames[$this->status], 'setStatus');
return $this->save($runValidation, $attributeNames);
}
示例7: sendForgotEmail
/**
* Send forgot email
*
* @return bool
*/
public function sendForgotEmail()
{
// validate
if ($this->validate()) {
// get user
$user = $this->getUser();
$user->generatePasswordResetToken();
$user->updatedBy = $user->Id;
$user->save();
// modify view path to module views
$mailer = Yii::$app->mailer;
$oldViewPath = $mailer->viewPath;
// send email
$subject = Yii::t("app", "[What's HOT CMS] Forgot password");
$message = Yii::$app->mailer->compose('passwordResetToken', compact("subject", "user"))->setTo($user->email)->setSubject($subject);
// check for messageConfig before sending (for backwards-compatible purposes)
\yii::trace(Yii::$app->params["adminEmail"]);
\yii::trace(Yii::$app->mailer->messageConfig["from"]);
if (empty(Yii::$app->mailer->messageConfig["from"])) {
$message->setFrom(Yii::$app->params["adminEmail"]);
}
$result = $message->send();
return $result;
}
return false;
}
示例8: actionLoadchain
public function actionLoadchain()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$model = new Restaurant();
$map = new \common\models\ResMap();
if ($model->load(Yii::$app->request->post())) {
$chaindata = $model->chainCity;
$chainmapstatus = $chaindata->chainFieldStatusMaps;
\yii::trace(print_r($chainmapstatus, true));
$finalmap = [];
foreach ($model->chainFieldMap() as $map) {
$map['id'] = \yii\helpers\BaseHtml::getInputId($model, $map['id']);
$map['lock'] = $chainmapstatus->{$map['value']};
$map['value'] = $chaindata->{$map['value']};
$finalmap[] = $map;
}
return ['responce' => ['map' => $finalmap]];
} else {
return ['responce' => 'false'];
}
}
示例9: checkActionAccess
private function checkActionAccess($module, $controller, $actions)
{
$permission = false;
if (isset($this->permission_rules['*##*##*']) || isset($this->permission_rules[$module . '##*##*']) || isset($this->permission_rules['*##' . $controller . '##*']) || isset($this->permission_rules[$module . '##' . $controller . '##*']) || isset($this->permission_rules['*##*##' . $actions])) {
if ($this->permission_rules['*##*##*'] == 1 || $this->permission_rules[$module . '##*##*'] == 1 || $this->permission_rules[$module . '##' . $controller . '##*'] == 1 || $this->permission_rules['*##' . $controller . '##*'] == 1 || $this->permission_rules['*##*##' . $actions] == 1) {
$permission = true;
}
}
//\yii::trace('Module Permission for '.$module.'|'.$controller.'|'.$actions.':'.(int)$permission,__METHOD__);
$controller_rule = [];
$action_rule = [];
foreach ($this->permission_rules as $rules => $status) {
list($moduleName, $controllerName, $actionName) = explode('##', $rules);
if (($moduleName == $module || $moduleName == '*') && ($controllerName == $controller || $controllerName == '*') && $actionName == $actions) {
if ($status == 1) {
$permission = true;
} else {
$permission = false;
}
} elseif (($moduleName == $module || $moduleName == '*') && ($controllerName == $controller || $controllerName == '*') && ($actionName == $actions || $actionName == '*')) {
if ($status == 1) {
$permission = true;
} else {
$permission = false;
}
} elseif ($moduleName == $module) {
// && ($controllerName == $controller || $controllerName == '*') && $actionName == $actions
if ($status == 1) {
//$permission = true;
$controller_rule[$controllerName] = 1;
$action_rule[$actionName] = 1;
} else {
//$permission = false;
$controller_rule[$controllerName] = 0;
$action_rule[$actionName] = 0;
}
}
\yii::trace('Module Permission for ' . $module . '|' . $controller . '|' . $actions . ':' . (int) $permission, __METHOD__);
}
//\yii::trace('Module Permission for '.$module.'|'.$controller.'|'.$actions.':'.var_dump($permission),__METHOD__);
return $permission;
}
示例10: alocateChain
public function alocateChain($chain, $validation = true)
{
$this->chainId = $chain->Id;
//$chain->refresh();
if ($chain->chainFieldStatusMaps->name == 1) {
\yii::trace('chain Name is Locked', __METHOD__);
$this->name = $chain->name;
} else {
if ($this->name === null || $this->name == '') {
\yii::trace('chain Name not Locked. but in db it is:' . $this->name . "with type" . var_export($this->name, true), __METHOD__);
$this->name = $chain->name;
}
}
if ($chain->chainFieldStatusMaps->website == 1) {
\yii::trace('chain Website is Locked', __METHOD__);
$this->website = $chain->website;
} else {
if ($this->website === null || $this->website == '') {
\yii::trace('chain Website not Locked. but in db it is:' . $this->website . "with type" . var_export($this->website, true), __METHOD__);
$this->website = $chain->website;
}
}
if ($chain->chainFieldStatusMaps->pricefortwo == 1) {
\yii::trace('chain Price for 2 is Locked', __METHOD__);
$this->priceForTwo = $chain->pricefortwo;
} else {
if ($this->priceForTwo === null || $this->priceForTwo == '' || $this->priceForTwo == 0) {
\yii::trace('chain Price for 2 not Locked. but in db it is:' . $this->priceForTwo . "with type" . var_export($this->priceForTwo, true), __METHOD__);
$this->priceForTwo = $chain->pricefortwo;
}
}
if ($chain->chainFieldStatusMaps->specilities == 1) {
\yii::trace('chain Specilities is Locked', __METHOD__);
$this->famousFor = $chain->specilities;
} else {
if ($this->famousFor === null || $this->famousFor == '') {
\yii::trace('chain Price for 2 not Locked. but in db it is:' . $this->famousFor . "with type" . var_export($this->famousFor, true), __METHOD__);
$this->famousFor = $chain->specilities;
}
}
if ($chain->chainFieldStatusMaps->whichType == 1) {
\yii::trace('chain whichtype is Locked', __METHOD__);
$this->entityType = $chain->whichType;
} else {
if ($this->entityType === null || $this->entityType == '' || $this->entityType == 0) {
\yii::trace('chain which type not Locked. but in db it is:' . $this->entityType . "with type" . var_export($this->entityType, true), __METHOD__);
$this->entityType = $chain->whichType;
}
}
if ($chain->chainFieldStatusMaps->facebookUrl == 1) {
\yii::trace('chain facebook is Locked', __METHOD__);
$this->facebook = $chain->facebookUrl;
} else {
if ($this->facebook === null || $this->facebook == '') {
\yii::trace('chain facebook not Locked. but in db it is:' . $this->facebook . "with type" . var_export($this->facebook, true), __METHOD__);
$this->facebook = $chain->facebookUrl;
}
}
$this->update($validation);
$datakey = ['types', 'feature', 'cuisines', 'payment', 'category', 'crowd', 'feature', 'music', 'usp', 'phone', 'mobile', 'media', 'menu', 'video', 'tag', 'logo'];
$map = ['types' => 'typesId', 'feature' => 'featureId', 'cuisines' => 'cuisineId', 'payment' => 'paymentId', 'category' => 'categoryId', 'crowd' => 'crowdId', 'feature' => 'featureId', 'music' => 'musicId', 'usp' => 'uspId', 'phone' => 'phone', 'mobile' => 'mobile'];
$length = 0;
$data = [];
if ($chain->chainFieldStatusMaps->cusinies == 1) {
\yii::trace('chain cuisine is Locked', __METHOD__);
$data['cuisines'] = explode(',', $chain->cusinies);
}
if ($chain->chainFieldStatusMaps->type == 1) {
\yii::trace('chain type is Locked', __METHOD__);
$data['types'] = explode(',', $chain->type);
}
foreach ($data as $key => $arval) {
if (is_array($arval) && ($ar_count = count($arval))) {
if ($ar_count > $length) {
$length = $ar_count;
}
}
}
if ($length) {
$mapAR = $this->resMaps;
//it will provide relational AR Array if there is any record. else it will be none.
$ar_count = count($mapAR);
for ($check_start = 0; $check_start < $length; $check_start++) {
foreach ($map as $key => $mapkey) {
//Yii::info("data for".$key.':'. var_dump($data[$key][$check_start]));
if (isset($data[$key][$check_start]) && $data[$key][$check_start] !== null && $data[$key][$check_start] != "") {
$doc[$mapkey] = $data[$key][$check_start];
}
}
if ($ar_count > 0 && isset($mapAR[$check_start])) {
//need to update
$armodel = $mapAR[$check_start];
} else {
//create new record
$armodel = new ResMap();
$armodel->loadDefaultValues();
}
//Yii::info("doc after load:".print_r($doc,true));
$armodel->load($doc, '');
$armodel->save($runValidation);
//.........这里部分代码省略.........
示例11: restore
public function restore()
{
if (!$this->beforeRestore()) {
return false;
}
$this->status = self::STATUS_PUBLISH;
\yii::trace('set Status::' . $this->statusnames[$this->status], 'setStatus');
$isSave = parent::save(false);
if ($isSave) {
$this->afterRestore();
}
return $isSave;
}
示例12: AddRestaurants
public function AddRestaurants($restaurantIds)
{
$db = static::getDb();
$transaction = $db->beginTransaction();
$restaurantAr = [];
try {
foreach ($restaurantIds as $values) {
$restaurantAr[] = $model = Restaurant::findOne($values);
$model->alocateChain($this, false);
}
$transaction->commit();
try {
foreach ($restaurantAr as $resmodel) {
$resmodel->published();
}
} catch (\Exception $e) {
\yii::trace($e->getMessage());
return false;
}
} catch (\Exception $e) {
\yii::trace($e->getMessage());
$transaction->rollBack();
return false;
}
}
示例13: removeTagEntity
/**
*
* @param integer $entityId
* @param integer $entityType
*/
public function removeTagEntity($entityId, $entityType)
{
$tagsId = [];
foreach ($this->tags as $tag) {
$tagsId[] = $tag->Id;
}
\yii::trace('delete Tags Ids:' . print_r($tagsId, true));
if (count($tagsId)) {
Tagmap::deleteAll(['entityId' => $entityId, 'entityType' => $entityType, 'tagId' => $tagsId]);
}
}
示例14: EventActionReStore
public static function EventActionReStore($event)
{
//echo get_class($event->sender) . ' is inserted';
\yii::trace('event handler publish function :' . __METHOD__, 'event');
$data = array();
$modelClass = get_class($event->sender);
$data_attribute = $event->sender->getAttributes();
$data_toarray = $event->sender->toArray();
$data = self::ToArrayAttributeDataMerger($data_toarray, $data_attribute);
$id = $data['Id'];
//echo "<pre>";
//print_r($event);
//var_dump($data);
//die;
// \yii::trace('in event Publish:'.__METHOD__,'event');
// \Yii::trace(print_r($data_attribute,true),__METHOD__);
// \Yii::trace(print_r($data_toarray,true),__METHOD__);
\Yii::trace(print_r($data, true), __METHOD__);
// \yii::trace('before event publish try: event .................'.$modelClass);
//\Yii::trace(print_r($event->sender->media,true),__METHOD__);
try {
//\yii::trace('in event publish try: event '.$modelClass);
switch ($modelClass) {
case "common\\models\\MovieTheaterMap":
$movieTheaterMap = new MovieWrite();
$dataMap = $movieTheaterMap->getMovieTheaterScheduleStatus($data['movieId'], $data['theaterId'], 2);
if (count($dataMap) > 0) {
$theaterMapId = $dataMap[0]['iMtmId'];
$masterWrite = new MasterWrite();
$dataArray = array();
$dataArray['iStatus'] = 1;
$dataArray['modified_date'] = date("Y-m-d H:i:s");
$dataArray['sync_source'] = 'New';
$result = $masterWrite->entityDelete($dataArray, 'tc_movie_theater_map', "iMtmId={$theaterMapId}");
}
break;
default:
}
} catch (\Exception $e) {
$message = 'Error in publish Flow ' . $modelClass . ' ' . $data['Id'] . ' ' . $e->getMessage() . ' ' . $e->getFile() . ' ' . $e->getLine();
$lockText = date('Y-m-d H:i:s') . ' - ' . $message . "\n";
Yii::error($lockText, 'writemodel');
//self::WriteModelErrorLogging($message);
}
}