/** * Executes this query and returns a QueryResult object. * * @return \PHPCR\Query\QueryInterface a QueryResult object * @throws \PHPCR\Query\InvalidQueryException if the query contains an unbound variable. * @throws \PHPCR\RepositoryException if an error occurs * @api */ public function execute() { $transport = $this->objectmanager->getTransport(); $rawData = $transport->querySQL($this->statement, $this->limit, $this->offset); $queryResult = $this->factory->get('Query\\QueryResult', array($rawData, $this->objectmanager)); return $queryResult; }
/** creates the corresponding workspace */ public function __construct($factory, Repository $repository, $workspaceName, \PHPCR\SimpleCredentials $credentials, TransportInterface $transport) { $this->factory = $factory; $this->repository = $repository; $this->objectManager = $this->factory->get('ObjectManager', array($transport, $this)); $this->workspace = $this->factory->get('Workspace', array($this, $this->objectManager, $workspaceName)); $this->credentials = $credentials; }
/** * Creates a new query by specifying the query statement itself and the language * in which the query is stated. The $language must be a string from among * those returned by QueryManager.getSupportedQueryLanguages(). * * @param string $statement * @param string $language * @return \PHPCR\Query\QueryInterface a Query object * @throws \PHPCR\Query\InvalidQueryException if the query statement is syntactically invalid or the specified language is not supported * @throws \PHPCR\RepositoryException if another error occurs * @api */ public function createQuery($statement, $language) { switch ($language) { case \PHPCR\Query\QueryInterface::JCR_SQL2: return $this->factory->get('Query\\SqlQuery', array($statement, $this->objectmanager)); case \PHPCR\Query\QueryInterface::JCR_JQOM: throw new NotImplementedException(); default: throw new \PHPCR\Query\InvalidQueryException("No such query language: {$language}"); } }
/** * Authenticates the user using the supplied credentials. If workspaceName is recognized as the * name of an existing workspace in the repository and authorization to access that workspace * is granted, then a new Session object is returned. workspaceName is a single string token. * * null credentials are currently not supported * * If workspaceName is null, a default workspace is automatically selected by the repository * implementation. This may, for example, be the "home workspace" of the user whose credentials * were passed, though this is entirely up to the configuration and implementation of the * repository. Alternatively, it may be a "null workspace" that serves only to provide the * method Workspace.getAccessibleWorkspaceNames(), allowing the client to select from among * available "real" workspaces. * * Note: The Java API defines this method with multiple differing signatures. * * @param \PHPCR\CredentialsInterface $credentials The credentials of the user * @param string $workspaceName the name of a workspace * @return \PHPCR\SessionInterface a valid session for the user to access the repository * @throws \PHPCR\LoginException if authentication or authorization (for the specified workspace) fails * @throws \PHPCR\NoSuchWorkspacexception if the specified workspaceName is not recognized * @throws \PHPCR\RepositoryException if another error occurs * @api */ public function login($credentials = null, $workspaceName = null) { if ($workspaceName == null) { $workspaceName = 'default'; } //TODO: can default workspace have other name? if (!$this->transport->login($credentials, $workspaceName)) { throw new \PHPCR\RepositoryException('transport failed to login without telling why'); } $session = $this->factory->get('Session', array($this, $workspaceName, $credentials, $this->transport)); return $session; }
/** * Initializes the created object. * * @param object $factory an object factory implementing "get" as described in \jackalope\Factory * @param TransportInterface $transport */ public function __construct($factory, TransportInterface $transport) { $this->factory = $factory; $this->transport = $transport; $this->namespaceManager = $this->factory->get('NamespaceManager', array($this->defaultNamespaces)); $namespaces = $transport->getNamespaces(); foreach ($namespaces as $prefix => $uri) { if (!array_key_exists($prefix, $this->defaultNamespaces)) { $this->userNamespaces[$prefix] = $uri; } } }
/** * Reads properties from XML * @param DOMElement $node The dom to parse properties from */ protected function fromXml(DOMElement $node) { $this->name = $node->getAttribute('name'); $this->isAbstract = Helper::getBoolAttribute($node, 'isAbstract'); $this->isMixin = Helper::getBoolAttribute($node, 'isMixin'); $this->isQueryable = Helper::getBoolAttribute($node, 'isQueryable'); $this->hasOrderableChildNodes = Helper::getBoolAttribute($node, 'hasOrderableChildNodes'); $this->primaryItemName = $node->getAttribute('primaryItemName'); if (empty($this->primaryItemName)) { $this->primaryItemName = null; } $this->declaredSuperTypeNames = array(); $xp = new DOMXPath($node->ownerDocument); $supertypes = $xp->query('supertypes/supertype', $node); foreach ($supertypes as $supertype) { $this->declaredSuperTypeNames[] = $supertype->nodeValue; } $this->declaredPropertyDefinitions = new ArrayObject(); $properties = $xp->query('propertyDefinition', $node); foreach ($properties as $property) { $this->declaredPropertyDefinitions[] = $this->factory->get('NodeType\\PropertyDefinition', array($property, $this->nodeTypeManager)); } $this->declaredNodeDefinitions = new ArrayObject(); $declaredNodeDefinitions = $xp->query('childNodeDefinition', $node); foreach ($declaredNodeDefinitions as $nodeDefinition) { $this->declaredNodeDefinitions[] = $this->factory->get('NodeType\\NodeDefinition', array($nodeDefinition, $this->nodeTypeManager)); } }
/** * Get the node identified by an absolute path. * * To prevent unnecessary work to be done a register will be written containing already retrieved nodes. * Unfortunately there is currently no way to refetch a node once it has been fetched. * * @param string $absPath The absolute path of the node to create. * @param string $class The class of node to get. TODO: Is it sane to fetch data separatly for Version and normal Node? * @return \PHPCR\Node * * @throws \PHPCR\ItemNotFoundException If nothing is found at that absolute path * @throws \PHPCR\RepositoryException If the path is not absolute or not well-formed */ public function getNodeByPath($absPath, $class = 'Node') { $absPath = $this->normalizePath($absPath); $this->verifyAbsolutePath($absPath); if (!isset($this->objectsByPath[$class])) { $this->objectsByPath[$class] = array(); } if (empty($this->objectsByPath[$class][$absPath])) { if (isset($this->itemsRemove[$absPath])) { throw new \PHPCR\ItemNotFoundException('Path not found (node deleted in current session): ' . $absPath); } // check whether a parent node was removed foreach ($this->itemsRemove as $path => $dummy) { if (strpos($absPath, $path) === 0) { throw new \PHPCR\ItemNotFoundException('Path not found (parent node deleted in current session): ' . $absPath); } } $fetchPath = $absPath; if (isset($this->nodesMove[$absPath])) { throw new \PHPCR\ItemNotFoundException('Path not found (moved in current session): ' . $absPath); } // The path was the destination of a previous move which isn't yet dispatched to the backend. // I guess an exception would be fine but we can also just fetch the node from the previous path $fetchPath = $this->resolveBackendPath($fetchPath); $node = $this->factory->get($class, array($this->transport->getItem($fetchPath), $absPath, $this->session, $this)); $this->objectsByUuid[$node->getIdentifier()] = $absPath; //FIXME: what about nodes that are NOT referencable? $this->objectsByPath[$class][$absPath] = $node; } return $this->objectsByPath[$class][$absPath]; }
/** * Creates a NodeType from a NodeTypeDefinition and validates it * * @param \PHPCR\NodeType\NodeTypeDefinitionInterface $ntd The node type definition * @param bool $allowUpdate Whether an existing note type can be updated * @return \PHPCR\NodeType\NodeType the node type corresponding to the type definition * @throws \PHPCR\NodeType\NodeTypeExistsException If the node type is already existing and allowUpdate is false */ protected function createNodeType(\PHPCR\NodeType\NodeTypeDefinitionInterface $ntd, $allowUpdate) { if ($this->hasNodeType($ntd->getName()) && !$allowUpdate) { throw new \PHPCR\NodeType\NodeTypeExistsException('NodeType already existing: ' . $ntd->getName()); } return $this->factory->get('NodeType\\NodeType', array($this, $ntd)); }
/** * {@inheritDoc} * * @api */ public function execute() { if (is_null($this->objectManager)) { // if the ObjectManager was not injected in the header. this is only supposed to happen in the DBAL client. throw new RepositoryException('Jackalope implementation error: This query was built for parsing only. (There is no ObjectManager to run the query against.)'); } $transport = $this->objectManager->getTransport(); $rawData = $transport->query($this); $queryResult = $this->factory->get('Query\\QueryResult', array($rawData, $this->objectManager)); return $queryResult; }
/** *getPermissionLevel * *Get our permission level for this object. * ------------------------------------------------------ * *@throws an exception if permissions were not loaded in an appropriate way for this object. *@param user - If a user is passed, we'll load permissions if we don't already have them. * *@return string * * * */ public function getPermissionLevel($user = false) { if (!empty($this->_permissions)) { return $this->_permissions; } if (!is_object($user)) { throw new \Zend\Db\Exception\InvalidArgumentException('getPermissionLevel called when permissions have not been loaded yet.'); } // Let's try to load permissions for this object. return $this->_permissions = Factory::get('ResourcesAccess')->hasResourceAccessTo($user, $this); }
/** * Opens a cURL session if not yet one open. * * @return null|false False in case there is already an open connection, else null; */ protected function getRequest($method, $uri) { // init curl if (is_null($this->curl)) { $this->curl = new curl(); } $uri = $this->normalizeUri($uri); $request = $this->factory->get('Transport\\Davex\\Request', array($this->curl, $method, $uri)); $request->setCredentials($this->credentials); foreach ($this->defaultHeaders as $header) { $request->addHeader($header); } if (!$this->sendExpect) { $request->addHeader("Expect:"); } return $request; }
/** Get instance of some class. * * This method is will call the Factory object to get a new object of * some class. You can specify, if you want to force the creation of a new * object or if it is ok for you, to reuse an existing one (default) * * @param string $class * Class of requested object * @param array $values * Parameters to hand to the objects constructor * @param bool $forceNew * Force object to be a new one * * @return object */ public function get($class, $values = array(), $forceNew = false) { return $this->Factory->get($class, $values, $forceNew); }
public function testGetPrivate() { $this->assertInstanceOf(self::$classMap['private'], $this->factory->get('unknown')); }
/** * Returns the VersionManager object. * * @return \PHPCR\Version\VersionManagerInterface a VersionManager object. * @throws \PHPCR\UnsupportedRepositoryOperationException if the implementation does not support versioning. * @throws \PHPCR\RepositoryException if an error occurs. * @api */ public function getVersionManager() { return $this->factory->get('Version\\VersionManager', array($this->session->getObjectManager())); }
/** * @param string $daoName * @return Dao */ public function get($daoName) { return parent::get($daoName); }
require_once 'app/class/Factory.php'; try { $session = new Session(3600); } catch (Exception $e) { echo $e->getMessage(); } ?> <style> .account, .user{ width:192px; height:92px; font:10px arial; border:2px dashed #B0ADAD; background-color: #D9D7D7; padding: 2px; } .account h1, .user h1{ font:bold 12px arial; } </style> <?php try { $testAccount = Factory::get('Account', 1); echo $testAccount; echo '<br>'; $testUserId = $testAccount->getProperty('user'); echo Factory::get('User', $testUserId); } catch (Exception $e) { echo $e->getMessage(); }
/** * @covers \phpDocumentor\Plugin\Scrybe\Template\Factory::get * @expectedException \RuntimeException */ public function testGetInvalidTemplateEngine() { $factory = new Factory(); $factory->register('Mock', '\\DOMDocument'); $factory->get('Mock'); }
/** * @expectedException \InvalidArgumentException */ public function testNotexisting() { $this->factory->get('ClassNotExisting'); }
/** * @test * @group library */ public function factoryReturnsChildExtendingCmsPublisher() { $publisher = Factory::get('Externalrukzukservice'); $this->assertSame('Cms\\Publisher\\Publisher', get_parent_class($publisher)); }
public function testGetCustom() { $this->assertInstanceOf('Emarref\\Jwt\\HeaderParameter\\Custom', $this->factory->get('foo')); }
/** * @expectedException \Zerg\Field\ConfigurationException * */ public function testCreationException() { Factory::get(['foo']); }