本文整理汇总了PHP中str_singular函数的典型用法代码示例。如果您正苦于以下问题:PHP str_singular函数的具体用法?PHP str_singular怎么用?PHP str_singular使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_singular函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: replaceClass
protected function replaceClass($stub, $name)
{
$stub = parent::replaceClass($stub, $name);
$noControllerName = str_replace('Controller', '', $this->getNameInput());
$dummyRoute = config('administr.prefix') . '.' . str_plural(strtolower(snake_case($noControllerName, '-')));
$stub = str_replace('dummyroute', $dummyRoute, $stub);
$appNamespace = $this->getLaravel()->getNamespace();
$dummyModel = str_singular($noControllerName);
$dummyModelNamespaced = $appNamespace . 'Models\\' . $dummyModel;
$stub = str_replace('DummyModelNamespaced', $dummyModelNamespaced, $stub);
$stub = str_replace('DummyModel', $dummyModel, $stub);
$dummyForm = str_singular($noControllerName) . 'Form';
$dummyFormNamespaced = $appNamespace . 'Http\\Forms\\' . $dummyForm;
$stub = str_replace('DummyFormNamespaced', $dummyFormNamespaced, $stub);
$stub = str_replace('DummyForm', $dummyForm, $stub);
$dummyListView = str_plural($noControllerName) . 'ListView';
$dummyListViewNamespaced = $appNamespace . 'Http\\ListViews\\' . $dummyListView;
$stub = str_replace('DummyListViewNamespaced', $dummyListViewNamespaced, $stub);
$stub = str_replace('DummyListView', $dummyListView, $stub);
$viewPath = config('administr.viewPath');
if (strlen($viewPath) > 0) {
$viewPath .= '.';
}
$dummyView = $viewPath . str_plural(snake_case(class_basename($noControllerName), '-'));
$stub = str_replace('dummyview', $dummyView, $stub);
return $stub;
}
开发者ID:administrcms,项目名称:administr,代码行数:27,代码来源:MakeAdminController.php
示例2: __construct
/**
* Constructor function
*
* @param string $type
* @param array $items
*/
public function __construct($type, $singular = '', $items = array(), $modelClassName)
{
$this->entity = $type;
$this->entity_singular = $singular ?: str_singular($type);
$this->setItems($items);
$this->modelClassName = $modelClassName;
}
开发者ID:ExplodingCabbage,项目名称:xero,代码行数:13,代码来源:Collection.php
示例3: buildClassContents
/**
* Get contents for base.stub
*
* @author Verron Knowles <[email protected]>
* @return string
*/
protected function buildClassContents($name, $stub_data)
{
$table_name = $this->getTableName($name);
$simple_name = str_singular($table_name);
$proper_name = $this->getProperName($simple_name);
$model_name = $this->input->getOption('model');
// Setup fillable namespace
$fillable = array();
foreach ($stub_data as $stubname => $column) {
if (empty(strpos($stubname, '&'))) {
if (!in_array($column['name'], $this->ignore_items, $column['name'])) {
$column_name = $column['name'];
$fillable[] = "\"{$column_name}\"";
}
}
}
$fillable = implode(",", $fillable);
$stub_contents = "";
foreach ($this->stub_names as $view) {
$stub_location = $this->getStubDirectory() . "{$view}.stub";
if ($this->files->isFile($stub_location)) {
$stub_contents .= file_get_contents($stub_location) . "\n";
}
}
// Build replacement tags
$replacements = compact('proper_name', 'simple_name', 'model_name', 'table_name', 'fillable');
$this->replaceTag($stub_contents, $replacements);
return $stub_contents;
}
开发者ID:develme,项目名称:schema-wireframe,代码行数:35,代码来源:ControllerMakeCommand.php
示例4: singular
/**
* Create a singular version of this name. Allows us to override
* any names that str_singular doesn't do correctly.
*
* @param string $name
* @return string
*/
protected function singular($name)
{
if ($name == "menus") {
return "menu";
}
return str_singular($name);
}
开发者ID:codesleeve,项目名称:platform-core,代码行数:14,代码来源:Breadcrumbs.php
示例5: goToView
public function goToView($route, $parentAssociation, $additionalAssigns, $content)
{
$route_array = explode('.', $route);
if (count($route_array) == 2) {
$parent = $route_array[0];
$action = $route_array[1];
$controller = $parent;
} elseif (count($route_array) == 3) {
$parent = $route_array[0];
$child = $route_array[1];
$action = $route_array[2];
$controller = $child;
} else {
throw new InvalidArgumentException("{$route} is not in correct format");
}
$assignStr = str_singular($controller);
$assigns = array($assignStr => $content);
if (!null_or_empty($parentAssociation)) {
$assigns = array_merge($assigns, $parentAssociation);
}
if (!null_or_empty($additionalAssigns)) {
$assigns = array_merge($assigns, $additionalAssigns);
}
return $this->view->make($controller . "." . $action, $assigns);
}
开发者ID:indatus,项目名称:ranger,代码行数:25,代码来源:ViewManager.php
示例6: create
/**
* Show the form for creating a new resource.
* GET /model/create
*
* @return Response
*/
public function create()
{
$model_class = $this->config->get('entrust.' . str_singular($this->resource));
$model = new $model_class();
$relations = $this->relation->lists('name', 'id');
return view('entrust-gui::' . $this->resource . '.create', compact('model', 'relations'));
}
开发者ID:decalages,项目名称:ct-base,代码行数:13,代码来源:ManyToManyController.php
示例7: addInclude
/**
* Add include to the construct method
*
* @param $stub
* @param $include
* @return $this
*/
private function addInclude(&$stub, $include)
{
$stub = str_replace('DummyIncludeCamel', camel_case($include), $stub);
$stub = str_replace('DummyIncludeStudly', studly_case($include), $stub);
$stub = str_replace('DummyIncludeSingleStudly', studly_case(str_singular($include)), $stub);
return $this;
}
开发者ID:ralphowino,项目名称:restful-api-helper,代码行数:14,代码来源:IncludeBuilder.php
示例8: testStrings
public function testStrings()
{
$this->assertTrue(str_singular('match') == 'match');
$this->assertTrue(str_singular('matches') == 'match');
$this->assertTrue(str_plural('matches') == 'matches');
$this->assertTrue(str_plural('match') == 'matches');
}
开发者ID:hyhyxu,项目名称:hook,代码行数:7,代码来源:StrTest.php
示例9: handle
/**
* Handle the command.
*
*/
public function handle()
{
$module = $this->module;
$stream = $this->stream;
$assignment = $this->assignment;
$destination = $module->getPath();
$entity = __DIR__ . '/../../resources/stubs/entity';
$source = $entity . '/code/{{namespace|studly_case}}/';
/* get the field config params from build.php */
$fieldConfig = _getFieldConfig($module, $stream->getNamespace(), $assignment->getFieldSlug());
/* protect module classes from being overwriten */
$this->files->setAvoidOverwrite(_config('builder.avoid_overwrite', $module));
/* get the template data */
$data = ['config' => _config('builder', $module), 'field_slug' => $assignment->getFieldSlug(), 'vendor' => $module->getVendor(), 'module_slug' => $module->getSlug(), 'namespace' => $stream->getNamespace(), 'stream_slug' => $stream->getSlug(), 'entity_name' => studly_case(str_singular($stream->getSlug())), 'column_template' => $fieldConfig['column_template']];
$entityDest = $destination . '/src/' . (_config('builder.group', $module) ? $data['namespace'] . '/' : '') . $data['entity_name'];
/* get the assigned class name, i.e. TextFieldType */
$fieldTypeClassName = _getFieldTypeClassName($assignment);
/* (1) process the form builder class */
if (!$fieldConfig['hide_field']) {
$this->processFormBuilder($entityDest . '/Form/' . $data['entity_name'] . 'FormBuilder.php', $entity . '/templates/field/form/', $fieldTypeClassName, $data);
}
/* (2) process the table column class */
if (!$fieldConfig['hide_column']) {
$this->processTableColumns($entityDest . '/Table/' . $data['entity_name'] . 'TableColumns.php', $entity . '/templates/field/table/' . ($data['column_template'] ? 'template/' : ''), $fieldTypeClassName, $data);
}
/* (3) process the field language file */
$this->processFile($destination . '/resources/lang/en/field.php', [$data['field_slug'] => $entity . '/templates/module/field.php'], $data);
}
开发者ID:websemantics,项目名称:entity_builder-extension,代码行数:32,代码来源:ModifyEntity.php
示例10: handle
public function handle()
{
$name = trim($this->argument('name'));
$nameSingular = str_singular($name);
$status = 0;
$controllerCmdArgs = ['name' => "{$name}Controller"];
if ($this->option('translated')) {
$controllerCmdArgs['--translated'] = true;
}
$status = $this->call('administr:controller', $controllerCmdArgs);
$status = $this->call('administr:form', ['name' => "{$nameSingular}Form"]);
$modelCmdArgs = ['name' => $nameSingular];
if ($this->option('translated')) {
$modelCmdArgs['--translated'] = true;
}
$status = $this->call('administr:model', $modelCmdArgs);
$status = $this->call('administr:listview', ['name' => "{$name}ListView"]);
$status = $this->call('make:seed', ['name' => "{$name}Seeder"]);
$table = str_plural(snake_case(class_basename($name)));
$status = $this->call('make:migration', ['name' => "create_{$table}_table", '--create' => $table]);
if ($status !== 0) {
$this->error('Some of the commands were not executed successfuly.');
}
$this->info('Admin scaffold generated!');
}
开发者ID:administrcms,项目名称:administr,代码行数:25,代码来源:MakeAdmin.php
示例11: rollback
public function rollback($entity, $id)
{
$modelString = 'Yab\\Quarx\\Models\\' . ucfirst($entity);
if (!class_exists($modelString)) {
$modelString = 'Yab\\Quarx\\Models\\' . ucfirst($entity) . 's';
}
if (!class_exists($modelString)) {
$modelString = 'Quarx\\Modules\\' . ucfirst(str_plural($entity)) . '.\\Models\\' . ucfirst(str_plural($entity));
}
if (!class_exists($modelString)) {
$modelString = 'Quarx\\Modules\\' . ucfirst(str_plural($entity)) . '\\Models\\' . ucfirst(str_singular($entity));
}
if (!class_exists($modelString)) {
$modelString = 'Quarx\\Modules\\' . ucfirst(str_singular($entity)) . '\\Models\\' . ucfirst(str_singular($entity));
}
if (!class_exists($modelString)) {
Quarx::notification('Could not rollback Model not found', 'warning');
return redirect(URL::previous());
}
$model = new $modelString();
$modelInstance = $model->find($id);
$archive = Archive::where('entity_id', $id)->where('entity_type', $modelString)->limit(1)->offset(1)->orderBy('id', 'desc')->first();
if (!$archive) {
Quarx::notification('Could not rollback', 'warning');
return redirect(URL::previous());
}
$archiveData = (array) json_decode($archive->entity_data);
$modelInstance->fill($archiveData);
$modelInstance->save();
Quarx::notification('Rollback was successful', 'success');
return redirect(URL::previous());
}
开发者ID:YABhq,项目名称:Quarx,代码行数:32,代码来源:QuarxFeatureController.php
示例12: getMainArea
/**
* Gets model names for the main navigation
*
* @return array
*/
public function getMainArea($currentArea)
{
$mainArea = '';
$currentArea = str_singular($currentArea);
foreach (config('admin.navigation_tree') as $parent) {
if (!$parent['children']) {
if ($currentArea == $parent['name']) {
$mainArea = $parent['name'];
}
} else {
foreach ($parent['children'] as $child) {
if (!$child['children']) {
if ($currentArea == $child['name']) {
$mainArea = $parent['name'];
}
} else {
foreach ($child['children'] as $grandchild) {
if ($currentArea == $grandchild['name']) {
$mainArea = $parent['name'];
}
}
}
}
}
}
return $mainArea;
}
开发者ID:manogi,项目名称:gfw-qm,代码行数:32,代码来源:EloquentAdminRepository.php
示例13: getModelName
/**
* Get the class name for the Eloquent model generator.
*
* @return string
*/
protected function getModelName()
{
if ($this->option('model')) {
return trim($this->option('model'));
}
return ucwords(str_singular(camel_case($this->meta['table'])));
}
开发者ID:ralphowino,项目名称:restful-api-helper,代码行数:12,代码来源:StarterMigrationCommand.php
示例14: handle
/**
* Handle the command.
*
*/
public function handle()
{
$stream = $this->stream;
$module = $this->module;
$entityPath = __DIR__ . '/../../resources/stubs/entity';
$modulePath = __DIR__ . '/../../resources/stubs/module';
$dest = $module->getPath();
/* seed file path for this entity */
$seedFile = "{$dest}/resources/seeders/" . strtolower(str_singular($stream->getSlug())) . ".php";
$data = ['config' => _config('builder', $module), 'vendor' => $module->getVendor(), 'namespace' => $stream->getNamespace(), 'module_slug' => $module->getSlug(), 'stream_slug' => $stream->getSlug(), 'entity_name' => studly_case(str_singular($stream->getSlug())), 'seeder_data' => file_exists($seedFile) ? file_get_contents($seedFile) : ''];
$moduleName = studly_case($data['module_slug']);
/* protect module classes from being overwriten */
$this->files->setAvoidOverwrite(_config('builder.avoid_overwrite', $module));
/* initially, copy the entity template files to the module src folder */
if (_config('builder.group', $module)) {
$this->files->parseDirectory($entityPath . "/code/", "{$dest}/src", $data);
} else {
$this->files->parseDirectory($entityPath . "/code/{{namespace|studly_case}}/", "{$dest}/src", $data);
$this->files->parseDirectory($entityPath . "/code/Http", "{$dest}/src/Http", $data);
}
/* create an empty seeder if it does not exist */
$this->put("{$dest}/resources/seeders/" . strtolower($data['entity_name']) . '.php', '', true);
try {
/* stitch the entity with the module classes */
$this->processFile("{$dest}/src/{$moduleName}" . 'ModuleServiceProvider.php', ['routes' => $entityPath . '/templates/module/routes.php', 'bindings' => $entityPath . '/templates/module/bindings.php', 'singletons' => $entityPath . '/templates/module/singletons.php'], $data);
$this->processFile("{$dest}/src/{$moduleName}" . 'Module.php', ['sections' => $entityPath . '/templates/module/sections.php'], $data);
$this->processFile("{$dest}/src/{$moduleName}" . 'ModuleSeeder.php', ['seeders' => $entityPath . '/templates/module/seeding.php'], $data);
$this->processFile("{$dest}/resources/lang/en/section.php", [strtolower(str_plural($data['entity_name'])) => $entityPath . '/templates/module/section.php'], $data);
$this->processFile("{$dest}/resources/config/permissions.php", [$data['stream_slug'] => $entityPath . '/templates/module/permissions.php'], $data);
$this->processFile("{$dest}/resources/lang/en/stream.php", [$data['stream_slug'] => $entityPath . '/templates/module/stream.php'], $data);
$this->processFile("{$dest}/resources/lang/en/permission.php", [$data['stream_slug'] => $entityPath . '/templates/module/permission.php'], $data);
} catch (\PhpParser\Error $e) {
die($e->getMessage());
}
}
开发者ID:websemantics,项目名称:entity_builder-extension,代码行数:39,代码来源:GenerateEntity.php
示例15: __construct
public function __construct()
{
//$this->beforeFilter(function(){ });
$this->uriSegment = null;
$this->modelName = null;
$this->viewsPath = null;
$this->resourceId = null;
if (Route::input('alias') !== null) {
$this->uriSegment = Route::input('alias');
$this->viewsPath = File::exists(app_path('views/' . Config::get('reactiveadmin::uri') . '/' . $this->uriSegment)) ? Config::get('reactiveadmin::uri') . '.' . $this->uriSegment : 'reactiveadmin::default';
$this->modelName = studly_case(str_singular(Route::input('alias')));
$this->modelWrapper = App::make('model_wrapper');
$this->modelWrapper->model($this->modelName);
if (Route::input('id') !== null) {
$this->resourceId = Route::input('id');
}
View::share('config', $this->modelWrapper->getConfig());
// TODO: refactor this!
// custom behavior
switch ($this->uriSegment) {
case 'settings':
View::composer(array('admin.' . $this->viewsPath . '.index'), function ($view) {
$view->with('settings', Settings::all());
});
break;
default:
# code...
break;
}
}
View::share('view', $this->uriSegment);
View::share('model', $this->modelName);
}
开发者ID:verticalhorizon,项目名称:reactiveadmin,代码行数:33,代码来源:AdminController.php
示例16: assertRelationship
public function assertRelationship($relationship, $class, $type)
{
$this->assertRespondsTo($relationship, $class);
$class = Mockery::mock($class . "[{$type}]");
$class->shouldReceive($type)->with('/' . str_singular($relationship) . '/i')->once();
$class->{$relationship}();
}
开发者ID:rosskmurphy,项目名称:Laravel-4-login-registration,代码行数:7,代码来源:ModelHelpers.php
示例17: parse
public function parse($source)
{
if ($this->parent->configHas('data')) {
$data = $this->parent->getConfig('data');
foreach ($data as $accessor) {
$classAccessor = $this->getClassAccessor($accessor);
$classMethod = $this->getClassMethod($accessor);
$classMethodId = $this->getClassMethodId($accessor);
if (isset($this->classes[$classAccessor])) {
$class = $this->classes[$classAccessor];
if (!is_null($classMethodId)) {
if (starts_with($classMethodId, '#')) {
$id = $this->realNumber($classMethodId);
} else {
$id = $classMethodId;
}
$dataObject = $class->{$classMethod}($id);
$this->parent->setAttribute(str_singular($classAccessor), $dataObject);
} else {
$dataObject = $class->{$classMethod}();
$this->parent->setAttribute($classAccessor, $dataObject);
}
} else {
throw new \Exception("Unknown data accessor: {$accessor}.");
}
}
}
return $source;
}
开发者ID:siipis,项目名称:cms,代码行数:29,代码来源:DataParser.php
示例18: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$name = $this->argument('name');
$view = $name;
// items
$request = str_singular(ucwords(camel_case($name))) . 'Request.php';
// ItemRequest.php
$model = str_singular(ucwords(camel_case($name))) . '.php';
// Item.php;
$presenter = str_singular(ucwords(camel_case($name))) . 'Presenter.php';
// ItemPresenter.php;
$controller = ucwords(camel_case($name)) . 'Controller.php';
// ItemsController.php
$seed = ucwords(camel_case($name)) . 'TableSeeder.php';
// ItemsTableSeeder.php
$views = base_path('resources/views/' . $view);
$request = base_path('app/Http/Requests/' . $request);
$model = base_path('app/Models/' . $model);
$presenter = base_path('app/Presenters/' . $presenter);
$controller = base_path('app/Http/Controllers/' . $controller);
$seed = base_path('database/seeds/' . $seed);
$this->files->delete([$request, $model, $presenter, $controller, $seed]);
$this->files->deleteDirectory($views);
$this->info('Delete ' . $views);
$this->info('Delete ' . $request);
$this->info('Delete ' . $model);
$this->info('Delete ' . $presenter);
$this->info('Delete ' . $controller);
$this->info('Delete ' . $seed);
$this->info('Dont forget to delete migration file and route');
}
开发者ID:OmarMakled,项目名称:Scaffold,代码行数:36,代码来源:ScaffoldDeleteCommand.php
示例19: setUpModel
protected function setUpModel(\Illuminate\Http\Request $request)
{
$uri = $request->route()->uri();
$modelSlug = strpos($uri, '/') ? substr($uri, 0, strpos($uri, '/')) : $uri;
$modelName = ucfirst(camel_case(str_singular($modelSlug)));
$modules = new \Ormic\Modules();
$module = $modules->getModuleOfModel($modelName);
if ($module) {
$modelClass = 'Ormic\\modules\\' . $module . '\\Model\\' . $modelName;
$viewName = snake_case($module) . '::' . snake_case($modelName) . '.' . $this->currentAction;
} else {
$modelClass = 'Ormic\\Model\\' . $modelName;
$viewName = snake_case($modelName) . '.' . $this->currentAction;
}
$this->model = new $modelClass();
$this->model->setUser($this->user);
try {
$this->view = view($viewName);
} catch (\InvalidArgumentException $ex) {
try {
$this->view = view('models.' . $this->currentAction);
} catch (\InvalidArgumentException $ex) {
// Still no view; give up.
$this->view = view();
}
}
$this->view->title = ucwords(str_replace('-', ' ', $modelSlug));
$this->view->modelSlug = $modelSlug;
$this->view->columns = $this->model->getColumns();
$this->view->record = $this->model;
}
开发者ID:samwilson,项目名称:ormic,代码行数:31,代码来源:ModelsController.php
示例20: 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());
}
}
开发者ID:websemantics,项目名称:entity_builder-extension,代码行数:33,代码来源:ModifyModule.php
注:本文中的str_singular函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论