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


PHP Inflector::classify方法代碼示例

本文整理匯總了PHP中Cake\Utility\Inflector::classify方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::classify方法的具體用法?PHP Inflector::classify怎麽用?PHP Inflector::classify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cake\Utility\Inflector的用法示例。


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

示例1: initialize

 /**
  * {@inheritdoc}
  *
  * @param array $config Strategy's configuration.
  * @return $this
  */
 public function initialize($config)
 {
     $config = parent::initialize($config)->config();
     $assocName = Inflector::pluralize(Inflector::classify($this->_alias));
     $this->_table->belongsTo($assocName, ['className' => $this->modelClass, 'foreignKey' => $config['field'], 'bindingKey' => 'name', 'conditions' => [$assocName . '.prefix' => $config['prefix']]]);
     return $this;
 }
開發者ID:omnuvito,項目名稱:Enum,代碼行數:13,代碼來源:LookupStrategy.php

示例2: getTransformer

 /**
  * Generates instance of the Transformer.
  *
  * The method works with the App::className() method.
  * This means that you can call app-related Transformers like `Books`.
  * Plugin-related Transformers can be called like `Plugin.Books`
  *
  * @param $className
  * @return TransformerAbstract
  * @throws MissingTransformerException
  */
 public function getTransformer($className)
 {
     $transformer = App::className(Inflector::classify($className), 'Transformer', 'Transformer');
     if ($transformer === false) {
         throw new MissingTransformerException(['transformer' => $className]);
     }
     return new $transformer();
 }
開發者ID:cakeplugins,項目名稱:api,代碼行數:19,代碼來源:TransformerAwareTrait.php

示例3: _getLastThreeLikes

 public function _getLastThreeLikes()
 {
     $alias = Inflector::classify($this->source());
     $uid = __LOGGEDINUSERID;
     $like = TableRegistry::get('Social.Likes');
     $_like = $like->find()->where(['Likes.object_id' => $this->id, 'Likes.object' => $alias, 'Fans.id !=' => $uid])->limit(2)->order('Likes.created')->contain(['Fans' => ['fields' => ['id', 'first_name', 'last_name']]]);
     return $_like->toArray();
 }
開發者ID:eripoll,項目名稱:webiplan,代碼行數:8,代碼來源:LikeableTrait.php

示例4: newEntity

 /**
  * Todo: doc bloc
  */
 public function newEntity($data = null, array $options = [])
 {
     if ($data === null && isset($options['gateway'])) {
         $gateway = Inflector::classify($options['gateway']);
         $chargeClass = '\\Payments\\Model\\Entity\\' . $gateway . 'Charge';
         $entity = new $chargeClass([], ['source' => $this->registryAlias()]);
         return $entity;
     }
     return parent::newEntity($data, $options);
 }
開發者ID:gintonicweb,項目名稱:payments,代碼行數:13,代碼來源:ChargesTable.php

示例5: _getLastFiveComments

 public function _getLastFiveComments()
 {
     $alias = Inflector::classify($this->source());
     $comment = TableRegistry::get('Social.Comments');
     $comments = $comment->find()->where(['Comments.object_id' => $this->id, 'Comments.object' => $alias])->limit(__MAX_COMMENTS_LISTED)->order('Comments.created DESC')->contain(['Authors' => ['fields' => ['id', 'first_name', 'last_name', 'avatar']]]);
     // Reorder the Comments by creation order
     // (even though we got them by descending order)
     $collection = new Collection($comments);
     $comments = $collection->sortBy('Comment.created');
     return $comments->toArray();
 }
開發者ID:eripoll,項目名稱:webiplan,代碼行數:11,代碼來源:CommentableTrait.php

示例6: views

 /**
  * Serve Html templates to batman.
  *
  * @return void
  */
 public function views($id)
 {
     $this->autoLayout = false;
     foreach (DashboardWidget::paths() as $path) {
         $path .= Inflector::classify($id) . DS . 'view.ctp';
         if (!file_exists($path)) {
             continue;
         }
         echo file_get_contents($path);
         exit;
     }
 }
開發者ID:gourmet,項目名稱:dashboard,代碼行數:17,代碼來源:DashboardController.php

示例7: __call

 /**
  * Proxies validation method calls to the Respect\Validation\Validator class.
  *
  * The last argument (context) will be sliced off for all methods since they
  * are unaware of it.
  *
  * @param string $method The validation method to call.
  * @param array $arguments The list of arguments to pass to the method.
  * @return bool Whether or not the validation rule passed.
  */
 public function __call($method, $arguments)
 {
     $class = $this->_namespace . '\\' . Inflector::classify($method);
     if (!class_exists($class)) {
         throw new Exception('Undefined iso codes validation method');
     }
     $context = array_pop($arguments);
     if (!is_array($context) || array_keys($context) === $this->_contextKeys) {
         array_push($arguments, $context);
     }
     return call_user_func_array([$class, 'validate'], $arguments);
 }
