Build writer strategy object.

@param string $basePath Base path for harvest
@param array  $settings Configuration settings

@return RecordWriterStrategyInterface
762159
public function getStrategy($basePath, $settings = [])
    {
        if (isset($settings['combineRecords']) && $settings['combineRecords']) {
            $combineTag = $settings['combineRecordsTag'] ?? null;
            return new CombinedRecordWriterStrategy($basePath, $combineTag);
        }
        return new IndividualRecordWriterStrategy($basePath);
    }
436558
public function determineFilePath($path, $basePath = null, $makeDir = false)
    {
        $this->logger->debug(sprintf('Search for path: %s with a prefix base path: %s', $path, $basePath));

        if ($this->variable->isEmpty($path)) {
            $this->logger->warning('No Path given to method');
            throw new \Exception('No Path given to method');
        }

        if ($this->variable->isEmpty($basePath)) {
            $basePath = BP;
        }

        // for windows systems
        $path = preg_replace('/\\\\/', '/', $path);

        $path = preg_match('/^\//', $path) || preg_match('/^[a-zA-Z]:\//', $path) ? rtrim($path, '/') :
            rtrim($basePath, '/') . '/' . trim($path, '/');

        $fileCheck = pathinfo($path);
        // Check for last character
        $pathEnding = substr($path, -1);

        if (( ! array_key_exists('extension', $fileCheck) || $this->variable->isEmpty($fileCheck[ 'extension' ])) &&
            $pathEnding != "/" && $pathEnding != "\\"
        ) {
            $path .= '/';
        }

        $dirPath = ! isset($fileCheck[ 'extension' ]) ? $path : dirname($path);

        if ($makeDir && ! is_dir($dirPath)) {
            $this->logger->debug(sprintf('Creating directory with path: %s', $path));

            if ($this->makeDirs($dirPath)) {
                $this->logger->debug(sprintf('Successfully created directory with path: %s', $dirPath));
            } else {
                $this->logger->warning(sprintf('Could not create directory with path: %s', $path));
            }
        }

        $this->logger->debug(sprintf('Created absolute path: %s', $path));

        return $path;
    }
395825
public function saveConfiguration($settings)
    {
        if (file_exists($this->path) && !is_writable($this->path)) {
            throw new Exception('The file "' . $this->path . '" isn\'t writable!');
        }
        
        $content = json_encode($settings);
        
        return file_put_contents($this->path, $content);
    }
727106
public function setCachePath($cachePath)
    {
        if (empty($cachePath) || !is_writable($cachePath)) {
            throw new PageCacheException(__METHOD__.' - Cache path not writable: '.$cachePath);
        }
        if (substr($cachePath, -1) !== '/') {
            throw new PageCacheException(__METHOD__.' - / trailing slash is expected at the end of cache_path.');
        }
        $this->cachePath = $cachePath;
        return $this;
    }
987987
private function buildIcons(array $resources, $basePath)
    {
        $data = [];

        foreach ($resources as $resource) {
            if (!preg_match("#^/phlexible/(.+?)/icons/(.*\.(png|gif))$#", $resource->getPath(), $match)) {
                continue;
            }

            $bundle = $match[1];
            $path = $match[2];
            $extension = $match[3];

            $filesystemPath = $resource->getFilesystemPath();
            $file = basename($filesystemPath);
            $name = basename($filesystemPath, ".$extension");

            $size = getimagesize($filesystemPath);
            if ($size[0] !== 16 || $size[1] !== 16) {
                continue;
            }

            $selector = sprintf('.p-%s-%s-icon', str_replace('phlexible', '', $bundle), $name);

            $data[] = [
                'bundle' => $bundle,
                'path' => $path,
                'file' => $file,
                'name' => $name,
                'selector' => $selector,
                'extension' => $extension,
            ];
        }

        $urlTemplate = $basePath.'/bundles/%s/icons/%s';

        $icons = '/* Created: '.date('Y-m-d H:i:s').' */'.PHP_EOL;

        foreach ($data as $row) {
            $url = sprintf($urlTemplate, $row['bundle'], $row['path']);

            $style = $row['selector'].' {background-image: url('.$url.') !important;}'.PHP_EOL;

            $icons .= $style;
        }

        return $icons;
    }
1083924
protected function buildSql(array $settings)/*# : string */
    {
        $result = $this->getType(); // type
        $settings['join'] = $settings['seperator'] . $settings['indent'];

        $result .= $this->buildBeforeAfter('AFTER', 'TYPE', $settings); // hint
        foreach ($this->getConfigs() as $pos => $prefix) {
            // before
            $result .= $this->buildBeforeAfter('BEFORE', $pos, $settings);

            $method = 'build' . ucfirst(strtolower($pos));
            $result .= $this->{$method}($prefix, $settings);

            // after
            $result .= $this->buildBeforeAfter('AFTER', $pos, $settings);
        }

        $result .= $this->buildBeforeAfter('AFTER', 'STMT', $settings);
        return $result;
    }
681204
public function baseUrl($targetPath = null)
    {
        if (!isset($this->baseUrl)) {
            throw new RuntimeException(sprintf(
                'The base URI is not defined for [%s]',
                get_class($this)
            ));
        }

        if ($targetPath !== null) {
            return $this->createAbsoluteUrl($this->baseUrl, $targetPath);
        }

        return rtrim($this->baseUrl, '/').'/';
    }
132434
private function createPackageDefinition($basePath, array $baseUrls, Reference $version)
    {
        if ($basePath && $baseUrls) {
            throw new \LogicException('An asset package cannot have base URLs and base paths.');
        }

        $package = new ChildDefinition($baseUrls ? 'assets.url_package' : 'assets.path_package');
        $package
            ->setPublic(false)
            ->replaceArgument(0, $baseUrls ?: $basePath)
            ->replaceArgument(1, $version)
        ;

        return $package;
    }
