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


PHP Inflector::classify方法代碼示例

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


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

示例1: main

 /**
  * undocumented function
  *
  * @return void
  */
 function main()
 {
     $choice = '';
     $Tasks = new Folder(dirname(__FILE__) . DS . 'tasks');
     list($folders, $files) = $Tasks->read();
     $i = 1;
     $choices = array();
     foreach ($files as $file) {
         if (preg_match('/upgrade_/', $file)) {
             $choices[$i] = basename($file, '.php');
             $this->out($i++ . '. ' . basename($file, '.php'));
         }
     }
     while ($choice == '') {
         $choice = $this->in("Enter a number from the list above, or 'q' to exit", null, 'q');
         if ($choice === 'q') {
             $this->out("Exit");
             $this->_stop();
         }
         if ($choice == '' || intval($choice) > count($choices)) {
             $this->err("The number you selected was not an option. Please try again.");
             $choice = '';
         }
     }
     if (intval($choice) > 0 && intval($choice) <= count($choices)) {
         $upgrade = Inflector::classify($choices[intval($choice)]);
     }
     $this->tasks = array($upgrade);
     $this->loadTasks();
     return $this->{$upgrade}->execute();
 }
開發者ID:Galvanio,項目名稱:Kinspir,代碼行數:36,代碼來源:chaw_upgrade.php

示例2: execute

 /**
  * Execution method always used for tasks
  *
  * @return void
  */
 public function execute()
 {
     if (!empty($this->args)) {
         $command = Inflector::classify(array_shift($this->args));
         if ($this->hasTask($command)) {
             return $this->{$command}->runCommand('execute', $this->args);
         }
     }
     $this->out(__d('webmaster', "Interactive Requirements Shell"));
     $this->hr();
     $this->out(__d('webmaster', "[A]vailability"));
     $this->out(__d('webmaster', "[I]mplementation"));
     $this->out(__d('webmaster', "[S]takeholder"));
     $this->out(__d('webmaster', "[Q]uit"));
     $option = $this->in(__d('webmaster', "What would you like to do?"), array_keys($this->__options));
     $method = $this->__options[strtoupper($option)];
     if ($this->hasMethod($method)) {
         $this->{$method}();
     } else {
         if ($this->hasTask($method)) {
             $this->{$method}->runCommand('execute', $this->args);
         }
     }
     $this->execute();
 }
開發者ID:gourmet,項目名稱:webmaster,代碼行數:30,代碼來源:RequirementsTask.php

示例3: authorize

 /**
  * Delegates the job of enforcing authorization to the active controller.
  *
  * When using this Authorize object, each Controller must define an
  * `::isAuthorized($user)` method. An Exception will be thrown if such
  * a method does not exist.
  *
  * The method takes as its only argument an array of User data as
  * normally provided by `Auth->user()` to use in determining access.
  *
  * The method must return a boolean true/false value where true
  * indicates the currently logged in User is allowed to access the
  * current CakeRequest, and false indicates the User's access is denied.
  *
  * As an example, if you wanted all logged-in-users to have access to
  * all parts of your app, you could add the following method to your
  * AppController:
  *
  * 		public function isAuthorized($user) {
  * 			return true;
  * 		}
  *
  * @param array $user An array containing a User record, typically provided by Auth->user().
  * @param CakeRequest $request The active HTTP request object.
  * @throws NotImplementedException If the controller does not define a valid ::isAuthorized() method.
  * @return bool	True if the current User has access to the requested section of the app, false otherwise.
  */
 public function authorize($user, CakeRequest $request)
 {
     if (!$this->controllerIsAuthorizedExists()) {
         throw new NotImplementedException(sprintf("%sController does not define the mandatory `::isAuthorized()` method used for authorization.", Inflector::classify($request->params['controller'])));
     }
     return $this->delegateToIsAuthorized($user);
 }
開發者ID:loadsys,項目名稱:cakephp-stateless-auth,代碼行數:34,代碼來源:IsAuthorizedAuthorize.php

