本文整理汇总了PHP中Phalcon\Text::camelize方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::camelize方法的具体用法?PHP Text::camelize怎么用?PHP Text::camelize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Text
的用法示例。
在下文中一共展示了Text::camelize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pageAction
public function pageAction()
{
$pageSlug = $this->getUriParameter('pageSlug');
$pageTitle = \Phalcon\Text::camelize($pageSlug);
$this->tag->setTitle($pageTitle);
$this->view->pick('pages/' . $pageSlug);
}
示例2: prepare
protected function prepare(Type $type)
{
if (!$this->getConnection()->tableExists($this->table)) {
throw new Exception("Table {$this->table} does not exist");
}
$name = $this->table;
if ($this->tablePrefix && Text::startsWith($name, $this->tablePrefix)) {
$name = substr($name, strlen($this->tablePrefix));
$name = trim($name, '_');
}
if (empty($name)) {
throw new Exception("Cannot infer model name from '{$this->table}'");
}
$name = Inflect::singularize($name);
$model_name = Text::camelize($name);
$vars['type'] = $type;
$vars['namespace'] = $this->namespace;
$vars['model_name'] = $model_name;
$vars['table_name'] = $this->table;
$vars['connection'] = $this->connectionService;
$vars['name'] = str_replace('_', ' ', ucfirst($name));
$vars['url'] = '/' . str_replace('_', '-', $name);
$vars['primary_key'] = $this->primaryKey;
return $vars;
}
示例3: resolve
/**
* {@inheritdoc}
*/
public function resolve(&$value)
{
if (is_string($value) && strlen($value) > 0) {
$value = \Phalcon\Text::camelize($value);
}
return $value;
}
示例4: __get
public function __get($name)
{
if ($this->getDI()->has($name)) {
return parent::__get($name);
}
return $this->{lcfirst(\Phalcon\Text::camelize("get_{$name}"))}();
}
示例5: dumpModulesFromVendor
/**
* Extract Vegas modules from composer vegas-cmf vendors.
*
* @param $modulesList
* @return mixed
*/
private function dumpModulesFromVendor(array &$modulesList)
{
if (!file_exists(APP_ROOT . '/composer.json')) {
return $modulesList;
}
$fileContent = file_get_contents(APP_ROOT . DIRECTORY_SEPARATOR . 'composer.json');
$json = json_decode($fileContent, true);
$vendorDir = realpath(APP_ROOT . (isset($json['config']['vendor-dir']) ? DIRECTORY_SEPARATOR . $json['config']['vendor-dir'] : DIRECTORY_SEPARATOR . 'vendor'));
$vendorDir .= DIRECTORY_SEPARATOR . 'vegas-cmf';
$directoryIterator = new \DirectoryIterator($vendorDir);
foreach ($directoryIterator as $libDir) {
if ($libDir->isDot()) {
continue;
}
//creates path to Module.php file
$moduleSettingsFile = implode(DIRECTORY_SEPARATOR, [$vendorDir, $libDir, 'module', self::MODULE_SETTINGS_FILE]);
if (!file_exists($moduleSettingsFile)) {
continue;
}
$baseName = Text::camelize($libDir->getBasename());
if (!isset($modulesList[$baseName])) {
$modulesList[$baseName] = ['className' => $baseName . '\\' . pathinfo(self::MODULE_SETTINGS_FILE, PATHINFO_FILENAME), 'path' => $moduleSettingsFile];
}
}
return $modulesList;
}
示例6: resetAction
public function resetAction()
{
$connection = new \Phalcon\Db\Adapter\Pdo\Mysql($this->config->database->toArray());
$tables = $connection->listTables();
foreach ($tables as $table) {
$tablename = \Phalcon\Text::camelize($table);
$fd = fopen("{$this->config->application->formsDir}/{$tablename}Form.php", "w");
fwrite($fd, "<?php" . self::NL . self::NL);
// Begin class
fwrite($fd, "class {$tablename}Form {" . self::NL);
$columns = $connection->describeColumns($table);
foreach ($columns as $column) {
if ($column instanceof \Phalcon\Db\Column) {
// Escape if column is primary
if ($column->isPrimary()) {
continue;
}
// Begin method
$columnname = \Phalcon\Text::camelize($column->getName());
fwrite($fd, self::TAB . "private function _{$columnname}() {" . self::NL);
// Write element
$columntype_base = $this->_getBaseType($column->getType());
$columntype = $this->_getType($columntype_base, $column);
fwrite($fd, self::TAB . self::TAB . "\$element = new \\Phalcon\\Forms\\Element\\{$columntype}(\"{$columnname}\");" . self::NL);
fwrite($fd, self::TAB . self::TAB . "\$element->setLabel(\"{$columnname}\");" . self::NL);
// Add empty selection for select fields
if ($columntype == "Select") {
fwrite($fd, self::TAB . self::TAB . "\$element->setOptions([]);" . self::NL);
}
// Add validator on text fields
if ($columntype == "Text" && $column->getSize() > 0) {
fwrite($fd, self::TAB . self::TAB . "\$element->addValidator(new \\Phalcon\\Validation\\Validator\\StringLength([" . self::NL);
fwrite($fd, self::TAB . self::TAB . self::TAB . "\"max\" => {$column->getSize()}" . self::NL);
fwrite($fd, self::TAB . self::TAB . "]));" . self::NL);
}
// End method
fwrite($fd, self::TAB . self::TAB . "return \$element;" . self::NL);
fwrite($fd, self::TAB . "}" . self::NL);
}
}
// Final method : construction of the form
fwrite($fd, self::TAB . "public function setFields() {" . self::NL);
foreach ($columns as $column) {
if ($column instanceof \Phalcon\Db\Column) {
if ($column->isPrimary()) {
continue;
}
$columnname = \Phalcon\Text::camelize($column->getName());
fwrite($fd, self::TAB . self::TAB . "\$this->add(\$this->_{$columnname}());" . self::NL);
}
}
fwrite($fd, self::TAB . "}" . self::NL);
// End class
fwrite($fd, "}" . self::NL . self::NL);
fclose($fd);
}
$this->view->disable();
echo "done!";
return FALSE;
}
示例7: getMenuOptions
/**
* Return menu options
*
* @return array
*/
public function getMenuOptions()
{
$this->_limitParamValue = 100;
$rows = $this->getColumnData();
$acl = $this->_di->get('acl');
$viewer = $this->_di->get('viewer');
$options = [];
foreach ($rows as $row) {
$option = [];
$option['id'] = $row['id'];
$option['text'] = $row['title'];
if ($row['module'] && $row['controller']) {
if (!$acl->isAllowed($viewer->getRole(), \Engine\Acl\Dispatcher::ACL_ADMIN_MODULE, \Engine\Acl\Dispatcher::ACL_ADMIN_CONTROLLER, '*') && !$acl->isAllowed($viewer->getRole(), \Engine\Acl\Dispatcher::ACL_ADMIN_MODULE, \Engine\Acl\Dispatcher::ACL_ADMIN_CONTROLLER, 'read')) {
if (!$acl->isAllowed($viewer->getRole(), $row['module'], $row['controller'], 'read')) {
continue;
}
}
$option['controller'] = \Phalcon\Text::camelize($row['module']) . ".controller." . \Phalcon\Text::camelize($row['controller']);
$option['moduleName'] = \Phalcon\Text::camelize($row['module']);
$option['controllerName'] = \Phalcon\Text::camelize($row['controller']);
$option['leaf'] = true;
$option['cls'] = 'window-list-item';
$option['iconCls'] = 'window-list-item-icon';
}
$option['qtip'] = $row['description'];
$options[] = $option;
}
return $options;
}
示例8: __get
/**
* @param string $name
* @return mixed
*/
public function __get($name)
{
$getter = 'get' . \Phalcon\Text::camelize($name);
if (method_exists($this, $getter)) {
return $this->{$getter}();
}
return null;
}
示例9: camelize
public static function camelize($title)
{
$words = explode(' ', trim($title));
foreach ($words as $key => $word) {
$words[$key] = \Phalcon\Text::camelize($word);
}
return implode(' ', $words);
}
示例10: correctCase
private function correctCase($key)
{
if (strpos($key, '_')) {
return lcfirst(Text::camelize($key));
} else {
return $key;
}
}
示例11: createAction
public function createAction($r_controller = null, $r_action = null, $r_id = null)
{
$mapServerConfig = $this->getDI()->getConfig()->mapserver;
$fileName = $mapServerConfig->mapfileCacheDir . $mapServerConfig->contextesCacheDir . $this->request->getPost("code") . ".map";
//Ne pas créer le contexte si il y en a déjà un avec le même code
if (file_exists($fileName)) {
$this->flash->error("Le fichier {$fileName} existe déjà!");
return $this->dispatcher->forward(array("controller" => $this->ctlName, "action" => "new", "param" => !is_null($r_id) ? "/" . $r_controller . "/" . $r_action . "/" . $r_id : ""));
}
$idContexteADupliquer = $this->request->getPost('id_contexte_a_dupliquer');
//On désire dupliquer un contexte
if ($idContexteADupliquer) {
if (!$this->peutDupliquerContexte($idContexteADupliquer)) {
$this->flash->error("Vous n'avez pas la permission de dupliquer le contexte {$idContexteADupliquer}.");
return $this->dispatcher->forward(array("controller" => $this->ctlName, "action" => "new", "param" => !is_null($r_id) ? "/" . $r_controller . "/" . $r_action . "/" . $r_id : ""));
}
}
$this->traiterCodeOnlineRessource();
$igoContexte = new IgoContexte();
$igoContexte->mode = $this->request->getPost("mode");
$igoContexte->position = $this->request->getPost("position");
$igoContexte->zoom = $this->request->getPost("zoom");
$igoContexte->code = $this->request->getPost("code");
$igoContexte->nom = $this->request->getPost("nom");
$igoContexte->description = $this->request->getPost("description");
$igoContexte->mf_map_def = $this->request->getPost("mf_map_def");
$igoContexte->date_modif = $this->request->getPost("date_modif");
$igoContexte->json = $this->request->getPost("json");
$igoContexte->mf_map_projection = $this->request->getPost("mf_map_projection");
$igoContexte->profil_proprietaire_id = $this->request->getPost("profil_proprietaire_id");
if ($igoContexte->profil_proprietaire_id == "") {
$igoContexte->profil_proprietaire_id = null;
}
//Valider la sélection ou pas du profil propriétaire
if (!$this->validationProfilProprietaire($igoContexte->profil_proprietaire_id, $messageErreurProfilProprietaire)) {
foreach ($messageErreurProfilProprietaire as $message) {
$this->flash->error($message);
}
return $this->dispatcher->forward(array("controller" => $this->ctlName, "action" => "new", "param" => !is_null($r_id) ? "/" . $r_controller . "/" . $r_action . "/" . $r_id : ""));
}
$igoContexte->mf_map_meta_onlineresource = $this->request->getPost("mf_map_meta_onlineresource");
$igoContexte->generer_onlineresource = $this->request->getPost("generer_onlineResource");
try {
if (!$igoContexte->save()) {
foreach ($igoContexte->getMessages() as $message) {
$this->flash->error($message);
}
return $this->dispatcher->forward(array("controller" => $this->ctlName, "action" => "new", "param" => !is_null($r_id) ? "/" . $r_controller . "/" . $r_action . "/" . $r_id : ""));
}
if ($idContexteADupliquer) {
$this->dupliquerContexte($idContexteADupliquer, $igoContexte->id);
}
$this->flash->success(Text::camelize(str_replace("igo_", "", $this->ctlName)) . " " . $igoContexte->id . " créé avec succès");
} catch (\Exception $e) {
$this->flash->error($e->getMessage());
return $this->dispatcher->forward(array("controller" => $this->ctlName, "action" => "new", "param" => !is_null($r_id) ? "/" . $r_controller . "/" . $r_action . "/" . $r_id : ""));
}
}
示例12: camelize
public static function camelize($module)
{
$tmpModuleNameArr = explode('-', $module);
$moduleName = '';
foreach ($tmpModuleNameArr as $part) {
$moduleName .= \Phalcon\Text::camelize($part);
}
return $moduleName;
}
示例13: run
public function run($parameters)
{
$name = $this->getOption(array('name', 1));
$className = Text::camelize(isset($parameters[2]) ? $parameters[2] : $name);
$fileName = Text::uncamelize($className);
$schema = $this->getOption('schema');
$modelBuilder = new \Phalcon\Builder\Model(array('name' => $name, 'schema' => $schema, 'className' => $className, 'fileName' => $fileName, 'genSettersGetters' => $this->isReceivedOption('get-set'), 'genDocMethods' => $this->isReceivedOption('doc'), 'namespace' => $this->getOption('namespace'), 'directory' => $this->getOption('directory'), 'force' => $this->isReceivedOption('force')));
$modelBuilder->build();
}
示例14: beforeDispatchLoop
/**
* @param Event $event
* @param DispatcherInterface $dispatcher
*/
public function beforeDispatchLoop(Event $event, DispatcherInterface $dispatcher, $data)
{
if ($dispatcher->getActionName()) {
$actionName = $dispatcher->getActionName();
$actionName = Text::camelize($actionName);
$actionName = lcfirst($actionName);
$dispatcher->setActionName($actionName);
}
}
示例15: run
/**
* @param $parameters
*/
public function run($parameters)
{
$name = $this->getOption(array('name', 1));
$className = Text::camelize(isset($parameters[1]) ? $parameters[1] : $name);
$fileName = Text::uncamelize($className);
$schema = $this->getOption('schema');
$modelBuilder = new ModelBuilder(array('name' => $name, 'schema' => $schema, 'className' => $className, 'fileName' => $fileName, 'genSettersGetters' => $this->isReceivedOption('get-set'), 'genDocMethods' => $this->isReceivedOption('doc'), 'namespace' => $this->getOption('namespace'), 'directory' => $this->getOption('directory'), 'modelsDir' => $this->getOption('output'), 'extends' => $this->getOption('extends'), 'excludeFields' => $this->getOption('excludefields'), 'force' => $this->isReceivedOption('force'), 'mapColumn' => $this->isReceivedOption('mapcolumn')));
$modelBuilder->build();
}