Пример #1
0
 /**
  * @return bool
  */
 public static function isCloudStorageCdnEnabled()
 {
     if (!static::isCloudStorageEnabled()) {
         return false;
     }
     return Config::get(LibraryConstants::CLOUD_CDN_ENABLED) === true;
 }
Пример #2
0
 /**
  * @return \PHPUnit_Framework_MockObject_MockObject|\Unit\Spryker\Shared\ZedRequest\Client\Fixture\AbstractHttpClient
  */
 protected function getAbstractRequestMock()
 {
     $baseUrl = 'http://' . Config::get(ApplicationConstants::HOST_ZED_GUI);
     $client = new AuthClient();
     $url = $baseUrl . '/';
     return $this->getMockBuilder(AbstractHttpClient::class)->setMethods(['sendRequest'])->setConstructorArgs([$client, $url])->getMock();
 }
Пример #3
0
 /**
  * @return \Monolog\Handler\StreamHandler
  */
 protected function createStreamHandler()
 {
     $streamHandler = new StreamHandler(Config::get(LogConstants::LOG_FILE_PATH), Config::get(LogConstants::LOG_LEVEL, Logger::INFO));
     $formatter = new LogstashFormatter('Spryker');
     $streamHandler->setFormatter($formatter);
     return $streamHandler;
 }
Пример #4
0
 /**
  * @param string $searchString
  *
  * @return \Elastica\Query\BoolQuery
  */
 protected function createFullTextSearchQuery($searchString)
 {
     $fields = [PageIndexMap::FULL_TEXT, PageIndexMap::FULL_TEXT_BOOSTED . '^' . Config::get(SearchConstants::FULL_TEXT_BOOSTED_BOOSTING_VALUE)];
     $multiMatch = (new MultiMatch())->setFields($fields)->setQuery($searchString)->setType(MultiMatch::TYPE_CROSS_FIELDS);
     $boolQuery = (new BoolQuery())->addMust($multiMatch);
     return $boolQuery;
 }
Пример #5
0
 /**
  * @param \Silex\Application $app
  *
  * @return void
  */
 public function register(Application $app)
 {
     $this->app = $app;
     $this->provideFormTypeExtension();
     $this->provideFormTypeTemplates();
     $app['twig.loader.zed'] = $app->share(function () {
         $namespaces = Config::get(ApplicationConstants::PROJECT_NAMESPACES);
         $storeName = Store::getInstance()->getStoreName();
         $paths = [];
         foreach ($namespaces as $namespace) {
             $paths[] = APPLICATION_SOURCE_DIR . '/' . $namespace . '/Zed/%s' . $storeName . '/Presentation/';
             $paths[] = APPLICATION_SOURCE_DIR . '/' . $namespace . '/Zed/%s/Presentation/';
         }
         $paths[] = $this->getConfig()->getBundlesDirectory() . '/%2$s/src/Spryker/Zed/%1$s/Presentation/';
         return new Filesystem($paths);
     });
     $app['twig.loader'] = $app->share(function ($app) {
         return new Twig_Loader_Chain([$app['twig.loader.zed'], $app['twig.loader.filesystem']]);
     });
     $app['twig.options'] = Config::get(ApplicationConstants::ZED_TWIG_OPTIONS);
     $app['twig.global.variables'] = $app->share(function () {
         return [];
     });
     $app['twig'] = $app->share($app->extend('twig', function (\Twig_Environment $twig) use($app) {
         foreach ($app['twig.global.variables'] as $name => $value) {
             $twig->addGlobal($name, $value);
         }
         return $twig;
     }));
 }
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @throws \Exception
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!Config::get(ApplicationConstants::ALLOW_INTEGRATION_CHECKS, false)) {
         throw new Exception('This command is only allowed to run in development environment');
     }
     $this->checkApplication($this->getCheckSteps());
 }
 /**
  * @param \Silex\Application $app
  *
  * @return void
  */
 public function register(Application $app)
 {
     if ((int) Config::get(ApplicationConstants::LOG_LEVEL) === 0) {
         return;
     }
     $app['logger'] = function () use($app) {
         return $app['monolog'];
     };
     $app['monolog.logger.class'] = 'Monolog\\Logger';
     $app['monolog'] = $app->share(function ($app) {
         $log = new $app['monolog.logger.class']($app['monolog.name']);
         $log->pushHandler($app['monolog.handler']);
         if ($app['debug']) {
             $log->pushHandler($app['monolog.handler.debug']);
         }
         return $log;
     });
     $app['monolog.logfile'] = function () {
         return Log::getFilePath('message.log');
     };
     $app['monolog.handler.debug'] = function () use($app) {
         return new StreamHandler($app['monolog.logfile'], $app['monolog.level']);
     };
     $app['monolog.handler'] = function () use($app) {
         return new EventJournalHandler($app['monolog.level']);
     };
     $app['monolog.level'] = function () {
         return Logger::INFO;
     };
     $app['monolog.name'] = 'yves';
 }