634104
public function create(array $settings = [])
    {
        $defaultDriver = $this->config->get('doctrine.cache.default', 'array');

        $configuration = $this->setup->createConfiguration(
            Arr::get($settings, 'dev', false),
            Arr::get($settings, 'proxies.path'),
            $this->cache->driver($defaultDriver)
        );

        $this->setMetadataDriver($settings, $configuration);

        $driver = $this->getConnectionDriver($settings);

        $connection = $this->connection->driver(
            $driver['driver'],
            $driver
        );

        if ($this->isMasterSlaveConfigured($driver)) {
            $this->hasValidMasterSlaveConfig($driver);
            $connection = (new MasterSlaveConnection($this->config, $connection))->resolve($driver);
        }

        $this->setNamingStrategy($settings, $configuration);
        $this->setCustomFunctions($configuration);
        $this->setCustomHydrationModes($configuration);
        $this->setCacheSettings($configuration);
        $this->configureProxies($settings, $configuration);
        $this->setCustomMappingDriverChain($settings, $configuration);
        $this->registerPaths($settings, $configuration);
        $this->setRepositoryFactory($settings, $configuration);

        $configuration->setDefaultRepositoryClassName(
            Arr::get($settings, 'repository', EntityRepository::class)
        );

        $configuration->setEntityListenerResolver($this->resolver);

        $manager = EntityManager::create(
            $connection,
            $configuration
        );

        $manager = $this->decorateManager($settings, $manager);

        $this->setLogger($manager, $configuration);
        $this->registerListeners($settings, $manager);
        $this->registerSubscribers($settings, $manager);
        $this->registerFilters($settings, $configuration, $manager);
        $this->registerMappingTypes($settings, $manager);

        return $manager;
    }
562255
public function basePath($basePath = null)
    {
        if (!func_num_args()) {
            return $this->_basePath;
        }
        $this->_basePath = $basePath;
        return $this;
    }
135052
public static function createFromReflection(\ReflectionMethod $reflectionMethod, string $basePath = '')
    {
        $routes = [];

        if (is_a($reflectionMethod->class, '\Berlioz\Core\Controller\Controller', true)) {
            try {
                if ($reflectionMethod->isPublic()) {
                    if ($methodDoc = $reflectionMethod->getDocComment()) {
                        $docBlock = Router::getDocBlockFactory()->create($methodDoc);

                        if ($docBlock->hasTag('route')) {
                            /** @var \phpDocumentor\Reflection\DocBlock\Tags\Generic $tag */
                            foreach ($docBlock->getTagsByName('route') as $tag) {
                                $route = new Route;
                                $route->setRouteDeclaration($tag->getDescription()->render(), $basePath);
                                $route->setSummary($docBlock->getSummary());
                                $route->setDescription($docBlock->getDescription()->render());
                                $route->setInvoke($reflectionMethod->class, $reflectionMethod->getName());
                                $route->getRouteRegex();

                                $routes[] = $route;
                            }
                        }
                    }
                } else {
                    /** @var \ReflectionMethod $reflectionMethod */
                    throw new BerliozException('Must be public');
                }
            } catch (BerliozException $e) {
                /** @var \ReflectionMethod $reflectionMethod */
                throw new BerliozException(sprintf('Method "%s::%s" route error: %s', $reflectionMethod->class, $reflectionMethod->getName(), $e->getMessage()));
            }
        } else {
            throw new BerliozException(sprintf('Class "%s" must be a sub class of "\Berlioz\Core\Controller\Controller"', $reflectionMethod->class));
        }

        return $routes;
    }
53954
public function write($settings) : ?Model
    {
        if (!$this->enabled) {
            return null;
        }

        $settings = $this->parseSettings($settings);

        return Tracker::createNew($this->getPayload($settings));
    }
550941
private function getPath(UploadedFile $uploadedFile, Settings $settings)
    {
        return env('APP_NAME').DIRECTORY_SEPARATOR.$this->getSubFolder($uploadedFile).DIRECTORY_SEPARATOR.$settings->getFolder();
    }
928970
public function basePath($basePath)
    {
        if (strlen($basePath) > 1 && substr($basePath, -1) === '/') {
            $this->basePath = substr($basePath, 0, -1);
        } else {
            $this->basePath = $basePath;
        }

        return $this;
    }
260837
public function create($start = NULL, Array $settings = []) : String
    {
        # The configuration arrays are merge.
        $settings = array_merge($this->config, $this->settings, $settings);

        # If the configuration is present, it is rearranged.
        if( ! empty($settings) )
        {
            $this->settings($settings);
        }

        # Gets information about which recording to start the paging process.
        $startRowNumber = $this->getStartRowNumber($start);

        # If the limit is set to 0, 1 is accepted.
        $this->limit = $this->limit === 0 ? 1 : $this->limit;
        
        # Generate pagination bar.
        if( $this->isPaginationBar() )
        {
            return $this->isBasicPaginationBar() ? $this->createBasicPaginationBar($startRowNumber) : $this->createAdvancedPaginationBar($startRowNumber);
        }

        return false;
    }
964720
public function createFromConfig(string $path) : SettingsContract {
        $configData = (array) $this->filesystem->getRequire($path);

        return $this->createFromData($configData);
    }
783034
public static function findOrCreateBySettingName($settingName)
    {
        try {
            return self::findBySettingName($settingName);
        } catch (RecordNotFoundException $er) {
            $setting = new self();
            $setting->SettingName = $settingName;

            return $setting;
        }
    }