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


PHP Support\Pluralizer类代码示例

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


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

示例1: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $originalName = $this->argument('feature');
     $feature = Pluralizer::plural(ucfirst($this->argument('feature')));
     $path = $this->option('path');
     $namespace = ucfirst($this->option('namespace'));
     $controllerPath = $path . '/' . $feature . '/Controllers';
     $modelPath = $path . '/' . $feature . '/Models';
     $providersPath = $path . '/' . $feature . '/Providers';
     $repositoriesPath = $path . '/' . $feature . '/Repositories';
     $this->info('Creating the feature: ' . $feature);
     $this->info('On the path: ' . $path);
     if ($this->confirm('Do you wish to continue? [yes|no]')) {
         $this->info('Creating folders');
         // Creating directories
         $this->createDirectories($path, $feature, $controllerPath, $modelPath, $providersPath, $repositoriesPath);
         $this->file->put($path . '/' . $feature . '/routes.php', '');
         // Create files
         $this->info('Creating controller');
         $controller = new ControllerGenerator($this->file);
         $this->printResult($controller->make($controllerPath . '/' . $feature . 'Controller.php', $namespace), $controllerPath . '/' . $feature . 'Controller.php');
         $this->info('Creating interface');
         $interface = new InterfaceGenerator($this->file);
         $this->printResult($interface->make($repositoriesPath . '/' . ucfirst($originalName) . 'Interface.php', $namespace), $repositoriesPath . '/' . ucfirst($originalName) . 'Interface.php');
         $this->info('Creating repository');
         $repository = new RepositoryGenerator($this->file);
         $this->printResult($repository->make($repositoriesPath . '/' . ucfirst($originalName) . 'Repository.php', $namespace), $repositoriesPath . '/' . ucfirst($originalName) . 'Repository.php');
         $this->info('Creating model');
         $model = new ModelGenerator($this->file);
         $this->printResult($model->make($modelPath . '/' . ucfirst($originalName) . '.php', $namespace), $modelPath . '/' . ucfirst($originalName) . '.php');
         $this->info('Creating service provider');
         $provider = new ProviderGenerator($this->file);
         $this->printResult($provider->make($providersPath . '/' . $feature . 'ServiceProvider.php', $namespace), $providersPath . '/' . $feature . 'ServiceProvider.php');
     }
 }
开发者ID:aindong,项目名称:custom-generator,代码行数:40,代码来源:GenerateFeature.php

示例2: getTemplate

 /**
  * Fetch the compiled template for a seed
  *
  * @param  string $template Path to template
  * @param  string $className
  *
  * @return string Compiled template
  */
 protected function getTemplate($template, $className)
 {
     $this->template = $this->file->get($template);
     $name = Pluralizer::singular(str_replace('TableSeeder', '', $className));
     $modelVars = GeneratorsServiceProvider::getModelVars($name);
     $this->template = str_replace('{{className}}', $className, $this->template);
     $template = GeneratorsServiceProvider::replaceModelVars($this->template, $modelVars);
     return $this->replaceStandardParams($template);
 }
开发者ID:vsch,项目名称:generators,代码行数:17,代码来源:SeedGenerator.php

示例3: generate

 public function generate($path, $name)
 {
     $singular = Pluralizer::singular($name);
     $plural = Pluralizer::plural($name);
     $segments = explode('/', $path);
     $module_dir = array_pop($segments);
     return new Collection(['model' => new BackboneComponent($path . '/' . $plural . '/models/' . $name . '.js', $module_dir . '/' . $plural . '/models/' . $name, ucfirst($singular)), 'view' => new BackboneComponent($path . '/' . $plural . '/views/' . $singular . '_view.js', $module_dir . '/' . $plural . '/views/' . $singular . '_view', ucfirst($singular) . 'View'), 'collection' => new BackboneComponent($path . '/' . $plural . '/collections/' . $plural . '.js', $module_dir . '/' . $plural . '/collections/' . $plural, ucfirst($singular) . 'Collection'), 'index' => new BackboneComponent($path . '/' . $plural . '/index.js', $module_dir . '/' . $plural . '/index', 'Index')]);
     return new Collection($ret);
 }
开发者ID:mindofmicah,项目名称:backbone-module-command,代码行数:9,代码来源:BackboneComponentGenerator.php

示例4: setApiName

 public function setApiName($name)
 {
     $this->_api_name = Pluralizer::singular($name);
     $this->_collection_name = Str::studly(Str::singular(Str::slug($this->_api_name, " ")));
     if (!class_exists("AndrewLamers\\Chargify\\" . $this->_collection_name)) {
         eval("namespace Andrewlamers\\Chargify; class " . $this->_collection_name . " extends \\Andrewlamers\\Chargify\\Fluent {}");
     }
     $this->_collection_name = "Andrewlamers\\Chargify\\" . $this->_collection_name;
 }
