當前位置: 首頁>>代碼示例>>PHP>>正文


PHP trait_uses_recursive函數代碼示例

本文整理匯總了PHP中trait_uses_recursive函數的典型用法代碼示例。如果您正苦於以下問題:PHP trait_uses_recursive函數的具體用法?PHP trait_uses_recursive怎麽用?PHP trait_uses_recursive使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了trait_uses_recursive函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: bootUpload

 protected static function bootUpload()
 {
     static::updating(function (Model $model) {
         foreach ($model->getUploadFields() as $key) {
             $originalValue = array_get($model->original, $key);
             if (!empty($originalValue) and $originalValue != $model->attributes[$key] and file_exists($filePath = public_path($originalValue))) {
                 unlink($filePath);
             }
         }
     });
     static::saving(function (Model $model) {
         foreach ($model->getUploadFields() as $key) {
             if ($model->{$key} instanceof UploadedFile) {
                 $model->attachFile($key, $model->{$key});
             }
         }
     });
     static::deleting(function (Model $model) {
         if (in_array(\Illuminate\Database\Eloquent\SoftDeletes::class, trait_uses_recursive($model)) && !$model->forceDeleting) {
             return;
         }
         foreach ($model->getUploadFields() as $key) {
             $filePath = $model->{$key . '_path'};
             if (!empty($filePath) and file_exists($filePath)) {
                 unlink($model->{$key . '_path'});
             }
         }
     });
 }
開發者ID:kodicomponents,項目名稱:support,代碼行數:29,代碼來源:Upload.php

示例2: trait_uses_recursive

 /**
  * Returns all traits used by a trait and its traits.
  *
  * @param  string  $trait
  * @return array
  */
 function trait_uses_recursive($trait)
 {
     $traits = class_uses($trait);
     foreach ($traits as $trait) {
         $traits += trait_uses_recursive($trait);
     }
     return $traits;
 }
開發者ID:weyii,項目名稱:yii2-base,代碼行數:14,代碼來源:helpers.php

示例3: class_uses_recursive

 /**
  * Returns all traits used by a class, it's subclasses and trait of their traits
  *
  * @param  string  $class
  * @return array
  */
 function class_uses_recursive($class)
 {
     $results = [];
     foreach (array_merge([$class => $class], class_parents($class)) as $class) {
         $results += trait_uses_recursive($class);
     }
     return array_unique($results);
 }
開發者ID:LuckyCyborg,項目名稱:simple-mvc-framework,代碼行數:14,代碼來源:functions.php


注:本文中的trait_uses_recursive函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。