開發者ID:gourmet,項目名稱:validation,代碼行數:22,代碼來源:IsoCodesProvider.php

示例8: __construct

 /**
  * Make the helper, possibly configuring with CrudData objects
  * 
  * @param \Cake\View\View $View
  * @param array $config An array of CrudData objects
  */
 public function __construct(View $View, array $config = array())
 {
     parent::__construct($View, $config);
     $config += ['_CrudData' => [], 'actions' => []];
     $this->_defaultAlias = new NameConventions(Inflector::pluralize(Inflector::classify($this->request->controller)));
     $this->_CrudData = $config['_CrudData'];
     $this->DecorationSetups = new DecorationFactory($this);
     //		$this->_Field = new Collection();
     foreach ($config['actions'] as $name => $pattern) {
         $this->{$name} = $pattern;
     }
     $this->useCrudData($this->_defaultAlias->name);
 }
開發者ID:OrigamiStructures,項目名稱:CrudViews,代碼行數:19,代碼來源:CrudHelper.php

示例9: initialize

 public function initialize(array $config)
 {
     $this->alias = Inflector::classify($this->_table->alias());
     $this->_table->hasMany('Comments', ['foreignKey' => 'object_id', 'joinType' => 'INNER', 'className' => 'Social.Comments', 'conditions' => ['Comments.object' => $this->alias], 'dependent' => true]);
 }
開發者ID:eripoll,項目名稱:webiplan,代碼行數:5,代碼來源:CommentableBehavior.php

示例10: testClassNaming

 /**
  * testClassNaming method
  *
  * @return void
  */
 public function testClassNaming()
 {
     $this->assertEquals('ArtistsGenre', Inflector::classify('artists_genres'));
     $this->assertEquals('FileSystem', Inflector::classify('file_systems'));
     $this->assertEquals('News', Inflector::classify('news'));
     $this->assertEquals('Bureau', Inflector::classify('bureaus'));
 }
開發者ID:jeremyheaton,項目名稱:ultiswap,代碼行數:12,代碼來源:InflectorTest.php

示例11: clean

 /**
  * Whitespaces before or after <?php and ?>.
  * The latter should be removed from PHP files by the way.
  *
  * @return void
  */
 public function clean()
 {
     if (!empty($this->args[0])) {
         $folder = realpath($this->args[0]);
     } elseif ($this->params['plugin']) {
         $folder = Plugin::path(Inflector::classify($this->params['plugin']));
     } else {
         $folder = APP;
     }
     $App = new Folder($folder);
     $this->out('Checking *.php in ' . $folder);
     $files = $App->findRecursive('.*\\.php');
     $this->out('Found ' . count($files) . ' files.');
     $action = $this->in('Continue? [y]/[n]', ['y', 'n'], 'n');
     if ($action !== 'y') {
         return $this->error('Aborted');
     }
     $folders = [];
     foreach ($files as $file) {
         $errors = [];
         $action = '';
         $this->out('Processing ' . $file, 1, Shell::VERBOSE);
         $c = file_get_contents($file);
         if (preg_match('/^[\\n\\r|\\n|\\r|\\s]+\\<\\?php/', $c)) {
             $errors[] = 'leading';
         }
         if (preg_match('/\\?\\>[\\n\\r|\\n|\\r|\\s]+$/', $c)) {
             $errors[] = 'trailing';
         }
         if (empty($errors)) {
             continue;
         }
         foreach ($errors as $e) {
             $this->report[$e][0]++;
         }
         $this->out('');
         $this->out('contains ' . implode(' and ', $errors) . ' whitespaces: ' . $this->shortPath($file));
         $dirname = dirname($file);
         if (in_array($dirname, $folders)) {
             $action = 'y';
         }
         while (empty($action)) {
             $action = $this->in('Remove? [y]/[n], [a] for all in this folder, [r] for all below, [*] for all files(!), [q] to quit', ['y', 'n', 'r', 'a', 'q', '*'], 'q');
         }
         if ($action === '*') {
             $action = 'y';
         } elseif ($action === 'a') {
             $action = 'y';
             $folders[] = $dirname;
             $this->out('All: ' . $dirname);
         }
         if ($action === 'q') {
             return $this->error('Abort... Done');
         }
         if ($action === 'y') {
             if (in_array('leading', $errors)) {
                 $c = preg_replace('/^\\s+\\<\\?php/', '<?php', $c);
             }
             if (in_array('trailing', $errors)) {
                 $c = preg_replace('/\\?\\>\\s+$/', '?>', $c);
             }
             file_put_contents($file, $c);
             foreach ($errors as $e) {
                 $this->report[$e][1]++;
             }
             $this->out('fixed ' . implode(' and ', $errors) . ' whitespaces: ' . $this->shortPath($file));
         }
     }
     // Report.
     $this->out('--------');
     $this->out('found ' . $this->report['leading'][0] . ' leading, ' . $this->report['trailing'][0] . ' trailing ws');
     $this->out('fixed ' . $this->report['leading'][1] . ' leading, ' . $this->report['trailing'][1] . ' trailing ws');
 }