示例4: generate

 public static function generate($args, $subfolder = 'default')
 {
     $subfolder = trim($subfolder, '/');
     if (!is_dir(PKGPATH . 'oil/views/' . $subfolder)) {
         throw new Exception('The subfolder for scaffolding templates doesn\'t exist or is spelled wrong: ' . $subfolder . ' ');
     }
     // Do this first as there is the largest chance of error here
     Generate::model($args, false);
     // Go through all arguments after the first and make them into field arrays
     $fields = array();
     foreach (array_slice($args, 1) as $arg) {
         // Parse the argument for each field in a pattern of name:type[constraint]
         preg_match('/([a-z0-9_]+):([a-z0-9_]+)(\\[([0-9]+)\\])?/i', $arg, $matches);
         $fields[] = array('name' => strtolower($matches[1]), 'type' => isset($matches[2]) ? $matches[2] : 'string', 'constraint' => isset($matches[4]) ? $matches[4] : null);
     }
     $data['singular'] = $singular = strtolower(array_shift($args));
     $data['model'] = $model_name = 'Model_' . \Inflector::classify($singular);
     $data['plural'] = $plural = \Inflector::pluralize($singular);
     $data['fields'] = $fields;
     $filepath = APPPATH . 'classes/controller/' . trim(str_replace(array('_', '-'), DS, $plural), DS) . '.php';
     $controller = \View::factory($subfolder . '/scaffold/controller', $data);
     $controller->actions = array(array('name' => 'index', 'params' => '', 'code' => \View::factory($subfolder . '/scaffold/actions/index', $data)), array('name' => 'view', 'params' => '$id = null', 'code' => \View::factory($subfolder . '/scaffold/actions/view', $data)), array('name' => 'create', 'params' => '$id = null', 'code' => \View::factory($subfolder . '/scaffold/actions/create', $data)), array('name' => 'edit', 'params' => '$id = null', 'code' => \View::factory($subfolder . '/scaffold/actions/edit', $data)), array('name' => 'delete', 'params' => '$id = null', 'code' => \View::factory($subfolder . '/scaffold/actions/delete', $data)));
     // Write controller
     Generate::create($filepath, $controller, 'controller');
     // Create each of the views
     foreach (array('index', 'view', 'create', 'edit', '_form') as $view) {
         Generate::create(APPPATH . 'views/' . $plural . '/' . $view . '.php', \View::factory($subfolder . '/scaffold/views/' . $view, $data), 'view');
     }
     // Add the default template if it doesnt exist
     if (!file_exists($app_template = APPPATH . 'views/template.php')) {
         Generate::create($app_template, file_get_contents(PKGPATH . 'oil/views/default/template.php'), 'view');
     }
     Generate::build();
 }
開發者ID:huglester,項目名稱:wtfismypagerank,代碼行數:34,代碼來源:scaffold.php

示例5: __construct

 public function __construct($from, $name, array $config)
 {
     $this->name = $name;
     $this->model_from = $from;
     $this->model_to = array_key_exists('model_to', $config) ? $config['model_to'] : \Inflector::get_namespace($from) . 'Model_' . \Inflector::classify($name);
     $this->key_from = array_key_exists('key_from', $config) ? (array) $config['key_from'] : $this->key_from;
     $this->key_to = array_key_exists('key_to', $config) ? (array) $config['key_to'] : $this->key_to;
     $this->conditions = array_key_exists('conditions', $config) ? (array) $config['conditions'] : array();
     if (!empty($config['table_through'])) {
         $this->table_through = $config['table_through'];
     } else {
         $table_name = array($this->model_from, $this->model_to);
         natcasesort($table_name);
         $table_name = array_merge($table_name);
         $this->table_through = \Inflector::tableize($table_name[0]) . '_' . \Inflector::tableize($table_name[1]);
     }
     $this->key_through_from = !empty($config['key_through_from']) ? (array) $config['key_through_from'] : (array) \Inflector::foreign_key($this->model_from);
     $this->key_through_to = !empty($config['key_through_to']) ? (array) $config['key_through_to'] : (array) \Inflector::foreign_key($this->model_to);
     $this->cascade_save = array_key_exists('cascade_save', $config) ? $config['cascade_save'] : $this->cascade_save;
     $this->cascade_delete = array_key_exists('cascade_delete', $config) ? $config['cascade_delete'] : $this->cascade_delete;
     if (!class_exists($this->model_to)) {
         throw new \FuelException('Related model not found by Many_Many relation "' . $this->name . '": ' . $this->model_to);
     }
     $this->model_to = get_real_class($this->model_to);
 }
