Read from one or more data-sources

@param ReadOptionsInterface $options
@param SectionConfig|null $sectionConfig
@return \ArrayIterator
777074
public function read(
        ReadOptionsInterface $options,
        SectionConfig $sectionConfig = null
    ): \ArrayIterator {
        $sectionData = new \ArrayIterator();

        $this->dispatcher->dispatch(
            SectionBeforeRead::NAME,
            new SectionBeforeRead($sectionData, $options, $sectionConfig)
        );

        if ($sectionConfig === null && count($options->getSection()) > 0) {
            $sectionConfig = $this->sectionManager->readByHandle(
                $options->getSection()[0]->toHandle()
            )->getConfig();
        }

        // Make sure we are passing the fully qualified class name as the section
        if (count($options->getSection()) > 0) {
            $optionsArray = $options->toArray();
            $optionsArray[ReadOptions::SECTION] = (string)$sectionConfig->getFullyQualifiedClassName();
            $options = ReadOptions::fromArray($optionsArray);
        }

        /** @var ReadSectionInterface $reader */
        foreach ($this->readers as $reader) {
            foreach ($reader->read($options, $sectionConfig) as $entry) {
                $sectionData->append($entry);
            }
        }

        $this->dispatcher->dispatch(
            SectionDataRead::NAME,
            new SectionDataRead($sectionData, $options, $sectionConfig)
        );

        return $sectionData;
    }
249733
public function deserialize(array $data, Options $options = null)
    {
        if (empty($options)) {
            $options = $this->optionsRepo->findOneBy(['id' => $data['id']]);
        }
        if (empty($options)) {
            $options = new Options();
        }
        if (isset($data['user'])) {
            $user = isset($data['user']['id']) ? $this->userRepo->findOneBy(['uuid' => $data['user']['id']]) : null;
            $options->setUser($user);
        }
        if (isset($data['data'])) {
            $options->setOptions($data['data']);
        }

        return $options;
    }
1212592
public function connect(array $config, array $options)
    {
        return new PhpRedisConnection($this->createClient(array_merge(
            $config, $options, Arr::pull($config, 'options', [])
        )));
    }
1002691
public function get_option($config = '') {
        if ($config === 'dropbox_key') {
            return trim(get_config('dropbox', 'dropbox_key'));
        } else if ($config === 'dropbox_secret') {
            return trim(get_config('dropbox', 'dropbox_secret'));
        } else if ($config === 'dropbox_cachelimit') {
            return $this->max_cache_bytes();
        } else {
            $options = parent::get_option();
            $options['dropbox_key'] = trim(get_config('dropbox', 'dropbox_key'));
            $options['dropbox_secret'] = trim(get_config('dropbox', 'dropbox_secret'));
            $options['dropbox_cachelimit'] = $this->max_cache_bytes();
        }

        return $options;
    }
992429
public function setConfig($config)
    {
        if(is_string($config)){
            if (file_exists($config)) {
                $config = \Zend\Config\Factory::fromFile($config);
            } else {
                throw new \InvalidArgumentException(
                    sprintf('Unable to read configurations from file %s',$config));
            }
        }
    
        if(!is_array($config) && !($config instanceof \Traversable)){
            throw new \InvalidArgumentException(
                    sprintf('Config must be an array, Traversable object or filename; %s received',
                            is_object($config) ? get_class($config) : gettype($config)));
        }
    
        $this->setOptions($config);
    }
300016
public function createCollection(array $data, array $options = [])
    {
        $this->setOptions($options);
        $coll = new Collection($this->client, $this->database);
        $coll->setHeaders($this->getHeaders());
        $rs = $coll->create($data);
        $this->checkResponse($rs);
        unset($rs['_curl_info']);

        return $rs;
    }