開發者ID:dereuromark,項目名稱:cakephp-setup,代碼行數:79,代碼來源:WhitespaceShell.php

示例12: fileName

 /**
  * {@inheritDoc}
  */
 public function fileName($name)
 {
     return Inflector::classify($this->args[0]) . 'Seed.php';
 }
開發者ID:josegonzalez,項目名稱:migrations,代碼行數:7,代碼來源:SeedTask.php

示例13: addType

 public function addType($key, $entityClass)
 {
     list($namespace, $entityName) = explode('\\Entity\\', $entityClass);
     $connection = $this->_table->connection();
     $table = $this->config('table');
     $alias = Inflector::pluralize($entityName);
     $className = $namespace . '\\Table\\' . $alias . 'Table';
     if (!class_exists($className)) {
         $className = null;
     }
     if (TableRegistry::exists($alias)) {
         $existingTable = TableRegistry::get($alias);
         if ($table !== $existingTable->table() || $connection !== $existingTable->connection() || $entityClass !== $existingTable->entityClass()) {
             throw new \Exception();
         }
     }
     $this->_typeMap[$key] = compact('alias', 'entityClass', 'table', 'connection', 'className');
     $method = 'new' . Inflector::classify($entityName);
     $this->config('implementedMethods.' . $method, $method);
 }
開發者ID:UseMuffin,項目名稱:Sti,代碼行數:20,代碼來源:StiBehavior.php

示例14: _getHandlerByFieldType

 /**
  * Method that retrieves handler class name based on provided field type.
  * It also handles more advanced field types like foreign key and list fields.
  * Example: if field type is 'string' then 'StringFieldHandler' will be returned.
  * Example: if field type is 'related:users' then 'RelatedFieldHandler' will be returned.
  * @param  string $type field type
  * @param  bool   $fqcn true to use fully-qualified class name
  * @return string       handler class name
  */
 protected function _getHandlerByFieldType($type, $fqcn = false)
 {
     if (false !== ($pos = strpos($type, ':'))) {
         $type = substr($type, 0, $pos);
     }
     $result = Inflector::classify($type) . static::HANDLER_SUFFIX;
     if ($fqcn) {
         $result = __NAMESPACE__ . '\\' . $result;
     }
     return $result;
 }
開發者ID:QoboLtd,項目名稱:cakephp-csv-views,代碼行數:20,代碼來源:FieldHandlerFactory.php

示例15: _loadFilter

 /**
  * Loads a search filter instance.
  *
  * @param string $name Name of the field
  * @param string $filter Filter name
  * @param array $options Filter options.
  * @return \Burzum\Search\Search\Filter\Base
  * @throws \InvalidArgumentException When no filter was found.
  */
 public function _loadFilter($name, $filter, array $options = [])
 {
     list($plugin, $filter) = pluginSplit($filter);
     $filter = Inflector::classify($filter);
     if (!empty($plugin)) {
         $className = '\\' . $plugin . '\\Search\\Type\\' . $filter;
         if (class_exists($className)) {
             return new $className($name, $options, $this);
         }
     }
     if (isset($config['typeClasses'][$filter])) {
         return new $config['typeClasses'][$filter]($filter, $options, $this);
     }
     if (class_exists('\\Burzum\\Search\\Search\\Filter\\' . $filter)) {
         $className = '\\Burzum\\Search\\Search\\Filter\\' . $filter;
         return new $className($name, $options, $this);
     }
     if (class_exists('\\App\\Search\\Type\\' . $filter)) {
         $className = '\\App\\Search\\Type\\' . $filter;
         return new $className($name, $options, $this);
     }
     throw new \InvalidArgumentException(sprintf('Can\'t find filter class %s!', $name));
 }
開發者ID:burzum,項目名稱:cakephp-search-plugin,代碼行數:32,代碼來源:Manager.php


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