/**
  * Fetch configuration details for a named adapter
  *
  * @param  string $name
  * @return ContentNegotiationEntity|false
  */
 public function fetch($name)
 {
     $config = $this->globalConfig->fetch(true);
     if (!isset($config['zf-content-negotiation']['selectors'][$name]) || !is_array($config['zf-content-negotiation']['selectors'][$name])) {
         return false;
     }
     return new ContentNegotiationEntity($name, $config['zf-content-negotiation']['selectors'][$name]);
 }
 /**
  * Delete the REST configuration associated with the given
  * service
  *
  * @param DoctrineRestServiceEntity $entity
  */
 public function deleteDoctrineRestConfig(DoctrineRestServiceEntity $entity)
 {
     // Get hydrator name
     $config = $this->configResource->fetch(true);
     $hydratorName = $config['zf-hal']['metadata_map'][$entity->entityClass]['hydrator'];
     $objectManagerClass = $config['doctrine-hydrator'][$hydratorName]['object_manager'];
     $key = ['doctrine-hydrator', $hydratorName];
     $this->configResource->deleteKey($key);
     $key = ['zf-apigility', 'doctrine-connected', $entity->resourceClass];
     $this->configResource->deleteKey($key);
     $key = ['zf-rest', $entity->controllerServiceName];
     $this->configResource->deleteKey($key);
     $key = ['zf-content-negotiation', 'controllers', $entity->controllerServiceName];
     $this->configResource->deleteKey($key);
     $key = ['zf-content-negotiation', 'accept-whitelist', $entity->controllerServiceName];
     $this->configResource->deleteKey($key);
     $key = ['zf-content-negotiation', 'content-type-whitelist', $entity->controllerServiceName];
     $this->configResource->deleteKey($key);
     $key = ['zf-hal', 'metadata_map', $entity->collectionClass];
     $this->configResource->deleteKey($key);
     $key = ['zf-hal', 'metadata_map', $entity->entityClass];
     $this->configResource->deleteKey($key);
     $validator = $config['zf-content-validation'][$entity->controllerServiceName]['input_filter'];
     $key = ['zf-content-validation', $entity->controllerServiceName];
     $this->configResource->deleteKey($key);
     $key = ['input_filter_specs', $validator];
     $this->configResource->deleteKey($key);
 }
 /**
  * Fetch configuration details for a named adapter
  *
  * @param $name
  * @return bool|DoctrineAdapterEntity
  */
 public function fetch($name)
 {
     $config = $this->localConfig->fetch(true);
     if (!isset($config['doctrine']) || !isset($config['doctrine']['connection']) || !is_array($config['doctrine']['connection']) || !isset($config['doctrine']['connection'][$name]) || !is_array($config['doctrine']['connection'][$name])) {
         return false;
     }
     return new DoctrineAdapterEntity($name, $config['doctrine']['connection'][$name]);
 }
 /**
  * Fetch configuration details for a named adapter
  *
  * @param  string $name
  * @return DbAdapterEntity|false
  */
 public function fetch($name)
 {
     $config = $this->localConfig->fetch(true);
     if (!isset($config['db']['adapters'][$name]) || !is_array($config['db']['adapters'][$name])) {
         return false;
     }
     return new DbAdapterEntity($name, $config['db']['adapters'][$name]);
 }
 /**
  * Remove authentication
  *
  * @return true
  */
 public function removeOldAuthentication()
 {
     $configKeys = ['zf-mvc-auth.authentication.http', 'zf-oauth2.db', 'zf-oauth2.mongo', 'zf-oauth2.storage'];
     foreach ($configKeys as $key) {
         $this->globalConfig->deleteKey($key);
         $this->localConfig->deleteKey($key);
     }
     return true;
 }
 /**
  * Delete the Content Negotiation configuration for a named RPC
  * service
  *
  * @param string $serviceName
  */
 public function deleteContentNegotiationConfig($serviceName)
 {
     $key = array('zf-content-negotiation', 'controllers', $serviceName);
     $this->configResource->deleteKey($key);
     $key = array('zf-content-negotiation', 'accept-whitelist', $serviceName);
     $this->configResource->deleteKey($key);
     $key = array('zf-content-negotiation', 'content-type-whitelist', $serviceName);
     $this->configResource->deleteKey($key);
 }
