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


PHP class_basename函数代码示例

本文整理汇总了PHP中class_basename函数的典型用法代码示例。如果您正苦于以下问题:PHP class_basename函数的具体用法?PHP class_basename怎么用?PHP class_basename使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: makeCustomPostType

 protected function makeCustomPostType(Post $model)
 {
     $postTypeSlug = strtolower(snake_case(class_basename($model)));
     if ($model instanceof CustomPostType) {
         $singular = property_exists($model, 'singular') ? $model->singular : str_replace(['-', '_'], ' ', $postTypeSlug);
         $plural = property_exists($model, 'plural') ? $model->plural : str_plural(str_replace(['-', '_'], ' ', $postTypeSlug));
         $postTypeData = $model->customPostTypeData();
         if (!is_array($postTypeData)) {
             $postTypeData = [];
         }
         $result = register_post_type($postTypeSlug, $this->buildPostTypeData($singular, $plural, $postTypeData));
         if (!$result instanceof \WP_Error) {
             $this->postTypes[$postTypeSlug] = get_class($model);
             if (property_exists($model, 'placeholderText')) {
                 add_filter('enter_title_here', function ($default) use($postTypeSlug, $model) {
                     if ($postTypeSlug == get_current_screen()->post_type) {
                         $default = $model->placeholderText;
                     }
                     return $default;
                 });
             }
         }
     } else {
         $this->postTypes[$postTypeSlug] = get_class($model);
     }
 }
开发者ID:ericbarnes,项目名称:framework,代码行数:26,代码来源:PostTypeManager.php

示例2: createMigration

 /**
  * Build the class name from the migration file.
  *
  * @todo Find a better way than doing this. This feels so icky all over
  *       whenever I look back at this.
  *       Maybe I can find something that's actually in native Laravel
  *       database classes.
  *
  * @param  string  $file
  * @return Migration
  */
 private function createMigration(string $file)
 {
     $basename = str_replace('.php', '', class_basename($file));
     $filename = substr($basename, 18);
     $classname = studly_case($filename);
     return new $classname();
 }
开发者ID:thirteen,项目名称:testbench,代码行数:18,代码来源:DatabaseMigrations.php

示例3: initForm

 /**
  * Prepare the widgets used by this action
  * @param Model $model
  * @return void
  */
 public function initForm($model)
 {
     $context = $this->formGetContext();
     $config = $this->makeConfig($this->config->form);
     $config->model = $model;
     $config->arrayName = class_basename($model);
     $config->context = $context;
     /*
      * Form Widget with extensibility
      */
     $this->formWidget = $this->makeWidget('Backend\\Widgets\\Form', $config);
     $this->formWidget->bindEvent('form.extendFieldsBefore', function () {
         $this->controller->formExtendFieldsBefore($this->formWidget);
     });
     $this->formWidget->bindEvent('form.extendFields', function () {
         $this->controller->formExtendFields($this->formWidget);
     });
     $this->formWidget->bindEvent('form.beforeRefresh', function ($saveData) {
         return $this->controller->formExtendRefreshData($this->formWidget, $saveData);
     });
     $this->formWidget->bindEvent('form.refresh', function ($result) {
         return $this->controller->formExtendRefreshResults($this->formWidget, $result);
     });
     $this->formWidget->bindToController();
     /*
      * Detected Relation controller behavior
      */
     if ($this->controller->isClassExtendedWith('Backend.Behaviors.RelationController')) {
         $this->controller->initRelation($model);
     }
     $this->prepareVars($model);
 }
开发者ID:Rudianasaja,项目名称:october,代码行数:37,代码来源:FormController.php