Пример #8
0
 /**
  * @param \Codeception\Lib\ModuleContainer $moduleContainer
  * @param null $config
  */
 public function __construct(ModuleContainer $moduleContainer, $config)
 {
     $propelConfig = Config::get(PropelConstants::PROPEL);
     $defaultConfig = $propelConfig['database']['connections']['default'];
     $config += ['dsn' => $defaultConfig['dsn'], 'user' => Config::get(PropelConstants::ZED_DB_USERNAME), 'password' => Config::get(PropelConstants::ZED_DB_PASSWORD)];
     parent::__construct($moduleContainer, $config);
 }
Пример #9
0
 /**
  * @return \Spryker\Shared\Kernel\ClassResolver\Cache\ProviderInterface
  */
 public function createClassResolverCacheProvider()
 {
     $this->assertConfig();
     $className = Config::get(KernelConstants::AUTO_LOADER_UNRESOLVABLE_CACHE_PROVIDER);
     $cacheProvider = new $className();
     $this->assertProviderInterface($cacheProvider);
     return $cacheProvider;
 }
 /**
  * @return \Elastica\Client
  */
 protected function createZedClient()
 {
     $config = ['transport' => ucfirst(Config::get(ApplicationConstants::ELASTICA_PARAMETER__TRANSPORT)), 'port' => Config::get(ApplicationConstants::ELASTICA_PARAMETER__PORT), 'host' => Config::get(ApplicationConstants::ELASTICA_PARAMETER__HOST)];
     if (Config::hasValue(ApplicationConstants::ELASTICA_PARAMETER__AUTH_HEADER)) {
         $config['headers'] = ['Authorization' => 'Basic ' . Config::get(ApplicationConstants::ELASTICA_PARAMETER__AUTH_HEADER)];
     }
     return new Client($config);
 }
Пример #11
0
 /**
  * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
  *
  * @return void
  */
 private function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults([self::OPTION_KEY_APPLICATION => self::APPLICATION, self::OPTION_KEY_BUNDLE_PROJECT_PATH_PATTERN => self::BUNDLE_PATH_PATTERN, self::OPTION_KEY_BUNDLE_PATH_PATTERN => self::BUNDLE_PATH_PATTERN, self::OPTION_KEY_PROJECT_PATH_PATTERN => APPLICATION_SOURCE_DIR, self::OPTION_KEY_VENDOR_PATH_PATTERN => Config::get(ApplicationConstants::APPLICATION_SPRYKER_ROOT) . '/*/src']);
     $resolver->setRequired([self::OPTION_KEY_PROJECT_PATH_PATTERN, self::OPTION_KEY_VENDOR_PATH_PATTERN, self::OPTION_KEY_APPLICATION]);
     $resolver->setAllowedTypes(self::OPTION_KEY_PROJECT_PATH_PATTERN, 'string');
     $resolver->setAllowedTypes(self::OPTION_KEY_VENDOR_PATH_PATTERN, 'string');
     $resolver->setAllowedTypes(self::OPTION_KEY_APPLICATION, 'string');
 }