534719
public function configASectionedCRUD($config, $section, $table, $splitTable)
    {
        $appPath = app()->path();
        $basePath = app()->basePath();
        $appNamespace = $this->appService->getAppNamespace();

        $sectionalConfig = [
            '_sectionPrefix_'            => strtolower($section).'.',
            '_sectionTablePrefix_'       => strtolower($section).'_',
            '_sectionRoutePrefix_'       => strtolower($section).'/',
            '_sectionNamespace_'         => ucfirst($section).'\\',
            '_path_facade_'              => $appPath.'/Facades',
            '_path_service_'             => $appPath.'/Services',
            '_path_model_'               => $appPath.'/Models/'.ucfirst($section).'/'.ucfirst($table),
            '_path_controller_'          => $appPath.'/Http/Controllers/'.ucfirst($section).'/',
            '_path_api_controller_'      => $appPath.'/Http/Controllers/Api/'.ucfirst($section).'/',
            '_path_views_'               => $basePath.'/resources/views/'.strtolower($section),
            '_path_tests_'               => $basePath.'/tests',
            '_path_request_'             => $appPath.'/Http/Requests/'.ucfirst($section),
            '_path_routes_'              => $appPath.'/Http/routes.php',
            '_path_api_routes_'          => $appPath.'/Http/api-routes.php',
            '_path_migrations_'          => $basePath.'/database/migrations',
            '_path_factory_'             => $basePath.'/database/factories/'.snake_case($table).'Factory.php',
            'routes_prefix'              => "\n\nRoute::group(['namespace' => '".ucfirst($section)."', 'prefix' => '".strtolower($section)."', 'middleware' => ['web']], function () { \n",
            'routes_suffix'              => "\n});",
            '_app_namespace_'            => $appNamespace,
            '_namespace_services_'       => $appNamespace.'Services\\'.ucfirst($section),
            '_namespace_facade_'         => $appNamespace.'Facades',
            '_namespace_model_'          => $appNamespace.'Models\\'.ucfirst($section).'\\'.ucfirst($table),
            '_namespace_controller_'     => $appNamespace.'Http\Controllers\\'.ucfirst($section),
            '_namespace_api_controller_' => $appNamespace.'Http\Controllers\Api\\'.ucfirst($section),
            '_namespace_request_'        => $appNamespace.'Http\Requests\\'.ucfirst($section),
            '_lower_case_'               => strtolower($splitTable[1]),
            '_lower_casePlural_'         => str_plural(strtolower($splitTable[1])),
            '_camel_case_'               => ucfirst(camel_case($splitTable[1])),
            '_camel_casePlural_'         => str_plural(camel_case($splitTable[1])),
            '_ucCamel_casePlural_'       => ucfirst(str_plural(camel_case($splitTable[1]))),
            '_table_name_'               => str_plural(strtolower(implode('_', $splitTable))),
        ];

        $config = array_merge($config, $sectionalConfig);
        $config = array_merge($config, app('config')->get('crudmaker.sectioned', []));
        $config = $this->setConfig($config, $section, $table);

        $pathsToMake = [
            '_path_model_',
            '_path_controller_',
            '_path_api_controller_',
            '_path_views_',
            '_path_request_',
        ];

        foreach ($config as $key => $value) {
            if (in_array($key, $pathsToMake) && !file_exists($value)) {
                mkdir($value, 0777, true);
            }
        }

        return $config;
    }
372907
public static function reader($config = null, $default = false) {
		if (empty($config)) {
			$config = array(
				'id' => 'json',
				'className' => 'JsonReader',
				'location' => 'Common.Configure'
			);
		}

		if (!is_array($config)) {
			$config = array(
				'id' => $config,
				'className' => ucfirst($config) . 'Reader',
				'location' => 'Configure'
			);
		}

		extract($config);

		if (Configure::configured($id)) {
			throw new ConfigureException(__d('_common_', "A reader with the '%s' name already exists.", $id));
		}

		foreach (array('id', 'className', 'location') as $var) {
			if (!isset($$var) || empty($$var)) {
				throw new ConfigureException(__d('_common_', "Reader configuration missing the '%s' key.", $key));
			}
		}

		App::uses($className, $location);
		Configure::config($default ? 'default' : $id, new $className);

		return $config;
	}