開發者ID:rickmellor,項目名稱:Infrastructure,代碼行數:25,代碼來源:manymany.php

示例6: getExternalConditions

 public static function getExternalConditions($select, $parentModel, $childName, $attributes)
 {
     $parentModelName = get_class($parentModel);
     $parentTableName = $parentModel->getTableName();
     // exhibitions
     $childName = array_key_exists('source', $attributes) ? $attributes['source'] : $childName;
     $childModelName = Inflector::classify($childName);
     $childTableName = Bbx_Model::load($childModelName)->getTableName();
     // images
     if (!array_key_exists($childTableName, $select->getPart('from'))) {
         $select->from($childTableName, array());
         // images
     }
     if (array_key_exists('as', $attributes)) {
         $refColumn = $attributes['as'] . '_id';
         $polyType = $attributes['as'] . '_type';
     } else {
         $refColumn = Inflector::singularize($parentTableName) . '_id';
     }
     try {
         $parentModel->getRowData();
         $select->where("`" . $childTableName . "`.`" . $refColumn . "` = " . $parentModel->id);
     } catch (Exception $e) {
         $select->where("`" . $childTableName . "`.`" . $refColumn . "` = `" . $parentTableName . "`.`id`");
     }
     if (isset($polyType)) {
         $select->where("`" . $childTableName . "`.`" . $polyType . "` = '" . Inflector::underscore($parentModelName) . "'");
     }
     return $select;
 }
開發者ID:rdallasgray,項目名稱:bbx,代碼行數:30,代碼來源:HasMany.php

示例7: testClassify

 /**
  * @todo Implement testClassify().
  */
 public function testClassify()
 {
     $this->assertEquals(Inflector::classify('path.to.class_name'), 'Path\\To\\ClassName');
     $this->assertEquals(Inflector::classify('/path/to/class-name'), '\\Path\\To\\ClassName');
     $this->assertEquals(Inflector::classify('Path/To/ClassName'), 'Path\\To\\ClassName');
     $this->assertEquals(Inflector::classify('class_name'), 'ClassName');
 }
開發者ID:ata,項目名稱:ostric,代碼行數:10,代碼來源:InflectorTest.php

示例8: main

 function main()
 {
     if (empty($this->args)) {
         return $this->err('Usage: ./cake fixturize <table>');
     }
     if ($this->args[0] == '?') {
         return $this->out('Usage: ./cake fixturize <table> [-force] [-reindex]');
     }
     $options = array('force' => false, 'reindex' => false);
     foreach ($this->params as $key => $val) {
         foreach ($options as $name => $option) {
             if (isset($this->params[$name]) || isset($this->params['-' . $name]) || isset($this->params[$name[0]])) {
                 $options[$name] = true;
             }
         }
     }
     foreach ($this->args as $table) {
         $name = Inflector::classify($table);
         $Model = new AppModel(array('name' => $name, 'table' => $table));
         $file = sprintf('%stests/fixtures/%s_fixture.php', APP, Inflector::underscore($name));
         $File = new File($file);
         if ($File->exists() && !$options['force']) {
             $this->err(sprintf('File %s already exists, use --force option.', $file));
             continue;
         }
         $records = $Model->find('all');
         $out = array();
         $out[] = '<?php';
         $out[] = '';
         $out[] = sprintf('class %sFixture extends CakeTestFixture {', $name);
         $out[] = sprintf('	var $name = \'%s\';', $name);
         $out[] = '	var $records = array(';
         $File->write(join("\n", $out));
         foreach ($records as $record) {
             $out = array();
             $out[] = '		array(';
             if ($options['reindex']) {
                 foreach (array('old_id', 'vendor_id') as $field) {
                     if ($Model->hasField($field)) {
                         $record[$name][$field] = $record[$name]['id'];
                         break;
                     }
                 }
                 $record[$name]['id'] = String::uuid();
             }
             foreach ($record[$name] as $field => $val) {
                 $out[] = sprintf('			\'%s\' => \'%s\',', addcslashes($field, "'"), addcslashes($val, "'"));
             }
             $out[] = '		),';
             $File->write(join("\n", $out));
         }
         $out = array();
         $out[] = '	);';
         $out[] = '}';
         $out[] = '';
         $out[] = '?>';
         $File->write(join("\n", $out));
         $this->out(sprintf('-> Create %sFixture with %d records (%d bytes) in "%s"', $name, count($records), $File->size(), $file));
     }
 }