Пример #12
0
 /**
  * @return array
  */
 private function getPropelConfig()
 {
     $propelConfig = Config::get(PropelConstants::PROPEL)['database']['connections']['default'];
     $propelConfig['user'] = Config::get(PropelConstants::ZED_DB_USERNAME);
     $propelConfig['password'] = Config::get(PropelConstants::ZED_DB_PASSWORD);
     $propelConfig['dsn'] = Config::get(PropelConstants::PROPEL)['database']['connections']['default']['dsn'];
     return $propelConfig;
 }
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return int|null
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (Config::get(PropelConstants::ZED_DB_ENGINE) === Config::get(PropelConstants::ZED_DB_ENGINE_PGSQL)) {
         $this->info('Adjust propel config for PostgreSQL and missing functions (group_concat)');
         $this->getFacade()->adjustPropelSchemaFilesForPostgresql();
         $this->getFacade()->adjustPostgresqlFunctions();
     }
 }
 /**
  * @return array
  */
 protected function getHstsConfig()
 {
     $config = [];
     if (Config::hasKey(ApplicationConstants::YVES_HTTP_STRICT_TRANSPORT_SECURITY_CONFIG)) {
         $config = Config::get(ApplicationConstants::YVES_HTTP_STRICT_TRANSPORT_SECURITY_CONFIG);
     }
     return $config;
 }
Пример #15
0
 /**
  * @throws \Spryker\Zed\Propel\Business\Exception\DatabaseCreatorNotFoundException
  *
  * @return \Spryker\Zed\Propel\Business\Model\PropelDatabase\DatabaseCreatorInterface
  */
 protected function getDatabaseCreator()
 {
     $engine = Config::get(PropelConstants::ZED_DB_ENGINE);
     if (!$this->databaseCreatorCollection->has($engine)) {
         throw new DatabaseCreatorNotFoundException(sprintf('Can not find a DatabaseCreator for "%s" engine', $engine));
     }
     return $this->databaseCreatorCollection->get($engine);
 }
Пример #16
0
 /**
  * @return void
  */
 protected function addConfiguredFilters()
 {
     $filters = Config::get(EventJournalConstants::FILTERS, []);
     $filterOptions = Config::get(EventJournalConstants::FILTER_OPTIONS, []);
     foreach ($filters[APPLICATION] as $filter) {
         $filterConfig = isset($filterOptions[$filter]) ? $filterOptions[$filter] : [];
         $this->setFilter(new $filter($filterConfig));
     }
 }
 /**
  * @param \Spryker\Zed\Kernel\ClassResolver\ClassInfo $callerClassInfo
  *
  * @return string
  */
 protected function buildMessage(ClassInfo $callerClassInfo)
 {
     $message = 'Spryker Kernel Exception' . PHP_EOL;
     $message .= sprintf('Can not resolve %1$sQueryContainer in persistence layer for your bundle "%1$s"', $callerClassInfo->getBundle()) . PHP_EOL;
     $message .= 'You can fix this by adding the missing QueryContainer to your bundle.' . PHP_EOL;
     $message .= sprintf('E.g. %1$s\\Zed\\%2$s\\Persistence\\%2$sQueryContainer', Config::getInstance()->get(KernelConstants::PROJECT_NAMESPACE), $callerClassInfo->getBundle());
     $message .= new Backtrace();
     return $message;
 }
 /**
  * @param \Spryker\Shared\Kernel\ClassResolver\ClassInfo $callerClassInfo
  *
  * @return string
  */
 protected function buildMessage(ClassInfo $callerClassInfo)
 {
     $message = 'Spryker Kernel Exception' . PHP_EOL;
     $message .= sprintf('Can not resolve %1$sDependencyProvider for your bundle "%1$s"', $callerClassInfo->getBundle()) . PHP_EOL;
     $message .= 'You can fix this by adding the missing DependencyProvider to your bundle.' . PHP_EOL;
     $message .= sprintf('E.g. %s\\Yves\\%2$s\\%2$sDependencyProvider', Config::getInstance()->get(KernelConstants::PROJECT_NAMESPACE), $callerClassInfo->getBundle());
     $message .= PHP_EOL . new Backtrace();
     return $message;
 }
Пример #19
0
 /**
  * @return array
  */
 public function getSourceDirectories()
 {
     $directories = [Config::get(ApplicationConstants::APPLICATION_SPRYKER_ROOT) . '/*/src/*/Shared/*/Transfer/'];
     $applicationTransferGlobPattern = APPLICATION_SOURCE_DIR . '/*/Shared/*/Transfer/';
     if (glob($applicationTransferGlobPattern)) {
         $directories[] = $applicationTransferGlobPattern;
     }
     return $directories;
 }
