本文整理汇总了PHP中dmString::modulize方法的典型用法代码示例。如果您正苦于以下问题:PHP dmString::modulize方法的具体用法?PHP dmString::modulize怎么用?PHP dmString::modulize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dmString
的用法示例。
在下文中一共展示了dmString::modulize方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getModule
/**
* @param string $moduleKey
* @param boolean $orNull
* @throws dmException
* @return dmModule
*/
public function getModule($moduleKey, $orNull = false)
{
$moduleKey = $moduleKey instanceof dmModule ? $moduleKey->getKey() : $moduleKey;
if (isset($this->modules[$moduleKey])) {
return $this->modules[$moduleKey];
} elseif (isset($this->modules[$moduleKey = dmString::modulize($moduleKey)])) {
return $this->modules[$moduleKey];
}
if ($orNull) {
return null;
}
throw new dmException(sprintf('The "%s" module does not exist', $moduleKey));
}
示例2: hasAncestor
public function hasAncestor($ancestorKey)
{
if (!$this->hasParent()) {
return null;
}
if ($ancestorKey instanceof dmModule) {
$ancestorKey = $ancestorKey->getKey();
}
if ($ancestorKey === $this->getKey()) {
return false;
}
return in_array(dmString::modulize($ancestorKey), $this->options['path_keys']);
}
示例3: checkModuleAction
public function checkModuleAction($validator, $values)
{
if (!empty($values['module']) && !empty($values['action'])) {
foreach (array('module', 'action') as $key) {
$values[$key] = dmString::modulize(str_replace('-', '_', dmString::slugify(dmString::underscore($values[$key]))));
}
$existingPage = dmDb::query('DmPage p')->where('p.module = ? AND p.action = ? and p.record_id = ? AND p.id != ?', array($values['module'], $values['action'], $this->object->record_id, $this->object->id))->fetchRecord();
if ($existingPage) {
$error = new sfValidatorError($validator, $this->getI18n()->__('The page "%1%" uses this module.action', array('%1%' => $existingPage->name)));
// throw an error bound to the password field
throw new sfValidatorErrorSchema($validator, array('action' => $error));
}
}
return $values;
}
示例4: doUpdateObject
protected function doUpdateObject($values)
{
$parent = dmDb::table('DmPage')->find($values['parent_id']);
if (!$parent instanceof DmPage) {
throw new dmException('Create page with unknown parent ' . $values['parent_id']);
}
parent::doUpdateObject($values);
$this->object->module = $parent->module;
$action = dmString::modulize(str_replace('-', '_', dmString::slugify($values['name'])));
if (dmDb::query('DmPage p')->where('p.module = ? AND p.action = ?', array($this->object->module, $action))->exists()) {
$iterator = 2;
while (dmDb::query('DmPage p')->where('p.module = ? AND p.action = ?', array($this->object->module, $action . $iterator))->exists()) {
$iterator++;
}
$action .= $iterator;
}
$this->object->action = $action;
$this->object->title = $this->object->name;
$this->object->Node->insertAsLastChildOf($parent);
$this->object->PageView->Layout = dmDb::table('DmLayout')->find($values['dm_layout_id']);
$this->object->PageView->save();
$this->object->save();
}
示例5: initialize
public function initialize($source, $isDefault = false)
{
$this->source = $source;
if (empty($source)) {
} elseif (is_string($source)) {
if (strncmp($source, 'media:', 6) === 0) {
$mediaId = preg_replace('|^media:(\\d+).*|', '$1', $source);
if ($media = dmDb::table('DmMedia')->findOneByIdWithFolder($mediaId)) {
$this->fromMedia($media);
} else {
throw new dmException(sprintf('%s is not a valid media resource. The media with id %s does not exist', $source, $mediaId));
}
} elseif (0 === strncmp($source, 'http://', 7)) {
$this->type = self::REMOTE;
$this->remotePath = $source;
$this->mime = $this->mimeTypeResolver->getGroupByFilename(dmString::getBaseFromUrl($source));
$this->mime = $this->mime ? $this->mime : 'image';
} else {
$this->type = self::FILE;
// allow culture variable in source
if (strpos($source, '%culture%') !== false) {
$source = str_replace('%culture%', $this->culture, $source);
}
/*
* Server full path
*/
if (strpos($source, sfConfig::get('sf_web_dir')) === 0) {
$this->pathFromWebDir = str_replace(sfConfig::get('sf_web_dir'), '', $source);
} elseif (strncmp($source, '/', 1) === 0) {
$this->pathFromWebDir = $source;
} elseif (strncmp($source, 'dm', 2) === 0) {
$type = preg_replace('|^dm(\\w+)/.+$|', '$1', $source);
$this->pathFromWebDir = '/' . sfConfig::get('dm_' . dmString::modulize($type) . '_asset') . '/' . str_replace('dm' . $type . '/', '', $source);
} else {
// and now some magic to allow to use "images/file.png" writing only "file.png"
if (strncmp($source, 'images/', 7) !== 0 && file_exists($this->theme->getFullPath('images/' . $source)) && !file_exists($this->theme->getFullPath($source))) {
$this->pathFromWebDir = $this->theme->getPath('images/' . $source);
} else {
$this->pathFromWebDir = $this->theme->getPath($source);
}
}
$this->mime = $this->mimeTypeResolver->getGroupByFilename(dmString::getBaseFromUrl($source));
}
} elseif ($source instanceof DmMedia) {
if ($source->isNew()) {
} else {
$this->fromMedia($source);
}
} else {
throw new dmException('Not a valid media source : ' . $source);
}
if (!$this->getMime()) {
if ($isDefault) {
$this->pathFromWebDir = '';
$this->mime = 'image';
} else {
$this->initialize(sfConfig::get('dm_media_default'), true);
}
}
return $this;
}
示例6: getReplacementsForPatterns
public function getReplacementsForPatterns(dmProjectModule $module, array $patterns, dmDoctrineRecord $record)
{
$moduleKey = $module->getKey();
$replacements = array();
foreach ($this->getPatternsPlaceholders($patterns) as $placeholder) {
if ('culture' === $placeholder || 'user.culture' === $placeholder) {
$replacements[$this->wrap($placeholder)] = $this->culture;
continue;
}
/*
* Extract model and field from 'model.field' or 'model'
*/
if (strpos($placeholder, '.')) {
list($usedModuleKey, $field) = explode('.', $placeholder);
} else {
$usedModuleKey = $placeholder;
$field = '__toString';
}
$usedModuleKey = dmString::modulize($usedModuleKey);
$usedRecord = null;
/*
* Retrieve used record
*/
if ($usedModuleKey === $moduleKey) {
$usedRecord = $record;
} elseif ($module->hasAncestor($usedModuleKey)) {
$usedRecord = $record->getAncestorRecord($module->getAncestor($usedModuleKey)->getModel());
} else {
$usedRecord = $record->getRelatedRecord($this->moduleManager->getModule($usedModuleKey)->getModel());
}
if ($usedRecord instanceof dmDoctrineRecord) {
/*
* get record value for field
*/
if ($field === '__toString') {
$usedValue = $usedRecord->__toString();
$processMarkdown = true;
} else {
try {
$usedValue = $usedRecord->get($field);
} catch (Doctrine_Record_UnknownPropertyException $e) {
$usedValue = $usedRecord->{'get' . dmString::camelize($field)}();
}
$processMarkdown = $this->shouldProcessMarkdown($usedRecord->getTable(), $field);
}
unset($usedRecord);
} else {
$usedValue = $moduleKey . '-' . $usedModuleKey . ' not found';
$processMarkdown = false;
}
$usedValue = trim($usedValue);
if ($processMarkdown) {
$usedValue = dmMarkdown::brutalToText($usedValue);
}
$replacements[$this->wrap($placeholder)] = $usedValue;
}
return $replacements;
}
示例7: getConfiguration
/**
* @see sfConfigHandler
*
* Additionally this method merges modules
*/
public static function getConfiguration(array $configFiles)
{
$config = array();
foreach ($configFiles as $configFile) {
$values = self::parseYaml($configFile);
// BC 5.0_BETA6 "Content" was named "Project"
if (isset($values['Project']) && !isset($values['Content'])) {
$values['Content'] = $values['Project'];
unset($values['Project']);
}
$pluginName = self::isProjectConfigFile($configFile) ? false : basename(str_replace('/config/dm/modules.yml', '', $configFile));
foreach ($values as $valuesTypeName => $valuesType) {
foreach ($valuesType as $valuesSpaceName => $valuesSpace) {
foreach (array_keys($valuesSpace) as $moduleKey) {
// add plugin name
$values[$valuesTypeName][$valuesSpaceName][$moduleKey]['plugin'] = $pluginName;
// fix non modulized module keys
if ($moduleKey !== dmString::modulize($moduleKey)) {
$values[$valuesTypeName][$valuesSpaceName][dmString::modulize($moduleKey)] = $values[$valuesTypeName][$valuesSpaceName][$moduleKey];
unset($values[$valuesTypeName][$valuesSpaceName][$moduleKey]);
}
}
// merge overridden modules
foreach ($config as $configTypeName => $configType) {
foreach ($configType as $configSpaceName => $configSpace) {
foreach (array_intersect_key($values[$valuesTypeName][$valuesSpaceName], $configSpace) as $moduleKey => $module) {
// merge the new module with the old one
$values[$valuesTypeName][$valuesSpaceName][$moduleKey] = sfToolkit::arrayDeepMerge($configSpace[$moduleKey], $values[$valuesTypeName][$valuesSpaceName][$moduleKey]);
$values[$valuesTypeName][$valuesSpaceName][$moduleKey]['overridden'] = true;
$values[$valuesTypeName][$valuesSpaceName][$moduleKey]['plugin'] = $configSpace[$moduleKey]['plugin'];
// remove the old module
unset($config[$configTypeName][$configSpaceName][$moduleKey]);
}
}
}
}
}
$config = sfToolkit::arrayDeepMerge($config, $values);
}
return $config;
}
示例8: getLinkToAction
/**
* Returns HTML code for an action link.
*
* @param string $actionName The action name
* @param array $params The parameters
* @param boolean $pk_link Whether to add a primary key link or not
*
* @return string HTML code
*/
public function getLinkToAction($actionName, $params, $pk_link = false)
{
$action = isset($params['action']) ? $params['action'] : dmString::modulize($actionName);
$url_params = $pk_link ? '?' . $this->getPrimaryKeyUrlParams() : '\'';
return '[?php echo link_to(__(\'' . dmArray::get($params, 'label', dmString::humanize($actionName)) . '\', array(), \'' . $this->getI18nCatalogue() . '\'), \'' . $this->getModuleName() . '/' . $action . $url_params . ', ' . $this->asPhp($params['params']) . ') ?]';
}
示例9: is
public function is($something)
{
if (is_string($something)) {
return $this->key == dmString::modulize($something);
}
if ($something instanceof dmModule) {
return $something->getKey() === $this->key;
}
return false;
}
示例10: addPermissionFor
protected function addPermissionFor($credential, $module, $action)
{
$dmPermissionName = 'DmPermission_' . str_replace('/', '_', dmString::modulize($credential));
$this->permissions[$dmPermissionName] = array('name' => $credential, 'description' => sprintf('Grant access to action %s of module %s', $action, $module));
}