開發者ID:stripthis,項目名稱:donate,代碼行數:60,代碼來源:fixturize.php

示例9: fireJob

 /**
  * Helper for firing jobs
  *
  * @param array $data array of data to pass into a job
  * @return bool
  * @throws CakeException If if the job is invalid, could not be loaded or could not be enqueued
  */
 public function fireJob($data = array())
 {
     if (isset($data['job'])) {
         $new = $data;
         unset($data);
         $data[$this->alias] = $new;
     }
     if (empty($data[$this->alias]['job'])) {
         throw new CakeException(__('Invalid job.'));
     }
     foreach ($data[$this->alias] as $key => $val) {
         if ($key == 'job') {
             continue;
         }
         if (strpos($key, '_id') !== false) {
             $model = Inflector::classify(substr($key, 0, strpos($key, '_id')));
             $Model = ClassRegistry::init($model);
             $res = $Model->findById($val);
             $data[$this->alias][$key] = $res[$Model->alias];
         }
     }
     if (empty($data[$this->alias]['job'])) {
         throw new CakeException(__('Job could not be loaded.'));
     }
     $job = $data[$this->alias]['job'];
     unset($data[$this->alias]['job']);
     $data = array_values($data[$this->alias]);
     if ($this->enqueue($job, $data)) {
         return true;
     }
     throw new CakeException(__('Job could not be enqueued.'));
 }
開發者ID:superstarrajini,項目名稱:cakepackages,代碼行數:39,代碼來源:AppModel.php

示例10: execute

 /**
  * Execution method always used for tasks
  *
  * @return void
  */
 function execute()
 {
     if (empty($this->params['skel'])) {
         $this->params['skel'] = '';
         if (is_dir(CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'console' . DS . 'libs' . DS . 'templates' . DS . 'skel') === true) {
             $this->params['skel'] = CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'console' . DS . 'libs' . DS . 'templates' . DS . 'skel';
         }
     }
     $plugin = null;
     if (isset($this->args[0])) {
         $plugin = Inflector::camelize($this->args[0]);
         $this->Dispatch->shiftArgs();
         $this->out(sprintf('Plugin: %s', $plugin));
         $pluginPath = Inflector::underscore($plugin) . DS;
         $this->out(sprintf('Plugin: %s', $this->path . $pluginPath));
     }
     if (isset($this->args[0]) && isset($plugin)) {
         $task = Inflector::classify($this->args[0]);
         $this->Dispatch->shiftArgs();
         if (in_array($task, $this->tasks)) {
             $this->{$task}->path = $this->path . $pluginPath . Inflector::underscore(Inflector::pluralize($task)) . DS;
             if (!is_dir($this->{$task}->path)) {
                 $this->err(sprintf(__("%s directory could not be found.\nBe sure you have created %s", true), $task, $this->{$task}->path));
             }
             $this->{$task}->loadTasks();
             $this->{$task}->execute();
         }
         exit;
     }
     $this->__interactive($plugin);
 }
開發者ID:kaz0636,項目名稱:openflp,代碼行數:36,代碼來源:plugin.php

示例11: get_class_name

 protected static function get_class_name($prefix = '')
 {
     if (!$prefix) {
         return __CLASS__;
     }
     return sprintf('%s_%s', __CLASS__, Inflector::classify($prefix));
 }
開發者ID:uzura8,項目名稱:flockbird,代碼行數:7,代碼來源:siteconfig.php