示例4: send

 /**
  * Send the given notification.
  *
  * @param  mixed  $notifiable
  * @param  \Illuminate\Notifications\Notification  $notification
  * @return void
  */
 public function send($notifiable, Notification $notification)
 {
     if (!$notifiable->routeNotificationFor('mail')) {
         return;
     }
     $message = $notification->toMail($notifiable);
     if ($message instanceof Mailable) {
         return $message->send($this->mailer);
     }
     $this->mailer->send($message->view, $message->data(), function ($m) use($notifiable, $notification, $message) {
         $recipients = empty($message->to) ? $notifiable->routeNotificationFor('mail') : $message->to;
         if (!empty($message->from)) {
             $m->from($message->from[0], isset($message->from[1]) ? $message->from[1] : null);
         }
         if (is_array($recipients)) {
             $m->bcc($recipients);
         } else {
             $m->to($recipients);
         }
         $m->subject($message->subject ?: Str::title(Str::snake(class_basename($notification), ' ')));
         foreach ($message->attachments as $attachment) {
             $m->attach($attachment['file'], $attachment['options']);
         }
         foreach ($message->rawAttachments as $attachment) {
             $m->attachData($attachment['data'], $attachment['name'], $attachment['options']);
         }
     });
 }
开发者ID:hannesvdvreken,项目名称:framework,代码行数:35,代码来源:MailChannel.php

示例5: setRelation

 /** 
  * Set the parent -> child relation.
  *
  * @param string   $relation
  * @param Eloquent $parent
  */
 public function setRelation($relation, $parent)
 {
     $this->relation = $relation;
     $function_call = call_user_func_array([$parent, $relation], []);
     $type = class_basename(get_class($function_call));
     switch ($type) {
         case 'BelongsTo':
             $this->is_parent = true;
             $this->pivot_table = null;
             $this->local_key_attribute = $function_call->getForeignKey();
             $this->parent_key_attribute = $function_call->getOtherKey();
             break;
         case 'BelongsToMany':
             $this->is_parent = false;
             $this->pivot_table = $function_call->getTable();
             $this->local_key_attribute = $function_call->getOtherKey();
             $this->parent_key_attribute = $function_call->getForeignKey();
             break;
         case 'HasOne':
         case 'HasMany':
             $this->is_parent = false;
             $this->pivot_table = null;
             $this->parent_key_attribute = $function_call->getPlainForeignKey();
             break;
         default:
             throw new Exception('Unhandled relation type');
             break;
     }
     $this->setModel($function_call->getRelated());
 }
开发者ID:feijs,项目名称:model-importer,代码行数:36,代码来源:RelationModelImporter.php

示例6: format

 public function format(array $record)
 {
     $vars = $this->normalize($record);
     $output = $this->format;
     if (isset($record['context']['exception']) && in_array(class_basename($record['context']['exception']), \Config::get('laraext.log.skip_trace'))) {
         $vars['message'] = get_class($record['context']['exception']) . ":" . $record['context']['exception']->getMessage();
     }
     if (\App::isBooted() && \Auth::check()) {
         $vars['user'] = \Auth::user()->id;
     } else {
         $vars['user'] = "0";
     }
     foreach ($vars['extra'] as $var => $val) {
         if (false !== strpos($output, '%extra.' . $var . '%')) {
             $output = str_replace('%extra.' . $var . '%', $this->stringify($val), $output);
             unset($vars['extra'][$var]);
         }
     }
     if ($this->ignoreEmptyContextAndExtra) {
         if (empty($vars['context'])) {
             unset($vars['context']);
             $output = str_replace('%context%', '', $output);
         }
         if (empty($vars['extra'])) {
             unset($vars['extra']);
             $output = str_replace('%extra%', '', $output);
         }
     }
     foreach ($vars as $var => $val) {
         if (false !== strpos($output, '%' . $var . '%')) {
             $output = str_replace('%' . $var . '%', $this->stringify($val), $output);
         }
     }
     return $output;
 }
开发者ID:skvn,项目名称:laraext,代码行数:35,代码来源:LineFormatter.php

