本文整理汇总了PHP中Repository类的典型用法代码示例。如果您正苦于以下问题:PHP Repository类的具体用法?PHP Repository怎么用?PHP Repository使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Repository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display($tpl = null)
{
// Get the url of the Alfresco repository from the Joosco plugin
// That's why the Joosco plugin needs to be installed and configured before the component
$plugin =& JPluginHelper::getPlugin('authentication', 'joosco');
$pluginParams = new JParameter($plugin->params);
// Here we connect to the Repository
$repositoryUrl = $pluginParams->get('alf-url');
$repository = new Repository($repositoryUrl);
// The ticket is created by the plugin when a user connects
$ticket = $_SESSION["ticket"];
$session = $repository->createSession($ticket);
$store = new SpacesStore($session);
$currentNode = null;
$uuid = null;
$uuid =& JRequest::getVar('uuid');
if (!isset($uuid)) {
$currentNode = $store->companyHome;
$path = 'Company Home';
} else {
$currentNode = $session->getNode($store, JRequest::getVar('uuid'));
$path = JRequest::getVar('path') . '|' . JRequest::getVar('uuid') . '|' . JRequest::getVar('name');
}
// Pass the values to the rest of the template
$this->assignRef('path', $path);
$this->assignRef('session', $session);
$this->assignRef('store', $store);
$this->assignRef('currentNode', $currentNode);
$this->assignRef('option', JRequest::getVar('option'));
$this->assignRef('view', JRequest::getVar('view'));
$this->assignRef('itemid', JRequest::getVar('Itemid'));
parent::display($tpl);
}
示例2: searchRepository
/**
* Add the field to query to find the model
*
* @param Repository $repository
*
* @return Repository
*/
public function searchRepository($repository, $value, $table = null)
{
if (!$table) {
$table = $this->getObjectSchema()->getTable();
}
return $repository->orWhere($table . "." . $this->getColumn(), (int) $value);
}
示例3: __construct
/**
* Constructor.
*
* @param Repository $repository
*/
public function __construct(Repository $repository)
{
$this->repository = $repository;
$this->manager = $repository->getManager();
$this->metadata = $repository->getMetadata();
$this->query = $this->manager->getConnection()->createQueryBuilder()->from($this->metadata->getTable());
}
示例4: doRepositoryTest
/**
* Test Repository
*
* @param Repository $repo
* @return Boolean
*/
public function doRepositoryTest($repo)
{
if ($repo->accessType != 'fs') {
return -1;
}
// Check the destination path
$this->failedInfo = "";
$safePath = $repo->getOption("PATH", true);
if (strstr($safePath, "AJXP_USER") !== false) {
return TRUE;
}
// CANNOT TEST THIS CASE!
$path = $repo->getOption("PATH", false);
$createOpt = $repo->getOption("CREATE");
$create = $createOpt == "true" || $createOpt === true ? true : false;
if (!$create && !@is_dir($path)) {
$this->failedInfo .= "Selected repository path " . $path . " doesn't exist, and the CREATE option is false";
return FALSE;
}
/* else if ($create && !is_writeable($path)) {
$this->failedInfo .= "Selected repository path ".$path." isn't writeable"; return FALSE;
}*/
// Do more tests here
return TRUE;
}
示例5: initRepository
public function initRepository()
{
if (is_array($this->pluginConf)) {
$this->driverConf = $this->pluginConf;
} else {
$this->driverConf = array();
}
$smbclientPath = $this->driverConf["SMBCLIENT"];
define('SMB4PHP_SMBCLIENT', $smbclientPath);
$smbtmpPath = $this->driverConf["SMB_PATH_TMP"];
define('SMB4PHP_SMBTMP', $smbtmpPath);
require_once $this->getBaseDir() . "/smb.php";
$create = $this->repository->getOption("CREATE");
$recycle = $this->repository->getOption("RECYCLE_BIN");
$this->detectStreamWrapper(true);
$this->urlBase = "pydio://" . $this->repository->getId();
if ($recycle != "" && !is_dir($this->urlBase . "/" . $recycle)) {
@mkdir($this->urlBase . "/" . $recycle);
if (!is_dir($this->urlBase . "/" . $recycle)) {
throw new AJXP_Exception("Cannot create recycle bin folder. Please check repository configuration or that your folder is writeable!");
}
}
if ($recycle != "") {
RecycleBinManager::init($this->urlBase, "/" . $recycle);
}
}
示例6: onAuthenticate
/**
* This method should handle any authentication and report back to the subject
*
* @access public
* @param array $credentials Array holding the user credentials
* @param array $options Array of extra options
* @param object $response Authentication response object
* @return boolean
* @since 1.5
*/
function onAuthenticate($credentials, $options, &$response)
{
// This file is needed to use the Repository class
require_once dirname(__FILE__) . '/alfresco-php-library/Repository.php';
// Get the URL of the Alfresco repository as a parameter of the plugin
$plugin =& JPluginHelper::getPlugin('authentication', 'joosco');
$pluginParams = new JParameter($plugin->params);
// Set the variables
$repositoryUrl = $pluginParams->get('alf-url');
$userName = $credentials['username'];
$password = $credentials['password'];
// Connect to the repository
$repository = new Repository($repositoryUrl);
$ticket = null;
try {
// Try to create a ticket
$ticket = $repository->authenticate($userName, $password);
// If the ticket fails, it means that the username and/or password are wrong
$_SESSION["ticket"] = $ticket;
$response->status = JAUTHENTICATE_STATUS_SUCCESS;
// There's no way to get the Alfresco name or email address of the user
// The only thing to do is wait for an update of the Alfresco PHP API
$response->username = $credentials['username'];
$response->email = $credentials['username'] . "@alfresco.user";
$response->fullname = $credentials['username'];
} catch (Exception $e) {
// Wrong username or password creates an exception
$response->status = JAUTHENTICATE_STATUS_FAILURE;
$response->error_message = 'Authentication failed';
}
}
示例7: __construct
/**
* Session constructor
*
* @param Repository $repository The repository to log in
* @param string $workspaceName The workspace's name
*
* @api
*/
public function __construct(Repository $repository, $workspaceName = null)
{
$this->repository = $repository;
$parameters = $repository->getParameters();
$credentials = new \PHPCR\SimpleCredentials($parameters['credentials.username'], $parameters['credentials.password']);
$this->session = $repository->login($credentials, $workspaceName);
}
示例8: send
/**
* Send linkback on "create" events to remote repositories
*/
public function send($event, Repository $repo)
{
if ($this->config === false) {
return;
}
if ($event != 'create') {
return;
}
$origin = $repo->getConnectionInfo()->getOrigin();
if ($origin === null) {
return;
}
$originWebUrl = $origin->getWebUrl(true);
if ($originWebUrl === null) {
return;
}
$this->pbc = new \PEAR2\Services\Linkback\Client();
$req = $this->pbc->getRequest();
$req->setConfig(array('ssl_verify_peer' => false, 'ssl_verify_host' => false));
$this->pbc->setRequestTemplate($req);
$req->setHeader('user-agent', 'phorkie');
try {
$res = $this->pbc->send($repo->getLink('display', null, true), $originWebUrl);
} catch (\Exception $e) {
//FIXME: log errors
}
}
示例9: initRepository
public function initRepository()
{
if (is_array($this->pluginConf)) {
$this->driverConf = $this->pluginConf;
} else {
$this->driverConf = array();
}
if (!function_exists('ssh2_connect')) {
throw new Exception("You must have the php ssh2 extension active!");
}
ConfService::setConf("PROBE_REAL_SIZE", false);
$path = $this->repository->getOption("PATH");
$recycle = $this->repository->getOption("RECYCLE_BIN");
$this->detectStreamWrapper(true);
$this->urlBase = "pydio://" . $this->repository->getId();
restore_error_handler();
if (!file_exists($this->urlBase)) {
if ($this->repository->getOption("CREATE")) {
$test = @mkdir($this->urlBase);
if (!$test) {
throw new AJXP_Exception("Cannot create path ({$path}) for your repository! Please check the configuration.");
}
} else {
throw new AJXP_Exception("Cannot find base path ({$path}) for your repository! Please check the configuration!");
}
}
if ($recycle != "") {
RecycleBinManager::init($this->urlBase, "/" . $recycle);
}
}
示例10: updateRepo
public function updateRepo(Repository $repo, $crdate = null, $modate = null)
{
//add repository
$r = new Database_Adapter_Elasticsearch_HTTPRequest($this->searchInstance . 'repo/' . $repo->id, \HTTP_Request2::METHOD_PUT);
$repoData = array('id' => $repo->id, 'description' => $repo->getDescription(), 'tstamp' => gmdate('c', time()));
if ($crdate == null) {
$crdate = $this->getCrDate($repo);
}
if ($crdate !== null) {
$repoData['crdate'] = gmdate('c', $crdate);
}
if ($modate == null) {
$modate = $this->getMoDate($repo);
}
if ($modate !== null) {
$repoData['modate'] = gmdate('c', $modate);
}
$r->setBody(json_encode((object) $repoData));
$r->send();
//add files
//clean up before adding files; files might have been deleted
$this->deleteRepoFiles($repo);
foreach ($repo->getFiles() as $file) {
$r = new Database_Adapter_Elasticsearch_HTTPRequest($this->searchInstance . 'file/?parent=' . $repo->id, \HTTP_Request2::METHOD_POST);
$r->setBody(json_encode((object) array('name' => $file->getFilename(), 'extension' => $file->getExt(), 'content' => $file->isText() ? $file->getContent() : '')));
$r->send();
}
}
示例11: createSharedChild
function createSharedChild($newLabel, $newOptions, $parentId, $owner, $uniqueUser)
{
$repo = new Repository(0, $newLabel, $this->accessType);
$newOptions = array_merge($this->options, $newOptions);
$repo->options = $newOptions;
$repo->setOwnerData($parentId, $owner, $uniqueUser);
return $repo;
}
示例12: testValidateData
/**
* test protected _validateData()
*/
public function testValidateData()
{
$sourceClassName = 'Magento_Module_Controller_Index';
$resultClassName = 'Magento_Module_Controller';
$repository = new Repository();
$repository->init($sourceClassName, $resultClassName);
$this->assertFalse($repository->generate());
}
示例13: __construct
/**
* Constructs a commit.
* If commit data is not given, constructor will fetch them from log.
*
* @param Repository $repository Instance of Repository
* @param type $commitHash Commit hash
* @param array $data Optional given commit data
*/
public function __construct(Repository $repository, $commitHash, array $data = [])
{
$this->repository = $repository;
$this->commitHash = $commitHash;
if (empty($data)) {
$data = $this->repository->getLog()->getCommitData($commitHash);
}
$this->setData($data);
}
示例14: getCollection
/**
* @param array $tags
* @return \AwsInspector\Model\Collection
*/
public static function getCollection(array $tags = [])
{
$hash = serialize($tags);
if (!isset(self::$registry[$hash])) {
$repository = new Repository();
self::$registry[$hash] = $repository->findEc2InstancesByTags($tags);
}
return self::$registry[$hash];
}
示例15: validateRepository
/**
* Callback function to validate data
* @return bool must return true or other hooks don't get called
*/
function validateRepository($editPage, $textBox1, $section, &$hookError)
{
$ns = $editPage->mTitle->getNamespace();
if ($ns == NS_REPOSITORY) {
$repository = new Repository($editPage->mTitle->getText());
$repository->validate($textBox1, $section, $hookError);
}
return true;
}