本文整理汇总了PHP中Repository::setSlug方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::setSlug方法的具体用法?PHP Repository::setSlug怎么用?PHP Repository::setSlug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository::setSlug方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveRepository
/**
* Store a newly created repository
*
* @param Repository $repositoryObject
* @param Boolean $update
* @return int -1 if failed
*/
public function saveRepository($repositoryObject, $update = false)
{
try {
if ($update) {
$repositoryObject->setSlug($this->uniquifySlug($repositoryObject->getSlug(), $repositoryObject->getUniqueId()));
} else {
$repositoryObject->setSlug($this->uniquifySlug($repositoryObject->getSlug()));
}
$repository_array = $this->repoToArray($repositoryObject);
$options = $repository_array['options'];
if ($repositoryObject->hasContentFilter()) {
$options["content_filter"] = $repositoryObject->getContentFilter();
}
unset($repository_array['options']);
if (!$update) {
dibi::query('INSERT INTO [ajxp_repo]', $repository_array);
foreach ($options as $k => $v) {
if (!is_string($v)) {
$v = '$phpserial$' . serialize($v);
}
dibi::query('INSERT INTO [ajxp_repo_options] ([uuid],[name],[val]) VALUES (%s,%s,%bin)', $repositoryObject->getUniqueId(), $k, $v);
}
} else {
dibi::query('DELETE FROM [ajxp_repo] WHERE [uuid] = %s', $repositoryObject->getUniqueId());
dibi::query('DELETE FROM [ajxp_repo_options] WHERE [uuid] = %s', $repositoryObject->getUniqueId());
dibi::query('INSERT INTO [ajxp_repo]', $repository_array);
foreach ($options as $k => $v) {
if (!is_string($v)) {
$v = '$phpserial$' . serialize($v);
}
dibi::query('INSERT INTO [ajxp_repo_options] ([uuid],[name],[val]) VALUES (%s,%s,%bin)', $repositoryObject->getUniqueId(), $k, $v);
}
}
} catch (DibiException $e) {
echo get_class($e), ': ', $e->getMessage(), "\n";
exit(1);
return -1;
}
}
示例2: createRepositoryFromArrayInst
/**
* See static method
* @param string $index
* @param array $repository
* @return Repository
*/
public function createRepositoryFromArrayInst($index, $repository)
{
$repo = new Repository($index, $repository["DISPLAY"], $repository["DRIVER"]);
if (isset($repository["DISPLAY_ID"])) {
$repo->setDisplayStringId($repository["DISPLAY_ID"]);
}
if (isset($repository["DESCRIPTION_ID"])) {
$repo->setDescription($repository["DESCRIPTION_ID"]);
}
if (isset($repository["AJXP_SLUG"])) {
$repo->setSlug($repository["AJXP_SLUG"]);
}
if (isset($repository["IS_TEMPLATE"]) && $repository["IS_TEMPLATE"]) {
$repo->isTemplate = true;
$repo->uuid = $index;
}
if (array_key_exists("DRIVER_OPTIONS", $repository) && is_array($repository["DRIVER_OPTIONS"])) {
foreach ($repository["DRIVER_OPTIONS"] as $oName => $oValue) {
$repo->addOption($oName, $oValue);
}
}
// BACKWARD COMPATIBILITY!
if (array_key_exists("PATH", $repository)) {
$repo->addOption("PATH", $repository["PATH"]);
$repo->addOption("CREATE", intval($repository["CREATE"]));
$repo->addOption("RECYCLE_BIN", $repository["RECYCLE_BIN"]);
}
return $repo;
}
示例3: repoFromDb
/**
* Create a Repository object from a Database Result
*
* The method expects the following schema:
* CREATE TABLE ajxp_repo ( uuid VARCHAR(33) PRIMARY KEY,
* path VARCHAR(255),
* display VARCHAR(255),
* accessType VARCHAR(20),
* recycle VARCHAR(255) ,
* bcreate BOOLEAN, -- For some reason 'create' is a reserved keyword
* writeable BOOLEAN,
* enabled BOOLEAN );
*
* Additionally, the options are stored in a separate table:
* CREATE TABLE ajxp_repo_options ( oid INTEGER PRIMARY KEY, uuid VARCHAR(33), name VARCHAR(50), val VARCHAR(255) );
*
* I recommend an index to increase performance of uuid lookups:
* CREATE INDEX ajxp_repo_options_uuid_idx ON ajxp_repo_options ( uuid );
*
*
* @param $result Result of a dibi::query() as array
* @param $options_result Result of dibi::query() for options as array
* @return Repository object
*/
function repoFromDb($result, $options_result = array())
{
$repo = new Repository($result['id'], $result['display'], $result['accessType']);
$repo->uuid = $result['uuid'];
$repo->setOwnerData($result['parent_uuid'], $result['owner_user_id'], $result['child_user_id']);
$repo->path = $result['path'];
$repo->create = $result['bcreate'];
$repo->writeable = $result['writeable'];
$repo->writeable = true;
$repo->enabled = $result['enabled'];
$repo->recycle = "";
$repo->setSlug($result['slug']);
$repo->isTemplate = intval($result['isTemplate']) == 1 ? true : false;
$repo->setInferOptionsFromParent(intval($result['inferOptionsFromParent']) == 1 ? true : false);
foreach ($options_result as $k => $v) {
if (strpos($v, '$phpserial$') !== false && strpos($v, '$phpserial$') === 0) {
$v = unserialize(substr($v, strlen('$phpserial$')));
} else {
if ($k == "META_SOURCES") {
$v = unserialize($v);
}
}
$repo->options[$k] = $v;
}
return $repo;
}