开发者ID:andrewlamers,项目名称:chargify-php-sdk,代码行数:9,代码来源:Chargify.php

示例5: __construct

 public function __construct($modelName, $tableName)
 {
     // Set the given table name, or plularize the model name if
     // not given
     if (!$tableName) {
         $this->tableName = strtolower(Pluralizer::plural($modelName));
     } else {
         $this->tableName = $tableName;
     }
 }
开发者ID:hilmysyarif,项目名称:l4-bootstrap-admin,代码行数:10,代码来源:Migration.php

示例6: formatTree

 private function formatTree(SimpleXMLElement $xml, array $serialized, SimpleXMLElement $rootNode = null, $parentName = null, SimpleXMLElement $parentNode = null)
 {
     foreach ($serialized as $key => $value) {
         if (is_array($value)) {
             // Branch
             if (count($value) === 0) {
                 // Empty array
                 $child = $xml->addChild($key);
                 $child->addAttribute("array", null);
             } else {
                 if (is_numeric($key)) {
                     // Numeric in array, singularize
                     $key = Pluralizer::singular($parentName);
                     if (!isset($parentNode["array"])) {
                         $parentNode->addAttribute("array", $key);
                     }
                 }
                 $child = $xml->addChild($key);
                 $this->formatTree($child, $value, $rootNode, $key, $child);
             }
         } else {
             // Leaf
             if ($key === "_ref") {
                 // Ref
                 $parentNode->addAttribute("ref", $value);
             } elseif ($key === "_id") {
                 // Id
                 if (!is_null($parentNode)) {
                     $parentNode->addAttribute("id", $value);
                 } else {
                     $rootNode->addAttribute("id", $value);
                 }
             } elseif (is_null($value)) {
                 // If value is null, denote it in the attribute
                 $child = $xml->addChild($key);
                 $child->addAttribute("scalar", "null");
             } elseif (is_int($value)) {
                 // If value is int, denote it in the attribute
                 $child = $xml->addChild($key, $value);
                 $child->addAttribute("scalar", "integer");
             } elseif (is_float($value)) {
                 // If value is float, denote it in the attribute
                 $child = $xml->addChild($key, $value);
                 $child->addAttribute("scalar", "float");
             } elseif (is_bool($value)) {
                 // If value is boolean, denote it in the attribute
                 $child = $xml->addChild($key, $value ? 1 : 0);
                 $child->addAttribute("scalar", "boolean");
             } else {
                 // Value
                 $xml->addChild($key, $value);
             }
         }
     }
 }
开发者ID:prewk,项目名称:seriplating,代码行数:55,代码来源:XmlFormatter.php

示例7: resolve

 /**
  * @inheritdoc
  */
 public function resolve($what)
 {
     if (class_exists($what)) {
         return $what;
     }
     $resolvable = method_exists($this, 'resolvable') ? $this->resolvable() : $this;
     $reflection = new ReflectionClass($resolvable);
     $suffix = ucfirst($what);
     $namespace = Pluralizer::plural($suffix);
     $fqcn = join('\\', [preg_replace('#Models?\\\\#', '', $reflection->getNamespaceName()), $namespace, $reflection->getShortName() . $suffix]);
     return $fqcn;
 }
开发者ID:deefour,项目名称:producer,代码行数:15,代码来源:ResolvesProducibles.php

示例8: getScaffoldedController

 /**
  * Get template for a scaffold
  *
  * @param  string $template Path to template
  * @param  string $name
  * @return string
  */
 protected function getScaffoldedController($template, $name)
 {
     $collection = strtolower(str_replace('Controller', '', $name));
     // dogs
     $modelInstance = Pluralizer::singular($collection);
     // dog
     $modelClass = ucwords($modelInstance);
     // Dog
     foreach (array('modelInstance', 'modelClass', 'collection') as $var) {
         $this->template = str_replace('{{' . $var . '}}', ${$var}, $this->template);
     }
     return $this->template;
 }
开发者ID:rosskmurphy,项目名称:Laravel-4-login-registration,代码行数:20,代码来源:ControllerGenerator.php

示例9: getScaffoldedController

 /**
  * Get template for a scaffold
  *
  * @param  string $template Path to template
  * @param  string $name
  * @return string
  */
 protected function getScaffoldedController($template, $className)
 {
     $model = $this->cache->getModelName();
     // post
     $models = Pluralizer::plural($model);
     // posts
     $Models = ucwords($models);
     // Posts
     $Model = Pluralizer::singular($Models);
     // Post
     foreach (array('model', 'models', 'Models', 'Model', 'className') as $var) {
         $this->template = str_replace('{{' . $var . '}}', ${$var}, $this->template);
     }
     return $this->template;
 }
