/**
  * @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());
 }
Пример #2
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);
 }
Пример #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
 /**
  * @return bool
  */
 public static function isCloudStorageCdnEnabled()
 {
     if (!static::isCloudStorageEnabled()) {
         return false;
     }
     return Config::get(LibraryConstants::CLOUD_CDN_ENABLED) === true;
 }
Пример #5
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;
 }
Пример #6
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();
 }
 /**
  * @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 \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;
     }));
 }
 /**
  * @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);
 }
 /**
  * @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;
 }
Пример #11
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;
 }
Пример #12
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);
 }
Пример #13
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');
 }
 /**
  * @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();
     }
 }
Пример #15
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;
 }
Пример #16
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;
 }
Пример #17
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));
     }
 }
Пример #18
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;
 }
Пример #19
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;
     });
 }
Пример #20
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;
     });
 }
Пример #21
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();
     }
 }
 /**
  * @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');
 }
Пример #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->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;
     });
 }
Пример #24
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) {
     }
 }
Пример #25
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');
 }
Пример #26
0
 /**
  * @param array $composerJson
  * @param \Symfony\Component\Finder\SplFileInfo $composerJsonFile
  *
  * @return array
  */
 public function update(array $composerJson, SplFileInfo $composerJsonFile)
 {
     $bundleName = $this->getBundleName($composerJson);
     $dependentBundles = $this->getDependentBundles($bundleName);
     if (!Config::hasValue(DevelopmentConstants::COMPOSER_REQUIRE_VERSION)) {
         return $composerJson;
     }
     $composerRequireVersion = Config::get(DevelopmentConstants::COMPOSER_REQUIRE_VERSION);
     if (preg_match('/^[0-9]/', $composerRequireVersion)) {
         $composerRequireVersion = self::RELEASE_OPERATOR . $composerRequireVersion;
     }
     foreach ($dependentBundles as $dependentBundle) {
         $filter = new CamelCaseToDash();
         $dependentBundle = strtolower($filter->filter($dependentBundle));
         $composerJson[self::KEY_REQUIRE]['spryker/' . $dependentBundle] = $composerRequireVersion;
     }
     return $composerJson;
 }
Пример #27
0
 /**
  * @param string $url
  * @param string $body
  *
  * @return string
  */
 private function callJenkins($url, $body = '')
 {
     $post_url = Config::get(SetupConstants::JENKINS_BASE_URL) . '/' . $url;
     //createItem?name=" . $v['name'];
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $post_url);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: text/xml']);
     curl_setopt($ch, CURLOPT_HEADER, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     Log::logRaw('CURL call: ' . $post_url . "body:\n[" . $body . "]\n\n", self::LOGFILE);
     $head = curl_exec($ch);
     Log::logRaw("CURL response:\n[" . $head . "]\n\n", self::LOGFILE);
     $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     curl_close($ch);
     return $httpCode;
 }
Пример #28
0
 /**
  * @return void
  */
 public static function initialize()
 {
     date_default_timezone_set('UTC');
     static::defineEnvironment();
     static::defineStore();
     static::defineApplication();
     static::defineApplicationRootDir();
     static::defineApplicationSourceDir();
     static::defineApplicationStaticDir();
     static::defineApplicationVendorDir();
     static::defineApplicationDataDir();
     static::initializeErrorHandlerEnvironment();
     ini_set('display_errors', Config::get(LibraryConstants::DISPLAY_ERRORS, false));
     $store = Store::getInstance();
     $locale = current($store->getLocales());
     self::initializeLocale($locale);
     mb_internal_encoding('UTF-8');
     mb_regex_encoding('UTF-8');
 }
Пример #29
0
 /**
  * @return array
  */
 protected function getConnectionParameters()
 {
     // TODO: Remove defaults. The default Config::get() values are for BC only.
     $config = ['protocol' => Config::get(StorageConstants::STORAGE_REDIS_PROTOCOL, Config::get(SessionConstants::YVES_SESSION_REDIS_PROTOCOL)), 'port' => Config::get(StorageConstants::STORAGE_REDIS_PORT, Config::get(SessionConstants::YVES_SESSION_REDIS_PORT)), 'host' => Config::get(StorageConstants::STORAGE_REDIS_HOST, Config::get(SessionConstants::YVES_SESSION_REDIS_HOST)), 'database' => Config::get(StorageConstants::STORAGE_REDIS_DATABASE, static::DEFAULT_REDIS_DATABASE)];
     // TODO: Remove elseif. Only for BC.
     if (Config::hasKey(StorageConstants::STORAGE_REDIS_PASSWORD)) {
         $config['password'] = Config::get(StorageConstants::STORAGE_REDIS_PASSWORD);
     } elseif (Config::hasKey(SessionConstants::YVES_SESSION_REDIS_PASSWORD)) {
         $config['password'] = Config::get(SessionConstants::YVES_SESSION_REDIS_PASSWORD);
     }
     // TODO: Remove elseif. Only for BC.
     $config['persistent'] = false;
     if (Config::hasKey(StorageConstants::STORAGE_PERSISTENT_CONNECTION)) {
         $config['persistent'] = (bool) Config::get(StorageConstants::STORAGE_PERSISTENT_CONNECTION);
     } elseif (Config::hasKey(SessionConstants::YVES_SESSION_PERSISTENT_CONNECTION)) {
         $config['persistent'] = (bool) Config::get(SessionConstants::YVES_SESSION_PERSISTENT_CONNECTION);
     }
     return $config;
 }
Пример #30
0
 /**
  * @param string $content
  *
  * @return bool
  */
 protected function optimisticRandomWrite($content)
 {
     for ($i = 0; $i <= 9; $i++) {
         $handle = $this->getOrCreateRandomFileHandle();
         $config = Config::get(EventJournalConstants::LOCK_OPTIONS);
         if (!empty($config[EventJournalConstants::NO_LOCK])) {
             self::$preferredHandle = $handle;
             fwrite($handle, $content);
             return true;
         }
         if ($this->acquireNonBlockingLock($handle)) {
             self::$preferredHandle = $handle;
             fwrite($handle, $content);
             $this->unlock($handle);
             return true;
         }
         self::$preferredHandle = null;
     }
     return false;
 }