/** * @param BindingSessionInterface $session * @param array $sessionParameters * @param Cache|null $typeDefinitionCache * @param BindingsObjectFactoryInterface|null $objectFactory */ public function __construct(BindingSessionInterface $session, array $sessionParameters, Cache $typeDefinitionCache = null, BindingsObjectFactoryInterface $objectFactory = null) { if (count($sessionParameters) === 0) { throw new CmisRuntimeException('Session parameters must be set!'); } if (!isset($sessionParameters[SessionParameter::BINDING_CLASS])) { throw new CmisInvalidArgumentException('Session parameters do not contain a binding class name!'); } $this->session = $session; foreach ($sessionParameters as $key => $value) { $this->session->put($key, $value); } // if ($typeDefinitionCache !== null) { // @TODO add cache // } if ($objectFactory !== null) { $this->objectFactory = $objectFactory; } else { $this->objectFactory = new BindingsObjectFactory(); } $this->repositoryService = new RepositoryService($this->session); }
/** * Returns the type definition cache from the session. * * @param BindingSessionInterface $session * @return Cache * @throws CmisRuntimeException Exception is thrown if cache instance could not be initialized. */ public function getTypeDefinitionCache(BindingSessionInterface $session) { $cache = $session->get(self::TYPE_DEFINITION_CACHE); if ($cache !== null) { return $cache; } $className = $session->get(SessionParameter::TYPE_DEFINITION_CACHE_CLASS); try { $cache = new $className(); } catch (\Exception $exception) { throw new CmisRuntimeException(sprintf('Could not create object of type "%s"!', $className), null, $exception); } $session->put(self::TYPE_DEFINITION_CACHE, $cache); return $cache; }