开发者ID:samplex,项目名称:shorturl,代码行数:22,代码来源:ControllerGenerator.php

示例10: getTemplate

 public function getTemplate($name, $namespace)
 {
     $path = __DIR__ . '/templates/model.txt';
     $this->template = $this->file->get($path);
     // Prepare strings to be placed on the template
     $singular = Pluralizer::singular(ucfirst($name));
     $singularLower = strtolower($singular);
     $plural = Pluralizer::plural(ucfirst($name));
     // Replace
     $this->template = str_replace('{{namespace}}', $namespace, $this->template);
     $this->template = str_replace('{{singular}}', $singular, $this->template);
     $this->template = str_replace('{{plural}}', $plural, $this->template);
     $this->template = str_replace('{{singularLower}}', $singularLower, $this->template);
     return $this->template;
 }
开发者ID:aindong,项目名称:custom-generator,代码行数:15,代码来源:ModelGenerator.php

示例11: parseResourceName

 /**
  * Parse the resource name from the called method.
  *
  * @param  string  $method
  * @return string
  */
 protected function parseResourceName($method)
 {
     // Here we check if the method is returned with
     // a different resource name.
     if (array_key_exists($method, $this->resourceResponseNames)) {
         return $this->resourceResponseNames[$method];
     }
     $plural = strtolower(str_replace($this->trimable, null, $method));
     // Here we check if the method is returned with
     // a plural resource name.
     if (in_array($plural, $this->pluralResponseNames)) {
         return $plural;
     }
     // Lastly we create a singular resource name.
     return Pluralizer::singular($plural);
 }
开发者ID:pcextreme,项目名称:cloudstack-client,代码行数:22,代码来源:CloudstackProcessor.php

示例12: getTemplate

 /**
  * Fetch the compiled template for a model
  *
  * @param  string $template Path to template
  * @param  string $className
  *
  * @return string Compiled template
  */
 protected function getTemplate($template, $className)
 {
     $this->template = $this->file->get($template);
     $relationModelList = GeneratorsServiceProvider::getRelationsModelVarsList(GeneratorsServiceProvider::splitFields($this->cache->getFields(), true));
     // Replace template vars
     $modelVars = GeneratorsServiceProvider::getModelVars($this->cache->getModelName());
     $this->template = GeneratorsServiceProvider::replaceModelVars($this->template, $modelVars);
     $fields = $this->cache->getFields() ?: [];
     $fields = GeneratorsServiceProvider::splitFields(implode(',', $fields), SCOPED_EXPLODE_WANT_ID_RECORD);
     $this->template = GeneratorsServiceProvider::replaceTemplateLines($this->template, '{{translations:line}}', function ($line, $fieldVar) use($fields, $relationModelList) {
         $fieldTexts = [];
         foreach ($fields + ['id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'] as $field => $type) {
             if (array_key_exists($field, $relationModelList)) {
                 // add the foreign model translation
                 $foreignName = $relationModelList[$field]['dash-model'];
                 $foreignNameText = $relationModelList[$field]['Space Model'];
                 $fieldTexts[] = str_replace($fieldVar, "'{$foreignName}' => '{$foreignNameText}',", $line);
                 if (trim_suffix($field, "_id") !== $foreignName) {
                     $foreignName = trim_suffix($field, "_id");
                     $foreignNameText = GeneratorsServiceProvider::getModelVars($foreignName)['Space Model'];
                     $fieldTexts[] = str_replace($fieldVar, "'{$foreignName}' => '{$foreignNameText}',", $line);
                 }
             }
             if (is_array($type) && ($bitset = hasIt($type, 'bitset', HASIT_WANT_PREFIX | HASIT_WANT_VALUE))) {
                 $params = preg_match('/bitset\\((.*)\\)/', $bitset, $matches) ? $matches[1] : '';
                 if ($params === '') {
                     $params = $field;
                 }
                 $params = explode(',', $params);
                 foreach ($params as $param) {
                     $bitFieldNameText = GeneratorsServiceProvider::getModelVars($param)['Space Model'];
                     $fieldTexts[] = str_replace($fieldVar, "'{$param}' => '{$bitFieldNameText}',", $line);
                 }
             }
             $modelVars = GeneratorsServiceProvider::getModelVars($field);
             $fieldNameTrans = $field !== Pluralizer::plural($field) ? $modelVars['Space Model'] : $modelVars['Space Models'];
             $fieldTexts[] = str_replace($fieldVar, "'{$field}' => '{$fieldNameTrans}',", $line);
         }
         sort($fieldTexts);
         return implode("\n", $fieldTexts) . "\n";
     });
     $this->template = $this->replaceStandardParams($this->template);
     return $this->template;
 }
开发者ID:vsch,项目名称:generators,代码行数:52,代码来源:TranslationsGenerator.php

