本文整理汇总了PHP中studly_case函数的典型用法代码示例。如果您正苦于以下问题:PHP studly_case函数的具体用法?PHP studly_case怎么用?PHP studly_case使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了studly_case函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: anyModule
/**
* Call Module action
*
* @param $name
* @param $action
* @return \Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function anyModule($name, $action)
{
global $app;
$name = strtolower($name);
if (isset($app['arxmin.modules.' . $name])) {
$model = $app['arxmin.modules.' . $name];
} else {
$model = "\\Arxmin\\" . ucfirst($name);
}
# force format action
$method = studly_case($action);
if ((class_exists($model, false) || is_object($model)) && method_exists($model, $method)) {
$params = Request::segments();
for ($i = 0; $i <= array_search($action, $params); $i++) {
unset($params[$i]);
}
if (count(Input::all())) {
$params[] = Input::all();
}
$response = call_user_func_array(array($model, $method), $params);
if (is_object($response) && method_exists($response, 'toArray')) {
$response = $response->toArray();
}
return Api::responseJson($response);
}
return Response::json(Api::response([], 400, "method not found"), 400);
}
示例2: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$name = $this->argument('name');
$studly_name = studly_case($name);
$directive_name = strtolower(substr($studly_name, 0, 1)) . substr($studly_name, 1);
$html = file_get_contents(__DIR__ . '/Stubs/AngularDirective/directive.html.stub');
$js = file_get_contents(__DIR__ . '/Stubs/AngularDirective/directive.js.stub');
$definition = file_get_contents(__DIR__ . '/Stubs/AngularDirective/definition.js.stub');
$less = file_get_contents(__DIR__ . '/Stubs/AngularDirective/directive.less.stub');
$js = str_replace('{{StudlyName}}', $studly_name, $js);
$definition = str_replace('{{StudlyName}}', $studly_name, $definition);
$definition = str_replace('{{name}}', $name, $definition);
$definition = str_replace('{{directiveName}}', $directive_name, $definition);
$folder = __DIR__ . '/../../../angular/directives/' . $name;
if (is_dir($folder)) {
$this->info('Folder already exists');
return false;
}
//create folder
File::makeDirectory($folder, 0775, true);
//create view (.html)
File::put($folder . '/' . $name . '.html', $html);
//create definition (.js)
File::put($folder . '/definition.js', $definition);
//create controller (.js)
File::put($folder . '/' . $name . '.js', $js);
//create less file (.less)
File::put($folder . '/' . $name . '.less', $less);
$this->info('Directive created successfully.');
}
示例3: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$table_name = strtolower($this->argument('name'));
$migration = "create_{$table_name}_table";
// The template file is the migration that ships with the package
$template_dir = __DIR__;
$template_file = 'SchemaTemplate.php';
$template_path = $template_dir . '/' . $template_file;
// Make sure the template path exists
if (!$this->fs->exists($template_path)) {
return $this->error('Unable to find template: ' . $template_path);
}
// Set the Destination Directory
$dest_dir = base_path() . '/database/migrations/';
$dest_file = date("Y_m_d_His") . '_' . $migration . '.php';
$dest_path = $dest_dir . $dest_file;
// Make Sure the Destination Directory exists
if (!$this->fs->isDirectory($dest_dir)) {
return $this->error('Unable to find destination directory: ' . $dest_dir);
}
// Read Template File
$template = $this->fs->get($template_path);
// Replace what is necessary
$classname = 'Create' . studly_case(ucfirst($table_name)) . 'Table';
$contents = str_replace("'__meta__'", "'" . $table_name . "'", $template);
$contents = str_replace('SchemaTemplate', $classname, $contents);
// Write new Migration to destination
$this->fs->put($dest_path, $contents);
// Dump-Autoload
// $this->call('dump-autoload');
$this->info($table_name . ' migration created. run "php artisan migrate" to create the table');
}
示例4: handleRule
/**
* Separate rule name from parameters and pass to matcher class to evaluate.
*
* @return boolean
*/
protected function handleRule($request, $rule)
{
$rule = explode(':', $rule);
$params = isset($rule[1]) ? $rule[1] : null;
$class = '\\PeterColes\\Themes\\Matchers\\' . studly_case($rule[0]);
return (new $class())->handle($request, $params);
}
示例5: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$name = $this->argument('name');
$studly_name = studly_case($name);
$js = file_get_contents(__DIR__ . '/Stubs/AngularService/service.js.stub');
$spec = file_get_contents(__DIR__ . '/Stubs/AngularService/service.spec.js.stub');
$js = str_replace('{{StudlyName}}', $studly_name, $js);
$spec = str_replace('{{StudlyName}}', $studly_name, $spec);
$folder = base_path(config('generators.source.root')) . '/' . config('generators.source.services');
$spec_folder = base_path(config('generators.tests.source.root')) . '/' . config('generators.tests.source.services');
//create service (.service.js)
File::put($folder . '/' . $name . config('generators.suffix.service'), $js);
if (!$this->option('no-spec') && config('generators.tests.enable.services')) {
//create spec folder
if (!File::exists($spec_folder)) {
File::makeDirectory($spec_folder, 0775, true);
}
//create spec (.service.spec.js)
File::put($spec_folder . '/' . $name . '.service.spec.js', $spec);
}
//import service
$services_index = base_path(config('generators.source.root')) . '/index.services.js';
if (config('generators.misc.auto_import') && !$this->option('no-import') && file_exists($services_index)) {
$services = file_get_contents($services_index);
$newService = "\r\n\t.service('{$studly_name}Service', {$studly_name}Service)";
$module = "angular.module('app.services')";
$services = str_replace($module, $module . $newService, $services);
$services = 'import {' . $studly_name . "Service} from './services/{$name}.service';\n" . $services;
file_put_contents($services_index, $services);
}
$this->info('Service created successfully.');
}
示例6: handle
/**
* Handle the command.
*
* Add a default Module route, language entries etc per Module
*
*/
public function handle()
{
$module = $this->module;
$dest = $module->getPath();
$data = ['config' => _config('builder', $module), 'vendor' => $module->getVendor(), 'module_name' => studly_case($module->getSlug())];
$src = __DIR__ . '/../../resources/stubs/module';
try {
if (_config('builder.landing_page', $module)) {
/* adding routes to the module service provider class
(currently, just for the optional landing (home) page) */
$this->processFile("{$dest}/src/" . $data['module_name'] . 'ModuleServiceProvider.php', ['routes' => $src . '/routes.php'], $data);
/* adding sections to the module class
(currently, just for the optional landing (home) page)*/
$this->processFile("{$dest}/src/" . $data['module_name'] . 'Module.php', ['sections' => $src . '/sections.php'], $data, true);
}
/* generate sitemap for the module main stream */
if ($stream_slug = _config('builder.sitemap.stream_slug', $module)) {
$data['entity_name'] = studly_case(str_singular($stream_slug));
$data['repository_name'] = str_plural($stream_slug);
$this->files->parseDirectory("{$src}/config", "{$dest}/resources/config", $data);
}
/* adding module icon */
$this->processVariable("{$dest}/src/" . $data['module_name'] . 'Module.php', ' "' . _config('builder.icon', $module) . '"', 'protected $icon =', ';');
} catch (\PhpParser\Error $e) {
die($e->getMessage());
}
}
示例7: setTable
/**
* Set table name
*
* @param string $table
*
* @return self
*/
private function setTable($table)
{
$this->table = strtolower($table);
$this->migrationName = snake_case($this->table);
$this->className = studly_case($this->migrationName);
return $this;
}
示例8: register
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
/** @var \Illuminate\Config\Repository $config */
$config = $this->app->make('config');
$this->app->singleton('Intervention\\Image\\ImageManager', function (Application $app) {
return new ImageManager(array('driver' => $app->config->get('imager::driver', 'gd')));
});
$this->app->bind('TippingCanoe\\Imager\\Repository\\Image', 'TippingCanoe\\Imager\\Repository\\DbImage');
$this->app->singleton('TippingCanoe\\Imager\\Service', function (Application $app) use($config) {
//
// Amazon S3
//
if ($s3Config = $config->get('imager::s3')) {
$this->app->bind('Aws\\S3\\S3Client', function (Application $app) use($s3Config) {
return \Aws\S3\S3Client::factory($s3Config);
});
}
// Run through and call each config option as a setter on the storage method.
$storageDrivers = [];
foreach ($config->get('imager::storage', []) as $abstract => $driverConfig) {
/** @var \TippingCanoe\Imager\Storage\Driver $driver */
$driver = $app->make($abstract);
foreach ($driverConfig as $property => $value) {
$setter = studly_case('set_' . $property);
$driver->{$setter}($value);
}
$storageDrivers[$abstract] = $driver;
}
$service = new Service($app->make('TippingCanoe\\Imager\\Repository\\Image'), $app->make('Intervention\\Image\\ImageManager'), $app, $storageDrivers);
return $service;
});
}
示例9: camel_case
function camel_case($value)
{
if (isset($camelCache[$value])) {
return $camelCache[$value];
}
return $camelCache[$value] = lcfirst(studly_case($value));
}
示例10: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->container['slug'] = strtolower($this->argument('slug'));
$this->container['namespace'] = studly_case($this->container['slug']);
$this->container['modelName'] = studly_case($this->argument('model'));
$this->container['tableName'] = $this->container['slug'] . '_' . strtolower($this->container['modelName']);
$this->container['className'] = studly_case($this->container['modelName']);
if ($this->module->exists($this->container['slug'])) {
$filename = $this->getDestinationFile();
$dir = pathinfo($filename, PATHINFO_DIRNAME);
if (!is_dir($dir)) {
mkdir($dir, 0777, true);
$this->line("<info>Created missing directory:</info> {$dir}");
}
if (file_exists($filename)) {
$this->line('File already exist.');
if ($this->confirm('Do you want to overwrite the file? [y|N]')) {
$this->createFile();
} else {
return $this->info('File not overwritten.');
}
} else {
$this->createFile();
}
return $this->line("<info>Created model for module:</info> {$filename}");
}
return $this->error('Module does not exist.');
}
示例11: 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();
}
示例12: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$name = $this->argument('name');
$studly_name = studly_case($name);
$component_name = strtolower(substr($studly_name, 0, 1)) . substr($studly_name, 1);
$html = file_get_contents(__DIR__ . '/Stubs/AngularComponent/component.html.stub');
$js = file_get_contents(__DIR__ . '/Stubs/AngularComponent/component.js.stub');
$less = file_get_contents(__DIR__ . '/Stubs/AngularComponent/component.less.stub');
$js = str_replace('{{StudlyName}}', $studly_name, $js);
$js = str_replace('{{name}}', $name, $js);
$js = str_replace('{{componentName}}', $component_name, $js);
$folder = base_path(config('generators.source.root')) . '/' . config('generators.source.components') . '/' . $name;
if (is_dir($folder)) {
$this->info('Folder already exists');
return false;
}
//create folder
File::makeDirectory($folder, 0775, true);
//create view (.component.html)
File::put($folder . '/' . $name . config('generators.prefix.componentView'), $html);
//create component (.component.js)
File::put($folder . '/' . $name . config('generators.prefix.component'), $js);
//create less file (.less)
File::put($folder . '/' . $name . '.less', $less);
$this->info('Component created successfully.');
}
示例13: mutateExtensionAttribute
/**
* Mutates and stores an attribute in array
*
* @param string $key
* @param string $type
* @return mixed
*/
protected function mutateExtensionAttribute($key, $type)
{
$value = $this->getAttributeFromArray($key);
$mutation = $this->{'make' . studly_case($type) . 'TypeMutation'}($value);
$this->mutations[$key] = $mutation;
return $mutation;
}
示例14: generate
protected function generate($type)
{
switch ($type) {
case 'controller':
$filename = studly_case(class_basename($this->getNameInput()) . ucfirst($type));
break;
case 'model':
$filename = studly_case(class_basename($this->getNameInput()));
break;
case 'view':
$filename = 'index.blade';
break;
case 'translation':
$filename = 'example';
break;
case 'routes':
$filename = 'routes';
break;
}
// $suffix = ($type == 'controller') ? ucfirst($type) : '';
$folder = $type != 'routes' ? ucfirst($type) . 's\\' . ($type === 'translation' ? 'en\\' : '') : '';
$name = $this->parseName('Modules\\' . $this->getNameInput() . '\\' . $folder . $filename);
if ($this->files->exists($path = $this->getPath($name))) {
return $this->error($this->type . ' already exists!');
}
$this->currentStub = __DIR__ . '/stubs/' . $type . '.stub';
$this->makeDirectory($path);
$this->files->put($path, $this->buildClass($name));
}
示例15: makeGroup
/**
* Simplify the process of routes registration
*
* @param Router $router
* @param $name
*/
protected function makeGroup(Router $router, $name)
{
$groupOpts = ['namespace' => $this->namespace . '\\' . studly_case($name), 'prefix' => $name, 'middleware' => ['web']];
$router->group($groupOpts, function ($router) use($name) {
require app_path('Http/routes/' . $name . '.php');
});
}