示例7: boot

 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $carpayment = CarPayment::find($model->carpaymentid);
         $model->provinceid = $carpayment->provinceid;
         $model->branchid = $carpayment->branchid;
         $model->createdby = Auth::user()->id;
         $model->createddate = date("Y-m-d H:i:s");
         $model->modifiedby = Auth::user()->id;
         $model->modifieddate = date("Y-m-d H:i:s");
     });
     static::created(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
     static::updating(function ($model) {
         $carpayment = CarPayment::find($model->carpaymentid);
         $model->provinceid = $carpayment->provinceid;
         $model->branchid = $carpayment->branchid;
         $model->accountingDetailReceiveAndPays()->delete();
         $model->modifiedby = Auth::user()->id;
         $model->modifieddate = date("Y-m-d H:i:s");
     });
     static::updated(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
     static::deleting(function ($model) {
         $model->accountingDetailReceiveAndPays()->delete();
     });
     static::deleted(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
 }
开发者ID:x-Zyte,项目名称:nissanhippro,代码行数:33,代码来源:AccountingDetail.php

示例8: getResourceAttributes

 /**
  * Returns attributes for the resource
  *
  * @return mixed[]
  */
 public function getResourceAttributes()
 {
     $attributes = $this->attributesToArray();
     // detect any translated attributes
     if (in_array(config('jsonapi.encoding.translatable_trait'), class_uses($this))) {
         foreach ($this->translatedAttributes as $key) {
             $attributes[$key] = $this->{$key};
         }
     }
     // unset primary key field
     unset($attributes[$this->getKeyName()]);
     // unset reserved fieldname "type"
     // reset it as modelname-type if that is not in use yet
     if (array_key_exists('type', $attributes)) {
         $typeRecast = Str::snake(class_basename($this) . '-type', '-');
         if (!array_key_exists($typeRecast, $attributes)) {
             $attributes[$typeRecast] = $attributes['type'];
         }
         unset($attributes['type']);
     }
     // map all fieldnames to dasherized case
     foreach ($attributes as $key => $value) {
         $dasherized = str_replace('_', '-', $key);
         if ($key !== $dasherized) {
             $attributes[$dasherized] = $value;
             unset($attributes[$key]);
         }
     }
     return $attributes;
 }
开发者ID:czim,项目名称:laravel-jsonapi,代码行数:35,代码来源:JsonApiResourceEloquentTrait.php

示例9: byDefault

 public function byDefault($site = null)
 {
     $model = $this->getModel();
     $modelName = strtolower(class_basename($model));
     $pref = $modelName != 'site' ? $modelName . ':' : '';
     if (empty($site)) {
         $settings = !empty($model->id) ? $model->getSettings() : Model\Site::$site->getSettings();
     } else {
         $settings = $site->getSettings();
     }
     if (!empty($settings)) {
         $count = !empty($settings['site'][$pref . 'count']) ? $settings['site'][$pref . 'count'] : 0;
         $pagination = !empty($settings['site'][$pref . 'pagination']) ? $settings['site'][$pref . 'pagination'] : 0;
         $sort_fields = !empty($settings['site'][$pref . 'sort_fields']) ? $settings['site'][$pref . 'sort_fields'] : '';
         $sort_type = !empty($settings['site'][$pref . 'sort_type']) ? $settings['site'][$pref . 'sort_type'] : '';
         if ($sort_type == 'RAND()') {
             $this->orderBy(DB::raw('RAND()'));
         } else {
             if ($sort_fields) {
                 $sort_type ? $this->orderBy($sort_fields, $sort_type) : $this->orderBy($sort_fields);
             }
         }
         if ($count) {
             $pagination ? $this->paginate($count) : $this->take($count);
         }
     }
     return $this;
 }
开发者ID:ognestraz,项目名称:laravel-model,代码行数:28,代码来源:Builder.php

示例10: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     // 404 page when a model is not found
     if ($e instanceof ModelNotFoundException) {
         if ($request->ajax() || $request->wantsJson()) {
             return response()->json(['error' => 404, 'mensaje' => 'Recurso no encontrado'], 404);
         }
         return response()->view('errors.404', [], 404);
     }
     if ($this->isHttpException($e)) {
         if ($request->ajax() || $request->wantsJson()) {
             return response()->json(['error' => 404, 'mensaje' => 'Recurso no encontrado!'], 404);
         }
         return $this->renderHttpException($e);
     } else {
         // Custom error 500 view on production
         if (app()->environment() == 'production') {
             if ($request->ajax() || $request->wantsJson()) {
                 return response()->json(['error' => ['exception' => class_basename($e) . ' in ' . basename($e->getFile()) . ' line ' . $e->getLine() . ': ' . $e->getMessage()]], 500);
             }
             return response()->view('errors.500', [], 500);
         }
         return parent::render($request, $e);
     }
 }
开发者ID:Nemeziz,项目名称:inegi,代码行数:32,代码来源:Handler.php

示例11: getFieldTypes

 /**
  * Returns an array of registered fields, keyed by field slug,
  * values in readable format
  *
  * @return array
  */
 public function getFieldTypes()
 {
     return array_map(function ($value) {
         $class_name = class_basename($value);
         return ucfirst(strtolower(preg_replace('/\\B([A-Z])/', ' $1', $class_name)));
     }, $this->getRegistrar()->getRegisteredFields());
 }
开发者ID:sodacms,项目名称:sodacms,代码行数:13,代码来源:FormBuilder.php

示例12: getKeyName

 /**
  * Get the primary key for the model.
  *
  * @return string
  */
 public function getKeyName()
 {
     if (isset($this->primaryKey)) {
         return $this->primaryKey;
     }
     return 'id_' . str_replace('\\', '', snake_case(class_basename($this)));
 }
开发者ID:neonbug,项目名称:meexo-common,代码行数:12,代码来源:BaseModel.php

示例13: __construct

 /**
  * Create a new event instance.
  *
  * @return void
  */
 public function __construct($location, User $user)
 {
     $this->user = $user;
     //sukuriam paminejima duomenu bazeje.
     $mention = \maze\Mention::create(['user_id' => $user->id, 'object_type' => class_basename($location), 'object_id' => $location->id]);
     $this->notifiable = $mention;
 }
开发者ID:PovilasLT,项目名称:maze,代码行数:12,代码来源:UserWasMentioned.php

示例14: article

 public function article($category_slug, $slug)
 {
     $key = snake_case(class_basename($this) . '_' . __FUNCTION__ . '_' . $category_slug . '_' . $slug);
     if ($this->cache->has($key)) {
         $view = $this->cache->get($key);
     } else {
         $category = $this->category->where('slug', $category_slug)->first();
         $filters = [['name' => 'enabled', 'value' => 1], ['name' => 'slug', 'value' => $slug]];
         if (is_object($category)) {
             $category_id = $category->id;
             $filters[] = ['name' => 'category_id', 'value' => $category_id];
         }
         if ($this->cache->has($slug)) {
             $content = $this->cache->get($slug);
         } else {
             $content = $this->content->filterAll($filters);
             if ($content->count()) {
                 $content = $content->first();
             } else {
                 return redirect()->route('404');
             }
             $this->cache->put($slug, $content, 60);
         }
         $content->category = $category;
         $view = view('pages.content_show', compact('content'))->render();
     }
     return $view;
 }
开发者ID:ritey,项目名称:absolutemini,代码行数:28,代码来源:ArticleController.php

示例15: getTable

 /**
  * 系统的默认表名会将类名变为复数,如 org 将会变为 orgs;
  * 复写该类取消这一功能,声明 Model 时将类名与表名保持一致即可
  */
 public function getTable()
 {
     if (isset($this->table)) {
         return $this->table;
     }
     return str_replace('\\', '', Str::snake(class_basename($this)));
 }
开发者ID:shiqusocialtouch,项目名称:laravel,代码行数:11,代码来源:BaseModel.php


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