示例12: send

 /**
  * send
  *
  */
 public function send($model)
 {
     $models = Configure::read('Reminder.models');
     $modelName = Inflector::classify($model);
     $loader = ReminderConfigLoader::init($modelName);
     $layout = $loader->load('layout');
     try {
         $this->Reminder = ClassRegistry::init('Reminder.Reminder');
         $result = $this->Reminder->send($this->request->data, $modelName);
         if ($result === true) {
             $this->request->data = null;
             $this->Session->setFlash(__('Reminder mail has been sent'), Configure::read('Reminder.setFlashElement.success'), Configure::read('Reminder.setFlashParams.success'));
             $view = $loader->load('view.sent');
             if (empty($view)) {
                 $view = 'sent';
             }
             return $this->render($view, $layout);
         }
     } catch (ReminderException $e) {
         $this->Session->setFlash($e->getMessage(), Configure::read('Reminder.setFlashElement.error'), Configure::read('Reminder.setFlashParams.error'));
     }
     $emailField = $loader->load('email');
     $this->set(array('model' => $model, 'modelName' => $modelName, 'emailField' => $emailField));
     $view = $loader->load('view.send');
     if (empty($view)) {
         $view = 'send';
     }
     return $this->render($view, $layout);
 }
開發者ID:k1low,項目名稱:reminder,代碼行數:33,代碼來源:ReminderController.php

示例13: initModel

 private function initModel()
 {
     if (!$this->model) {
         $model = Inflector::classify($this->controller);
     }
     $this->{$model} = new $model();
 }
開發者ID:pudney,項目名稱:hellaphone,代碼行數:7,代碼來源:controller.php

示例14: main

 function main()
 {
     if (empty($this->args)) {
         return $this->err('Usage: ./cake uuidize <table>');
     }
     if ($this->args[0] == '?') {
         return $this->out('Usage: ./cake uuidize <table> [-force] [-reindex]');
     }
     $options = array('force' => false, 'reindex' => false);
     foreach ($this->params as $key => $val) {
         foreach ($options as $name => $option) {
             if (isset($this->params[$name]) || isset($this->params['-' . $name]) || isset($this->params[$name[0]])) {
                 $options[$name] = true;
             }
         }
     }
     foreach ($this->args as $table) {
         $name = Inflector::classify($table);
         $Model = new AppModel(array('name' => $name, 'table' => $table));
         $records = $Model->find('all');
         foreach ($records as $record) {
             $Model->updateAll(array('id' => '"' . String::uuid() . '"'), array('id' => $record[$name]['id']));
         }
     }
 }
開發者ID:stripthis,項目名稱:donate,代碼行數:25,代碼來源:uuidize.php

示例15: setup

 /**
  * setup
  *
  * @param Model $Model
  * @param array $config
  * @return void
  */
 public function setup(Model $Model, $config = array())
 {
     $recipe = Configure::read('Oven.recipe');
     if (!empty($recipe)) {
         foreach ($recipe as $key => $type) {
             $modelName = Inflector::classify($key);
             if (!isset($this->settings['uploadFields'][$modelName])) {
                 $this->settings['uploadFields'][$modelName] = array();
             }
             if (!empty($type['schema'])) {
                 foreach ($type['schema'] as $field => $val) {
                     if (empty($val['type'])) {
                         continue;
                     }
                     if ($val['type'] == 'file') {
                         $this->settings['uploadFields'][$modelName][] = $field;
                     }
                 }
             }
         }
     }
     if (empty($config['uploadLocation'])) {
         $config['uploadLocation'] = Configure::read('Oven.config.upload_location');
         if (empty($config['uploadLocation'])) {
             $config['uploadLocation'] = WWW_ROOT . 'files' . DS . 'uploads' . DS;
         }
     }
     if (!file_exists($config['uploadLocation'])) {
         new Folder($config['uploadLocation'], true);
     }
     $this->settings = Set::merge($this->settings, $config);
 }
開發者ID:shama,項目名稱:oven,代碼行數:39,代碼來源:UploadBehavior.php


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