108747
protected function renderSection($sectionName, $sectionData, OutputInterface $output, FormatterHelper $formatter)
    {
        $output->writeln('');
        $output->writeln('');
        $optionsHeader = $formatter->formatSection($sectionName, '');
        $output->writeln($optionsHeader);

        foreach ($sectionData as $serviceId => $service) {
            $output->writeln('');
            $output->writeln(" - <comment>$serviceId</comment>:");

            // Class
            $output->writeln('');
            $output->writeln("     <comment>Class</comment>: ${service['class']}");

            // Routes
            $output->writeln('');
            $output->writeln('     <comment>Routes</comment>:');
            foreach ($service['routes'] as $consumerRoute) {
                $output->writeln("     - $consumerRoute");
            }

            // Options
            if (!empty($service['options'])) {
                $output->writeln('');
                $output->writeln('     <comment>Options</comment>:');
                foreach ($service['options'] as $consumerOptionName => $consumerOption) {
                    $output->writeln("     - <comment>$consumerOptionName</comment>:");
                    $output->writeln("         $consumerOption[0]");
                    if (!empty($consumerOption[1])) {
                        $output->writeln('         Accepted values:');
                        foreach ($consumerOption[1] as $value => $valueDescription) {
                            $output->writeln("         - <comment>$value</comment>: $valueDescription");
                        }
                    }
                }
            }
        }
    }
550878
public function configure(array $options = array())
    {
        if (isset($options['host'])) {
            $this->host = $options['host'];
        }
        if (isset($options['port'])) {
            if (!is_numeric($options['port']) || is_float($options['port']) || $options['port'] < 0 || $options['port'] > 65535) {
                throw new ConfigurationException($this, 'Port is out of range');
            }
            $this->port = $options['port'];
        }

        if (isset($options['namespace'])) {
            $this->namespace = $options['namespace'];
        }

        if (isset($options['timeout'])) {
            $this->timeout = $options['timeout'];
        }

        if (isset($options['throwConnectionExceptions'])) {
            $this->throwConnectionExceptions = $options['throwConnectionExceptions'];
        }

        if (isset($options['tags'])) {
            $this->tags = $options['tags'];
        }

        return $this;
    }
1097158
public function getOptions(array $config)
    {
        $options = array_get($config, 'options', array());

        return array_diff_key($this->options, $options) + $options;
    }
1302108
public function assemble(Traversable $config, array $options = []) {
		$jsonOptions = 0;
		
		$options += $this->defaultOptions;
		
		if ($options[self::OPTION_PRETTY] === true) {
			$jsonOptions += JSON_PRETTY_PRINT;
		}
		
		return json_encode($this->iteratoToArray($config), $jsonOptions);
	}
290869
private function getSections(Options $options): array
    {
        $allSections = [];

        /** @var \eZ\Publish\API\Repository\Values\Content\Section[] $sections */
        $sections = $this->sectionService->loadSections();
        $configuredSections = $options['sections'];

        foreach ($sections as $section) {
            if (count($configuredSections) > 0 && !in_array($section->identifier, $configuredSections, true)) {
                continue;
            }

            $allSections[$section->name] = $section->identifier;
        }

        return $allSections;
    }
42575
public function getCollection(array $options = array())
    {
        /** @var UserEntity[] $collection */
        $collection = $this->userManager->findUsers();
        $resource   = new Resource($this->generateBrowseUrl(), array('count' => count($collection)));

        foreach ($collection as $element) {
            $resource->setEmbedded('user', $this->createResourceFromUser($element));
        }

        return $resource;
    }
440443
public function select($options = [])
    {
        $source = [];

        foreach ($options as $key => $value) {
            $source[] = [
                'value' => $key,
                'text' => $value,
            ];
        }

        $this->addOptions(['source' => $source]);
    }
612855
public function parseSections(array $sections, Configuration $configuration = null)
    {
        if (is_null($configuration)) {
            $configuration = new Configuration();
        }

        foreach ($sections as $sectionName => $section) {
            $name = explode(':', $sectionName, 2);

            $class = $configuration->findSection($name[0]);

            if (false === $class) {
                $class = 'Supervisor\Configuration\Section\GenericSection';
                $name[1] = $sectionName;
            }

            if (isset($name[1])) {
                $section = new $class($name[1], $section);
            } else {
                $section = new $class($section);
            }

            $configuration->addSection($section);
        }

        return $configuration;
    }
156273
public function setSection($section, array $config, $overwrite = false)
    {
        if (false === $overwrite && array_key_exists($section, $this->raw_parameters)) {
            $this->raw_parameters[$section] = Collection::array_merge_assoc_recursive($this->raw_parameters[$section], $config);
        } else {
            $this->raw_parameters[$section] = $config;
        }

        if (array_key_exists($section, $this->parameters)) {
            unset($this->parameters[$section]);
        }

        return $this;
    }