Пример #20
0
 /**
  * @param \Spryker\Zed\Kernel\ClassResolver\ClassInfo $callerClassInfo
  *
  * @return string
  */
 protected function buildMessage(ClassInfo $callerClassInfo)
 {
     $message = 'Spryker Kernel Exception' . PHP_EOL;
     $message .= sprintf('Can not resolve $1Facade in Business layer for your bundle "%s"', $callerClassInfo->getBundle()) . PHP_EOL;
     $message .= 'You can fix this by adding the missing Facade to your bundle.' . PHP_EOL;
     $message .= sprintf('E.g. %s\\Zed\\%2$s\\Business\\%2$sFacade', Config::getInstance()->get(KernelConstants::PROJECT_NAMESPACE), $callerClassInfo->getBundle());
     $message .= new Backtrace();
     return $message;
 }
Пример #21
0
 /**
  * @param array $composerJson
  * @param \Symfony\Component\Finder\SplFileInfo $composerJsonFile
  *
  * @return array
  */
 public function update(array $composerJson, SplFileInfo $composerJsonFile)
 {
     if (!Config::hasValue(DevelopmentConstants::COMPOSER_BRANCH_ALIAS)) {
         return $composerJson;
     }
     $alias = Config::get(DevelopmentConstants::COMPOSER_BRANCH_ALIAS);
     $composerJson[self::KEY_EXTRA] = [self::KEY_BRANCH_ALIAS => [self::KEY_MASTER_BRANCH => $alias]];
     return $composerJson;
 }
Пример #22
0
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->info('Build propel models');
     $config = Config::get(PropelConstants::PROPEL);
     $command = 'APPLICATION_ENV=' . APPLICATION_ENV . ' APPLICATION_STORE=' . APPLICATION_STORE . ' APPLICATION_ROOT_DIR=' . APPLICATION_ROOT_DIR . ' APPLICATION=' . APPLICATION . ' vendor/bin/propel model:build --config-dir ' . $config['paths']['phpConfDir'] . ' --schema-dir ' . $config['paths']['schemaDir'] . ' --disable-namespace-auto-package';
     $process = new Process($command, APPLICATION_ROOT_DIR);
     return $process->run(function ($type, $buffer) {
         echo $buffer;
     });
 }
Пример #23
0
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->info('Build sql');
     $config = Config::get(PropelConstants::PROPEL);
     $command = 'vendor/bin/propel sql:build --config-dir ' . $config['paths']['phpConfDir'] . ' --schema-dir ' . $config['paths']['schemaDir'];
     $process = new Process($command, APPLICATION_ROOT_DIR);
     return $process->run(function ($type, $buffer) {
         echo $buffer;
     });
 }
Пример #24
0
 /**
  * close redis connection
  */
 public function __destruct()
 {
     $isPersistent = false;
     if (Config::hasKey(LibraryConstants::YVES_STORAGE_SESSION_PERSISTENT_CONNECTION)) {
         $isPersistent = (bool) Config::get(LibraryConstants::YVES_STORAGE_SESSION_PERSISTENT_CONNECTION);
     }
     if (!$isPersistent && $this->resource) {
         $this->resource->disconnect();
     }
 }
 /**
  * @return callable
  */
 protected function getFunction()
 {
     return function ($path) {
         $path = ltrim($path, '@');
         $bundleName = strstr($path, '/', true);
         $bundleName = ucfirst($bundleName);
         $bundlePath = strstr($path, '/');
         $projectName = Config::getInstance()->get(ApplicationConstants::PROJECT_NAMESPACE);
         return sprintf('%s/%s/Zed/%s/Presentation%s', APPLICATION_SOURCE_DIR, $projectName, $bundleName, $bundlePath);
     };
 }
 /**
  * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
  *
  * @return void
  */
 protected function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults([self::OPTION_KEY_APPLICATION => self::APPLICATION, self::OPTION_KEY_NAMESPACE_PATTERN => self::NAMESPACE_PATTERN, self::OPTION_KEY_PROJECT_PATH_PATTERN => APPLICATION_SOURCE_DIR, self::OPTION_KEY_VENDOR_PATH_PATTERN => Config::get(ApplicationConstants::APPLICATION_SPRYKER_ROOT) . '/*/src']);
     $resolver->setRequired([self::OPTION_KEY_METHOD_STRING_PATTERN, self::OPTION_KEY_PATH_PATTERN, self::OPTION_KEY_FILE_NAME_SUFFIX, self::OPTION_KEY_PROJECT_PATH_PATTERN, self::OPTION_KEY_VENDOR_PATH_PATTERN, self::OPTION_KEY_APPLICATION]);
     $resolver->setAllowedTypes(self::OPTION_KEY_METHOD_STRING_PATTERN, 'string');
     $resolver->setAllowedTypes(self::OPTION_KEY_PATH_PATTERN, 'string');
     $resolver->setAllowedTypes(self::OPTION_KEY_FILE_NAME_SUFFIX, 'string');
     $resolver->setAllowedTypes(self::OPTION_KEY_PROJECT_PATH_PATTERN, 'string');
     $resolver->setAllowedTypes(self::OPTION_KEY_VENDOR_PATH_PATTERN, 'string');
     $resolver->setAllowedTypes(self::OPTION_KEY_APPLICATION, 'string');
 }