Пример #7
0
    /**
     * Update the authorization list for a given module by version
     *
     * @param array $privileges
     * @param int $version
     * @return AuthorizationEntity
     */
    public function update(array $privileges, $version = 1)
    {
        $toStore = array(
            'zf-mvc-auth' => array(
                'authorization' => $this->remapServiceNamesForStorage($privileges),
            ),
        );

        $this->configResource->patch($toStore, true);
        return $this->fetch($version);
    }
 /**
  * Update the documentation to add a new $version based on the $previous
  *
  * @param  int $previous Previous version
  * @param  int $version New version
  * @return true
  */
 protected function updateDocumentationVersion($previous, $version)
 {
     if (!$this->docsConfigResource) {
         // Nothing to do
         return true;
     }
     $originalDocs = $this->docsConfigResource->fetch(true);
     $newDocs = $this->changeVersionArray($originalDocs, $previous, $version);
     $this->docsConfigResource->patch($newDocs, true);
     return true;
 }
 /**
  * Traverse an array for a subkey
  *
  * Subkey is given in "." notation, which is then split, and
  * the configuration is traversed until no more keys are available,
  * or a corresponding entry is not found; in the latter case,
  * the $default will be provided.
  *
  * @param string $subKey
  * @param array|mixed $default
  * @return mixed
  */
 protected function getConfigForSubkey($subKey, $default = [])
 {
     $config = $this->configResource->fetch(true);
     $keys = explode('.', $subKey);
     do {
         $key = array_shift($keys);
         if (!isset($config[$key])) {
             return $default;
         }
         $config = $config[$key];
     } while (count($keys));
     return $config;
 }
 /**
  * Patch the OAuth2 configuration
  *
  * @param AuthenticationEntity $entity
  * @param array $global
  * @param array $local
  * @return void
  */
 protected function patchOAuth2Config(AuthenticationEntity $entity, array $global, array $local)
 {
     if (isset($global['route_match']) && $global['route_match']) {
         $this->globalConfig->patchKey('router.routes.oauth.options.route', $global['route_match']);
     }
     switch ($entity->getDsnType()) {
         case AuthenticationEntity::DSN_MONGO:
             $toSet = array('storage' => 'ZF\\OAuth2\\Adapter\\MongoAdapter', 'mongo' => $local);
             break;
         case AuthenticationEntity::DSN_PDO:
         default:
             $toSet = array('storage' => 'ZF\\OAuth2\\Adapter\\PdoAdapter', 'db' => $local);
             break;
     }
     $key = 'zf-oauth2';
     $this->localConfig->patchKey($key, $toSet);
 }
 public function testDeleteNonexistentKeyShouldDoNothing()
 {
     $config = [];
     $writer = new PhpArray();
     $writer->toFile($this->file, $config);
     // Ensure the writer has written to the file!
     $this->assertEquals($config, include $this->file);
     // Create config resource, and delete a key
     $configResource = new ConfigResource($config, $this->file, $writer);
     $test = $configResource->deleteKey('sub.sub2.sub3');
     // Verify what was returned was what we expected
     $expected = [];
     $this->assertEquals($expected, $test);
     // Verify the file contains what we expect
     $test = (include $this->file);
     $this->assertEquals($expected, $test);
 }
 /**
  * Delete authorization configuration associated with a service
  *
  * @param  string $serviceName
  */
 public function deleteAuthorizationConfig($serviceName)
 {
     $key = ['zf-mvc-auth', 'authorization', $serviceName];
     $this->configResource->deleteKey($key);
 }
Пример #13
0
 protected function persistData()
 {
     $this->configResource->overWrite($this->data);
 }