示例13: createTableMigration

 /**
  * For a given table, generate the migration object with the appropriate
  * parameters
  * @param  string $tableName The name of the table
  * @param  array  $columns   An array of SchemaExtractor Column objects
  */
 private function createTableMigration($tableName, $columns)
 {
     // Get the parsed columns
     $parsedColumns = $this->schemaExtractor->extract($columns, $this->dbType);
     // Get the model name form the table name
     $modelName = ucwords(Pluralizer::singular($tableName));
     // Create a new migration
     $this->migrationList->create($modelName, $tableName);
     // Now, proceed towards adding columns
     foreach ($parsedColumns as $column) {
         $type = $this->getLaravelColumnType($column);
         // For primary keys, we simply set pK
         if ($type == 'increments') {
             $this->migrationList->setPrimaryKey($modelName, $column->name);
             continue;
         }
         $c = array('name' => $column->name, 'type' => $type, 'parameters' => $this->getLaravelColumnParameters($column->parameters, $type), 'default' => is_null($column->defaultValue) ? '' : $column->defaultValue, 'unsigned' => $column->unsigned, 'nullable' => $column->null, 'primary' => $column->index == 'primary', 'unique' => $column->index == 'unique', 'index' => $column->index == 'multicolumn');
         $this->migrationList->addColumn($modelName, $c);
     }
 }
开发者ID:hilmysyarif,项目名称:l4-bootstrap-admin,代码行数:26,代码来源:DbParser.php

示例14: getScaffoldedController

 /**
  * Get template for a scaffold
  *
  * @param  string $template Path to template
  * @param  string $name
  * @return string
  */
 protected function getScaffoldedController($template, $className)
 {
     $model = $this->cache->getModelName();
     // post
     $models = Pluralizer::plural($model);
     // posts
     $Models = ucwords($models);
     // Posts
     $Model = Pluralizer::singular($Models);
     // Post
     $namespace = $this->cache->getValue('namespace');
     $classNamespace = empty($namespace) ? '' : "namespace " . ucwords(str_replace('/', '\\', $namespace)) . ";";
     $multi_key = empty($namespace) ? $models : str_replace('/', '.', $namespace) . ".{$models}";
     $fields = join(",", array_map(function ($f) {
         return "'{$f}'";
     }, array_keys($this->cache->getFields())));
     foreach (array('model', 'models', 'Models', 'Model', 'className', 'multi_key', 'classNamespace', 'fields') as $var) {
         $this->template = str_replace('{{' . $var . '}}', ${$var}, $this->template);
     }
     return $this->template;
 }
开发者ID:amaly,项目名称:laravel-generators,代码行数:28,代码来源:ControllerGenerator.php

示例15: fire

 public function fire()
 {
     if (!class_exists('Way\\Generators\\GeneratorsServiceProvider')) {
         $this->error('Way Generators are not installed! Lapigen needs this package to run!');
     }
     $lowerCase = strtolower($this->argument('name'));
     $capitalFirst = ucfirst($lowerCase);
     $this->line('');
     $this->line('|***************************************************|');
     $this->line('|');
     $this->line('| I choose you LAPIGEN!');
     $this->line('|');
     $this->line('| Generating full API resource!');
     $this->line('|');
     $this->line('|***************************************************|');
     $this->line('');
     $this->line('*** Controller ***');
     $controllerName = Pluralizer::singular($capitalFirst) . 'Controller';
     $this->call('generate:controller', array('name' => $controllerName, '--path' => $this->option('controllerpath'), '--template' => __DIR__ . '/stubs/controller.txt'));
     $this->line('');
     $this->line('*** Route ***');
     $routesFilePath = $routesFilePath = app_path() . '/routes.php';
     $this->setLapiRoute($routesFilePath, $lowerCase, $controllerName);
     $this->line("Updated {$routesFilePath}");
     $this->line('');
     $this->line('*** Model ***');
     $this->call('generate:model', array('name' => Pluralizer::singular($capitalFirst), '--path' => $this->option('modelpath'), '--template' => __DIR__ . '/stubs/model.txt'));
     $this->line('');
     $this->line('*** Seeder ***');
     $this->call('generate:seed', array('name' => Pluralizer::plural($lowerCase), '--path' => $this->option('seedpath')));
     $this->line('');
     $this->line('*** Migration and "artisan optimize" ***');
     $this->call('generate:migration', array('name' => 'create_' . Pluralizer::plural($lowerCase) . '_table', '--path' => $this->option('migrationspath'), '--fields' => $this->option('fields')));
     $this->line('');
     $this->line('|***************************************************|');
     $this->line('|');
     $this->line('| Ready to rumble!');
     $this->line('|');
     $this->line('|***************************************************|');
 }
开发者ID:kyjan,项目名称:lapi,代码行数:40,代码来源:LapigenRessourceCommand.php


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