/** * {@inheritdoc} */ public function fileReflection($filename) { $fileMD5 = $this->files->md5($filename = $this->files->normalizePath($filename)); $reflection = new ReflectionFile($this->fetchTokens($filename), (array) $this->memory->loadData($fileMD5, self::MEMORY_LOCATION)); //Let's save to cache $this->memory->saveData($fileMD5, $reflection->exportSchema(), static::MEMORY_LOCATION); return $reflection; }
/** * Bootload set of classes * * @param array $classes * @param string|null $memory Memory section to be used for caching, set to null to disable * caching. */ public function bootload(array $classes, $memory = null) { if (!empty($memory)) { $schema = $this->memory->loadData($memory); } if (empty($schema) || $schema['snapshot'] != $classes) { //Schema expired or empty $schema = $this->generateSchema($classes, $this->container); if (!empty($memory)) { $this->memory->saveData($memory, $schema); } return; } //We can initiate schema thought the cached schema $this->schematicBootload($this->container, $schema); }
/** * Load environment data. * * @return $this */ public function load() { if (!$this->files->exists($this->filename)) { throw new EnvironmentException("Unable to load environment, file is missing"); } //Unique env file hash $this->id = $this->files->md5($this->filename); if (!empty($values = $this->memory->loadData($this->id, static::MEMORY_SECTION))) { //Restore from cache $this->initEnvironment($values); return $this; } //Load env values using DotEnv extension $values = $this->initEnvironment($this->parseValues($this->filename)); $this->memory->saveData($this->id, $values, static::MEMORY_SECTION); return $this; }
/** * Trying to load domain data from memory. * * @param string $domain */ protected function loadDomain($domain) { $data = $this->memory->loadData("{$this->locale}-{$domain}", static::MEMORY_LOCATION); if (empty($data)) { $data = []; } $this->domains[$domain] = $data; }
/** * Set loadmap name (section to be used). * * @param string $name */ public function setName($name) { if ($this->name != $name && !empty($name)) { if (empty($this->loadmap = (array) $this->memory->loadData($name))) { $this->loadmap = []; } } $this->name = $name; }
/** * Location language bundle from memory if not loaded already. * * @param string $bundle */ protected function loadBundle($bundle) { if (isset($this->bundles[$bundle])) { return; } $this->bundles[$bundle] = $this->memory->loadData($bundle, $this->languageOptions['directory']); if (empty($this->bundles[$bundle])) { $this->bundles[$bundle] = []; } }
/** * @param TranslatorConfig $config * @param HippocampusInterface $memory * @param SourceInterface $source * @param MessageSelector $selector */ public function __construct(TranslatorConfig $config, HippocampusInterface $memory, SourceInterface $source, MessageSelector $selector = null) { $this->config = $config; $this->memory = $memory; $this->source = $source; $this->selector = $selector; //List of known and loaded locales $this->loadedLocales = (array) $this->memory->loadData(static::MEMORY); $this->locale = $this->config->defaultLocale(); $this->fallbackCatalogue = $this->loadCatalogue($this->config->fallbackLocale()); }
/** * {@inheritdoc} */ public function import($replace = false) { if (empty($this->language)) { throw new ImporterException("Unable to perform bundles import, no language detected."); } if (!isset($this->translator->config()['languages'][$this->language])) { throw new ImporterException("Unable to import language '{$this->language}', no presets found."); } $directory = $this->translator->config()['languages'][$this->language]['directory']; foreach ($this->bundles as $bundle => $strings) { if (!$replace && !empty($existed = $this->memory->loadData($bundle, $directory))) { $strings = $strings + $existed; } $this->memory->saveData($bundle, $strings, $directory); } }
/** * Get singular primary key associated with desired table. Used to emulate last insert id. * * @param string $table Fully specified table name, including postfix. * @return string * @throws DriverException */ public function getPrimary($table) { if (empty($this->primaryKeys)) { $this->primaryKeys = $this->memory->loadData($this->getSource() . '-primary'); } if (!empty($this->primaryKeys) && array_key_exists($table, $this->primaryKeys)) { return $this->primaryKeys[$table]; } if (!$this->hasTable($table)) { throw new DriverException("Unable to fetch table primary key, no such table '{$table}' exists."); } $this->primaryKeys[$table] = $this->tableSchema($table)->getPrimaryKeys(); if (count($this->primaryKeys[$table]) === 1) { //We do support only single primary key $this->primaryKeys[$table] = $this->primaryKeys[$table][0]; } else { $this->primaryKeys[$table] = null; } //Caching $this->memory->saveData($this->getSource() . '-primary', $this->primaryKeys); return $this->primaryKeys[$table]; }
/** * @param ConfiguratorInterface $configurator * @param ContainerInterface $container * @param HippocampusInterface $memory * @param DatabaseManager $databases */ public function __construct(ConfiguratorInterface $configurator, ContainerInterface $container, HippocampusInterface $memory, DatabaseManager $databases) { $this->config = $configurator->getConfig(static::CONFIG); $this->schema = (array) $memory->loadData(static::SCHEMA_SECTION); $this->databases = $databases; $this->memory = $memory; $this->container = $container; }
/** * @param ContainerInterface $container * @param HippocampusInterface $memory * @param ClassLocatorInterface $locator * @param Debugger $debugger */ public function __construct(ContainerInterface $container, HippocampusInterface $memory, ClassLocatorInterface $locator, Debugger $debugger) { $this->container = $container; $this->memory = $memory; $this->locator = $locator; //Trying to load list of commands from memory cache $this->commands = $memory->loadData('commands'); if (!is_array($this->commands)) { $this->commands = []; } $this->debugger = $debugger; }
/** * @param ConfiguratorInterface $configurator * @param ContainerInterface $container * @param HippocampusInterface $memory * @param TokenizerInterface $tokenizer * @param Loader $loader */ public function __construct(ConfiguratorInterface $configurator, ContainerInterface $container, HippocampusInterface $memory, TokenizerInterface $tokenizer, Loader $loader) { $this->config = $configurator->getConfig(static::CONFIG); $this->container = $container; $this->memory = $memory; $this->tokenizer = $tokenizer; $this->loader = $loader; //Trying to load list of commands from memory cache $this->commands = $memory->loadData('commands'); if (!is_array($this->commands)) { $this->commands = []; } }
/** * @param ORMConfig $config * @param EntityCache $cache * @param HippocampusInterface $memory * @param DatabaseManager $databases * @param FactoryInterface $factory */ public function __construct(ORMConfig $config, EntityCache $cache, HippocampusInterface $memory, DatabaseManager $databases, FactoryInterface $factory) { $this->config = $config; $this->memory = $memory; $this->cache = $cache; $this->schema = (array) $memory->loadData(static::MEMORY); $this->databases = $databases; $this->factory = $factory; }
/** * @param ODMConfig $config * @param HippocampusInterface $memory * @param FactoryInterface $factory */ public function __construct(ODMConfig $config, HippocampusInterface $memory, FactoryInterface $factory) { $this->config = $config; $this->memory = $memory; //Loading schema from memory $this->schema = (array) $memory->loadData(static::MEMORY); $this->factory = $factory; }