Пример #27
0
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->runDependingCommand(SchemaCopyConsole::COMMAND_NAME);
     $this->info('Create diff');
     $config = Config::get(PropelConstants::PROPEL);
     $command = 'vendor/bin/propel diff --config-dir ' . $config['paths']['phpConfDir'] . ' --schema-dir ' . $config['paths']['schemaDir'];
     $process = new Process($command, APPLICATION_ROOT_DIR);
     $process->setTimeout(self::PROCESS_TIMEOUT);
     return $process->run(function ($type, $buffer) {
         echo $buffer;
     });
 }
Пример #28
0
 /**
  * @param array $data
  *
  * @return void
  */
 public function persist(array $data)
 {
     try {
         $string = var_export($data, true);
         $flag = LOCK_EX | LOCK_NB;
         if (Config::get(KernelConstants::AUTO_LOADER_CACHE_FILE_NO_LOCK)) {
             $flag = LOCK_NB;
         }
         file_put_contents($this->getCacheFilename(), '<?php return ' . $string . ';', $flag);
     } catch (Exception $exception) {
     }
 }
Пример #29
0
 /**
  * @param \Spryker\Shared\ZedRequest\Client\RequestInterface $transferObject
  * @param \Symfony\Component\HttpFoundation\Request $httpRequest
  *
  * @return void
  */
 public function setRepeatData(RequestInterface $transferObject, HttpRequest $httpRequest)
 {
     if ($this->isRepeatInProgress) {
         return;
     }
     if (Config::get(ApplicationConstants::SET_REPEAT_DATA, false) === false) {
         return;
     }
     $repeatData = ['module' => $httpRequest->attributes->get('module'), 'controller' => $httpRequest->attributes->get('controller'), 'action' => $httpRequest->attributes->get('action'), 'params' => $transferObject->toArray(false)];
     $mvc = sprintf('%s_%s_%s', $httpRequest->attributes->get('module'), $httpRequest->attributes->get('controller'), $httpRequest->attributes->get('action'));
     Log::setFlashInFile($repeatData, 'last_yves_request_' . $mvc . '.log');
     Log::setFlashInFile($repeatData, 'last_yves_request.log');
 }
 /**
  * @return callable
  */
 protected function getFunction()
 {
     return function ($path, $dataType = 'x-font-woff', $absolutePath = false) {
         if (!$absolutePath) {
             $path = ltrim($path, '@');
             $bundleName = strstr($path, '/', true);
             $bundleName = ucfirst($bundleName);
             $bundlePath = strstr($path, '/');
             $projectName = Config::getInstance()->get(ApplicationConstants::PROJECT_NAMESPACE);
             $fullPath = sprintf('%s/%s/Zed/%s/Presentation%s', APPLICATION_SOURCE_DIR, $projectName, $bundleName, $bundlePath);
         } else {
             $fullPath = $path;
         }
         $base64Content = base64_encode(file_get_contents($fullPath));
         return sprintf('data:application/%s;charset=utf-8;base64,%s', $dataType, $base64Content);
     };
 }